about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/clienthooks.cpp1
-rw-r--r--src/game/client/gameclient.cpp96
-rw-r--r--src/game/client/gameclient.hpp1
-rw-r--r--src/game/gamecore.hpp35
-rw-r--r--src/game/server/gamecontext.cpp37
-rw-r--r--src/game/server/gamecontext.hpp1
-rw-r--r--src/game/server/hooks.cpp11
-rw-r--r--src/game/server/player.cpp14
8 files changed, 80 insertions, 116 deletions
diff --git a/src/game/client/clienthooks.cpp b/src/game/client/clienthooks.cpp
index 1611b00d..88a7722a 100644
--- a/src/game/client/clienthooks.cpp
+++ b/src/game/client/clienthooks.cpp
@@ -17,7 +17,6 @@ extern "C" void modc_init() { gameclient.on_init(); }
 extern "C" void modc_connected() { gameclient.on_connected(); }
 extern "C" void modc_predict() { gameclient.on_predict(); }
 extern "C" void modc_newsnapshot() { gameclient.on_snapshot(); }
-extern "C" void modc_recordkeyframe() { gameclient.on_recordkeyframe(); }
 extern "C" int modc_snap_input(int *data) { return gameclient.on_snapinput(data); }
 extern "C" void modc_statechange(int state, int old) { gameclient.on_statechange(state, old); }
 extern "C" void modc_render() { gameclient.on_render(); }
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 6fc478b0..7c9a1ed6 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -424,44 +424,7 @@ void GAMECLIENT::on_message(int msgtype)
 	for(int i = 0; i < all.num; i++)
 		all.components[i]->on_message(msgtype, rawmsg);
 	
-	// handle core messages
-	if(msgtype == NETMSGTYPE_SV_SETINFO)
-	{
-		NETMSG_SV_SETINFO *msg = (NETMSG_SV_SETINFO *)rawmsg;
-		
-		str_copy(clients[msg->cid].name, msg->name, 64);
-		str_copy(clients[msg->cid].skin_name, msg->skin, 64);
-		
-		// make sure that we don't set a special skin on the client
-		if(clients[msg->cid].skin_name[0] == 'x' || clients[msg->cid].skin_name[1] == '_')
-			str_copy(clients[msg->cid].skin_name, "default", 64);
-		
-		clients[msg->cid].color_body = msg->color_body;
-		clients[msg->cid].color_feet = msg->color_feet;
-		
-		clients[msg->cid].skin_info.color_body = skins->get_color(msg->color_body);
-		clients[msg->cid].skin_info.color_feet = skins->get_color(msg->color_feet);
-		clients[msg->cid].skin_info.size = 64;
-		
-		// find new skin
-		clients[msg->cid].skin_id = gameclient.skins->find(clients[msg->cid].skin_name);
-		if(clients[msg->cid].skin_id < 0)
-			clients[msg->cid].skin_id = 0;
-		
-		clients[msg->cid].use_custom_color = msg->use_custom_color;
-		
-		if(msg->use_custom_color)
-			clients[msg->cid].skin_info.texture = gameclient.skins->get(clients[msg->cid].skin_id)->color_texture;
-		else
-		{
-			clients[msg->cid].skin_info.texture = gameclient.skins->get(clients[msg->cid].skin_id)->org_texture;
-			clients[msg->cid].skin_info.color_body = vec4(1,1,1,1);
-			clients[msg->cid].skin_info.color_feet = vec4(1,1,1,1);
-		}
-
-		clients[msg->cid].update_render_info();
-	}
-	else if(msgtype == NETMSGTYPE_SV_READYTOENTER)
+	if(msgtype == NETMSGTYPE_SV_READYTOENTER)
 	{
 		client_entergame();
 	}
@@ -579,7 +542,43 @@ void GAMECLIENT::on_snapshot()
 			SNAP_ITEM item;
 			const void *data = snap_get_item(SNAP_CURRENT, i, &item);
 
-			if(item.type == NETOBJTYPE_PLAYER_INFO)
+			if(item.type == NETOBJTYPE_CLIENT_INFO)
+			{
+				const NETOBJ_CLIENT_INFO *info = (const NETOBJ_CLIENT_INFO *)data;
+				int cid = item.id;
+				ints_to_str(&info->name0, 6, clients[cid].name);
+				ints_to_str(&info->skin0, 6, clients[cid].skin_name);
+				
+				clients[cid].use_custom_color = info->use_custom_color;
+				clients[cid].color_body = info->color_body;
+				clients[cid].color_feet = info->color_feet;
+				
+				// prepare the info
+				if(clients[cid].skin_name[0] == 'x' || clients[cid].skin_name[1] == '_')
+					str_copy(clients[cid].skin_name, "default", 64);
+					
+				clients[cid].skin_info.color_body = skins->get_color(clients[cid].color_body);
+				clients[cid].skin_info.color_feet = skins->get_color(clients[cid].color_feet);
+				clients[cid].skin_info.size = 64;
+				
+				// find new skin
+				clients[cid].skin_id = gameclient.skins->find(clients[cid].skin_name);
+				if(clients[cid].skin_id < 0)
+					clients[cid].skin_id = 0;
+				
+				if(clients[cid].use_custom_color)
+					clients[cid].skin_info.texture = gameclient.skins->get(clients[cid].skin_id)->color_texture;
+				else
+				{
+					clients[cid].skin_info.texture = gameclient.skins->get(clients[cid].skin_id)->org_texture;
+					clients[cid].skin_info.color_body = vec4(1,1,1,1);
+					clients[cid].skin_info.color_feet = vec4(1,1,1,1);
+				}
+
+				clients[cid].update_render_info();					
+				
+			}
+			else if(item.type == NETOBJTYPE_PLAYER_INFO)
 			{
 				const NETOBJ_PLAYER_INFO *info = (const NETOBJ_PLAYER_INFO *)data;
 				
@@ -808,25 +807,6 @@ void GAMECLIENT::send_kill(int client_id)
 	client_send_msg();
 }
 
-void GAMECLIENT::on_recordkeyframe()
-{
-	for(int i = 0; i < MAX_CLIENTS; i++)
-	{
-		if(!snap.player_infos[i])
-			continue;
-			
-		NETMSG_SV_SETINFO msg;
-		msg.cid = i;
-		msg.name = clients[i].name;
-		msg.skin = clients[i].skin_name;
-		msg.use_custom_color = clients[i].use_custom_color;
-		msg.color_body = clients[i].color_body;
-		msg.color_feet = clients[i].color_feet;
-		msg.pack(MSGFLAG_NOSEND|MSGFLAG_RECORD);
-		client_send_msg();
-	}
-}
-
 void GAMECLIENT::con_team(void *result, void *user_data)
 {
 	((GAMECLIENT*)user_data)->send_switch_team(console_arg_int(result, 0));
diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp
index b9ee325e..d2a12099 100644
--- a/src/game/client/gameclient.hpp
+++ b/src/game/client/gameclient.hpp
@@ -119,7 +119,6 @@ public:
 	void on_snapshot();
 	void on_predict();
 	int on_snapinput(int *data);
-	void on_recordkeyframe();
 
 	// actions
 	// TODO: move these
diff --git a/src/game/gamecore.hpp b/src/game/gamecore.hpp
index 0e0c1c4a..5db5207b 100644
--- a/src/game/gamecore.hpp
+++ b/src/game/gamecore.hpp
@@ -53,6 +53,41 @@ inline float get_angle(vec2 dir)
 	return a;
 }
 
+inline void str_to_ints(int *ints, int num, const char *str)
+{
+	int index = 0;
+	while(num)
+	{
+		char buf[4] = {0,0,0,0};
+		for(int c = 0; c < 4 && str[index]; c++, index++)
+			buf[c] = str[index];
+		*ints = (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3];
+		ints++;
+		num--;
+	}
+	
+	// null terminate
+	ints[-1] &= 0xffffff00;
+}
+
+inline void ints_to_str(const int *ints, int num, char *str)
+{
+	while(num)
+	{
+		str[0] = ((*ints)>>24)&0xff;
+		str[1] = ((*ints)>>16)&0xff;
+		str[2] = ((*ints)>>8)&0xff;
+		str[3] = (*ints)&0xff;
+		str += 4;
+		ints++;
+		num--;
+	}
+	
+	// null terminate
+	str[-1] = 0;
+}
+
+
 
 inline vec2 calc_pos(vec2 p, vec2 v, float curvature, float speed, float t)
 {
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 0cdd4227..a36a9144 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -170,29 +170,6 @@ void GAMECONTEXT::send_chat(int chatter_cid, int team, const char *text)
 	}
 }
 
