about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 09:15:34 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 09:15:34 +0000
commit3b1871499c52a41c6fe1e017d6da858b7e70a396 (patch)
tree410cca70987d8789088e25c8a8b5b24eb46a8c06 /src/game
parent1950995bb5137e084b5706275cce1d9d7398fc34 (diff)
downloadzcatch-3b1871499c52a41c6fe1e017d6da858b7e70a396.tar.gz
zcatch-3b1871499c52a41c6fe1e017d6da858b7e70a396.zip
laggometer, smaller gfx fixes
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/game_client.cpp10
-rw-r--r--src/game/client/mapres_image.cpp2
-rw-r--r--src/game/client/mapres_tilemap.cpp28
-rw-r--r--src/game/game.h1
-rw-r--r--src/game/server/game_server.cpp50
5 files changed, 71 insertions, 20 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index c101b291..9ed43d1a 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -1108,6 +1108,8 @@ void modc_render()
 
 	// pseudo format
 	float zoom = 3.0f;
+	if(inp_key_pressed('I'))
+		zoom = 1.0f;
 	
 	float width = 400*zoom;
 	float height = 300*zoom;
@@ -1343,7 +1345,8 @@ void modc_render()
 		{
 			// Normal deathmatch
 
-			float x = 50.0f;
+			float w = 550.0f;
+			float x = width-w-50.0f;
 			float y = 150.0f;
 
 			gfx_blend_normal();
@@ -1351,7 +1354,7 @@ void modc_render()
 			gfx_texture_set(-1);
 			gfx_quads_begin();
 			gfx_quads_setcolor(0,0,0,0.5f);
-			gfx_quads_drawTL(x-10.f, y-10.f, 400.0f, 600.0f);
+			gfx_quads_drawTL(x-10.f, y-10.f, w, 600.0f);
 			gfx_quads_end();
 			
 			gfx_pretty_text(x, y, 64, "Score Board");
@@ -1386,6 +1389,9 @@ void modc_render()
 						sprintf(buf, "%4d", player->score);
 						gfx_pretty_text(x+60-gfx_pretty_text_width(48,buf), y, 48, buf);
 						gfx_pretty_text(x+128, y, 48, client_datas[player->clientid].name);
+						sprintf(buf, "%4d", player->latency);
+						float tw = gfx_pretty_text_width(48.0f, buf);
+						gfx_pretty_text(x+w-tw-20, y, 48, buf);
 
 						render_tee(&idlestate, player->clientid, vec2(1,0), vec2(x+90, y+24));
 						y += 58.0f;
diff --git a/src/game/client/mapres_image.cpp b/src/game/client/mapres_image.cpp
index 8d286b85..eca7882f 100644
--- a/src/game/client/mapres_image.cpp
+++ b/src/game/client/mapres_image.cpp
@@ -6,6 +6,8 @@
 static int map_textures[64] = {0};
 static int count = 0;
 
+extern int DEBUGTEST_MAPIMAGE;
+
 int img_init()
 {
 	int start, count;
diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp
index 52f2a9b1..6476f26d 100644
--- a/src/game/client/mapres_tilemap.cpp
+++ b/src/game/client/mapres_tilemap.cpp
@@ -3,6 +3,8 @@
 #include "mapres_image.h"
 #include "../mapres.h"
 
+#include <baselib/opengl.h>
+
 int tilemap_init()
 {
 	return 0;
@@ -17,6 +19,12 @@ void tilemap_render(float scale, int fg)
 	int start, num;
 	map_get_type(MAPRES_TILEMAP, &start, &num);
 
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+
+
 	// render tilemaps
 	int passed_main = 0;
 	for(int t = 0; t < num; t++)
@@ -34,6 +42,8 @@ void tilemap_render(float scale, int fg)
 			
 			int c = 0;
 			float frac = (1.0f/1024.0f);//2.0f; //2.0f;
+			float texsize = 1024.0f;
+			float nudge = 0.5f/texsize;
 			const float s = 1.0f;
 			for(int y = 0; y < tmap->height; y++)
 				for(int x = 0; x < tmap->width; x++, c++)
@@ -41,11 +51,25 @@ void tilemap_render(float scale, int fg)
 					unsigned char d = data[c*2];
 					if(d)
 					{
+						/*
 						gfx_quads_setsubset(
 							(d%16)/16.0f*s+frac,
 							(d/16)/16.0f*s+frac,
 							((d%16)/16.0f+1.0f/16.0f)*s-frac,
 							((d/16)/16.0f+1.0f/16.0f)*s-frac);
+							*/
+						int tx = d%16;
+						int ty = d/16;
+						int px0 = tx*(1024/16);
+						int py0 = ty*(1024/16);
+						int px1 = (tx+1)*(1024/16)-1;
+						int py1 = (ty+1)*(1024/16)-1;
+						gfx_quads_setsubset(
+							nudge + px0/texsize+frac,
+							nudge + py0/texsize+frac,
+							nudge + px1/texsize-frac,
+							nudge + py1/texsize-frac);
+
 						gfx_quads_drawTL(x*scale, y*scale, scale, scale);
 					}
 				}
@@ -53,4 +77,8 @@ void tilemap_render(float scale, int fg)
 			gfx_quads_end();
 		}
 	}
