/* * G_RunEntity * */ void G_RunEntity( edict_t *ent ) { edict_t *part; if( !level.canSpawnEntities ) { // don't try to think before map entities are spawned return; } if( ISEVENTENTITY( &ent->s ) ) { // events do not think return; } if( ent->timeDelta && !( ent->r.svflags & SVF_PROJECTILE ) ) { G_Printf( "Warning: G_RunEntity 'Fixing timeDelta on non projectile entity\n" ); ent->timeDelta = 0; } // only team captains decide the think, and they make think their team members when they do if( !( ent->flags & FL_TEAMSLAVE ) ) { for( part = ent; part; part = part->teamchain ) { SV_RunThink( part ); } } switch( (int)ent->movetype ) { case MOVETYPE_NONE: case MOVETYPE_NOCLIP: // only used for clients, that use pmove SV_Physics_None( ent ); break; case MOVETYPE_PLAYER: SV_Physics_None( ent ); break; case MOVETYPE_PUSH: case MOVETYPE_STOP: SV_Physics_Pusher( ent ); break; case MOVETYPE_BOUNCE: case MOVETYPE_BOUNCEGRENADE: SV_Physics_Toss( ent ); break; case MOVETYPE_TOSS: SV_Physics_Toss( ent ); break; case MOVETYPE_FLY: SV_Physics_Toss( ent ); break; case MOVETYPE_LINEARPROJECTILE: SV_Physics_LinearProjectile( ent ); break; case MOVETYPE_TOSSSLIDE: G_BoxSlideMove( ent, ent->r.clipmask ? ent->r.clipmask : MASK_PLAYERSOLID, 1.01f, 10 ); break; case MOVETYPE_STEP: SV_Physics_Step( ent ); break; default: G_Error( "SV_Physics: bad movetype %i", (int)ent->movetype ); } }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; edict_t *ent; // let the progs know that a new frame has started pr_global_struct->self = ((int)EDICT_TO_PROG(sv.edicts)); pr_global_struct->other = ((int)EDICT_TO_PROG(sv.edicts)); pr_global_struct->time = sv.time; PR_ExecuteProgram (pr_global_struct->StartFrame); //SV_CheckAllEnts (); // // treat each object in turn // ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; if (pr_global_struct->force_retouch) { SV_LinkEdict (ent, true); // force retouch even for stationary } if (i > 0 && i <= svs.maxclients) SV_Physics_Client (ent, i); else if (ent->v.movetype == MOVETYPE_PUSH) SV_Physics_Pusher (ent); else if (ent->v.movetype == MOVETYPE_FAKEPUSH) SV_Physics_FakePusher (ent); else if (ent->v.movetype == MOVETYPE_NONE) SV_Physics_None (ent); #ifdef QUAKE2 else if (ent->v.movetype == MOVETYPE_FOLLOW) SV_Physics_Follow (ent); #endif else if (ent->v.movetype == MOVETYPE_NOCLIP) SV_Physics_Noclip (ent); else if (ent->v.movetype == MOVETYPE_STEP) SV_Physics_Step (ent); else if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE #ifdef QUAKE2 || ent->v.movetype == MOVETYPE_BOUNCEMISSILE #endif || ent->v.movetype == MOVETYPE_FLY || ent->v.movetype == MOVETYPE_FLYMISSILE) SV_Physics_Toss (ent); else Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); } if (pr_global_struct->force_retouch) pr_global_struct->force_retouch--; sv.time += host_frametime; }
/* ================ SV_RunEntity ================ */ void SV_RunEntity (edict_t *ent) { if (ent->v.lastruntime == (float)realtime) return; ent->v.lastruntime = (float)realtime; switch ( (int)ent->v.movetype) { case MOVETYPE_PUSH: SV_Physics_Pusher (ent); break; case MOVETYPE_NONE: SV_Physics_None (ent); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip (ent); break; case MOVETYPE_STEP: SV_Physics_Step (ent); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLY: case MOVETYPE_FLYMISSILE: SV_Physics_Toss (ent); break; default: SV_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); } }
/* ================ G_RunEntity ================ */ void G_RunEntity (edict_t *ent) { if (ent->prethink) ent->prethink (ent); switch ( (int)ent->movetype) { case MOVETYPE_PUSH: case MOVETYPE_STOP: SV_Physics_Pusher (ent); break; case MOVETYPE_NONE: SV_Physics_None (ent); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip (ent); break; case MOVETYPE_STEP: SV_Physics_Step (ent); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLY: case MOVETYPE_FLYMISSILE: case MOVETYPE_WALLBOUNCE: case MOVETYPE_TOSS_SLIDE: SV_Physics_Toss (ent); break; default: gi.error ("SV_Physics: bad movetype %i", (int)ent->movetype); } }
//============================================================================ static void SV_Physics_Entity( edict_t *ent ) { // user dll can override movement type (Xash3D extension) if( svgame.physFuncs.SV_PhysicsEntity && svgame.physFuncs.SV_PhysicsEntity( ent )) return; // overrided SV_UpdateBaseVelocity( ent ); if(!( ent->v.flags & FL_BASEVELOCITY ) && !VectorIsNull( ent->v.basevelocity )) { // Apply momentum (add in half of the previous frame of velocity first) VectorMA( ent->v.velocity, 1.0f + (host.frametime * 0.5f), ent->v.basevelocity, ent->v.velocity ); VectorClear( ent->v.basevelocity ); } ent->v.flags &= ~FL_BASEVELOCITY; if( svgame.globals->force_retouch != 0.0f ) { // force retouch even for stationary SV_LinkEdict( ent, true ); } switch( ent->v.movetype ) { case MOVETYPE_NONE: SV_Physics_None( ent ); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip( ent ); break; case MOVETYPE_FOLLOW: SV_Physics_Follow( ent ); break; case MOVETYPE_COMPOUND: SV_Physics_Compound( ent ); break; case MOVETYPE_STEP: case MOVETYPE_PUSHSTEP: SV_Physics_Step( ent ); break; case MOVETYPE_FLY: case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLYMISSILE: case MOVETYPE_BOUNCEMISSILE: SV_Physics_Toss( ent ); break; case MOVETYPE_PUSH: SV_Physics_Pusher( ent ); break; case MOVETYPE_WALK: Host_Error( "SV_Physics: bad movetype %i\n", ent->v.movetype ); break; } // g-cont. don't alow free entities during loading because // this produce a corrupted baselines if( sv.state == ss_active && ent->v.flags & FL_KILLME ) SV_FreeEdict( ent ); }
/* ================ G_RunEntity ================ */ void G_RunEntity (edict_t *ent) { //PGM trace_t trace; vec3_t previous_origin; if(ent->movetype == MOVETYPE_STEP) VectorCopy(ent->s.origin, previous_origin); //PGM if (ent->prethink) ent->prethink (ent); switch ( (int)ent->movetype) { case MOVETYPE_PUSH: case MOVETYPE_STOP: SV_Physics_Pusher (ent); break; case MOVETYPE_NONE: SV_Physics_None (ent); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip (ent); break; case MOVETYPE_STEP: SV_Physics_Step (ent); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLY: case MOVETYPE_FLYMISSILE: SV_Physics_Toss (ent); break; case MOVETYPE_NEWTOSS: SV_Physics_NewToss (ent); break; default: gi.error ("SV_Physics: bad movetype %i", (int)ent->movetype); } //PGM if(ent->movetype == MOVETYPE_STEP) { // if we moved, check and fix origin if needed if (!VectorCompare(ent->s.origin, previous_origin)) { trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, previous_origin, ent, MASK_MONSTERSOLID); if(trace.allsolid || trace.startsolid) VectorCopy (previous_origin, ent->s.origin); } } //PGM }
/* * ================ G_RunEntity ================ */ void G_RunEntity(edict_t * ent) { if (!ent) return; if (ent->prethink) ent->prethink(ent); switch ((int)ent->movetype) { #ifdef WITH_ACEBOT /* ACEBOT_ADD */ case MOVETYPE_WALK: SV_RunThink(ent); break; /* ACEBOT_END */ #endif case MOVETYPE_PUSH: case MOVETYPE_STOP: SV_Physics_Pusher(ent); break; case MOVETYPE_NONE: SV_Physics_None(ent); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip(ent); break; case MOVETYPE_STEP: SV_Physics_Step(ent); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLY: case MOVETYPE_FLYMISSILE: // RAFAEL case MOVETYPE_WALLBOUNCE: SV_Physics_Toss(ent); break; default: gi.error("SV_Physics: bad movetype %i", (int)ent->movetype); } }
/* ================ G_RunEntity ================ */ void G_RunEntity (edict_t * ent) { if (ent->prethink) ent->prethink (ent); switch ((int) ent->movetype) { case MOVETYPE_PUSH: case MOVETYPE_STOP: SV_Physics_Pusher (ent); break; case MOVETYPE_NONE: SV_Physics_None (ent); break; case MOVETYPE_NOCLIP: SV_Physics_Noclip (ent); break; case MOVETYPE_STEP: SV_Physics_Step (ent); break; case MOVETYPE_BOUNCE: SV_Physics_Bounce (ent); // provided by siris break; case MOVETYPE_TOSS: case MOVETYPE_FLY: // zucc added for blood splatting case MOVETYPE_BLOOD: // zucc case MOVETYPE_FLYMISSILE: SV_Physics_Toss (ent); break; default: gi.error ("SV_Physics: bad movetype %i", (int) ent->movetype); } }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; edict_t *ent; // 2000-04-30 NVS HANDSHAKE SRV<->CL/QC<->CL by Maddes start eval_t *val; // let the QuakeC code know the NVS versions of the server and clients if (pr_field_nvs_svc) { // set world/server // 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes start // val = GetEdictFieldValue(sv.edicts, "nvs_svc"); val = GETEDICTFIELDVALUE(sv.edicts, pr_field_nvs_svc); // 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes end if (val) { val->_float = nvs_current_ssvc->value; } // set clients ent = NEXT_EDICT(sv.edicts); // set to first not-world entity (=1st client) for (i=1 ; i<=svs.maxclients && i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; if (!svs.clients[i-1].active) continue; // unconnected slot // 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes start // val = GetEdictFieldValue(ent, "nvs_svc"); val = GETEDICTFIELDVALUE(ent, pr_field_nvs_svc); // 2001-11-15 Better GetEdictFieldValue performance by LordHavoc/Maddes end if (val) { val->_float = svs.clients[i-1].nvs_csvc; } } } // 2000-04-30 NVS HANDSHAKE SRV<->CL/QC<->CL by Maddes end // let the progs know that a new frame has started pr_global_struct->self = EDICT_TO_PROG(sv.edicts); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); pr_global_struct->time = sv.time; PR_ExecuteProgram (pr_global_struct->StartFrame); //SV_CheckAllEnts (); // // treat each object in turn // ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; if (pr_global_struct->force_retouch) { SV_LinkEdict (ent, true); // force retouch even for stationary } if (i > 0 && i <= svs.maxclients) SV_Physics_Client (ent, i); else if (ent->v.movetype == MOVETYPE_PUSH) SV_Physics_Pusher (ent); else if (ent->v.movetype == MOVETYPE_NONE) SV_Physics_None (ent); else if (ent->v.movetype == MOVETYPE_FOLLOW) SV_Physics_Follow (ent); else if (ent->v.movetype == MOVETYPE_NOCLIP) SV_Physics_Noclip (ent); else if (ent->v.movetype == MOVETYPE_STEP) SV_Physics_Step (ent); else if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE || ent->v.movetype == MOVETYPE_BOUNCEMISSILE || ent->v.movetype == MOVETYPE_FLY || ent->v.movetype == MOVETYPE_FLYMISSILE) SV_Physics_Toss (ent); else Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); } // 2000-01-02 EndFrame function by Maddes/FrikaC start if (pr_func_endframe) { // let the progs know that a new frame has ended pr_global_struct->self = EDICT_TO_PROG(sv.edicts); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); pr_global_struct->time = sv.time; PR_ExecuteProgram (pr_func_endframe); } // 2000-01-02 EndFrame function by Maddes/FrikaC end if (pr_global_struct->force_retouch) pr_global_struct->force_retouch--; sv.time += host_frametime; }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; edict_t *ent; // let the progs know that a new frame has started #ifdef HEXEN2_SUPPORT edict_t *ent2; vec3_t oldOrigin, oldAngle; int originMoved, c; #endif PR_GLOBAL(self) = EDICT_TO_PROG(sv.edicts); PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts); PR_GLOBAL(time) = sv.time; PR_ExecuteProgram (PR_GLOBAL(StartFrame)); //SV_CheckAllEnts (); // treat each object in turn ent = sv.edicts; for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; #ifndef RQM_SV_ONLY if (!isDedicated && ((i+1) % 100 == 0)) S_ExtraUpdateTime (); // BJP: Improve sound when many entities #endif #ifdef HEXEN2_SUPPORT if (hexen2) { ent2 = PROG_TO_EDICT (ent->v.movechain); if (ent2 != sv.edicts) { VectorCopy (ent->v.origin, oldOrigin); VectorCopy (ent->v.angles, oldAngle); } } #endif if (pr_global_ptrs.force_retouch && *pr_global_ptrs.force_retouch) SV_LinkEdict (ent, true); // force retouch even for stationary if (i > 0 && i <= svs.maxclients) SV_Physics_Client (ent, i); else if (ent->v.movetype == MOVETYPE_PUSH) SV_Physics_Pusher (ent); else if (ent->v.movetype == MOVETYPE_NONE) SV_Physics_None (ent); else if (ent->v.movetype == MOVETYPE_NOCLIP) SV_Physics_Noclip (ent); else if (ent->v.movetype == MOVETYPE_STEP) SV_Physics_Step (ent); #ifdef HEXEN2_SUPPORT else if ((hexen2) && (ent->v.movetype == MOVETYPE_PUSHPULL)) SV_Physics_Step (ent); #endif else if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE #ifdef HEXEN2_SUPPORT || ((hexen2) && ((ent->v.movetype == MOVETYPE_BOUNCEMISSILE) || (ent->v.movetype == MOVETYPE_SWIM))) #endif || ent->v.movetype == MOVETYPE_FLY || ent->v.movetype == MOVETYPE_FLYMISSILE) SV_Physics_Toss (ent); else Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); #ifdef HEXEN2_SUPPORT if ((hexen2) && (ent2 != sv.edicts)) { originMoved = !VectorCompare(ent->v.origin, oldOrigin); if (originMoved || !VectorCompare(ent->v.angles, oldAngle)) { VectorSubtract(ent->v.origin, oldOrigin, oldOrigin); VectorSubtract(ent->v.angles, oldAngle, oldAngle); for (c=0; c<10; c++) { // chain a max of 10 objects if (ent2->free) break; VectorAdd(oldOrigin, ent2->v.origin, ent2->v.origin); if ((int) ent2->v.flags & FL_MOVECHAIN_ANGLE) { VectorAdd(oldAngle, ent2->v.angles, ent2->v.angles); } if (originMoved && ent2->v.chainmoved) { // callback function *pr_global_ptrs.self = EDICT_TO_PROG(ent2); *pr_global_ptrs.other = EDICT_TO_PROG(ent); PR_ExecuteProgram(ent2->v.chainmoved); } ent2 = PROG_TO_EDICT( ent2->v.movechain ); if (ent2 == sv.edicts) break; } } } #endif } if (pr_global_ptrs.force_retouch && *pr_global_ptrs.force_retouch) PR_GLOBAL(force_retouch)--; sv.time += host_frametime; }
/* ================ SV_Physics ================ */ void SV_Physics (void) { int i; int entity_cap; // For sv_freezenonclients edict_t *ent; // let the progs know that a new frame has started pr_global_struct->self = EDICT_TO_PROG(sv.edicts); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); pr_global_struct->time = sv.time; PR_ExecuteProgram (pr_global_struct->StartFrame); //SV_CheckAllEnts (); // // treat each object in turn // ent = sv.edicts; if (sv.frozen) entity_cap = svs.maxclients + 1; // Only run physics on clients and the world else entity_cap = sv.num_edicts; for (i=0 ; i<entity_cap ; i++, ent = NEXT_EDICT(ent)) // for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; if (pr_global_struct->force_retouch) { SV_LinkEdict (ent, true); // force retouch even for stationary } if (i > 0 && i <= svs.maxclients) SV_Physics_Client (ent, i); else if (ent->v.movetype == MOVETYPE_PUSH) SV_Physics_Pusher (ent); else if (ent->v.movetype == MOVETYPE_NONE) SV_Physics_None (ent); else if (ent->v.movetype == MOVETYPE_FOLLOW) // Nehahra SV_Physics_Follow (ent); else if (ent->v.movetype == MOVETYPE_NOCLIP) SV_Physics_Noclip (ent); else if (ent->v.movetype == MOVETYPE_STEP) SV_Physics_Step (ent); else if (ent->v.movetype == MOVETYPE_WALK) // Nehahra { if (!SV_RunThink (ent)) return; if (!SV_CheckWater (ent) && ! ((int)ent->v.flags & FL_WATERJUMP) ) SV_AddGravity (ent); SV_CheckStuck (ent); SV_WalkMove (ent); } else if (ent->v.movetype == MOVETYPE_TOSS || ent->v.movetype == MOVETYPE_BOUNCE || ent->v.movetype == MOVETYPE_FLY || ent->v.movetype == MOVETYPE_FLYMISSILE) SV_Physics_Toss (ent); else Host_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype); } if (pr_global_struct->force_retouch) pr_global_struct->force_retouch--; if (!sv.frozen) sv.time += host_frametime; }