X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmapvoting.qc;h=a4e68e7da7bd3e9b5766c30925b54434a7d52b85;hb=133cba402a7d11565c47dc42412b2ac0b9b8f121;hp=ceb2cdd07850a884875e4895d71f614e3de7867e;hpb=be37ea91fb3bbd1a6fa4f0b70b32d1ea95343ad4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mapvoting.qc b/qcsrc/server/mapvoting.qc index ceb2cdd07..a4e68e7da 100644 --- a/qcsrc/server/mapvoting.qc +++ b/qcsrc/server/mapvoting.qc @@ -1,17 +1,19 @@ #include "mapvoting.qh" -#include -#include -#include "g_world.qh" -#include "command/cmd.qh" -#include "command/getreplies.qh" -#include "../common/constants.qh" +#include +#include #include -#include "../common/mapinfo.qh" -#include "../common/playerstats.qh" +#include #include -#include "../common/util.qh" - +#include +#include +#include +#include +#include +#include +#include +#include +#include // definitions @@ -46,10 +48,10 @@ entity mapvote_ent; */ Gametype GameTypeVote_Type_FromString(string type_name) { - Gametype type = MapInfo_Type_FromString(type_name); + Gametype type = MapInfo_Type_FromString(type_name, false, false); if (type == NULL) type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type"))); + strcat("sv_vote_gametype_",type_name,"_type")), false, false); return type; } @@ -57,11 +59,11 @@ int GameTypeVote_AvailabilityStatus(string type_name) { int flag = GTV_FORBIDDEN; - Gametype type = MapInfo_Type_FromString(type_name); + Gametype type = MapInfo_Type_FromString(type_name, false, false); if ( type == NULL ) { type = MapInfo_Type_FromString(cvar_string( - strcat("sv_vote_gametype_",type_name,"_type"))); + strcat("sv_vote_gametype_",type_name,"_type")), false, false); flag |= GTV_CUSTOM; } @@ -335,6 +337,8 @@ void GameTypeVote_SendOption(int i) } } +int mapvote_winner; +float mapvote_winner_time; bool MapVote_SendEntity(entity this, entity to, int sf) { int i; @@ -342,6 +346,9 @@ bool MapVote_SendEntity(entity this, entity to, int sf) if(sf & 1) sf &= ~2; // if we send 1, we don't need to also send 2 + if (!mapvote_winner_time) + sf &= ~8; // no winner yet + WriteHeader(MSG_ENTITY, ENT_CLIENT_MAPVOTE); WriteByte(MSG_ENTITY, sf); @@ -399,12 +406,17 @@ bool MapVote_SendEntity(entity this, entity to, int sf) WriteByte(MSG_ENTITY, to.mapvote); } + if(sf & 8) + { + WriteByte(MSG_ENTITY, mapvote_winner + 1); + } + return true; } void MapVote_Spawn() { - Net_LinkEntity(mapvote_ent = spawn(), false, 0, MapVote_SendEntity); + Net_LinkEntity(mapvote_ent = new(mapvote_ent), false, 0, MapVote_SendEntity); } void MapVote_TouchMask() @@ -417,6 +429,13 @@ void MapVote_TouchVotes(entity voter) mapvote_ent.SendFlags |= 4; } +void MapVote_Winner(int mappos) +{ + mapvote_ent.SendFlags |= 8; + mapvote_winner_time = time; + mapvote_winner = mappos; +} + bool MapVote_Finished(int mappos) { if(alreadychangedlevel) @@ -468,8 +487,7 @@ bool MapVote_Finished(int mappos) return false; } - Map_Goto_SetStr(mapvote_maps[mappos]); - Map_Goto(0); + MapVote_Winner(mappos); alreadychangedlevel = true; return true; @@ -525,7 +543,7 @@ bool MapVote_CheckRules_2() } } firstPlaceVotes = RandomSelection_best_priority; - if ( autocvar_sv_vote_gametype_default_current && currentVotes == firstPlaceVotes ) + if ( autocvar_sv_vote_gametype_default_current && firstPlaceVotes == 0 ) firstPlace = currentPlace; else firstPlace = RandomSelection_chosen_float; @@ -583,17 +601,23 @@ bool MapVote_CheckRules_2() void MapVote_Tick() { - MapVote_CheckRules_1(); // count if(MapVote_CheckRules_2()) // decide return; int totalvotes = 0; - FOREACH_CLIENT(IS_REAL_CLIENT(it), { + FOREACH_CLIENT(true, { + if(!IS_REAL_CLIENT(it)) + { + // apply the same special health value to bots too for consistency's sake + if(GetResource(it, RES_HEALTH) != 2342) + SetResourceExplicit(it, RES_HEALTH, 2342); + continue; + } // hide scoreboard again if(GetResource(it, RES_HEALTH) != 2342) { - SetResourceExplicit(it, RES_HEALTH, 2342); + SetResourceExplicit(it, RES_HEALTH, 2342); // health in the voting phase CS(it).impulse = 0; msg_entity = it; @@ -638,6 +662,16 @@ void MapVote_Think() if(!mapvote_run) return; + if (mapvote_winner_time) + { + if (time > mapvote_winner_time + 1) + { + Map_Goto_SetStr(mapvote_maps[mapvote_winner]); + Map_Goto(0); + } + return; + } + if(alreadychangedlevel) return; @@ -646,6 +680,8 @@ void MapVote_Think() //dprint("tick\n"); mapvote_nextthink = time + 0.5; + if (mapvote_nextthink > mapvote_timeout - 0.1) // make sure there's no delay when map vote times out + mapvote_nextthink = mapvote_timeout + 0.001; if(!mapvote_initialized) { @@ -726,14 +762,14 @@ bool GameTypeVote_Finished(int pos) if(!gametypevote || gametypevote_finished) return false; + localcmd("sv_vote_gametype_hook_all\n"); + localcmd("sv_vote_gametype_hook_", mapvote_maps[pos], "\n"); + if ( !GameTypeVote_SetGametype(GameTypeVote_Type_FromString(mapvote_maps[pos])) ) { LOG_TRACE("Selected gametype is not supported by any map"); } - localcmd("sv_vote_gametype_hook_all\n"); - localcmd("sv_vote_gametype_hook_", mapvote_maps[pos], "\n"); - gametypevote_finished = true; return true;