about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-06 17:36:24 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-06 17:36:24 +0000
commitf055f15ae7ef67069d51251b43c8bda22622018d (patch)
tree0320c5f0aada1626be291cf6b3e3d5227a1bd405 /src/game
parentee105f1cfd701fa411319d6f14c28c7d675afe7a (diff)
downloadzcatch-f055f15ae7ef67069d51251b43c8bda22622018d.tar.gz
zcatch-f055f15ae7ef67069d51251b43c8bda22622018d.zip
added warmup
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/game_client.cpp16
-rw-r--r--src/game/game_protocol.h2
-rw-r--r--src/game/game_variables.h2
-rw-r--r--src/game/server/game_server.cpp6
-rw-r--r--src/game/server/srv_common.cpp19
-rw-r--r--src/game/server/srv_common.h3
6 files changed, 47 insertions, 1 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index f6fd9dd2..a6eac2e7 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -2189,6 +2189,22 @@ void render_game()
 				gfx_pretty_text(320+t*35+30/2-w/2, 300-15, 14, buf, -1);
 			}
 		}
+		
+		// render warmup timer
+		if(gameobj->warmup)
+		{
+			char buf[256];
+			float w = gfx_pretty_text_width(24, "Warmup", -1);
+			gfx_pretty_text(200+-w/2, 50, 24, "Warmup", -1);
+			
+			int seconds = gameobj->warmup/SERVER_TICK_SPEED;
+			if(seconds < 5)
+				sprintf(buf, "%d.%d", seconds, (gameobj->warmup*10/SERVER_TICK_SPEED)%10);
+			else
+				sprintf(buf, "%d", seconds);
+			w = gfx_pretty_text_width(24, buf, -1);
+			gfx_pretty_text(200+-w/2, 75, 24, buf, -1);
+		}
 	}
 
 	if (menu_active)
diff --git a/src/game/game_protocol.h b/src/game/game_protocol.h
index 925de7b8..da3b424b 100644
--- a/src/game/game_protocol.h
+++ b/src/game/game_protocol.h
@@ -125,6 +125,8 @@ struct obj_game
 	int time_limit;
 	int gametype;
 	
+	int warmup;
+	
 	int teamscore[2];
 };
 
diff --git a/src/game/game_variables.h b/src/game/game_variables.h
index 74ac9f75..7cf423a8 100644
--- a/src/game/game_variables.h
+++ b/src/game/game_variables.h
@@ -31,4 +31,6 @@ MACRO_CONFIG_STR(sv_maprotation, 512, "")
 
 MACRO_CONFIG_INT(dynamic_camera, 1, 0, 1)
 
+MACRO_CONFIG_INT(warmup, 0, 0, 0)
+
 
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 1d2f4324..d1620193 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -1309,7 +1309,11 @@ void mods_tick()
 	
 	if(config.restart)
 	{
-		gameobj->startround();
+		if(config.restart > 1)
+			gameobj->do_warmup(config.restart);
+		else
+			gameobj->startround();
+			
 		config.restart = 0;
 	}
 }
diff --git a/src/game/server/srv_common.cpp b/src/game/server/srv_common.cpp
index d7b91178..6d2abf0c 100644
--- a/src/game/server/srv_common.cpp
+++ b/src/game/server/srv_common.cpp
@@ -23,6 +23,7 @@ gameobject::gameobject()
 	}
 		
 	//
+	do_warmup(config.warmup);
 	game_over_tick = -1;
 	sudden_death = 0;
 	round_start_tick = server_tick();
@@ -31,6 +32,9 @@ gameobject::gameobject()
 
 void gameobject::endround()
 {
+	if(warmup) // game can't end when we are running warmup
+		return;
+		
 	world->paused = true;
 	game_over_tick = server_tick();
 	sudden_death = 0;
@@ -116,9 +120,22 @@ void gameobject::on_player_death(class player *victim, class player *killer, int
 		killer->score++; // good shit
 }
 
+void gameobject::do_warmup(int seconds)
+{
+	warmup = seconds*SERVER_TICK_SPEED;
+}
+
 
 void gameobject::tick()
 {
+	// do warmup
+	if(warmup)
+	{
+		warmup--;
+		if(!warmup)
+			resetgame();
+	}
+	
 	if(game_over_tick != -1)
 	{
 		// game over.. wait for restart
@@ -142,6 +159,8 @@ void gameobject::snap(int snapping_client)
 	game->round_start_tick = round_start_tick;
 	game->gametype = gametype;
 	
+	game->warmup = warmup;
+	
 	game->teamscore[0] = teamscore[0];
 	game->teamscore[1] = teamscore[1];
 }
diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h
index 21941f06..103e4a01 100644
--- a/src/game/server/srv_common.h
+++ b/src/game/server/srv_common.h
@@ -118,12 +118,15 @@ protected:
 	
 	int teamscore[2];
 	
+	int warmup;
 	int round_count;
 	
 public:
 	int gametype;
 	gameobject();
 
+	void do_warmup(int seconds);
+	
 	void startround();
 	void endround();