diff options
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/gs_common.h | 4 | ||||
| -rw-r--r-- | src/game/server/gs_game.cpp | 35 | ||||
| -rw-r--r-- | src/game/server/gs_game_ctf.cpp | 2 | ||||
| -rw-r--r-- | src/game/server/gs_game_dm.cpp | 34 | ||||
| -rw-r--r-- | src/game/server/gs_game_tdm.cpp | 4 |
5 files changed, 40 insertions, 39 deletions
diff --git a/src/game/server/gs_common.h b/src/game/server/gs_common.h index 90363cb8..b91e777e 100644 --- a/src/game/server/gs_common.h +++ b/src/game/server/gs_common.h @@ -133,7 +133,9 @@ public: int gametype; gameobject(); - void do_team_wincheck(); + void do_team_score_wincheck(); + void do_player_score_wincheck(); + void do_warmup(int seconds); void startround(); diff --git a/src/game/server/gs_game.cpp b/src/game/server/gs_game.cpp index bae964ab..2d44a499 100644 --- a/src/game/server/gs_game.cpp +++ b/src/game/server/gs_game.cpp @@ -289,7 +289,40 @@ int gameobject::getteam(int notthisid) return numplayers[0] > numplayers[1] ? 1 : 0; } -void gameobject::do_team_wincheck() +void gameobject::do_player_score_wincheck() +{ + if(game_over_tick == -1 && !warmup) + { + // 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 + 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; + } + } +} + +void gameobject::do_team_score_wincheck() { if(game_over_tick == -1 && !warmup) { diff --git a/src/game/server/gs_game_ctf.cpp b/src/game/server/gs_game_ctf.cpp index fd54a97b..7581f015 100644 --- a/src/game/server/gs_game_ctf.cpp +++ b/src/game/server/gs_game_ctf.cpp @@ -62,7 +62,7 @@ void gameobject_ctf::tick() { gameobject::tick(); - do_team_wincheck(); + do_team_score_wincheck(); // do flags for(int fi = 0; fi < 2; fi++) diff --git a/src/game/server/gs_game_dm.cpp b/src/game/server/gs_game_dm.cpp index 98317578..49de6b56 100644 --- a/src/game/server/gs_game_dm.cpp +++ b/src/game/server/gs_game_dm.cpp @@ -5,38 +5,6 @@ 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 - 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; - } - } - + do_player_score_wincheck(); gameobject::tick(); } - diff --git a/src/game/server/gs_game_tdm.cpp b/src/game/server/gs_game_tdm.cpp index 7aa12e2b..fb2f569b 100644 --- a/src/game/server/gs_game_tdm.cpp +++ b/src/game/server/gs_game_tdm.cpp @@ -8,7 +8,6 @@ gameobject_tdm::gameobject_tdm() is_teamplay = true; } - int gameobject_tdm::on_player_death(class player *victim, class player *killer, int weapon) { gameobject::on_player_death(victim, killer, weapon); @@ -26,7 +25,6 @@ int gameobject_tdm::on_player_death(class player *victim, class player *killer, void gameobject_tdm::tick() { - do_team_wincheck(); - + do_team_score_wincheck(); gameobject::tick(); } |