/* ================ G_RunItem ================ */ void G_RunItem( gentity_t *ent ) { vec3_t origin; trace_t tr; int contents; int mask; // if groundentity has been set to -1, it may have been pushed off an edge if ( ent->s.groundEntityNum == -1 ) { if ( ent->s.pos.trType != TR_GRAVITY ) { ent->s.pos.trType = TR_GRAVITY; ent->s.pos.trTime = level.time; } } if ( ent->s.pos.trType == TR_STATIONARY ) { // check think function G_RunThink( ent ); return; } // get current position BG_EvaluateTrajectory( &ent->s.pos, level.time, origin ); // trace a line from the previous position to the current position if ( ent->clipmask ) { mask = ent->clipmask; } else { mask = MASK_PLAYERSOLID & ~CONTENTS_BODY;//MASK_SOLID; } trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->r.ownerNum, mask ); VectorCopy( tr.endpos, ent->r.currentOrigin ); if ( tr.startsolid ) { tr.fraction = 0; } trap_LinkEntity( ent ); // FIXME: avoid this for stationary? // check think function G_RunThink( ent ); if ( tr.fraction == 1 ) { return; } // if it is in a nodrop volume, remove it contents = trap_PointContents( ent->r.currentOrigin, -1 ); if ( contents & CONTENTS_NODROP ) { if (ent->item && ent->item->giType == IT_TEAM) { Team_FreeEntity(ent); } else { G_FreeEntity( ent ); } return; } G_BounceItem( ent, &tr ); }
/* ================ G_RunItem ================ */ void G_RunItem(gentity_t * ent) { vec3_t origin; trace_t tr; int contents; int mask; // if its groundentity has been set to none, it may have been pushed off an edge if (ent->s.groundEntityNum == ENTITYNUM_NONE) { if (ent->s.pos.trType != TR_GRAVITY) { ent->s.pos.trType = TR_GRAVITY; ent->s.pos.trTime = level.time; } } if (ent->s.pos.trType == TR_STATIONARY) { // check think function G_RunThink(ent); return; } // get current position G_EvaluateTrajectory(&ent->s.pos, level.time, origin); // trace a line from the previous position to the current position if (ent->clipmask) { mask = ent->clipmask; } else { mask = MASK_PLAYERSOLID & ~CONTENTS_BODY; //MASK_SOLID; } trap_Trace(&tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->r.ownerNum, mask); VectorCopy(tr.endpos, ent->r.currentOrigin); if (tr.startsolid) { tr.fraction = 0; } if (ent->flags & FL_DROPPED_ITEM && VectorLength(ent->s.pos.trDelta) != 0 && (ent->item->giType == IT_WEAPON || ent->item->giType == IT_HOLDABLE)) { // calculate spin -- should be identical to cg.autoAngles //cg.autoAnglesFast[1] = ( cg.time & 1023 ) * 360 / 1024.0f; ent->s.angles[1] = (level.time & 1023) * 360 / 1024.0f; } trap_LinkEntity(ent); // FIXME: avoid this for stationary? // check think function G_RunThink(ent); if (tr.fraction == 1) { return; } //Elder: debug //if (ent->item && ent->item->giType == IT_WEAPON) { //G_Printf("item velocity: %s\n", vtos(ent->s.pos.trDelta)); //} // if it is in a nodrop volume, remove it contents = trap_PointContents(ent->r.currentOrigin, -1); if (contents & CONTENTS_NODROP) { if (ent->item && ent->item->giType == IT_TEAM) { Team_FreeEntity(ent); } else if (ent->item && ent->item->giType == IT_WEAPON) { //Elder: force-call the weaponthink function RQ3_DroppedWeaponThink(ent); } else if (ent->item && ent->item->giType == IT_HOLDABLE) { RQ3_DroppedItemThink(ent); } else { G_FreeEntity(ent); } return; } G_BounceItem(ent, &tr); }