/* ================ 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; }
void Physics_ServerFrame(void) { int i; edict_t *eEntity; // Let the progs know that a new frame has started pr_global_struct.self = EDICT_TO_PROG(sv.edicts); pr_global_struct.eOther = sv.edicts; // TODO: should we pass the time to this? ~hogsy Game->Server_StartFrame(); // Treat each object in turn eEntity = sv.edicts; for(i = 0; i < sv.num_edicts; i++,eEntity = NEXT_EDICT(eEntity)) { if(eEntity->free) continue; if(pr_global_struct.force_retouch) SV_LinkEdict(eEntity,true); // Force retouch even for stationary // [11/7/2013] Cleaned this up and gave it its own function ~hogsy Game->Server_EntityFrame(eEntity); if(i > 0 && i <= svs.maxclients) SV_Physics_Client(eEntity,i); else { switch(eEntity->v.movetype) { case MOVETYPE_NONE: Server_RunThink(eEntity); break; case MOVETYPE_PUSH: SV_Physics_Pusher(eEntity); break; case MOVETYPE_NOCLIP: Physics_NoClip(eEntity); break; case MOVETYPE_WALK: case MOVETYPE_STEP: Game->Physics_CheckVelocity(eEntity); Game->Physics_SetGravity(eEntity); Physics_AddFriction(eEntity,eEntity->v.velocity,eEntity->v.origin); SV_WalkMove(eEntity); SV_LinkEdict(eEntity,true); Server_RunThink(eEntity); break; case MOVETYPE_TOSS: case MOVETYPE_BOUNCE: case MOVETYPE_FLY: case MOVETYPE_FLYMISSILE: case MOVETYPE_FLYBOUNCE: Physics_Toss(eEntity); break; default: Con_Warning("Bad movetype set for entity! (%s)",eEntity->v.cClassname); } } } 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; 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; 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; }