Page 1 of 1

Physics: Freeze all non-clients

Posted: Tue Jun 07, 2011 5:25 pm
by Baker
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.

Posted: Fri Jun 10, 2011 3:11 am
by stevenaaus
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

Posted: Fri Jun 10, 2011 6:40 am
by ooppee
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.