src/game/g_weapon.c: Some sanity check changes.

This commit is contained in:
Sander van Dijk 2012-08-26 20:31:17 +02:00 committed by Yamagi Burmeister
parent 7958767922
commit 1f2452e7a6

View file

@ -396,7 +396,7 @@ blaster_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
return; return;
} }
if (self->owner->client) if (self->owner && self->owner->client)
{ {
PlayerNoise(self->owner, self->s.origin, PNOISE_IMPACT); PlayerNoise(self->owner, self->s.origin, PNOISE_IMPACT);
} }
@ -412,10 +412,18 @@ blaster_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
mod = MOD_BLASTER; mod = MOD_BLASTER;
} }
if (plane)
{
T_Damage(other, self, self->owner, self->velocity, self->s.origin, T_Damage(other, self, self->owner, self->velocity, self->s.origin,
plane->normal, self->dmg, 1, DAMAGE_ENERGY, mod); plane->normal, self->dmg, 1, DAMAGE_ENERGY, mod);
} }
else else
{
T_Damage(other, self, self->owner, self->velocity, self->s.origin,
vec3_origin, self->dmg, 1, DAMAGE_ENERGY, mod);
}
}
else
{ {
gi.WriteByte(svc_temp_entity); gi.WriteByte(svc_temp_entity);
gi.WriteByte(TE_BLASTER); gi.WriteByte(TE_BLASTER);
@ -590,7 +598,7 @@ Grenade_Explode(edict_t *ent)
void void
Grenade_Touch(edict_t *ent, edict_t *other, cplane_t *plane /* unused */, csurface_t *surf) Grenade_Touch(edict_t *ent, edict_t *other, cplane_t *plane /* unused */, csurface_t *surf)
{ {
if (!ent || !other || !surf) if (!ent || !other)
{ {
G_FreeEdict(ent); G_FreeEdict(ent);
return; return;
@ -601,7 +609,7 @@ Grenade_Touch(edict_t *ent, edict_t *other, cplane_t *plane /* unused */, csurfa
return; return;
} }
if (surf->flags & SURF_SKY) if (surf && (surf->flags & SURF_SKY))
{ {
G_FreeEdict(ent); G_FreeEdict(ent);
return; return;
@ -741,7 +749,7 @@ rocket_touch(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
vec3_t origin; vec3_t origin;
int n; int n;
if (!ent || !other || !plane || !surf) if (!ent || !other)
{ {
G_FreeEdict(ent); G_FreeEdict(ent);
return; return;
@ -752,7 +760,7 @@ rocket_touch(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
return; return;
} }
if (surf->flags & SURF_SKY) if (surf && (surf->flags & SURF_SKY))
{ {
G_FreeEdict(ent); G_FreeEdict(ent);
return; return;
@ -767,11 +775,19 @@ rocket_touch(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
VectorMA(ent->s.origin, -0.02, ent->velocity, origin); VectorMA(ent->s.origin, -0.02, ent->velocity, origin);
if (other->takedamage) if (other->takedamage)
{
if (plane)
{ {
T_Damage(other, ent, ent->owner, ent->velocity, ent->s.origin, T_Damage(other, ent, ent->owner, ent->velocity, ent->s.origin,
plane->normal, ent->dmg, 0, 0, MOD_ROCKET); plane->normal, ent->dmg, 0, 0, MOD_ROCKET);
} }
else else
{
T_Damage(other, ent, ent->owner, ent->velocity, ent->s.origin,
vec3_origin, ent->dmg, 0, 0, MOD_ROCKET);
}
}
else
{ {
/* don't throw any debris in net games */ /* don't throw any debris in net games */
if (!deathmatch->value && !coop->value) if (!deathmatch->value && !coop->value)
@ -1001,7 +1017,7 @@ bfg_explode(edict_t *self)
void void
bfg_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) bfg_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{ {
if (!self || !other || !plane || !surf) if (!self || !other)
{ {
G_FreeEdict(self); G_FreeEdict(self);
return; return;
@ -1012,23 +1028,31 @@ bfg_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
return; return;
} }
if (surf->flags & SURF_SKY) if (surf && (surf->flags & SURF_SKY))
{ {
G_FreeEdict(self); G_FreeEdict(self);
return; return;
} }
if (self->owner->client) if (self->owner && self->owner->client)
{ {
PlayerNoise(self->owner, self->s.origin, PNOISE_IMPACT); PlayerNoise(self->owner, self->s.origin, PNOISE_IMPACT);
} }
/* core explosion - prevents firing it into the wall/floor */ /* core explosion - prevents firing it into the wall/floor */
if (other->takedamage) if (other->takedamage)
{
if (plane)
{ {
T_Damage(other, self, self->owner, self->velocity, self->s.origin, T_Damage(other, self, self->owner, self->velocity, self->s.origin,
plane->normal, 200, 0, 0, MOD_BFG_BLAST); plane->normal, 200, 0, 0, MOD_BFG_BLAST);
} }
else
{
T_Damage(other, self, self->owner, self->velocity, self->s.origin,
vec3_origin, 200, 0, 0, MOD_BFG_BLAST);
}
}
T_RadiusDamage(self, self->owner, 200, other, 100, MOD_BFG_BLAST); T_RadiusDamage(self, self->owner, 200, other, 100, MOD_BFG_BLAST);