-
-void GAMECONTEXT::send_info(int who, int to_who, bool recordonly)
-{
-	NETMSG_SV_SETINFO msg;
-	msg.cid = who;
-	msg.name = server_clientname(who);
-	msg.skin = players[who]->skin_name;
-	msg.use_custom_color = players[who]->use_custom_color;
-	msg.color_body = players[who]->color_body;
-	msg.color_feet = players[who]->color_feet;
-	
-	if(recordonly)
-	{
-		msg.pack(MSGFLAG_NOSEND);
-		server_send_msg(to_who);
-	}
-	else
-	{
-		msg.pack(MSGFLAG_VITAL);
-		server_send_msg(to_who);
-	}
-}
-
 void GAMECONTEXT::send_emoticon(int cid, int emoticon)
 {
 	NETMSG_SV_EMOTICON msg;
@@ -219,8 +196,6 @@ void GAMECONTEXT::send_broadcast(const char *text, int cid)
 	server_send_msg(cid);
 }
 
-
-
 // 
 void GAMECONTEXT::start_vote(const char *desc, const char *command)
 {
@@ -341,18 +316,6 @@ void GAMECONTEXT::tick()
 
 void GAMECONTEXT::snap(int client_id)
 {
-	// check if we are recording a demo
-	if(client_id == -1)
-	{
-		// we are recording, make sure that we set
-		// the info for all players all the time
-		for(int i = 0; i < MAX_CLIENTS; i++)
-		{
-			if(game.players[i])
-				send_info(i, -1, true);
-		}
-	}
-	
 	world.snap(client_id);
 	controller->snap(client_id);
 	events.snap(client_id);
diff --git a/src/game/server/gamecontext.hpp b/src/game/server/gamecontext.hpp
index 8a1ff918..6e833178 100644
--- a/src/game/server/gamecontext.hpp
+++ b/src/game/server/gamecontext.hpp
@@ -77,7 +77,6 @@ public:
 	void send_emoticon(int cid, int emoticon);
 	void send_weapon_pickup(int cid, int weapon);
 	void send_broadcast(const char *text, int cid);
-	void send_info(int who, int to_who, bool recordonly = false);
 
 };
 
diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp
index b3425694..d8e6c9bb 100644
--- a/src/game/server/hooks.cpp
+++ b/src/game/server/hooks.cpp
@@ -281,15 +281,6 @@ void mods_message(int msgtype, int client_id)
 		
 		if(msgtype == NETMSGTYPE_CL_STARTINFO)
 		{
-			// a client that connected!
-			
-			// send all info to this client
-			for(int i = 0; i < MAX_CLIENTS; i++)
-			{
-				if(game.players[i])
-					game.send_info(i, client_id);
-			}
-
 			// send tuning parameters to client
 			send_tuning_params(client_id);
 			
@@ -306,8 +297,6 @@ void mods_message(int msgtype, int client_id)
 			m.pack(MSGFLAG_VITAL|MSGFLAG_FLUSH);
 			server_send_msg(client_id);
 		}
-		
-		game.send_info(client_id, -1);
 	}
 	else if (msgtype == NETMSGTYPE_CL_EMOTICON)
 	{
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 45d56388..b2f72d0e 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -62,6 +62,13 @@ void PLAYER::tick()
 
 void PLAYER::snap(int snaping_client)
 {
+	NETOBJ_CLIENT_INFO *client_info = (NETOBJ_CLIENT_INFO *)snap_new_item(NETOBJTYPE_CLIENT_INFO, client_id, sizeof(NETOBJ_CLIENT_INFO));
+	str_to_ints(&client_info->name0, 6, server_clientname(client_id));
+	str_to_ints(&client_info->skin0, 6, skin_name);
+	client_info->use_custom_color = use_custom_color;
+	client_info->color_body = color_body;
+	client_info->color_feet = color_feet;
+
 	NETOBJ_PLAYER_INFO *info = (NETOBJ_PLAYER_INFO *)snap_new_item(NETOBJTYPE_PLAYER_INFO, client_id, sizeof(NETOBJ_PLAYER_INFO));
 
 	info->latency = latency.min;
@@ -151,13 +158,6 @@ void PLAYER::set_team(int new_team)
 	dbg_msg("game", "team_join player='%d:%s' team=%d", client_id, server_clientname(client_id), team);
 	
 	game.controller->on_player_info_change(game.players[client_id]);
-
-	// send all info to this client
-	for(int i = 0; i < MAX_CLIENTS; i++)
-	{
-		if(game.players[i])
-			game.send_info(i, -1);
-	}
 }
 
 void PLAYER::try_respawn()