diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-31 14:37:35 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-08-31 14:37:35 +0000 |
| commit | 0a48454a554f8aa221a54b694b32b3004b9f6fd7 (patch) | |
| tree | c114ff110c99468f236c51cae51c191e74a049da /src/game/server | |
| parent | 5198d6bf016014dd85c96ebd97147fa3f24bcc7a (diff) | |
| download | zcatch-0a48454a554f8aa221a54b694b32b3004b9f6fd7.tar.gz zcatch-0a48454a554f8aa221a54b694b32b3004b9f6fd7.zip | |
removed the GAMETYPE_ enum
Diffstat (limited to 'src/game/server')
| -rw-r--r-- | src/game/server/gamecontroller.cpp | 45 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.hpp | 7 | ||||
| -rw-r--r-- | src/game/server/gamemodes/ctf.cpp | 2 | ||||
| -rw-r--r-- | src/game/server/gamemodes/tdm.cpp | 2 | ||||
| -rw-r--r-- | src/game/server/hooks.cpp | 2 |
5 files changed, 26 insertions, 32 deletions
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 76b3ef3e..76d003e7 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -14,30 +14,15 @@ GAMECONTROLLER::GAMECONTROLLER() { - // select gametype - if(strcmp(config.sv_gametype, "ctf") == 0) - { - gametype = GAMETYPE_CTF; - dbg_msg("game", "-- Capture The Flag --"); - } - else if(strcmp(config.sv_gametype, "tdm") == 0) - { - gametype = GAMETYPE_TDM; - dbg_msg("game", "-- Team Death Match --"); - } - else - { - gametype = GAMETYPE_DM; - dbg_msg("game", "-- Death Match --"); - } - + gametype = config.sv_gametype; + // do_warmup(config.sv_warmup); game_over_tick = -1; sudden_death = 0; round_start_tick = server_tick(); round_count = 0; - is_teamplay = false; + game_flags = 0; teamscore[0] = 0; teamscore[1] = 0; @@ -87,7 +72,7 @@ bool GAMECONTROLLER::can_spawn(PLAYER *player, vec2 *out_pos) { SPAWNEVAL eval; - if(is_teamplay) + if(is_teamplay()) { eval.friendly_team = player->team; @@ -175,7 +160,7 @@ void GAMECONTROLLER::resetgame() const char *GAMECONTROLLER::get_team_name(int team) { - if(is_teamplay) + if(is_teamplay()) { if(team == 0) return "red team"; @@ -276,7 +261,7 @@ void GAMECONTROLLER::post_reset() void GAMECONTROLLER::on_player_info_change(class PLAYER *p) { const int team_colors[2] = {65387, 10223467}; - if(is_teamplay) + if(is_teamplay()) { if(p->team >= 0 || p->team <= 1) { @@ -297,7 +282,7 @@ int GAMECONTROLLER::on_character_death(class CHARACTER *victim, class PLAYER *ki victim->player->score--; // suicide else { - if(is_teamplay && victim->team == killer->team) + if(is_teamplay() && victim->team == killer->team) killer->score--; // teamkill else killer->score++; // normal kill @@ -327,7 +312,7 @@ bool GAMECONTROLLER::is_friendly_fire(int cid1, int cid2) if(cid1 == cid2) return false; - if(is_teamplay) + if(is_teamplay()) { if(game.players[cid1].team == game.players[cid2].team) return true; @@ -364,7 +349,7 @@ void GAMECONTROLLER::tick() if(config.sv_scorelimit) { - if(is_teamplay) + if(is_teamplay()) { prog = max(prog, (teamscore[0]*100)/config.sv_scorelimit); prog = max(prog, (teamscore[1]*100)/config.sv_scorelimit); @@ -385,6 +370,12 @@ void GAMECONTROLLER::tick() server_setbrowseinfo(gametype, prog); } + +bool GAMECONTROLLER::is_teamplay() const +{ + return game_flags&GAMEFLAG_TEAMS; +} + void GAMECONTROLLER::snap(int snapping_client) { NETOBJ_GAME *gameobj = (NETOBJ_GAME *)snap_new_item(NETOBJTYPE_GAME, 0, sizeof(NETOBJ_GAME)); @@ -395,7 +386,7 @@ void GAMECONTROLLER::snap(int snapping_client) gameobj->score_limit = config.sv_scorelimit; gameobj->time_limit = config.sv_timelimit; gameobj->round_start_tick = round_start_tick; - gameobj->gametype = gametype; + gameobj->flags = game_flags; gameobj->warmup = warmup; @@ -416,7 +407,7 @@ int GAMECONTROLLER::get_auto_team(int notthisid) } int team = 0; - if(is_teamplay) + if(is_teamplay()) team = numplayers[0] > numplayers[1] ? 1 : 0; if(can_join_team(team, notthisid)) @@ -493,7 +484,7 @@ int GAMECONTROLLER::clampteam(int team) { if(team < 0) // spectator return -1; - if(is_teamplay) + if(is_teamplay()) return team&1; return 0; } diff --git a/src/game/server/gamecontroller.hpp b/src/game/server/gamecontroller.hpp index 9006f985..1a87034b 100644 --- a/src/game/server/gamecontroller.hpp +++ b/src/game/server/gamecontroller.hpp @@ -35,6 +35,8 @@ protected: void cyclemap(); void resetgame(); + const char *gametype; + int round_start_tick; int game_over_tick; int sudden_death; @@ -44,10 +46,11 @@ protected: int warmup; int round_count; + int game_flags; + public: - int gametype; - bool is_teamplay; + bool is_teamplay() const; GAMECONTROLLER(); diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 8d1cdef8..ba8df237 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -10,7 +10,7 @@ GAMECONTROLLER_CTF::GAMECONTROLLER_CTF() { flags[0] = 0; flags[1] = 0; - is_teamplay = true; + game_flags = GAMEFLAG_TEAMS|GAMEFLAG_FLAGS; } bool GAMECONTROLLER_CTF::on_entity(int index, vec2 pos) diff --git a/src/game/server/gamemodes/tdm.cpp b/src/game/server/gamemodes/tdm.cpp index 26441c9f..914bae08 100644 --- a/src/game/server/gamemodes/tdm.cpp +++ b/src/game/server/gamemodes/tdm.cpp @@ -6,7 +6,7 @@ GAMECONTROLLER_TDM::GAMECONTROLLER_TDM() { - is_teamplay = true; + game_flags = GAMEFLAG_TEAMS; } int GAMECONTROLLER_TDM::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon) diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index dd2d9db9..f3d35026 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -359,7 +359,7 @@ void mods_init() { mods_connected(MAX_CLIENTS-i-1); mods_client_enter(MAX_CLIENTS-i-1); - if(game.controller->is_teamplay) + if(game.controller->is_teamplay()) game.players[MAX_CLIENTS-i-1].team = i&1; } } |