Forum

Physics: Freeze all non-clients

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Physics: Freeze all non-clients

Postby Baker » Tue Jun 07, 2011 5:25 pm

Image

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;
.
.
.


3. Create an integer variable called entity_cap

void SV_Physics (void)
{
int i;
int entity_cap; // For sv_freezenonclients
edict_t *ent;


4. Conditionally run the physics on all the entities or just players + the world instead of all the entities.

// 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))


5. Don't advance the server time. Go to bottom of function and add the yellow.

if (!sv_freezenonclients.value)
sv.time += host_frametime;
}


6. Start a map. Run around and then do "sv_freezenonclients 1" in the console.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby stevenaaus » Fri Jun 10, 2011 3:11 am

Ha ha.. thanks Baker.

The code is in quakespasm subversion - at least for the moment - as not sure how useful it is. Shame you can't have some fun and shoot them up while frozen.

svn co https://quakespasm.svn.sourceforge.net/ ... pasm/trunk -r 457
stevenaaus
 
Posts: 23
Joined: Fri Jan 08, 2010 10:15 am

Postby ooppee » Fri Jun 10, 2011 6:40 am

Like to see this out so other engines can support it. I use this command VERY frequently in DP to test out models. Hard to see the texture detail on a enemy shooting you and constantly moving.
ooppee
 
Posts: 70
Joined: Thu Oct 28, 2010 2:57 am


Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest