about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 20:17:04 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 20:17:04 +0000
commit25a2e529bab1d65e19f4bddebda94539f576e2ad (patch)
treed14ebd03c6d123fd10c4e603f8b6a463e7044618 /src/game
parent72ec4f1a9da63ae6364cf72cd10cd5a0966e3f1f (diff)
downloadzcatch-25a2e529bab1d65e19f4bddebda94539f576e2ad.tar.gz
zcatch-25a2e529bab1d65e19f4bddebda94539f576e2ad.zip
fixed so the client gets the correct player info
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/gameclient.cpp60
-rw-r--r--src/game/client/gc_hooks.cpp4
-rw-r--r--src/game/server/entities/character.cpp1
-rw-r--r--src/game/server/gamecontroller.cpp3
-rw-r--r--src/game/server/player.cpp79
5 files changed, 64 insertions, 83 deletions
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 40682297..12f54b67 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -226,6 +226,63 @@ void GAMECLIENT::on_message(int msgtype)
 	// TODO: this should be done smarter
 	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].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;
+		
+		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_WEAPONPICKUP)
+    {
+    	// TODO: repair me
+    	/*NETMSG_SV_WEAPONPICKUP *msg = (NETMSG_SV_WEAPONPICKUP *)rawmsg;
+        if(config.cl_autoswitch_weapons)
+        	input_data.wanted_weapon = msg->weapon+1;*/
+    }
+	else if(msgtype == NETMSGTYPE_SV_READYTOENTER)
+	{
+		client_entergame();
+	}
+	else if (msgtype == NETMSGTYPE_SV_EMOTICON)
+	{
+		NETMSG_SV_EMOTICON *msg = (NETMSG_SV_EMOTICON *)rawmsg;
+
+		// apply
+		clients[msg->cid].emoticon = msg->emoticon;
+		clients[msg->cid].emoticon_start = client_tick();
+	}
+	else if(msgtype == NETMSGTYPE_SV_SOUNDGLOBAL)
+	{
+		NETMSG_SV_SOUNDGLOBAL *msg = (NETMSG_SV_SOUNDGLOBAL *)rawmsg;
+		snd_play_random(CHN_GLOBAL, msg->soundid, 1.0f, vec2(0,0));
+	}		
 }
 
 void GAMECLIENT::on_statechange(int new_state, int old_state)
@@ -506,9 +563,6 @@ void GAMECLIENT::CLIENT_DATA::update_render_info()
 	}		
 }
 
-
-
-
 void GAMECLIENT::send_switch_team(int team)
 {
 	NETMSG_CL_SETTEAM msg;
diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp
index 4d0be686..df808a67 100644
--- a/src/game/client/gc_hooks.cpp
+++ b/src/game/client/gc_hooks.cpp
@@ -188,6 +188,7 @@ extern "C" void modc_message(int msgtype)
 
 	gameclient.on_message(msgtype);
 
+#if 0
 	// normal 
 	void *rawmsg = netmsg_secure_unpack(msgtype);
 	if(!rawmsg)
@@ -237,6 +238,7 @@ extern "C" void modc_message(int msgtype)
 	}
 	else if(msgtype == NETMSGTYPE_SV_SETINFO)
 	{
+		dbg_msg("DEBUG", "got info");
 		NETMSG_SV_SETINFO *msg = (NETMSG_SV_SETINFO *)rawmsg;
 		
 		str_copy(gameclient.clients[msg->cid].name, msg->name, 64);
@@ -309,6 +311,8 @@ extern "C" void modc_message(int msgtype)
 		NETMSG_SV_SOUNDGLOBAL *msg = (NETMSG_SV_SOUNDGLOBAL *)rawmsg;
 		snd_play_random(CHN_GLOBAL, msg->soundid, 1.0f, vec2(0,0));
 	}
