about summary refs log tree commit diff
path: root/src/game/server/entities
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 23:00:46 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 23:00:46 +0000
commitac1aeab149f704ab1b297be9c7662c5705e5e40d (patch)
tree2c5fe9dcfe06c648ea2e1d8e87b638a76aeb1813 /src/game/server/entities
parent9f7a6a04b0862737ca4566fb443140025505a522 (diff)
downloadzcatch-ac1aeab149f704ab1b297be9c7662c5705e5e40d.tar.gz
zcatch-ac1aeab149f704ab1b297be9c7662c5705e5e40d.zip
fixed incorrect handling of projectiel and laser owner
Diffstat (limited to 'src/game/server/entities')
-rw-r--r--src/game/server/entities/character.cpp5
-rw-r--r--src/game/server/entities/laser.cpp7
-rw-r--r--src/game/server/entities/laser.hpp4
-rw-r--r--src/game/server/entities/projectile.cpp7
-rw-r--r--src/game/server/entities/projectile.hpp3
5 files changed, 11 insertions, 15 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 2efaf00f..8ad15284 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -322,7 +322,6 @@ void CHARACTER::fire_weapon()
 				projectile_startpos,
 				direction,
 				(int)(server_tickspeed()*tuning.gun_lifetime),
-				this,
 				1, 0, 0, -1, WEAPON_GUN);
 				
 			// pack the projectile and send it to the client directly
@@ -358,7 +357,6 @@ void CHARACTER::fire_weapon()
 					projectile_startpos,
 					vec2(cosf(a), sinf(a))*speed,
 					(int)(server_tickspeed()*tuning.shotgun_lifetime),
-					this,
 					1, 0, 0, -1, WEAPON_SHOTGUN);
 					
 				// pack the projectile and send it to the client directly
@@ -382,7 +380,6 @@ void CHARACTER::fire_weapon()
 				projectile_startpos,
 				direction,
 				(int)(server_tickspeed()*tuning.grenade_lifetime),
-				this,
 				1, PROJECTILE::PROJECTILE_FLAGS_EXPLODE, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
 
 			// pack the projectile and send it to the client directly
@@ -401,7 +398,7 @@ void CHARACTER::fire_weapon()
 		
 		case WEAPON_RIFLE:
 		{
-			new LASER(pos, direction, tuning.laser_reach, this);
+			new LASER(pos, direction, tuning.laser_reach, player->client_id);
 			game.create_sound(pos, SOUND_RIFLE_FIRE);
 		} break;
 		
diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp
index 8b512d82..20054ed4 100644
--- a/src/game/server/entities/laser.cpp
+++ b/src/game/server/entities/laser.cpp
@@ -7,7 +7,7 @@
 //////////////////////////////////////////////////
 // laser
 //////////////////////////////////////////////////
-LASER::LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner)
+LASER::LASER(vec2 pos, vec2 direction, float start_energy, int owner)
 : ENTITY(NETOBJTYPE_LASER)
 {
 	this->pos = pos;
@@ -24,14 +24,15 @@ LASER::LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner)
 bool LASER::hit_character(vec2 from, vec2 to)
 {
 	vec2 at;
-	CHARACTER *hit = game.world.intersect_character(pos, to, 0.0f, at, owner);
+	CHARACTER *owner_char = game.get_player_char(owner);
+	CHARACTER *hit = game.world.intersect_character(pos, to, 0.0f, at, owner_char);
 	if(!hit)
 		return false;
 
 	this->from = from;
 	pos = at;
 	energy = -1;		
-	hit->take_damage(vec2(0,0), tuning.laser_damage, owner->player->client_id, WEAPON_RIFLE);
+	hit->take_damage(vec2(0,0), tuning.laser_damage, owner, WEAPON_RIFLE);
 	return true;
 }
 
diff --git a/src/game/server/entities/laser.hpp b/src/game/server/entities/laser.hpp
index 4842b3f8..aa4c2284 100644
--- a/src/game/server/entities/laser.hpp
+++ b/src/game/server/entities/laser.hpp
@@ -14,14 +14,14 @@ class LASER : public ENTITY
 	float energy;
 	int bounces;
 	int eval_tick;
-	CHARACTER *owner;
+	int owner;
 	
 	bool hit_character(vec2 from, vec2 to);
 	void do_bounce();
 	
 public:
 	
-	LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner);
+	LASER(vec2 pos, vec2 direction, float start_energy, int owner);
 	
 	virtual void reset();
 	virtual void tick();
diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp
index cd15ba10..e0b4701a 100644
--- a/src/game/server/entities/projectile.cpp
+++ b/src/game/server/entities/projectile.cpp
@@ -7,7 +7,7 @@
 //////////////////////////////////////////////////
 // projectile
 //////////////////////////////////////////////////
-PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span, ENTITY* powner,
+PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span,
 	int damage, int flags, float force, int sound_impact, int weapon)
 : ENTITY(NETOBJTYPE_PROJECTILE)
 {
@@ -16,7 +16,6 @@ PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span, ENTITY
 	this->direction = dir;
 	this->lifespan = span;
 	this->owner = owner;
-	this->powner = powner;
 	this->flags = flags;
 	this->force = force;
 	this->damage = damage;
@@ -68,8 +67,8 @@ void PROJECTILE::tick()
 	
 	int collide = col_intersect_line(prevpos, curpos, &curpos);
 	//int collide = col_check_point((int)curpos.x, (int)curpos.y);
-	
-	CHARACTER *targetchr = game.world.intersect_character(prevpos, curpos, 6.0f, curpos, powner);
+	CHARACTER *ownerchar = game.get_player_char(owner);
+	CHARACTER *targetchr = game.world.intersect_character(prevpos, curpos, 6.0f, curpos, ownerchar);
 	if(targetchr || collide || lifespan < 0)
 	{
 		if(lifespan >= 0 || weapon == WEAPON_GRENADE)
diff --git a/src/game/server/entities/projectile.hpp b/src/game/server/entities/projectile.hpp
index c1370af1..a5c3b88f 100644
--- a/src/game/server/entities/projectile.hpp
+++ b/src/game/server/entities/projectile.hpp
@@ -12,7 +12,6 @@ public:
 	};
 	
 	vec2 direction;
-	ENTITY *powner; // this is nasty, could be removed when client quits
 	int lifespan;
 	int owner;
 	int type;
@@ -24,7 +23,7 @@ public:
 	float force;
 	int start_tick;
 	
-	PROJECTILE(int type, int owner, vec2 pos, vec2 vel, int span, ENTITY* powner,
+	PROJECTILE(int type, int owner, vec2 pos, vec2 vel, int span,
 		int damage, int flags, float force, int sound_impact, int weapon);
 
 	vec2 get_pos(float time);