about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-17 22:36:03 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-17 22:36:03 +0000
commit511720b0e4493617dfdbe87f98802e594e61d8ea (patch)
treeb59bd21b0e0cfd4f78f535ada7fd2a9e695f4f86
parent8cb74cfabe8392194a7e91d099ef3678c5fa61a9 (diff)
downloadzcatch-511720b0e4493617dfdbe87f98802e594e61d8ea.tar.gz
zcatch-511720b0e4493617dfdbe87f98802e594e61d8ea.zip
loads of minor fixes here and there. fixed invalid corrections and stuff like that
-rw-r--r--scripts/netobj.py20
-rw-r--r--src/game/client/gc_client.cpp7
-rw-r--r--src/game/g_protocol.def7
-rw-r--r--src/game/server/gs_server.cpp20
4 files changed, 23 insertions, 31 deletions
diff --git a/scripts/netobj.py b/scripts/netobj.py
index 6d9a1412..d8c5a7cd 100644
--- a/scripts/netobj.py
+++ b/scripts/netobj.py
@@ -12,7 +12,7 @@ class variable:
 		return ["\tint %s;" % self.name]
 	def linedef(self):
 		return "#line %d" % self.line
-	def emit_secure(self):
+	def emit_secure(self, parent):
 		return []
 	def emit_unpack(self):
 		return ["msg.%s = msg_unpack_int();" % self.name]
@@ -32,8 +32,8 @@ class var_range(variable):
 		self.max = args[1]
 	def emit_unpack_check(self):
 		return ["if(msg.%s < %s || msg.%s > %s) { msg_failed_on = \"%s\"; return 0; }" % (self.name, self.min, self.name, self.max, self.name)]
-	def emit_secure(self):
-		return [self.linedef(), "obj->%s = netobj_clamp_int(obj->%s, %s, %s);" % (self.name, self.name, self.min, self.max)]
+	def emit_secure(self, parent):
+		return [self.linedef(), "obj->%s = netobj_clamp_int(\"%s.%s\", obj->%s, %s, %s);" % (self.name, parent.name, self.name, self.name, self.min, self.max)]
 
 class var_string(variable):
 	def __init__(self, args, name):
@@ -105,7 +105,7 @@ class object:
 	def emit_secure(self):
 		lines = []
 		for m in self.members:
-			lines += m.emit_secure()
+			lines += m.emit_secure(self)
 		return lines
 
 class message:
@@ -212,14 +212,13 @@ def load(filename):
 	# read the file
 	global line_count
 	line_count = 0
-	lines = [line.strip() for line in file(filename).readlines()]
+	lines = [line.split("//", 2)[0].strip() for line in file(filename).readlines()]
 	
 	p = proto()
 
 	while len(lines):
 		line_count += 1
 		line = lines[0]
-		line = line.split("//", 2)[0] # strip comment
 		
 		if not len(line):
 			del lines[0]
@@ -279,6 +278,7 @@ def emit_header_file(f, p):
 	print >>f, "int netobj_secure(int type, void *data, int size);"
 	print >>f, "const char *netobj_get_name(int type);"
 	print >>f, "int netobj_num_corrections();"
+	print >>f, "const char *netobj_corrected_on();"
 	print >>f, ""
 	print >>f, "void *netmsg_secure_unpack(int type);"
 	print >>f, "const char *netmsg_get_name(int type);"
@@ -302,14 +302,16 @@ def emit_source_file(f, p, protofilename):
 		print >>f, l
 
 	print >>f, "const char *msg_failed_on = \"\";"
+	print >>f, "const char *obj_corrected_on = \"\";"
 	print >>f, "static int num_corrections = 0;"
 	print >>f, "int netobj_num_corrections() { return num_corrections; }"
+	print >>f, "const char *netobj_corrected_on() { return obj_corrected_on; }"
 	print >>f, "const char *netmsg_failed_on() { return msg_failed_on; }"
 	print >>f, ""
-	print >>f, "static int netobj_clamp_int(int v, int min, int max)"
+	print >>f, "static int netobj_clamp_int(const char *error_msg, int v, int min, int max)"
 	print >>f, "{"
-	print >>f, "\tif(v<min) { num_corrections++; return min; }"
-	print >>f, "\tif(v>max) { num_corrections++; return max; }"
+	print >>f, "\tif(v<min) { obj_corrected_on = error_msg; num_corrections++; return min; }"
+	print >>f, "\tif(v>max) { obj_corrected_on = error_msg; num_corrections++; return max; }"
 	print >>f, "\treturn v;"
 	print >>f, "}"
 	print >>f, ""
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index 168f6913..4ef64f87 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -1056,9 +1056,6 @@ void render_game()
 		gfx_mapscreen(0,0,300*gfx_screenaspect(),300);
 		
 		// if weaponstage is active, put a "glow" around the stage ammo
-		select_sprite(SPRITE_TEE_BODY);
-		for (int i = 0; i < netobjects.local_character->weaponstage; i++)
-			gfx_quads_drawTL(x+netobjects.local_character->ammocount * 12 -i*12, y+22, 11, 11);
 		select_sprite(data->weapons[netobjects.local_character->weapon%data->num_weapons].sprite_proj);
 		for (int i = 0; i < min(netobjects.local_character->ammocount, 10); i++)
 			gfx_quads_drawTL(x+i*12,y+24,10,10);