+	
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+	
 }
diff --git a/src/game/game.h b/src/game/game.h
index 00df52bc..c9010aa0 100644
--- a/src/game/game.h
+++ b/src/game/game.h
@@ -147,6 +147,7 @@ struct obj_player
 	int attacktick; // num attack ticks left of current attack
 	
 	int score;
+	int latency;
 	int emote;
 	
 	int hook_active;
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index ecb57716..af705e19 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -343,7 +343,7 @@ game_world world;
 gameobject::gameobject()
 : entity(OBJTYPE_GAME)
 {
-	gametype = GAMETYPE_TDM;
+	gametype = GAMETYPE_DM;
 	game_over_tick = -1;
 	sudden_death = 0;
 	round_start_tick = server_tick();
@@ -1032,6 +1032,9 @@ void player::tick()
 		
 	if(hook_state == HOOK_GRABBED)
 	{
+		if(hooked_player)
+			hook_pos = hooked_player->pos;
+			
 		/*if(hooked_player)
 			hook_pos = hooked_player->pos;
 
@@ -1043,24 +1046,29 @@ void player::tick()
 			vel.x = saturated_add(-hook_drag_speed, hook_drag_speed, vel.x, -accel*dir.x*0.75f);
 			vel.y = saturated_add(-hook_drag_speed, hook_drag_speed, vel.y, -accel*dir.y);
 		}*/
-		// Old version feels much better (to me atleast)
-		vec2 hookvel = normalize(hook_pos-pos)*hook_drag_accel;
-		// the hook as more power to drag you up then down.
-		// this makes it easier to get on top of an platform
-		if(hookvel.y > 0)
-			hookvel.y *= 0.3f;
-		
-		// the hook will boost it's power if the player wants to move
-		// in that direction. otherwise it will dampen everything abit
-		if((hookvel.x < 0 && input.left) || (hookvel.x > 0 && input.right)) 
-			hookvel.x *= 0.95f;
-		else
-			hookvel.x *= 0.75f;
-		vec2 new_vel = vel+hookvel;
 		
-		// check if we are under the legal limit for the hook
-		if(length(new_vel) < hook_drag_speed || length(new_vel) < length(vel))
-			vel = new_vel; // no problem. apply
+		// Old version feels much better (to me atleast)
+		if(distance(hook_pos, pos) > 46.0f)
+		{
+			vec2 hookvel = normalize(hook_pos-pos)*hook_drag_accel;
+			// the hook as more power to drag you up then down.
+			// this makes it easier to get on top of an platform
+			if(hookvel.y > 0)
+				hookvel.y *= 0.3f;
+			
+			// the hook will boost it's power if the player wants to move
+			// in that direction. otherwise it will dampen everything abit
+			if((hookvel.x < 0 && input.left) || (hookvel.x > 0 && input.right)) 
+				hookvel.x *= 0.95f;
+			else
+				hookvel.x *= 0.75f;
+			
+			vec2 new_vel = vel+hookvel;
+			
+			// check if we are under the legal limit for the hook
+			if(length(new_vel) < hook_drag_speed || length(new_vel) < length(vel))
+				vel = new_vel; // no problem. apply
+		}
 	}
 		
 	// fix influence of other players, collision + hook
@@ -1205,6 +1213,12 @@ void player::snap(int snaping_client)
 	player->vy = (int)vel.y;
 	player->emote = EMOTE_NORMAL;
 
+	player->latency = 0;
+	client_info info;
+	if(server_getclientinfo(client_id, &info))
+		player->latency = info.latency;
+	
+
 	player->ammocount = weapons[active_weapon].ammo;
 	player->health = 0;
 	player->armor = 0;