about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-03 21:32:02 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-10-03 21:32:02 +0000
commita67738e9801a4485cfaf68012279cd5042dc2ab9 (patch)
tree5a4fa1db378b9b889b73b66ff9ac974fdc141dca /src/game
parent30a7246f2fd5e2141de2c37f01b491abe374f3f9 (diff)
downloadzcatch-a67738e9801a4485cfaf68012279cd5042dc2ab9.tar.gz
zcatch-a67738e9801a4485cfaf68012279cd5042dc2ab9.zip
general fixes. fixed scoreboard
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/game_client.cpp25
-rw-r--r--src/game/client/mapres_tilemap.h6
-rw-r--r--src/game/game_protocol.h2
-rw-r--r--src/game/server/game_server.cpp5
-rw-r--r--src/game/server/srv_common.h2
-rw-r--r--src/game/server/srv_ctf.cpp1
-rw-r--r--src/game/server/srv_tdm.cpp11
7 files changed, 45 insertions, 7 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index 3288fa65..8a2c5523 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -1562,10 +1562,31 @@ void render_scoreboard(obj_game *gameobj, float x, float y, float w, int team, c
 	}
 
 	float tw = gfx_pretty_text_width( 64, title, -1);
-	gfx_pretty_text(x+w/2-tw/2, y, 64, title, -1);
-	
 
+	if(team == -1)
+	{
+		gfx_pretty_text(x+w/2-tw/2, y, 64, title, -1);
+	}
+	else
+	{
+		gfx_pretty_text(x+10, y, 64, title, -1);
+		
+		char buf[128];
+		sprintf(buf, "%d", gameobj->teamscore[team&1]);
+		tw = gfx_pretty_text_width(64, buf, -1);
+		gfx_pretty_text(x+w-tw-40, y, 64, buf, -1);
+	}
+	
 	y += 64.0f;
+	
+	/*
+	if(team)
+	{
+		char buf[128];
+		sprintf(buf, "%4d", gameobj->teamscore[team&1]);
+		gfx_pretty_text(x+w/2-tw/2, y, 32, buf, -1);
+	}*/
+
 
 	// find players
 	const obj_player *players[MAX_CLIENTS] = {0};
diff --git a/src/game/client/mapres_tilemap.h b/src/game/client/mapres_tilemap.h
index 6e9d81be..df2da7a3 100644
--- a/src/game/client/mapres_tilemap.h
+++ b/src/game/client/mapres_tilemap.h
@@ -7,6 +7,12 @@ int tilemap_init();
 // renders the tilemaps
 void tilemap_render(float scale, int fg);
 
+enum
+{
+	TILEFLAG_VFLIP=1,
+	TILEFLAG_HFLIP=2,
+};
+
 struct mapres_tilemap
 {
 	int image;
diff --git a/src/game/game_protocol.h b/src/game/game_protocol.h
index f7249501..925de7b8 100644
--- a/src/game/game_protocol.h
+++ b/src/game/game_protocol.h
@@ -124,6 +124,8 @@ struct obj_game
 	int score_limit;
 	int time_limit;
 	int gametype;
+	
+	int teamscore[2];
 };
 
 struct obj_projectile
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 0e42614e..78b95de3 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -306,6 +306,8 @@ void gameobject::startround()
 	sudden_death = 0;
 	game_over_tick = -1;
 	world->paused = false;
+	teamscore[0] = 0;
+	teamscore[1] = 0;
 }
 
 void gameobject::post_reset()
@@ -344,6 +346,9 @@ void gameobject::snap(int snapping_client)
 	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)
diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h
index 7b6e7e1e..22aa4535 100644
--- a/src/game/server/srv_common.h
+++ b/src/game/server/srv_common.h
@@ -117,6 +117,8 @@ protected:
 	int game_over_tick;
 	int sudden_death;
 	
+	int teamscore[2];
+	
 public:
 	int gametype;
 	gameobject();
diff --git a/src/game/server/srv_ctf.cpp b/src/game/server/srv_ctf.cpp
index 7a13b877..1831db31 100644
--- a/src/game/server/srv_ctf.cpp
+++ b/src/game/server/srv_ctf.cpp
@@ -59,6 +59,7 @@ void gameobject_ctf::tick()
 				if(distance(f->pos, flags[fi^1]->pos) < 24)
 				{
 					// CAPTURE! \o/
+					teamscore[fi^1]++;
 					for(int i = 0; i < 2; i++)
 						flags[i]->reset();
 				}
diff --git a/src/game/server/srv_tdm.cpp b/src/game/server/srv_tdm.cpp
index ca1a5a67..3ed35dca 100644
--- a/src/game/server/srv_tdm.cpp
+++ b/src/game/server/srv_tdm.cpp
@@ -7,22 +7,23 @@ void gameobject_tdm::tick()
 	if(game_over_tick == -1)
 	{
 		// game is running
+		teamscore[0] = 0;
+		teamscore[1] = 0;
 		
 		// gather some stats
-		int totalscore[2] = {0,0};
 		int topscore_count = 0;
 		for(int i = 0; i < MAX_CLIENTS; i++)
 		{
 			if(players[i].client_id != -1)
-				totalscore[players[i].team] += players[i].score;
+				teamscore[players[i].team] += players[i].score;
 		}
-		if (totalscore[0] >= config.scorelimit)
+		if (teamscore[0] >= config.scorelimit)
 			topscore_count++;
-		if (totalscore[1] >= config.scorelimit)
+		if (teamscore[1] >= config.scorelimit)
 			topscore_count++;
 		
 		// check score win condition
-		if((config.scorelimit > 0 && (totalscore[0] >= config.scorelimit || totalscore[1] >= config.scorelimit)) ||
+		if((config.scorelimit > 0 && (teamscore[0] >= config.scorelimit || teamscore[1] >= config.scorelimit)) ||
 			(config.timelimit > 0 && (server_tick()-round_start_tick) >= config.timelimit*server_tickspeed()*60))
 		{
 			if(topscore_count == 1)