Removing debugging from G_FreeEntity and removing the G_RealFreeEntity funtion

This commit is contained in:
Richard Allen 2011-07-14 18:58:56 +00:00
parent 3505b12514
commit e13306a73a
15 changed files with 52 additions and 79 deletions

View File

@ -2001,7 +2001,7 @@ void ClientDisconnect(int clientNum)
// JBravo: if the client had a laser, turn it off so it doesnt stay there forever.
if (ent->client->lasersight) {
G_FreeEntity(ent->client->lasersight, __LINE__, __FILE__);
G_FreeEntity(ent->client->lasersight);
ent->client->lasersight = NULL;
}
// stop any following clients

View File

@ -848,7 +848,7 @@ void Cmd_Give_f(gentity_t * ent)
memset(&trace, 0, sizeof(trace));
Touch_Item(it_ent, ent, &trace);
if (it_ent->inuse) {
G_FreeEntity(it_ent, __LINE__, __FILE__);
G_FreeEntity(it_ent);
}
}
}

View File

@ -1211,7 +1211,7 @@ void player_die(gentity_t * self, gentity_t * inflictor, gentity_t * attacker, i
//JBravo: switch off the lasersight
if (self->client->lasersight) {
G_FreeEntity(self->client->lasersight, __LINE__, __FILE__);
G_FreeEntity(self->client->lasersight);
self->client->lasersight = NULL;
}
// JBravo: clear the gib flag

View File

@ -858,7 +858,7 @@ gentity_t *LaunchItem(gitem_t * item, vec3_t origin, vec3_t velocity, int xr_fla
dropped->nextthink = level.time + RQ3_RESPAWNTIME_DEFAULT;
} else {
// auto-remove after 30 seconds
dropped->think = G_RealFreeEntity;
dropped->think = G_FreeEntity;
dropped->nextthink = level.time + 30000;
}
@ -1000,7 +1000,7 @@ void FinishSpawningItem(gentity_t * ent)
trap_Trace(&tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent->s.number, MASK_SOLID);
if (tr.startsolid) {
G_Printf("FinishSpawningItem: %s startsolid at %s\n", ent->classname, vtos(ent->s.origin));
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
// allow to ride movers
@ -1211,7 +1211,7 @@ void G_ResetItem(gentity_t *ent)
case WP_PISTOL:
case WP_KNIFE:
case WP_GRENADE:
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
break;
default:
break;
@ -1224,13 +1224,13 @@ void G_ResetItem(gentity_t *ent)
case HI_BANDOLIER:
case HI_SLIPPERS:
case HI_HELMET:
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
break;
default:
break;
}
} else if (ent->item->giType == IT_AMMO) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
}
@ -1398,7 +1398,7 @@ void G_RunItem(gentity_t * ent)
} else if (ent->item && ent->item->giType == IT_HOLDABLE) {
RQ3_DroppedItemThink(ent);
} else {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
return;
}
@ -1433,7 +1433,7 @@ void RQ3_DroppedWeaponThink(gentity_t * ent)
case WP_KNIFE:
case WP_GRENADE:
//Just free the entity
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
break;
case WP_AKIMBO:
@ -1510,7 +1510,7 @@ void RQ3_ResetWeapon(int weapon)
(ent->flags & FL_RQ3_JUNKITEM) == FL_RQ3_JUNKITEM) {
//Elder: removed because of possible door collision removal
//level.time - ent->timestamp >= RQ3_RESPAWNTIME_DEFAULT) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
numRemoved++;
} else {
//rent = ent;
@ -1555,12 +1555,12 @@ void RQ3_DroppedItemThink(gentity_t * ent)
case HI_SLIPPERS:
case HI_HELMET:
RQ3_ResetItem(ent->item->giTag);
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
break;
default:
//Elder: shouldn't have to come here
G_Printf("RQ3_DroppedItemThink: Out of range or invalid item %d\n", ent->item->giTag);
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
break;
}
}

View File

