DarkPlaces has a really cool cvar (sv_freezenonclients) that stops the physics and QuakeC for everything except players. Basically, the world freezes and the monsters stop and you can go around and tour and inspect the world. Particles stay where they are, falling things stop in mid-air, etc.
Sometimes when you are working on a single player mod, you just want everything to stop moving beyond what "notarget" and "god" and "noclip" have to offer.
Adding sv_freezenonclients...
1. Create and register the cvar sv_freezenonclients.
2. In sv_phys.c
Locate the SV_Physics function, we will be changing this ...
Code: Select all
/*
================
SV_Physics
================
*/
void SV_Physics (void)
{
int i;
edict_t *ent;
.
.
.
4. Conditionally run the physics on all the entities or just players + the world instead of all the entities.void SV_Physics (void)
{
int i;
int entity_cap; // For sv_freezenonclients
edict_t *ent;
5. Don't advance the server time. Go to bottom of function and add the yellow.// treat each object in turn
ent = sv.edicts;
if (sv_freezenonclients.value)
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))
//old was: for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
6. Start a map. Run around and then do "sv_freezenonclients 1" in the console.if (!sv_freezenonclients.value)
sv.time += host_frametime;
}