about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-31 14:37:35 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-31 14:37:35 +0000
commit0a48454a554f8aa221a54b694b32b3004b9f6fd7 (patch)
treec114ff110c99468f236c51cae51c191e74a049da
parent5198d6bf016014dd85c96ebd97147fa3f24bcc7a (diff)
downloadzcatch-0a48454a554f8aa221a54b694b32b3004b9f6fd7.tar.gz
zcatch-0a48454a554f8aa221a54b694b32b3004b9f6fd7.zip
removed the GAMETYPE_ enum
-rw-r--r--datasrc/network.py5
-rw-r--r--src/engine/e_if_server.h2
-rw-r--r--src/engine/server/es_server.c6
-rw-r--r--src/game/client/components/hud.cpp3
-rw-r--r--src/game/client/components/killmessages.cpp4
-rw-r--r--src/game/client/components/menus_settings.cpp6
-rw-r--r--src/game/server/gamecontroller.cpp45
-rw-r--r--src/game/server/gamecontroller.hpp7
-rw-r--r--src/game/server/gamemodes/ctf.cpp2
-rw-r--r--src/game/server/gamemodes/tdm.cpp2
-rw-r--r--src/game/server/hooks.cpp2
11 files changed, 35 insertions, 49 deletions
diff --git a/datasrc/network.py b/datasrc/network.py
index 81b435f4..7bb8e7ef 100644
--- a/datasrc/network.py
+++ b/datasrc/network.py
@@ -2,8 +2,7 @@ from datatypes import *
 
 Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
 PlayerStates = ["UNKNOWN", "PLAYING", "IN_MENU", "CHATTING"]
-GameTypes = ["DM", "TDM", "CTF"]
-GameFlags = ["TEAMS"]
+GameFlags = ["TEAMS", "FLAGS"]
 
 Emoticons = [str(x) for x in xrange(1,16)]
 
@@ -22,7 +21,6 @@ RawSource = '''
 '''
 
 Enums = [
-	Enum("GAMETYPE", GameTypes),
 	Enum("PLAYERSTATE", PlayerStates),
 	Enum("EMOTE", Emotes),
 	Enum("POWERUP", Powerups),
@@ -96,7 +94,6 @@ Objects = [
 		
 		NetIntRange("score_limit", 0, 'max_int'),
 		NetIntRange("time_limit", 0, 'max_int'),
-		NetIntRange("gametype", 0, len(GameTypes)),
 		
 		NetIntRange("warmup", 0, 'max_int'),
 
diff --git a/src/engine/e_if_server.h b/src/engine/e_if_server.h
index dd5e1403..98e2b452 100644
--- a/src/engine/e_if_server.h
+++ b/src/engine/e_if_server.h
@@ -91,7 +91,7 @@ void server_setclientscore(int client_id, int score);
 	See Also:
 		<other_func>
 */
-void server_setbrowseinfo(int game_type, int progression);
+void server_setbrowseinfo(const char *game_type, int progression);
 
 /*
 	Function: server_kick
diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c
index 905ee272..8db9865c 100644
--- a/src/engine/server/es_server.c
+++ b/src/engine/server/es_server.c
@@ -27,7 +27,7 @@ static int64 game_start_time;
 static int current_tick = 0;
 static int run_server = 1;
 
-static int browseinfo_gametype = -1;
+static char browseinfo_gametype[16] = {0};
 static int browseinfo_progression = -1;
 
 static int64 lastheartbeat;
@@ -250,9 +250,9 @@ void server_setclientscore(int client_id, int score)
 	clients[client_id].score = score;
 }
 
-void server_setbrowseinfo(int game_type, int progression)
+void server_setbrowseinfo(const char *game_type, int progression)
 {
-	browseinfo_gametype = game_type;
+	str_copy(browseinfo_gametype, game_type, sizeof(browseinfo_gametype));
 	browseinfo_progression = progression;
 	if(browseinfo_progression > 100)
 		browseinfo_progression = 100;
diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp
index 5349401b..762ed1fb 100644
--- a/src/game/client/components/hud.cpp
+++ b/src/game/client/components/hud.cpp
@@ -31,7 +31,6 @@ void HUD::render_goals()
 	// render_scorehud
 	// render_warmuptimer
 	
-	int gametype = gameclient.snap.gameobj->gametype;
 	int gameflags = gameclient.snap.gameobj->flags;
 	
 	float whole = 300*gfx_screenaspect();
@@ -84,7 +83,7 @@ void HUD::render_goals()
 			str_format(buf, sizeof(buf), "%d", t?gameclient.snap.gameobj->teamscore_blue:gameclient.snap.gameobj->teamscore_red);
 			float w = gfx_text_width(0, 14, buf, -1);
 			
-			if(gametype == GAMETYPE_CTF)
+			if(gameflags&GAMEFLAG_FLAGS)
 			{
 				gfx_text(0, whole-20-w/2+5, 300-40-15+t*20, 14, buf, -1);
 				if(gameclient.snap.flags[t])
diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp
index 106433f5..410f2c3d 100644
--- a/src/game/client/components/killmessages.cpp
+++ b/src/game/client/components/killmessages.cpp
@@ -62,7 +62,7 @@ void KILLMESSAGES::on_render()
 		// render victim tee
 		x -= 24.0f;
 		
-		if(gameclient.snap.gameobj && gameclient.snap.gameobj->gametype == GAMETYPE_CTF)
+		if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS)
 		{
 			if(killmsgs[r].mode_special&1)
 			{
@@ -96,7 +96,7 @@ void KILLMESSAGES::on_render()
 
 		if(killmsgs[r].victim != killmsgs[r].killer)
 		{
-			if(gameclient.snap.gameobj && gameclient.snap.gameobj->gametype == GAMETYPE_CTF)
+			if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS)
 			{
 				if(killmsgs[r].mode_special&2)
 				{
diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp
index 95a097c2..e43793a4 100644
--- a/src/game/client/components/menus_settings.cpp
+++ b/src/game/client/components/menus_settings.cpp
@@ -4,11 +4,7 @@
 #include <string.h> // strcmp, strlen, strncpy
 #include <stdlib.h> // atoi
 
-extern "C" {
-	#include <engine/e_client_interface.h>
-	#include <engine/e_config.h>
-	#include <engine/client/ec_font.h>
-}
+#include <engine/e_client_interface.h>
 
 #include <game/generated/g_protocol.hpp>
 #include <game/generated/gc_data.hpp>
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;
 		}
 	}