@@ -1300,7 +1297,7 @@ void render_game()
 				
 				if(gametype == GAMETYPE_CTF)
 				{
-					gfx_text(0, whole-20-w/2+5, 300-40-15+t*20+2, 14, buf, -1);
+					gfx_text(0, whole-20-w/2+5, 300-40-15+t*20, 14, buf, -1);
 					if(netobjects.flags[t])
 					{
  						if(netobjects.flags[t]->carried_by == -2 || (netobjects.flags[t]->carried_by == -1 && ((client_tick()/10)&1)))
@@ -1398,7 +1395,7 @@ void render_game()
 		float ramp = velocity_ramp(velspeed, tuning.velramp_start, tuning.velramp_range, tuning.velramp_curvature);
 		
 		char buf[512];
-		str_format(buf, sizeof(buf), "%.0f\n%.0f\n%.2f\n%d", velspeed, velspeed*ramp, ramp, netobj_num_corrections());
+		str_format(buf, sizeof(buf), "%.0f\n%.0f\n%.2f\n%d %s", velspeed, velspeed*ramp, ramp, netobj_num_corrections(), netobj_corrected_on());
 		gfx_text(0, 150, 50, 12, buf, -1);
 	}
 
diff --git a/src/game/g_protocol.def b/src/game/g_protocol.def
index 4a7b79bc..d731b37e 100644
--- a/src/game/g_protocol.def
+++ b/src/game/g_protocol.def
@@ -64,7 +64,7 @@ end
 object projectile
 	any x, y
 	any vx, vy
-	range(0, NUM_WEAPONS) type
+	range(0, NUM_WEAPONS-1) type
 	range(0, max_int) start_tick
 end
 
@@ -85,7 +85,7 @@ end
 object flag
 	any x, y
 	range(0, 1) team
-	range(-1,MAX_CLIENTS-1) carried_by
+	range(-2,MAX_CLIENTS-1) carried_by // -2 == at stand -1 == on the field
 end
 
 object game
@@ -114,7 +114,7 @@ object player_core
 	range(0, 3) jumped
 
 	range(-1,MAX_CLIENTS-1) hooked_player
-	range(0, 3) hook_state
+	range(-1,2) hook_state
 	range(0, max_int) hook_tick
 
 	any hook_x
@@ -136,7 +136,6 @@ object player_character extends player_core
 	range(0, NUM_WEAPONS-1) weapon
 	range(0, NUM_EMOTES-1) emote
 	
-	range(0, 10) weaponstage
 	range(0, max_int) attacktick
 end
 
diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp
index 21b2f61f..70027086 100644
--- a/src/game/server/gs_server.cpp
+++ b/src/game/server/gs_server.cpp
@@ -855,7 +855,7 @@ void player::try_respawn()
 	weapons[WEAPON_GUN].ammo = data->weapons[WEAPON_GUN].maxammo;
 
 	weapons[WEAPON_RIFLE].got = true;
-	weapons[WEAPON_RIFLE].ammo = 100000; //data->weapons[WEAPON_LASER].maxammo;
+	weapons[WEAPON_RIFLE].ammo = -1;
 	
 	active_weapon = WEAPON_GUN;
 	last_weapon = WEAPON_HAMMER;
@@ -1101,7 +1101,8 @@ void player::fire_weapon()
 		
 	}
 
-	weapons[active_weapon].ammo--;
+	if(weapons[active_weapon].ammo > 0) // -1 == unlimited
+		weapons[active_weapon].ammo--;
 	attack_tick = server_tick();
 	reload_timer = data->weapons[active_weapon].firedelay * server_tickspeed() / 1000;
 }
@@ -1622,7 +1623,7 @@ void player::snap(int snaping_client)
 			info->local = 1;
 	}
 
-	if(health > 0 && team >= 0 && distance(players[snaping_client].pos, pos) < 1000.0f)
+	if(!dead && health > 0 && team >= 0 && distance(players[snaping_client].pos, pos) < 1000.0f)
 	{
 		NETOBJ_PLAYER_CHARACTER *character = (NETOBJ_PLAYER_CHARACTER *)snap_new_item(NETOBJTYPE_PLAYER_CHARACTER, client_id, sizeof(NETOBJ_PLAYER_CHARACTER));
 
@@ -1643,7 +1644,7 @@ void player::snap(int snaping_client)
 
 		character->emote = emote_type;
 
-		character->ammocount = weapons[active_weapon].ammo;
+		character->ammocount = 0;
 		character->health = 0;
 		character->armor = 0;
 		
@@ -1661,17 +1662,10 @@ void player::snap(int snaping_client)
 		{
 			character->health = health;
 			character->armor = armor;
+			if(weapons[active_weapon].ammo > 0)
+				character->ammocount = weapons[active_weapon].ammo;
 		}
 
-		if(dead)
-			character->health = -1;
-
-		//if(length(vel) > 15.0f)
-		//	player->emote = EMOTE_HAPPY;
-
-		//if(damage_taken_tick+50 > server_tick())
-		//	player->emote = EMOTE_PAIN;
-
 		if (character->emote == EMOTE_NORMAL)
 		{
 			if(250 - ((server_tick() - last_action)%(250)) < 5)