about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-18 21:19:49 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-18 21:19:49 +0000
commitc561c365d70c73b3842709f76a3cafaa553dead0 (patch)
tree0a8e83d15a8d454afdda24ca6aaedef2bae4797f
parentc995aff8e3e7f756eab2740b82115fc0f5579b4a (diff)
downloadzcatch-c561c365d70c73b3842709f76a3cafaa553dead0.tar.gz
zcatch-c561c365d70c73b3842709f76a3cafaa553dead0.zip
fixed potential crash when players leave and there are projectiles left from them
-rw-r--r--src/game/server/entities/character.cpp4
-rw-r--r--src/game/server/player.hpp1
2 files changed, 3 insertions, 2 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 88fa3ffa..aa0adcf5 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -802,7 +802,7 @@ bool CHARACTER::take_damage(vec2 force, int dmg, int from, int weapon)
 	damage_taken_tick = server_tick();
 
 	// do damage hit sound
-	if(from >= 0 && from != player->client_id)
+	if(from >= 0 && from != player->client_id && game.players[from])
 		game.create_sound(game.players[from]->view_pos, SOUND_HIT, cmask_one(from));
 
 	// check for death
@@ -811,7 +811,7 @@ bool CHARACTER::take_damage(vec2 force, int dmg, int from, int weapon)
 		die(from, weapon);
 		
 		// set attacker's face to happy (taunt!)
-		if (from >= 0 && from != player->client_id)
+		if (from >= 0 && from != player->client_id && game.players[from])
 		{
 			CHARACTER *chr = game.players[from]->get_character();
 			if (chr)
diff --git a/src/game/server/player.hpp b/src/game/server/player.hpp
index a1aed594..92d950c2 100644
--- a/src/game/server/player.hpp
+++ b/src/game/server/player.hpp
@@ -66,6 +66,7 @@ public:
 	void tick();
 	void snap(int snapping_client);
 
+	void on_character_death();
 	void on_direct_input(NETOBJ_PLAYER_INPUT *new_input);
 	void on_predicted_input(NETOBJ_PLAYER_INPUT *new_input);
 	void on_disconnect();