diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 8ae8bab5..a4573fde 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -470,7 +470,7 @@ void freebotent(botent *d) } } -VAR(lastpm, -1, -1, -1); +VAR(lastpm, 1, -1, 0); void zapplayer(playerent *&d) { if(d && d->clientnum == lastpm) lastpm = -1; diff --git a/source/src/server.cpp b/source/src/server.cpp index 3cb2434a..cc7d3654 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1082,38 +1082,35 @@ void resetflag(int cn) void htf_forceflag(int flag) { sflaginfo &f = sflaginfos[flag]; - int besthealth = 0, numbesthealth = 0; + int besthealth = 0; + vector clientnumbers; loopv(clients) if(clients[i]->type!=ST_EMPTY) { if(clients[i]->state.state == CS_ALIVE && team_base(clients[i]->team) == flag) { if(clients[i]->state.health == besthealth) - numbesthealth++; + clientnumbers.add(i); else { if(clients[i]->state.health > besthealth) { besthealth = clients[i]->state.health; - numbesthealth = 1; + clientnumbers.shrink(0); + clientnumbers.add(i); } } } } - if(numbesthealth) + + if(clientnumbers.length()) { - int pick = rnd(numbesthealth); - loopv(clients) if(clients[i]->type!=ST_EMPTY) - { - if(clients[i]->state.state == CS_ALIVE && team_base(clients[i]->team) == flag && --pick < 0) - { - f.state = CTFF_STOLEN; - f.actor_cn = i; - sendflaginfo(flag); - flagmessage(flag, FM_PICKUP, i); - logline(ACLOG_INFO,"[%s] %s got forced to pickup the flag", clients[i]->hostname, clients[i]->name); - break; - } - } + int pick = rnd(clientnumbers.length()); + client *cl = clients[clientnumbers[pick]]; + f.state = CTFF_STOLEN; + f.actor_cn = cl->clientnum; + sendflaginfo(flag); + flagmessage(flag, FM_PICKUP, cl->clientnum); + logline(ACLOG_INFO,"[%s] %s got forced to pickup the flag", cl->hostname, cl->name); } f.lastupdate = gamemillis; } diff --git a/source/src/serveractions.h b/source/src/serveractions.h index 167477e7..c18060a1 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -68,8 +68,10 @@ struct mapaction : serveraction mapok = (ms != NULL) && ( (mode != GMODE_COOPEDIT && mapisok(ms)) || (mode == GMODE_COOPEDIT && !readonlymap(maploc)) ); if(!mapok) { - defformatstring(msg)("%s", ms ? ( mode == GMODE_COOPEDIT ? "this map cannot be coopedited in this server" : "sorry, but this map does not satisfy some quality requisites to be played in MultiPlayer Mode" ) : "the server does not have this map" ); - if(notify) sendservmsg(msg, caller); + if(notify) sendservmsg(ms ? + ( mode == GMODE_COOPEDIT ? "this map cannot be coopedited in this server" : "sorry, but this map does not satisfy some quality requisites to be played in MultiPlayer Mode" ) : + "the server does not have this map", + caller); } else { // check, if map supports mode