about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/game/server/game_server.cpp163
-rw-r--r--src/game/server/srv_common.cpp163
2 files changed, 163 insertions, 163 deletions
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 346a9229..1d2f4324 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -258,169 +258,6 @@ void game_world::tick()
 }
 
 //////////////////////////////////////////////////
-// game object
-//////////////////////////////////////////////////
-gameobject::gameobject()
-: entity(OBJTYPE_GAME)
-{
-	// select gametype
-	if(strcmp(config.gametype, "ctf") == 0)
-	{
-		gametype = GAMETYPE_CTF;
-		dbg_msg("game", "-- Capture The Flag --");
-	}
-	else if(strcmp(config.gametype, "tdm") == 0)
-	{
-		gametype = GAMETYPE_TDM;
-		dbg_msg("game", "-- Team Death Match --");
-	}
-	else
-	{
-		gametype = GAMETYPE_DM;
-		dbg_msg("game", "-- Death Match --");
-	}
-		
-	//
-	game_over_tick = -1;
-	sudden_death = 0;
-	round_start_tick = server_tick();
-	round_count = 0;
-}
-
-void gameobject::endround()
-{
-	world->paused = true;
-	game_over_tick = server_tick();
-	sudden_death = 0;
-}
-
-void gameobject::resetgame()
-{
-	world->reset_requested = true;
-}
-
-static bool is_separator(char c)
-{
-	return c == ';' || c == ' ' || c == ',' || c == '\t';
-}
-
-void gameobject::startround()
-{
-	resetgame();
-	
-	round_start_tick = server_tick();
-	sudden_death = 0;
-	game_over_tick = -1;
-	world->paused = false;
-	teamscore[0] = 0;
-	teamscore[1] = 0;
-	round_count++;
-}
-
-void gameobject::cyclemap()
-{
-	if(!strlen(config.sv_maprotation))
-		return;
-	// handle maprotation
-	char buf[512];
-	const char *s = strstr(config.sv_maprotation, config.sv_map);
-	if(s == 0)
-		s = config.sv_maprotation; // restart rotation
-	else
-	{
-		s += strlen(config.sv_map); // skip this map
-		while(is_separator(s[0]))
-			s++;
-		if(s[0] == 0)
-			s = config.sv_maprotation; // restart rotation
-	}
-		
-	int i = 0;
-	for(; i < 512; i++)
-	{
-		buf[i] = s[i];
-		if(is_separator(s[i]) || s[i] == 0)
-		{
-			buf[i] = 0;
-			break;
-		}
-	}
-	
-	i = 0; // skip spaces
-	while(is_separator(buf[i]))
-		i++;
-	
-	dbg_msg("game", "rotating map to %s", &buf[i]);
-	strcpy(config.sv_map, &buf[i]);
-}
-
-void gameobject::post_reset()
-{
-	for(int i = 0; i < MAX_CLIENTS; i++)
-	{
-		if(players[i].client_id != -1)
-			players[i].respawn();
-	}
-}
-
-void gameobject::on_player_death(class player *victim, class player *killer, int weapon)
-{
-	// do scoreing
-	if(!killer)
-		return;
-	if(killer == victim)
-		victim->score--; // klant arschel
-	else
-		killer->score++; // good shit
-}
-
-
-void gameobject::tick()
-{
-	if(game_over_tick != -1)
-	{
-		// game over.. wait for restart
-		if(server_tick() > game_over_tick+server_tickspeed()*10)
-		{
-			cyclemap();
-			startround();
-		}
-	}
-}
-
-void gameobject::snap(int snapping_client)
-{
-	obj_game *game = (obj_game *)snap_new_item(OBJTYPE_GAME, 0, sizeof(obj_game));
-	game->paused = world->paused;
-	game->game_over = game_over_tick==-1?0:1;
-	game->sudden_death = sudden_death;
-	
-	game->score_limit = config.scorelimit;
-	game->time_limit = config.timelimit;
-	game->round_start_tick = round_start_tick;
-	game->gametype = gametype;
-	
-	game->teamscore[0] = teamscore[0];
-	game->teamscore[1] = teamscore[1];
-}
-
-int gameobject::getteam(int notthisid)
-{
-	int numplayers[2] = {0,0};
-	for(int i = 0; i < MAX_CLIENTS; i++)
-	{
-		if(players[i].client_id != -1 && players[i].client_id != notthisid)
-		{
-			numplayers[players[i].team]++;
-		}
-	}
-
-	return numplayers[0] > numplayers[1] ? 1 : 0;
-}
-
-gameobject *gameobj = 0;
-
-//////////////////////////////////////////////////
 // projectile
 //////////////////////////////////////////////////
 projectile::projectile(int type, int owner, vec2 pos, vec2 vel, int span, entity* powner,
diff --git a/src/game/server/srv_common.cpp b/src/game/server/srv_common.cpp
new file mode 100644
index 00000000..d7b91178
--- /dev/null
+++ b/src/game/server/srv_common.cpp
@@ -0,0 +1,163 @@
+#include <engine/config.h>
+#include "srv_common.h"
+#include <string.h>
+
+gameobject::gameobject()
+: entity(OBJTYPE_GAME)
+{
+	// select gametype
+	if(strcmp(config.gametype, "ctf") == 0)
+	{
+		gametype = GAMETYPE_CTF;
+		dbg_msg("game", "-- Capture The Flag --");
+	}
+	else if(strcmp(config.gametype, "tdm") == 0)
+	{
+		gametype = GAMETYPE_TDM;
+		dbg_msg("game", "-- Team Death Match --");
+	}
+	else
+	{
+		gametype = GAMETYPE_DM;
+		dbg_msg("game", "-- Death Match --");
+	}
+		
+	//
+	game_over_tick = -1;
+	sudden_death = 0;
+	round_start_tick = server_tick();
+	round_count = 0;
+}
+
+void gameobject::endround()
+{
+	world->paused = true;
+	game_over_tick = server_tick();
+	sudden_death = 0;
+}
+
+void gameobject::resetgame()
+{
+	world->reset_requested = true;
+}
+
+static bool is_separator(char c)
+{
+	return c == ';' || c == ' ' || c == ',' || c == '\t';
+}
+
+void gameobject::startround()
+{
+	resetgame();
+	
+	round_start_tick = server_tick();
+	sudden_death = 0;
+	game_over_tick = -1;
+	world->paused = false;
+	teamscore[0] = 0;
+	teamscore[1] = 0;
+	round_count++;
+}
+
+void gameobject::cyclemap()
+{
+	if(!strlen(config.sv_maprotation))
+		return;
+	// handle maprotation
+	char buf[512];
+	const char *s = strstr(config.sv_maprotation, config.sv_map);
+	if(s == 0)
+		s = config.sv_maprotation; // restart rotation
+	else
+	{
+		s += strlen(config.sv_map); // skip this map
+		while(is_separator(s[0]))
+			s++;
+		if(s[0] == 0)
+			s = config.sv_maprotation; // restart rotation
+	}
+		
+	int i = 0;
+	for(; i < 512; i++)
+	{
+		buf[i] = s[i];
+		if(is_separator(s[i]) || s[i] == 0)
+		{
+			buf[i] = 0;
+			break;
+		}
+	}
+	
+	i = 0; // skip spaces
+	while(is_separator(buf[i]))
+		i++;
+	
+	dbg_msg("game", "rotating map to %s", &buf[i]);
+	strcpy(config.sv_map, &buf[i]);
+}
+
+void gameobject::post_reset()
+{
+	for(int i = 0; i < MAX_CLIENTS; i++)
+	{
+		if(players[i].client_id != -1)
+			players[i].respawn();
+	}
+}
+
+void gameobject::on_player_death(class player *victim, class player *killer, int weapon)
+{
+	// do scoreing
+	if(!killer)
+		return;
+	if(killer == victim)
+		victim->score--; // klant arschel
+	else
+		killer->score++; // good shit
+}
+
+
+void gameobject::tick()
+{
+	if(game_over_tick != -1)
+	{
+		// game over.. wait for restart
+		if(server_tick() > game_over_tick+server_tickspeed()*10)
+		{
+			cyclemap();
+			startround();
+		}
+	}
+}
+
+void gameobject::snap(int snapping_client)
+{
+	obj_game *game = (obj_game *)snap_new_item(OBJTYPE_GAME, 0, sizeof(obj_game));
+	game->paused = world->paused;
+	game->game_over = game_over_tick==-1?0:1;
+	game->sudden_death = sudden_death;
+	
+	game->score_limit = config.scorelimit;
+	game->time_limit = config.timelimit;
+	game->round_start_tick = round_start_tick;
+	game->gametype = gametype;
+	
+	game->teamscore[0] = teamscore[0];
+	game->teamscore[1] = teamscore[1];
+}
+
+int gameobject::getteam(int notthisid)
+{
+	int numplayers[2] = {0,0};
+	for(int i = 0; i < MAX_CLIENTS; i++)
+	{
+		if(players[i].client_id != -1 && players[i].client_id != notthisid)
+		{
+			numplayers[players[i].team]++;
+		}
+	}
+
+	return numplayers[0] > numplayers[1] ? 1 : 0;
+}
+
+gameobject *gameobj = 0;