Skip to content

Python1320/gmsv_physframe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

gmsv_physframe

Warning

HERE BE DRAGONS

Hooks into Source engine physics to provide crash mitigation / physics simulation control. Used on Metastruct for past ~10 years for crash mitigation.

image

Intercepts PhysFrame, PhysIsInCallback, PhysOnCleanupDeleteList, and "IVP tree expansion" to:

  • Pause/unpause physics simulation from Lua (_G.SetShouldSimulate, _G.GetShouldSimulate)
  • Time individual physics frames (GetPhysFrameLength) (now implemented in GMod)
  • Suppress physics cleanup when the server is about to crash (used by gmsv_segfault)
  • Detect "runaway" "IVP tree expansion" and fire a Lua callback (PhysFailed) (false positives?)

Also includes:

  • stop_physics_damnit: Callable from C to prevent physics cleanup deletion during crash handling.

Lua API (registered on successful init)

Lua function C function Description
SetShouldSimulate(bool) SetShouldSimulate Pause/resume physics simulation
GetShouldSimulate() GetShouldSimulate Returns whether physics is simulating
GetPhysFrameLength() GetPhysFrameLength Returns last physics frame time in seconds
PhysFailed() (callback) Called when IVP tree expansion exceeds safe limits

Build

  1. Install premake
  2. Copy this repo inside the gbins alongside all the other binary modules
  3. Run build.cmd or build as appropriate

Install

  1. Put gmsv_physframe_linux.dll into garrysmod/lua/bin/
  2. Install autorun lua to server.

Notes

  • Depends on symbol signatures from server_srv.so and vphysics_srv.so — x86-64 branch not supported.
  • Physics pausing works by patching the m_bPaused field at offset +0x58 on CPhysicsHook, uhoh.

Thanks

Garry, Metastruct, FreezeBug, BlueShank, MetaMan, SpiralP, CapsAdmin, etc, etc etc

About

Garry's Mod Source Engine Physics frame debug hacks

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages