about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-04 23:58:22 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-04 23:58:22 +0000
commitf7b5cfc67284768e2ba4c30f5e63a49b64d29e01 (patch)
treeaabcce334f90dcd8d3b8368851ae568b2f8202a3 /src
parent018abbdd0a770cde38035fe44e0dcef55b2d4b50 (diff)
downloadzcatch-f7b5cfc67284768e2ba4c30f5e63a49b64d29e01.tar.gz
zcatch-f7b5cfc67284768e2ba4c30f5e63a49b64d29e01.zip
fixed restart command
Diffstat (limited to 'src')
-rw-r--r--src/game/game_variables.h2
-rw-r--r--src/game/server/game_server.cpp92
-rw-r--r--src/game/server/srv_common.h11
-rw-r--r--src/game/server/srv_dm.cpp8
-rw-r--r--src/game/server/srv_tdm.cpp8
5 files changed, 66 insertions, 55 deletions
diff --git a/src/game/game_variables.h b/src/game/game_variables.h
index 59af7246..74ac9f75 100644
--- a/src/game/game_variables.h
+++ b/src/game/game_variables.h
@@ -21,10 +21,12 @@ MACRO_CONFIG_INT(scroll_weapon, 1, 0, 1)
 MACRO_CONFIG_INT(scorelimit, 20, 0, 1000)
 MACRO_CONFIG_INT(timelimit, 0, 0, 1000)
 MACRO_CONFIG_STR(gametype, 32, "dm")
+MACRO_CONFIG_INT(restart, 0, 0, 120)
 
 MACRO_CONFIG_INT(dbg_bots, 0, 0, 7)
 MACRO_CONFIG_INT(cl_predict, 1, 0, 1)
 
+
 MACRO_CONFIG_STR(sv_maprotation, 512, "")
 
 MACRO_CONFIG_INT(dynamic_camera, 1, 0, 1)
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index f72b5be5..346a9229 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -308,40 +308,6 @@ void gameobject::startround()
 {
 	resetgame();
 	
-	if(strlen(config.sv_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]);
-	}
-	
 	round_start_tick = server_tick();
 	sudden_death = 0;
 	game_over_tick = -1;
@@ -351,6 +317,43 @@ void gameobject::startround()
 	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++)
@@ -374,6 +377,15 @@ void gameobject::on_player_death(class player *victim, class player *killer, int
 
 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)
@@ -810,7 +822,7 @@ int player::handle_weapons()
 						break;
 
 					case WEAPON_GUN:
-						new projectile(projectile::WEAPON_PROJECTILETYPE_GUN,
+						new projectile(WEAPON_GUN,
 							client_id,
 							pos+vec2(0,0),
 							direction*30.0f,
@@ -821,7 +833,7 @@ int player::handle_weapons()
 						break;
 					case WEAPON_ROCKET:
 					{
-						new projectile(projectile::WEAPON_PROJECTILETYPE_ROCKET,
+						new projectile(WEAPON_ROCKET,
 							client_id,
 							pos+vec2(0,0),
 							direction*15.0f,
@@ -838,7 +850,7 @@ int player::handle_weapons()
 						{
 							float a = get_angle(direction);
 							a += i*0.08f;
-							new projectile(projectile::WEAPON_PROJECTILETYPE_SHOTGUN,
+							new projectile(WEAPON_SHOTGUN,
 								client_id,
 								pos+vec2(0,0),
 								vec2(cosf(a), sinf(a))*25.0f,
@@ -1457,6 +1469,12 @@ void mods_tick()
 	
 	if(world->paused) // make sure that the game object always updates
 		gameobj->tick();
+	
+	if(config.restart)
+	{
+		gameobj->startround();
+		config.restart = 0;
+	}
 }
 
 void mods_snap(int client_id)
diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h
index f01dd39c..21941f06 100644
--- a/src/game/server/srv_common.h
+++ b/src/game/server/srv_common.h
@@ -109,9 +109,8 @@ extern game_world *world;
 class gameobject : public entity
 {
 protected:
+	void cyclemap();
 	void resetgame();
-	void startround();
-	void endround();
 	
 	int round_start_tick;
 	int game_over_tick;
@@ -124,6 +123,10 @@ protected:
 public:
 	int gametype;
 	gameobject();
+
+	void startround();
+	void endround();
+
 	virtual void post_reset();
 	virtual void tick();
 	
@@ -160,10 +163,6 @@ public:
 	enum
 	{
 		PROJECTILE_FLAGS_EXPLODE = 1 << 0,
-		
-		WEAPON_PROJECTILETYPE_GUN		= 0,
-		WEAPON_PROJECTILETYPE_ROCKET	= 1,
-		WEAPON_PROJECTILETYPE_SHOTGUN	= 2,
 	};
 	
 	vec2 vel;
diff --git a/src/game/server/srv_dm.cpp b/src/game/server/srv_dm.cpp
index 01817262..7be74ca3 100644
--- a/src/game/server/srv_dm.cpp
+++ b/src/game/server/srv_dm.cpp
@@ -35,11 +35,7 @@ void gameobject_dm::tick()
 				sudden_death = 1;
 		}
 	}
-	else
-	{
-		// game over.. wait for restart
-		if(server_tick() > game_over_tick+server_tickspeed()*10)
-			startround();
-	}
+	
+	gameobject::tick();
 }
 
diff --git a/src/game/server/srv_tdm.cpp b/src/game/server/srv_tdm.cpp
index 3ed35dca..ba3ff238 100644
--- a/src/game/server/srv_tdm.cpp
+++ b/src/game/server/srv_tdm.cpp
@@ -32,10 +32,6 @@ void gameobject_tdm::tick()
 				sudden_death = 1;
 		}
 	}
-	else
-	{
-		// game over.. wait for restart
-		if(server_tick() > game_over_tick+server_tickspeed()*10)
-			startround();
-	}
+	
+	gameobject::tick();
 }