-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button spawnflag "Sparks" doesn't work as intended #1681
Comments
Note that this only happens if maxplayers is larger than 1. In singleplayer it works because the engine simulates few enough frames that the initial time still works. This can be tested easily on Additionally the link above doesn't work properly, so here's a proper one: Line 574 in c7240b9
See Quake for the logic behind the use of |
There is an additional change needed to fully fix this: Line 796 in c7240b9
This needs to be changed to: pev->nextthink = pev->ltime + 0.5;// no hurry. Otherwise the sparks may not show at all once the button has been activated and returned to its off state. |
The func_button spawnflag "Sparks" does not work as intended. Because it uses gpGlobals->time, its nextthink will be incorrect. It should be using pev->ltime.
Offending line: https://github.com/ValveSoftware/halflife/blob/master/dlls/buttons.cpp#L574
Change
pev->nextthink = gpGlobals->time + ( 0.1 + RANDOM_FLOAT ( 0, 1.5 ) );// spark again at random interval
to
pev->nextthink = pev->ltime + ( 0.1 + RANDOM_FLOAT ( 0, 1.5 ) );// spark again at random interval
This happens because buttons use a different approach to thinking. Unlike all other move types, they only think if nextthink falls between ltime and ltime + frametime. If gpGlobals->time is used, then nextthink may be smaller than ltime.
The engine simulates several frames to get physics going, so it's very likely to cause this issue. gpGlobals->time is 1 during map spawn simulation, whereas pev->ltime changes with every frame.
Dedicated servers seem more affected, likely due to differing frametime.
Note: this issue was made by @SamVanheer while logged into an account used for a college assignment. Refer to him for more information.
The text was updated successfully, but these errors were encountered: