2007-09-25 23:03:15 +00:00
|
|
|
#include <engine/config.h>
|
|
|
|
#include "srv_common.h"
|
|
|
|
#include "srv_tdm.h"
|
|
|
|
|
2007-11-04 00:19:41 +00:00
|
|
|
gameobject_tdm::gameobject_tdm()
|
|
|
|
{
|
|
|
|
is_teamplay = true;
|
|
|
|
}
|
|
|
|
|
2007-09-25 23:03:15 +00:00
|
|
|
void gameobject_tdm::tick()
|
|
|
|
{
|
|
|
|
if(game_over_tick == -1)
|
|
|
|
{
|
|
|
|
// game is running
|
2007-10-03 21:32:02 +00:00
|
|
|
teamscore[0] = 0;
|
|
|
|
teamscore[1] = 0;
|
2007-09-25 23:03:15 +00:00
|
|
|
|
|
|
|
// gather some stats
|
|
|
|
int topscore_count = 0;
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
{
|
|
|
|
if(players[i].client_id != -1)
|
2007-10-03 21:32:02 +00:00
|
|
|
teamscore[players[i].team] += players[i].score;
|
2007-09-25 23:03:15 +00:00
|
|
|
}
|
2007-10-03 21:32:02 +00:00
|
|
|
if (teamscore[0] >= config.scorelimit)
|
2007-09-25 23:03:15 +00:00
|
|
|
topscore_count++;
|
2007-10-03 21:32:02 +00:00
|
|
|
if (teamscore[1] >= config.scorelimit)
|
2007-09-25 23:03:15 +00:00
|
|
|
topscore_count++;
|
|
|
|
|
|
|
|
// check score win condition
|
2007-10-03 21:32:02 +00:00
|
|
|
if((config.scorelimit > 0 && (teamscore[0] >= config.scorelimit || teamscore[1] >= config.scorelimit)) ||
|
2007-09-25 23:03:15 +00:00
|
|
|
(config.timelimit > 0 && (server_tick()-round_start_tick) >= config.timelimit*server_tickspeed()*60))
|
|
|
|
{
|
|
|
|
if(topscore_count == 1)
|
|
|
|
endround();
|
|
|
|
else
|
|
|
|
sudden_death = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-10-04 23:58:22 +00:00
|
|
|
|
|
|
|
gameobject::tick();
|
2007-09-25 23:03:15 +00:00
|
|
|
}
|