// =======================
// Resets the state of all clients, items, weapons, waypoints, ... of the map.
-void reset_map(float dorespawn)
+void reset_map(bool dorespawn)
{
SELFPARAM();
- if (time <= game_starttime && round_handler_IsActive())
- round_handler_Reset(game_starttime);
+ if (time <= game_starttime && round_handler_IsActive()) round_handler_Reset(game_starttime);
MUTATOR_CALLHOOK(reset_map_global);
for (entity e = world; (e = nextent(e)); )
{
- setself(e);
- if (IS_NOT_A_CLIENT(self))
+ if (IS_NOT_A_CLIENT(e))
{
- if (self.reset)
+ if (e.reset)
{
- self.reset();
+ WITH(entity, self, e, e.reset());
continue;
}
-
- if (self.team_saved) self.team = self.team_saved;
-
- if (self.flags & FL_PROJECTILE) // remove any projectiles left
- remove(self);
+ if (e.team_saved) e.team = e.team_saved;
+ if (e.flags & FL_PROJECTILE) remove(e); // remove any projectiles left
}
}
entity e;
FOR_EACH_PLAYER(e)
- if (e.frozen) WITH(entity, self, e, Unfreeze(self));
+ if (e.frozen) WITH(entity, self, e, Unfreeze(e));
// Moving the player reset code here since the player-reset depends
// on spawnpoint entities which have to be reset first --blub
void ReadyRestart_think()
{
SELFPARAM();
- restart_mapalreadyrestarted = 1;
+ restart_mapalreadyrestarted = true;
reset_map(true);
Score_ClearAll();
- remove(self);
+ remove(this);
}
// Forces a restart of the game without actually reloading the map // this is a mess...
void ReadyRestart_force()
{
- entity tmp_player, restart_timer;
-
bprint("^1Server is restarting...\n");
VoteReset();
// clear overtime, we have to decrease timelimit to its original value again.
- if (checkrules_overtimesadded > 0 && g_race_qualifying != 2) cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime)));
+ if (checkrules_overtimesadded > 0 && g_race_qualifying != 2)
+ cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime)));
checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = 0;
- readyrestart_happened = 1;
+ readyrestart_happened = true;
game_starttime = time + RESTART_COUNTDOWN;
+ entity tmp_player;
+
// clear player attributes
FOR_EACH_CLIENT(tmp_player)
{
PS_GR_P_ADDVAL(tmp_player, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(tmp_player, PLAYERSTATS_ALIVETIME, 0));
}
- restart_mapalreadyrestarted = 0; // reset this var, needed when cvar sv_ready_restart_repeatable is in use
+ restart_mapalreadyrestarted = false; // reset this var, needed when cvar sv_ready_restart_repeatable is in use
// disable the warmup global for the server
warmup_stage = 0; // once the game is restarted the game is in match stage
// reset the .ready status of all players (also spectators)
FOR_EACH_REALCLIENT(tmp_player)
{
- tmp_player.ready = 0;
+ tmp_player.ready = false;
}
readycount = 0;
Nagger_ReadyCounted(); // NOTE: this causes a resend of that entity, and will also turn off warmup state on the client
// lock teams with lockonrestart
if (autocvar_teamplay_lockonrestart && teamplay)
{
- lockteams = 1;
+ lockteams = true;
bprint("^1The teams are now locked.\n");
}
// initiate the restart-countdown-announcer entity
if (autocvar_sv_ready_restart_after_countdown)
{
- restart_timer = spawn();
+ entity restart_timer = new(restart_timer);
+ make_pure(restart_timer);
restart_timer.think = ReadyRestart_think;
restart_timer.nextthink = game_starttime;
}
{
tmp_player.allowed_timeouts = autocvar_sv_timeout_number;
}
- // reset map immediately if this cvar is not set
- if (!autocvar_sv_ready_restart_after_countdown) reset_map(true); }
- if (autocvar_sv_eventlog) GameLogEcho(":restart"); }
+ }
+ // reset map immediately if this cvar is not set
+ if (!autocvar_sv_ready_restart_after_countdown) reset_map(true);
+ if (autocvar_sv_eventlog) GameLogEcho(":restart");
+}
void ReadyRestart()
{
// Reset ALL scores, but only do that at the beginning of the countdown if sv_ready_restart_after_countdown is off!
// Otherwise scores could be manipulated during the countdown.
- if (!autocvar_sv_ready_restart_after_countdown) Score_ClearAll();
+ if (!autocvar_sv_ready_restart_after_countdown) Score_ClearAll();
ReadyRestart_force();
}