ddnet/src/game/server/gs_game_dm.cpp

43 lines
888 B
C++
Raw Normal View History

2007-11-25 19:42:40 +00:00
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
2007-12-15 10:24:49 +00:00
#include <engine/e_config.h>
#include "gs_common.h"
#include "gs_game_dm.h"
void gameobject_dm::tick()
{
if(game_over_tick == -1)
{
// game is running
// gather some stats
int topscore = 0;
int topscore_count = 0;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(players[i].client_id != -1)
{
if(players[i].score > topscore)
{
topscore = players[i].score;
topscore_count = 1;
}
else if(players[i].score == topscore)
topscore_count++;
}
}
// check score win condition
2007-12-11 23:10:07 +00:00
if((config.sv_scorelimit > 0 && topscore >= config.sv_scorelimit) ||
(config.sv_timelimit > 0 && (server_tick()-round_start_tick) >= config.sv_timelimit*server_tickspeed()*60))
{
if(topscore_count == 1)
endround();
else
sudden_death = 1;
}
}
2007-10-04 23:58:22 +00:00
gameobject::tick();
}