Files
fulpstation/code/__HELPERS/stoplag.dm
Nick 2f028886fc Late September TGU: Bitrunning and other stuff probably (#1053)
* September TGU: Initial commit

* September TGU: Updates wounds

* some mob changes

* September TGU: Removed infil tool parcel

* September TGU: Spider path change

* September TGU: Updated m_intent to move_intent

* September TGU: Refactor of no_transform to trait

* September TGU: Removes BEPIS machines o7

* September TGU: Vomit refactor

* September TGU: Fixs typo

* September TGU: FULP EDIT
Adds our greyscales folder to a sanity check

* September TGU: Implemented icon_for for beefmen

* September TGU: Occupancy limits for shuttles

* September TGU: Added bitrunning to helio

* September TGU: Added bitrunning to selene

* September TGU: Pubbystation bitrunning

* September TGU: Added cams to bitrunner rooms

* September TGU: Appeasing linter

* September TGU: More linter appeasment

* More linter

* i love unit testing !!!

* more unit test fixes

* Maybe fixes screenshot test

* Removes bitrunning unit test.
This exact change has already been made on TG's master, right after
i copied stuff over from there

* Nah we just ignore it whatever

* Accidentally updated maps.txt oopsie

* Removes bitrunning unit tests
This has already been done on TG

* Fixed TGUI (missed a tg edit)

* Made a TG edit more visible

* Removing self-assigning objectives until we have a policy on that

* Maps now use proper MOD crate

* Ports chaplain offering fixes

* Ported #78622 from TG

* Merges helio rewiring

* oooooh spooky
Ports #79062 from upstream

* Fixing mapping issues
2023-10-21 16:48:16 -03:00

29 lines
1.1 KiB
Plaintext

//Key thing that stops lag. Cornerstone of performance in ss13, Just sitting here, in unsorted.dm. Now with dedicated file!
///Increases delay as the server gets more overloaded, as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful
#define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta-1,1)), 1)
///returns the number of ticks slept
/proc/stoplag(initial_delay)
if (!Master || Master.init_stage_completed < INITSTAGE_MAX)
sleep(world.tick_lag)
return 1
if (!initial_delay)
initial_delay = world.tick_lag
// Unit tests are not the normal environemnt. The mc can get absolutely thigh crushed, and sleeping procs running for ages is much more common
// We don't want spurious hard deletes off this, so let's only sleep for the requested period of time here yeah?
#ifdef UNIT_TESTS
sleep(initial_delay)
return CEILING(DS2TICKS(initial_delay), 1)
#else
. = 0
var/i = DS2TICKS(initial_delay)
do
. += CEILING(i * DELTA_CALC, 1)
sleep(i * world.tick_lag * DELTA_CALC)
i *= 2
while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit))
#endif
#undef DELTA_CALC