mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Skip leading whitespace in Q_atoi and Q_atof
This matches the standard library and also fixes the following bug:
- load ad_sepulcher and move to an area where water is visible
- open up the console
- save waterbug
- load waterbug
Water is now invisible as long as the console is still active.
The issue stems from the fact that cvar_set is called at startup
with the arguments ("r_wateralpha", ftos(liquid_alpha)) [1],
and ftos pads its output (" 0.6"). Without skipping the leading
whitespace, Q_atof ends up returning 0, which then gets assigned
to r_wateralpha. This makes the water invisible until a stuffcmd
that sets r_wateralpha again is later received from the server.
With the console open at startup, however, the stuffcmd message
can be delayed indefinitely.
[1] 320f1cec45/world.qc (L641)
This commit is contained in:
parent
6071c47c91
commit
8f4c5b3dfa
1 changed files with 6 additions and 0 deletions
|
@ -421,6 +421,9 @@ int Q_atoi (const char *str)
|
|||
int sign;
|
||||
int c;
|
||||
|
||||
while (q_isspace (*str))
|
||||
++str;
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
sign = -1;
|
||||
|
@ -481,6 +484,9 @@ float Q_atof (const char *str)
|
|||
int c;
|
||||
int decimal, total;
|
||||
|
||||
while (q_isspace (*str))
|
||||
++str;
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
sign = -1;
|
||||
|
|
Loading…
Reference in a new issue