@ -1113,8 +1113,7 @@ gentity_t *G_TempEntity(vec3_t origin, int event);
//Elder: added
gentity_t *G_TempEntity2(vec3_t origin, int event, int eParm);
void G_Sound(gentity_t * ent, int channel, int soundIndex);
void G_FreeEntity(gentity_t * e, int line, char *file);
void G_RealFreeEntity(gentity_t * e);
void G_FreeEntity(gentity_t * e);
//Elder: added
void RQ3_SaveZoomLevel(gentity_t * ent);

View File

@ -2807,7 +2807,7 @@ void G_RunFrame(int levelTime)
}
}
if (ent->freeAfterEvent) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
continue;
} else if (ent->unlinkAfterEvent) {
// items that will respawn will hide themselves after their pickup event

View File

@ -261,7 +261,7 @@ Used as a positional target for calculations in the utilities (spotlights, etc),
*/
void SP_info_null(gentity_t * self)
{
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
}
/*QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4)
@ -282,7 +282,7 @@ Lights pointed at a target will be spotlights.
*/
void SP_light(gentity_t * self)
{
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
}
/*QUAKED light_d (0 1 0) (-8 -8 -8) (8 8 8) ADDITIVE FLICKER PULSE STROBE START_OFF
@ -438,7 +438,7 @@ void SP_dlight(gentity_t * ent)
}
if (!ent->target) {
G_Printf("%s without a target at %s\n", ent->classname, vtos(ent->r.absmin));
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
InitMover(ent);
@ -526,7 +526,7 @@ void Think_SetupFlare(gentity_t *ent)
trap_SetConfigstring(CS_SKYPORTAL, info);
*/
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
void SP_misc_lens_flare(gentity_t *ent)
@ -687,7 +687,7 @@ void SP_misc_model(gentity_t * ent)
G_SetOrigin(ent, ent->s.origin);
VectorCopy(ent->s.angles, ent->s.apos.trBase);
#else
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
#endif
}
@ -708,7 +708,7 @@ void locateCamera(gentity_t * ent)
if (!owner) {
//Makro - fixed typo (misc_partal_surface)
G_Printf("Couldn't find target for misc_portal_surface\n");
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
ent->r.ownerNum = owner->s.number;
@ -842,7 +842,7 @@ void Think_SetupSkyPortal(gentity_t *ent)
//ent->r.svFlags |= SVF_BROADCAST;
} else {
G_Printf(S_COLOR_YELLOW "WARNING: misc_sky_portal entity with bad target at %s\n", vtos(ent->s.origin));
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
} else {
ent->s.origin2[0] = atof(Info_ValueForKey(info, "x"));
@ -1067,12 +1067,12 @@ static void InitBreakable_Finish(gentity_t * ent)
ent->nextthink = 0;
if (ent->s.weapon < 0 || ent->s.weapon >= RQ3_MAX_BREAKABLES) {
G_Printf(S_COLOR_RED, "ERROR: Invalid func_breakable id (%d)\n", ent->s.weapon);
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
trap_GetConfigstring(CS_BREAKABLES + ent->s.weapon, info, sizeof(info));
if (strlen(Info_ValueForKey(info, "type")) == 0) {
G_Printf(S_COLOR_RED, "ERROR: Invalid func_breakable id (%d)\n", ent->s.weapon);
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
ent->s.eventParm |= (ent->s.weapon & 0x0FFF);
ent->s.weapon = 0;
@ -1223,13 +1223,13 @@ void SP_func_breakable(gentity_t * ent)
G_SpawnString("id", "0", &id);
if (atoi(id) < 0 || atoi(id) >= RQ3_MAX_BREAKABLES) {
G_Printf("^2ERROR: ID too high\n");
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
//Com_Printf("ID (%d) ", id);
if (!G_SpawnString("type", "", &name)) {
G_Printf("^2ERROR: broken breakable name (%s)\n", name);
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
//Com_Printf("type (%s)\n",name);
@ -1355,7 +1355,7 @@ void G_BreakGlass(gentity_t * ent, gentity_t * inflictor, gentity_t * attacker,
func_breakable_die(ent, inflictor, attacker, damage, mod, impactPoint);
}
G_UseTargets(ent, ent->activator);
//G_FreeEntity( ent, __LINE__, __FILE__ );
//G_FreeEntity( ent );
//G_Printf("%s shift: %i\n", vtos(impactPoint), shiftCount);
switch (shiftCount) {
case 0:
@ -1422,7 +1422,7 @@ void G_BreakGlass(gentity_t * ent, gentity_t * inflictor, gentity_t * attacker,
break;
}
//G_FreeEntity( ent, __LINE__, __FILE__ );
//G_FreeEntity( ent );
//G_Printf("%s shift: %i\n", vtos(impactPoint), shiftCount);
tent = G_TempEntity2(impactPoint, EV_CHIP_GLASS, eParm);

View File

@ -396,7 +396,7 @@ void G_RunMissile(gentity_t * ent)
if (ent->parent && ent->parent->client && ent->parent->client->hook == ent) {
ent->parent->client->hook = NULL;
}
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
G_MissileImpact(ent, &tr);
@ -503,7 +503,7 @@ gentity_t *fire_knife(gentity_t * self, vec3_t start, vec3_t dir)
bolt = G_Spawn();
bolt->classname = "weapon_knife";
bolt->nextthink = level.time + 10000;
bolt->think = G_RealFreeEntity;
bolt->think = G_FreeEntity;
bolt->s.eType = ET_MISSILE;
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_KNIFE;

View File

@ -1341,7 +1341,7 @@ void Blocked_Door(gentity_t * ent, gentity_t * other)
}
}
G_TempEntity(other->s.origin, EV_ITEM_POP);
G_FreeEntity(other, __LINE__, __FILE__);
G_FreeEntity(other);
return;
}
@ -2429,7 +2429,7 @@ void SP_path_corner(gentity_t * self)
if (!self->targetname) {
G_Printf("path_corner with no targetname at %s\n", vtos(self->s.origin));
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}
//Makro - added
@ -2577,7 +2577,7 @@ void SP_func_train(gentity_t * self)
if (!self->target) {
G_Printf("func_train without a target at %s\n", vtos(self->r.absmin));
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}

View File

@ -711,34 +711,34 @@ void G_SpawnGEntityFromSpawnVars(void)
if (g_gametype.integer == GT_SINGLE_PLAYER) {
G_SpawnInt("notsingle", "0", &i);
if (i) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
}
//Makro - check for "notgametype" key
if (G_SpawnInt("notgametype", "0", &i)) {
if ((i & (1 << g_gametype.integer)) != 0) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
// check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
} else if (g_gametype.integer >= GT_TEAM) {
G_SpawnInt("notteam", "0", &i);
if (i) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
} else {
G_SpawnInt("notfree", "0", &i);
if (i) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
}
G_SpawnInt("notq3a", "0", &i);
if (i) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
@ -748,7 +748,7 @@ void G_SpawnGEntityFromSpawnVars(void)
s = strstr(value, gametypeName);
if (!s) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
}
@ -759,7 +759,7 @@ void G_SpawnGEntityFromSpawnVars(void)
// if we didn't get a classname, don't bother spawning anything
if (!G_CallSpawn(ent)) {
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
//Makro - is the entity in a sky portal ?

View File

@ -527,7 +527,7 @@ void SP_target_activate(gentity_t * self)
{
if (!self->target) {
G_Printf(S_COLOR_YELLOW "WARNING: target_activate with no target at %s^7\n", vtos(self->s.origin));
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}
self->use = target_activate_use;

View File

@ -559,7 +559,7 @@ gentity_t *Team_ResetFlag(int team)
ent = NULL;
while ((ent = G_Find(ent, FOFS(classname), c)) != NULL) {
if (ent->flags & FL_DROPPED_ITEM)
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
else {
rent = ent;
RespawnItem(ent);

View File

@ -176,7 +176,7 @@ void multi_trigger(gentity_t * ent, gentity_t * activator)
/*
ent->touch = 0;
ent->nextthink = level.time + FRAMETIME;
ent->think = G_RealFreeEntity;
ent->think = G_FreeEntity;
*/
//On second thought, now that I've added those soundInactive/targetInactive keys
//I think just setting touch to 0 will do
@ -253,7 +253,7 @@ void trigger_always_think(gentity_t * ent)
G_UseTargets(ent, ent);
//Makro - we want to be able to re-use this entity (round-based gametypes)
//so we're not going to free it
//G_FreeEntity(ent, __LINE__, __FILE__);
//G_FreeEntity(ent);
trap_UnlinkEntity(ent);
}
@ -345,7 +345,7 @@ void AimAtTarget(gentity_t * self)
ent = G_PickTarget(self->target);
if (!ent) {
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}
@ -353,7 +353,7 @@ void AimAtTarget(gentity_t * self)
gravity = g_gravity.value;
time = sqrt(height / (.5 * gravity));
if (!time) {
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}
// set s.origin2 to the push velocity

View File

@ -583,34 +583,8 @@ G_FreeEntity
Marks the entity as free
=================
*/
void G_FreeEntity(gentity_t * ed, int line, char *file)
void G_FreeEntity(gentity_t * ed)
{
if (ed == NULL || ed-g_entities < 0 || ed-g_entities > level.num_entities || ed->s.number <0 || ed->s.number > level.num_entities) {
trap_SendServerCommand(-1, va("print \"^1G_FreeEntity got called with a bad ent from line %d of file %s. PLEASE report this to the RQ3 team\"", line, file));
G_LogPrintf("G_FreeEntity got called with a bad ent from line %d of file %s. PLEASE report this to the RQ3 team", line, file);
return;
}
trap_UnlinkEntity(ed); // unlink from world
if (ed->neverFree) {
return;
}
memset(ed, 0, sizeof(*ed));
ed->classname = "freed";
ed->freetime = level.time;
ed->inuse = qfalse;
}
void G_RealFreeEntity(gentity_t * ed)
{
if (ed == NULL || ed-g_entities < 0 || ed-g_entities > level.num_entities || ed->s.number <0 || ed->s.number > level.num_entities) {
trap_SendServerCommand(-1, va("print \"^1G_FreeEntity got called with a bad ent with no tracing. PLEASE report this to the RQ3 team\""));
G_LogPrintf("G_FreeEntity got called with a bad ent with no tracing. PLEASE report this to the RQ3 team");
return;
}
trap_UnlinkEntity(ed); // unlink from world
if (ed->neverFree) {

View File

@ -1071,7 +1071,7 @@ void Knife_Touch(gentity_t * ent, gentity_t * other, trace_t * trace)
//Blaze: Get rid of the knife if it hits the sky
// G_FreeEdict (ent);
//Elder: I think you want this
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
return;
}
@ -1124,7 +1124,7 @@ void Knife_Touch(gentity_t * ent, gentity_t * other, trace_t * trace)
xr_drop->count = 1;
}
G_FreeEntity(ent, __LINE__, __FILE__);
G_FreeEntity(ent);
}
//gentity_t *Knife_Throw (gentity_t *self,vec3_t start, vec3_t dir, int damage, int speed )
@ -1865,7 +1865,7 @@ void Laser_Gen(gentity_t * ent, qboolean enabled)
if (ent->client->ps.weapon != WP_PISTOL && ent->client->ps.weapon != WP_MP5 && ent->client->ps.weapon != WP_M4) {
//Kill laser if it exists
if (ent->client->lasersight) {
G_FreeEntity(ent->client->lasersight, __LINE__, __FILE__);
G_FreeEntity(ent->client->lasersight);
ent->client->lasersight = NULL;
}
ent->client->ps.powerups[PW_LASERSIGHT] = 0;
@ -1875,7 +1875,7 @@ void Laser_Gen(gentity_t * ent, qboolean enabled)
if (ent->client->lasersight || enabled == qfalse) {
// JBravo: fixing the bad gEnt crashbug
if (ent->client->lasersight)
G_FreeEntity(ent->client->lasersight, __LINE__, __FILE__);
G_FreeEntity(ent->client->lasersight);
ent->client->lasersight = NULL;
ent->client->ps.powerups[PW_LASERSIGHT] = 0;
return;
@ -1925,7 +1925,7 @@ void Laser_Think(gentity_t * self)
//Make sure you kill the reference before freeing the entity
self->parent->client->lasersight = NULL;
self->parent->client->ps.powerups[PW_LASERSIGHT] = 0;
G_FreeEntity(self, __LINE__, __FILE__);
G_FreeEntity(self);
return;
}
//Set Aiming Directions