/* ================ SV_Physics_Pusher Bmodel objects don't interact with each other, but push all box objects ================ */ void SV_Physics_Pusher (edict_t *ent) { vec3_t move, amove; edict_t *part, *mv; // if not a team captain, so movement will be handled elsewhere if ( ent->flags & FL_TEAMSLAVE) return; // make sure all team slaves can move before commiting // any moves or calling any think functions // if the move is blocked, all moved objects will be backed out //retry: pushed_p = pushed; for (part = ent ; part ; part=part->teamchain) { if (part->velocity[0] || part->velocity[1] || part->velocity[2] || part->avelocity[0] || part->avelocity[1] || part->avelocity[2] ) { // object is moving VectorScale (part->velocity, FRAMETIME, move); VectorScale (part->avelocity, FRAMETIME, amove); if (!SV_Push (part, move, amove)) break; // move was blocked } } if (pushed_p > &pushed[MAX_EDICTS]) gi.error (ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); if (part) { // the move failed, bump all nextthink times and back out moves for (mv = ent ; mv ; mv=mv->teamchain) { if (mv->nextthink > 0) mv->nextthink += FRAMETIME; } // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone if (part->blocked) part->blocked (part, obstacle); #if 0 // if the pushed entity went away and the pusher is still there if (!obstacle->inuse && part->inuse) goto retry; #endif } else { // the move succeeded, so call all think functions for (part = ent ; part ; part=part->teamchain) { // prevent entities that are on trains that have gone away from thinking! if (part->inuse) SV_RunThink (part); } } }
/* * SV_Physics_Pusher * * Bmodel objects don't interact with each other, but * push all box objects */ static void SV_Physics_Pusher( edict_t *ent ) { vec3_t move, amove; edict_t *part, *mover; // if not a team captain, so movement will be handled elsewhere if( ent->flags & FL_TEAMSLAVE ) { return; } // make sure all team slaves can move before commiting // any moves or calling any think functions // if the move is blocked, all moved objects will be backed out //retry: pushed_p = pushed; for( part = ent; part; part = part->teamchain ) { if( part->velocity[0] || part->velocity[1] || part->velocity[2] || part->avelocity[0] || part->avelocity[1] || part->avelocity[2] ) { // object is moving if( part->s.linearMovement ) { GS_LinearMovement( &part->s, game.serverTime, move ); VectorSubtract( move, part->s.origin, move ); VectorScale( part->avelocity, FRAMETIME, amove ); } else { VectorScale( part->velocity, FRAMETIME, move ); VectorScale( part->avelocity, FRAMETIME, amove ); } if( !SV_Push( part, move, amove ) ) { break; // move was blocked } } } if( pushed_p > &pushed[MAX_EDICTS] ) { G_Error( "pushed_p > &pushed[MAX_EDICTS], memory corrupted" ); } if( part ) { // the move failed, bump all nextthink times and back out moves for( mover = ent; mover; mover = mover->teamchain ) { if( mover->nextThink > 0 ) { mover->nextThink += game.frametime; } } // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone if( part->moveinfo.blocked ) { part->moveinfo.blocked( part, obstacle ); } #if 0 // if the obstacle went away and the pusher is still there if( !obstacle->r.inuse && part->r.inuse ) { goto retry; } #endif } }
/* * ================ SV_Physics_Pusher ================ * * Bmodel objects don't interact with each other, but push all box objects */ void SV_Physics_Pusher(edict_t * ent) { vec3_t move , amove; edict_t *part, *mv; if (!ent) return; /* if not a team captain, so movement will be handled elsewhere */ if (ent->flags & FL_TEAMSLAVE) return; /* make sure all team slaves can move before commiting * any moves or calling any think functions * if the move is blocked, all moved objects will be backed out */ pushed_p = pushed; for (part = ent; part; part = part->teamchain) { if (part->velocity[0] || part->velocity[1] || part->velocity[2] || part->avelocity[0] || part->avelocity[1] || part->avelocity[2]) { /* object is moving */ VectorScale(part->velocity, FRAMETIME, move); VectorScale(part->avelocity, FRAMETIME, amove); if (!SV_Push(part, move, amove)) break; /* move was blocked */ } } if (pushed_p > &pushed[MAX_EDICTS]) gi.error(ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); if (part) { /* the move failed, bump all nextthink times and back out * moves */ for (mv = ent; mv; mv = mv->teamchain) { if (mv->nextthink > 0) mv->nextthink += FRAMETIME; } /* if the pusher has a "blocked" function, call it * otherwise, just stay in place until the obstacle is gone */ if (part->blocked) part->blocked(part, obstacle); } else { /* the move succeeded, so call all think functions */ for (part = ent; part; part = part->teamchain) { SV_RunThink(part); } } }
/* ================ SV_Physics_Pusher ================ */ void SV_Physics_Pusher (edict_t *ent) { float thinktime; float oldltime; float movetime; vec3_t oldorg, move; float l; oldltime = ent->v.ltime; thinktime = ent->v.nextthink; if (thinktime < ent->v.ltime + sv_frametime) { movetime = thinktime - ent->v.ltime; if (movetime < 0) movetime = 0; } else movetime = sv_frametime; if (movetime) { if (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2]) SV_PushRotate (ent, sv_frametime); else SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked } if (thinktime > oldltime && thinktime <= ent->v.ltime) { VectorCopy (ent->v.origin, oldorg); ent->v.nextthink = 0; pr_global_struct->time = sv.time; pr_global_struct->self = EDICT_TO_PROG(ent); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); PR_ExecuteProgram (ent->v.think); if (!ent->inuse) return; VectorSubtract (ent->v.origin, oldorg, move); l = VectorLength(move); if (l > 1.0/64) { // Com_Printf ("**** snap: %f\n", Length (l)); VectorCopy (oldorg, ent->v.origin); SV_Push (ent, move); } } }
/* ============ SV_PushMove ============ */ void SV_PushMove (edict_t *pusher, float movetime) { int i; vec3_t move; if (!pusher->v.velocity[0] && !pusher->v.velocity[1] && !pusher->v.velocity[2]) { pusher->v.ltime += movetime; return; } for (i=0 ; i<3 ; i++) move[i] = pusher->v.velocity[i] * movetime; if (SV_Push (pusher, move)) pusher->v.ltime += movetime; }
/* ================ SV_Physics_Pusher Bmodel objects don't interact with each other, but push all box objects ================ */ void SV_Physics_Pusher (edict_t *ent) { vec3_t move, amove; edict_t *part, *mv; // if not a team captain, so movement will be handled elsewhere if ( ent->flags & FL_TEAMSLAVE) return; // make sure all team slaves can move before commiting // any moves or calling any think functions // if the move is blocked, all moved objects will be backed out //retry: pushed_p = pushed; for (part = ent ; part ; part=part->teamchain) { if (part->velocity[0] || part->velocity[1] || part->velocity[2] || part->avelocity[0] || part->avelocity[1] || part->avelocity[2] ) { // object is moving VectorScale (part->velocity, FRAMETIME, move); VectorScale (part->avelocity, FRAMETIME, amove); // JOSEPH 5-APR-99 if (!SV_Push (part, move, amove)) break; // move was blocked // END JOSEPH } } if (pushed_p > &pushed[MAX_EDICTS]) gi.error (ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); if (part) { // the move failed, bump all nextthink times and back out moves for (mv = ent ; mv ; mv=mv->teamchain) { if (mv->nextthink > 0) mv->nextthink += FRAMETIME; } // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone if (part->blocked) part->blocked (part, obstacle); #if 0 // if the pushed entity went away and the pusher is still there if (!obstacle->inuse && part->inuse) goto retry; #endif } else { // the move succeeded, so call all think functions for (part = ent ; part ; part=part->teamchain) { SV_RunThink (part); } } // JOSEPH 28-APR-99 if (ent->classname) { if (!strcmp(ent->classname, "func_button")) { int i; edict_t *e = NULL; for (i=1, e=g_edicts+i ; i < globals.num_edicts ; i++,e++) { if ((e->classname) && (!strcmp(e->classname, "func_lift")) && (e->target2) && (ent->target2) && (!strcmp(e->target2, ent->target2))) { ent->s.origin[2] = e->s.origin[2] + ent->handleflag; } } } else if (!strcmp(ent->classname, "func_lift")) { int i; edict_t *e = NULL; for (i=1, e=g_edicts+i ; i < globals.num_edicts ; i++,e++) { if ((e->classname) && (!strcmp(e->classname, "func_button")) && (e->target2) && (ent->target2) && (!strcmp(e->target2, ent->target2))) { e->s.origin[2] = ent->s.origin[2] + e->handleflag; } } } } // END JOSEPH }