mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
Backports retail 4.x's frame-cached GetTime() behavior under a distinct name, leaving vanilla GetTime() live/per-call. 1.12's Script_GetTime recomputes the OS tick on every call, so same-frame calls can differ; GetTimeCached() samples once per frame (via the shared Tick::WorldTick hook) and returns that until the next frame, on the same epoch as GetTime() so the two are directly comparable. Falls back to a live sample before the first world tick so it never returns 0. Deliberately NOT a perf feature and documented as such: the 1.12 tick source is cheap (GetTickCount shared-page read or rdtsc) and both functions pay the same dominant Lua->C dispatch, so caching saves nothing measurable. The only benefit is frame-stable semantics; the real hot-loop fix is caching GetTime() in a Lua local, which no C function can do for the caller. New global chosen over modifying GetTime() to avoid changing a core vanilla function's behavior.