+	
+#endif
 }
 
 extern "C" void modc_connected()
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index cc3bf445..5c307e62 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -806,7 +806,6 @@ void CHARACTER::snap(int snaping_client)
 	else if(!input.left && input.right)
 		character->wanted_direction = 1;*/
 
-
 	if(player->client_id == snaping_client)
 	{
 		character->health = health;
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp
index 8dec6795..76b3ef3e 100644
--- a/src/game/server/gamecontroller.cpp
+++ b/src/game/server/gamecontroller.cpp
@@ -307,6 +307,9 @@ int GAMECONTROLLER::on_character_death(class CHARACTER *victim, class PLAYER *ki
 
 void GAMECONTROLLER::on_character_spawn(class CHARACTER *chr)
 {
+	// default health
+	chr->health = 10;
+	
 	// give default weapons
 	chr->weapons[WEAPON_HAMMER].got = 1;
 	chr->weapons[WEAPON_HAMMER].ammo = -1;
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 1ad19701..fb4df781 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -78,10 +78,6 @@ void PLAYER::on_disconnect()
 
 	// clear this whole structure
 	init(-1);
-
-	/*game.world.remove_entity(&game.players[client_id]);
-	game.world.core.players[client_id] = 0x0;
-	game.players[client_id].client_id = -1;	*/
 }
 
 void PLAYER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
@@ -155,39 +151,6 @@ void PLAYER::try_respawn()
 	
 	if(!game.controller->can_spawn(this, &spawnpos))
 		return;
-	
-	// get spawn point
-	//SPAWNEVAL eval;
-	//eval.die_pos = die_pos;
-	
-	/*
-	eval.pos = vec2(100, 100);
-	
-	if(game.controller->gametype == GAMETYPE_CTF)
-	{
-		eval.friendly_team = team;
-		
-		// try first try own team spawn, then normal spawn and then enemy
-		evaluate_spawn_type(&eval, 1+(team&1));
-		if(!eval.got)
-		{
-			evaluate_spawn_type(&eval, 0);
-			if(!eval.got)
-				evaluate_spawn_type(&eval, 1+((team+1)&1));
-		}
-	}
-	else
-	{
-		if(game.controller->gametype == GAMETYPE_TDM)
-			eval.friendly_team = team;
-			
-		evaluate_spawn_type(&eval, 0);
-		evaluate_spawn_type(&eval, 1);
-		evaluate_spawn_type(&eval, 2);
-	}
-	
-	spawnpos = eval.pos;
-	*/
 
 	// check if the position is occupado
 	ENTITY *ents[2] = {0};
@@ -198,46 +161,4 @@ void PLAYER::try_respawn()
 		spawning = false;
 		character.spawn(this, spawnpos, team);
 	}
-	
-	/*
-	pos = spawnpos;
-
-	core.pos = pos;
-	core.vel = vec2(0,0);
-	core.hooked_player = -1;
-
-	health = 10;
-	armor = 0;
-	jumped = 0;
-	
-	mem_zero(&ninja, sizeof(ninja));
-	
-	dead = false;
-	player_state = PLAYERSTATE_PLAYING;
-	
-	game.world.insert_entity(this);
-
-	core.hook_state = HOOK_IDLE;
-
-	mem_zero(&input, sizeof(input));
-
-	// init weapons
-	mem_zero(&weapons, sizeof(weapons));
-	weapons[WEAPON_HAMMER].got = true;
-	weapons[WEAPON_HAMMER].ammo = -1;
-	weapons[WEAPON_GUN].got = true;
-	weapons[WEAPON_GUN].ammo = 10;
-
-	active_weapon = WEAPON_GUN;
-	last_weapon = WEAPON_HAMMER;
-	queued_weapon = 0;
-
-	reload_timer = 0;
-
-	// Create sound and spawn effects
-	game.create_sound(pos, SOUND_PLAYER_SPAWN);
-	game.create_playerspawn(pos);
-
-	game.controller->on_player_spawn(player);
-	*/
 }