diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 0f040dde..c6a7bfe2 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -603,6 +603,18 @@ bool bad_map() // this function makes a pair with good_map from clients2c return (gamemode != GMODE_COOPEDIT && ( Mh >= MAXMHEIGHT || MA >= MAXMAREA )); } + +inline const char * spawn_message() +{ + if (spawnpermission == SP_WRONGMAP) + { + if (securemapcheck(getclientmap())) return "3The server has a different version for this secured map!! Impossible to spawn or getmap!!\nCheck if your client or the server is outdated."; + else return "3You have to be on the correct map to spawn. Type /getmap"; + } + else if (m_coop) return "3Type /getmap or send a new map to the server and vote it"; + else return "4Awaiting permission to spawn. Don\'t panic!"; +} + bool tryrespawn() { if ( m_mp(gamemode) && bad_map() ) @@ -611,9 +623,9 @@ bool tryrespawn() } else if(spawnpermission > SP_OK_NUM) { - hudeditf(HUDMSG_TIMER, "\f%s", (spawnpermission == SP_WRONGMAP || m_coop) ? "3You have to be on the correct map to spawn. Type /getmap" : "4Awaiting permission to spawn. Don\'t panic!"); + hudeditf(HUDMSG_TIMER, "\f%s", spawn_message()); } - else if(player1->state==CS_DEAD) + else if(player1->state==CS_DEAD || player1->state==CS_SPECTATE) { if(team_isspect(player1->team)) { diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 7083f350..9c700ce7 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -967,28 +967,28 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } - case SV_SERVOPINFO: - { + case SV_SERVOPINFO: + { loopv(players) { if(players[i]) players[i]->clientrole = CR_DEFAULT; } - player1->clientrole = CR_DEFAULT; + player1->clientrole = CR_DEFAULT; - int cl = getint(p), r = getint(p); - if(cl >= 0 && r >= 0) - { - playerent *pl = (cl == getclientnum() ? player1 : newclient(cl)); - if(pl) - { - pl->clientrole = r; + int cl = getint(p), r = getint(p); + if(cl >= 0 && r >= 0) + { + playerent *pl = (cl == getclientnum() ? player1 : newclient(cl)); + if(pl) + { + pl->clientrole = r; if(pl->name[0]) { // two messages required to allow for proper german translation - is there a better way to do it? if(pl==player1) conoutf(_("you claimed %s status"), r == CR_ADMIN ? "admin" : "master"); else conoutf(_("%s claimed %s status"), colorname(pl), r == CR_ADMIN ? "admin" : "master"); } - } - } - break; - } + } + } + break; + } case SV_TEAMDENY: { @@ -999,7 +999,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) } else { - conoutf(_("you can't change to %s mode"), team_isspect(t) ? _("spectate") : _("active")); + conoutf(_("you can't change to %s mode"), team_isspect(t) ? _("spectate") : _("active")); } break; } diff --git a/source/src/server.cpp b/source/src/server.cpp index 4361afc2..c07f1c9a 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1397,7 +1397,7 @@ void updatesdesc(const char *newdesc, ENetAddress *caller = NULL) int canspawn(client *c) // beware: canspawn() doesn't check m_arena! { if(!c || c->type == ST_EMPTY || !c->isauthed || !team_isvalid(c->team) || - (servmillis - c->connectmillis < 5000 && gamemillis > 10000 && totalclients > 3) ) return -1; + (servmillis - c->connectmillis < 5000 + c->state.reconnections && gamemillis > 10000 && totalclients > 3) ) return -1; if(!c->isonrightmap) return SP_WRONGMAP; if(mastermode == MM_MATCH && matchteamsize) { @@ -2159,6 +2159,7 @@ void disconnect_client(int n, int reason) if(!clients.inrange(n) || clients[n]->type!=ST_TCPIP) return; sdropflag(n); client &c = *clients[n]; + if (c.state.state == CS_ALIVE) c.state.lastdisc = servmillis; const char *scoresaved = ""; if(c.haswelcome) { @@ -2287,6 +2288,7 @@ bool restorescore(client &c) { sc->restore(c.state); sc->valid = false; + if ( c.connectmillis - sc->lastdisc < 5000 && (++c.state.reconnections >= 3) ) c.state.deaths++; return true; } return false; @@ -2718,6 +2720,7 @@ void process(ENetPacket *packet, int sender, int chan) forcedeath(cl); logline(ACLOG_INFO, "[%s] %s is on the wrong map: revision %d/%d", cl->hostname, cl->name, rev, gzs); cl->loggedwrongmap = true; + sendf(sender, 1, "rii", SV_SPAWNDENY, SP_WRONGMAP); } QUEUE_MSG; break; diff --git a/source/src/server.h b/source/src/server.h index 44e504e2..5e3f4ed7 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -124,7 +124,7 @@ struct clientstate : playerstate projectilestate<8> grenades; int akimbomillis; bool scoped; - int flagscore, frags, teamkills, deaths, shotdamage, damage, points, events; + int flagscore, frags, teamkills, deaths, shotdamage, damage, points, events, lastdisc, reconnections; clientstate() : state(CS_DEAD) {} @@ -147,7 +147,7 @@ struct clientstate : playerstate grenades.reset(); akimbomillis = 0; scoped = forced = false; - flagscore = frags = teamkills = deaths = shotdamage = damage = points = events = 0; + flagscore = frags = teamkills = deaths = shotdamage = damage = points = events = lastdisc = reconnections = 0; respawn(); } @@ -168,9 +168,15 @@ struct savedscore { string name; uint ip; - int frags, flagscore, deaths, teamkills, shotdamage, damage, team, points, events; + int frags, flagscore, deaths, teamkills, shotdamage, damage, team, points, events, lastdisc, reconnections; bool valid, forced; + void reset() + { + // to avoid 2 connections with the same score... this can disrupt some laggers that eventually produces 2 connections (but it is rare) + frags = flagscore = deaths = teamkills = shotdamage = damage = points = events = lastdisc = reconnections = 0; + } + void save(clientstate &cs, int t) { frags = cs.frags; @@ -182,6 +188,8 @@ struct savedscore points = cs.points; forced = cs.forced; events = cs.events; + lastdisc = cs.lastdisc; + reconnections = cs.reconnections; team = t; valid = true; } @@ -197,6 +205,9 @@ struct savedscore cs.points = points; cs.forced = forced; cs.events = events; + cs.lastdisc = lastdisc; + cs.reconnections = reconnections; + reset(); } }; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 93a178f3..2076f267 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -370,14 +370,8 @@ void save_world(char *mname) toptimize(); setnames(mname); backup(cgzname, bakname); - // MediaPacks (flowtron) 2009oct07 - // - check map dependencies and - // set the appropriate value (NULL, "-1" or "A,B,C,...") - // in the header checkmapdependencies(true); copystring(hdr.mediareq, reqmpak, 128); - // ?? output? IIRC I did some somewhere .. 2010apr02 - // :: -- - MediaPack - -- --- ---- stream *f = opengzfile(cgzname, "wb"); if(!f) { conoutf("could not write map to %s", cgzname); return; } hdr.version = MAPVERSION;