mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Sort grenates into a linked list
This commit is contained in:
parent
c196b662b6
commit
f77683e60a
3 changed files with 41 additions and 4 deletions
|
@ -1106,5 +1106,9 @@ struct edict_s
|
|||
// common data blocks
|
||||
moveinfo_t moveinfo;
|
||||
monsterinfo_t monsterinfo;
|
||||
|
||||
// grenate list
|
||||
edict_t *next_grenade;
|
||||
edict_t *prev_grenade;
|
||||
};
|
||||
|
||||
|
|
|
@ -115,6 +115,9 @@ field_t fields[] = {
|
|||
{"maxpitch", STOFS(maxpitch), F_FLOAT, FFL_SPAWNTEMP},
|
||||
{"nextmap", STOFS(nextmap), F_LSTRING, FFL_SPAWNTEMP},
|
||||
|
||||
{"next_grenade", FOFS(next_grenade), F_EDICT, FFL_NOSPAWN},
|
||||
{"prev_grenade", FOFS(prev_grenade), F_EDICT, FFL_NOSPAWN},
|
||||
|
||||
{0, 0, 0, 0}
|
||||
|
||||
};
|
||||
|
|
|
@ -68,10 +68,9 @@ qboolean fire_hit (edict_t *self, vec3_t aim, int damage, int kick)
|
|||
vec3_t point;
|
||||
float range;
|
||||
vec3_t dir;
|
||||
|
||||
// Lazarus: Paranoia check
|
||||
if(!self->enemy)
|
||||
return false;
|
||||
|
||||
if(!self->enemy)
|
||||
return false;
|
||||
|
||||
//see if enemy is in range
|
||||
VectorSubtract (self->enemy->s.origin, self->s.origin, dir);
|
||||
|
@ -400,11 +399,38 @@ void fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int spee
|
|||
fire_grenade
|
||||
=================
|
||||
*/
|
||||
|
||||
static void Grenade_Add_To_Chain (edict_t *grenade)
|
||||
{
|
||||
edict_t *ancestor;
|
||||
|
||||
ancestor = world;
|
||||
while(ancestor->next_grenade && ancestor->next_grenade->inuse)
|
||||
ancestor = ancestor->next_grenade;
|
||||
ancestor->next_grenade = grenade;
|
||||
grenade->prev_grenade = ancestor;
|
||||
}
|
||||
|
||||
|
||||
static void Grenade_Remove_From_Chain (edict_t *grenade)
|
||||
{
|
||||
if(grenade->prev_grenade)
|
||||
{
|
||||
// "prev_grenade" should always be valid for other than player-thrown
|
||||
// grenades that explode in player's hand
|
||||
grenade->prev_grenade->next_grenade = grenade->next_grenade;
|
||||
if(grenade->next_grenade)
|
||||
grenade->next_grenade->prev_grenade = grenade->prev_grenade;
|
||||
}
|
||||
}
|
||||
|
||||
static void Grenade_Explode (edict_t *ent)
|
||||
{
|
||||
vec3_t origin;
|
||||
int mod;
|
||||
|
||||
Grenade_Remove_From_Chain(ent);
|
||||
|
||||
if (ent->owner && ent->owner->client)
|
||||
PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);
|
||||
|
||||
|
@ -464,6 +490,7 @@ static void Grenade_Touch (edict_t *ent, edict_t *other, cplane_t *plane, csurfa
|
|||
|
||||
if (surf && (surf->flags & SURF_SKY))
|
||||
{
|
||||
Grenade_Remove_From_Chain (ent);
|
||||
G_FreeEdict (ent);
|
||||
return;
|
||||
}
|
||||
|
@ -518,6 +545,8 @@ void fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int s
|
|||
grenade->dmg_radius = damage_radius;
|
||||
grenade->classname = "grenade";
|
||||
|
||||
Grenade_Add_To_Chain (grenade);
|
||||
|
||||
gi.linkentity (grenade);
|
||||
}
|
||||
|
||||
|
@ -561,6 +590,7 @@ void fire_grenade2 (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int
|
|||
else
|
||||
{
|
||||
gi.sound (self, CHAN_WEAPON, gi.soundindex ("weapons/hgrent1a.wav"), 1, ATTN_NORM, 0);
|
||||
Grenade_Add_To_Chain (grenade);
|
||||
gi.linkentity (grenade);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue