Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Hibernation mode #826
Please don't store the cvar old value in a std::string
Plus you didn't include !
Cvar_SetValue does exist so you can save values. Might be better to not make extra globals and put them in a server structure. It's still very hackish to actually change the sv_fps value though. It may trigger issues with the client snaps limiting to server fps.
I would hold off on merging this right now because there's a patch for com_dedicated_sleep that may also be useful.
I can't comment on code quality, but since I asked @EpicLoyd to code this, I figured I'd give a little bit of background.
What this does is reduce sv_fps to 1 when a server doesn't have any humans online for sv_hibernatetime seconds, then revert it to the previous value when a human connects. It saves a lot of CPU for servers which run a lot of bots, or when a lot of different servers are hosted on a single machine, as is the case with my hosting. I've been running it in production without any issues for several days on 30ish instances of openjkded.i386.
Afaik, client snaps will not be limited unless sv_snapsmax is set, and as said, I haven't received any reports of issues about this whatsoever. By default, sv_hibernatetime is 0, so the server does not hibernate at all unless the server owner sets it to.