*/
Gametype GameTypeVote_Type_FromString(string type_name)
{
- Gametype type = MapInfo_Type_FromString(type_name, false);
+ 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")), false);
+ strcat("sv_vote_gametype_",type_name,"_type")), false, false);
return type;
}
{
int flag = GTV_FORBIDDEN;
- Gametype type = MapInfo_Type_FromString(type_name, false);
+ 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")), false);
+ strcat("sv_vote_gametype_",type_name,"_type")), false, false);
flag |= GTV_CUSTOM;
}
}
}
+int mapvote_winner;
+float mapvote_winner_time;
bool MapVote_SendEntity(entity this, entity to, int sf)
{
int i;
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);
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()
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)
return false;
}
- Map_Goto_SetStr(mapvote_maps[mappos]);
- Map_Goto(0);
+ MapVote_Winner(mappos);
alreadychangedlevel = true;
return true;
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;
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;
//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)
{