Ronchon
Member
Hi!
After updating to latest version, i've witnessed a few weird corrupted calculation results in my game.
No errors, just odd values.
After narrowing one down, i diagnosed it with debug messages and found out the variables involved were in an apparently corrupted state. Neither a real, nor a string, nor undefined, nor NaN. Not throwing errors, still acting up as a normal real in most cases except for some calculations, for unknown reasons.
Below is the case i diagnosed, involving 2 variables called sc_state_cltr (=310) and sc_tot_cltr (=359).
Can anyone explain these results? What the hell is going on here ?
________________________________________________________________
UPDATE:
After tracking the "path" of these variables to see at what point they became corrupted, i found out the potential buggy cause.
At one point these variables values are transferred to the client via a buffer ( multiplayer game ).
The corruption seems to be originating from the buffer_read function, when setting the variable's value on the client from the received buffer.
These variables were of the buffer_s16 type.
It seemed to affect only some specific types of values and not all. Maybe even just buffer_s16. hard to tell at this point.
I'll add a " real" failsafe on all these functions to try fixing the issue for now.
buggy function:
After updating to latest version, i've witnessed a few weird corrupted calculation results in my game.
No errors, just odd values.
After narrowing one down, i diagnosed it with debug messages and found out the variables involved were in an apparently corrupted state. Neither a real, nor a string, nor undefined, nor NaN. Not throwing errors, still acting up as a normal real in most cases except for some calculations, for unknown reasons.
Below is the case i diagnosed, involving 2 variables called sc_state_cltr (=310) and sc_tot_cltr (=359).
Can anyone explain these results? What the hell is going on here ?
Code:
show_debug_message("sc_state_cltr: "+string(sc_state_cltr)+" is real? "+string(is_real(sc_state_cltr))+" is string? "+string(is_string(sc_state_cltr)) )
show_debug_message("sc_tot_cltr: "+string(sc_tot_cltr)+" is real? "+string(is_real(sc_tot_cltr))+" is string? "+string(is_string(sc_tot_cltr)) )
show_debug_message("0 - "+string( sc_state_cltr)+"/"+string(sc_tot_cltr) )
show_debug_message("1 - "+string( sc_state_cltr/sc_tot_cltr ))
show_debug_message("2 - "+string( sc_state_cltr/sc_tot_cltr*100 ))
show_debug_message("3 - "+string( round(sc_state_cltr/sc_tot_cltr *100) ))
show_debug_message("4 - "+string( 2*( round(sc_state_cltr/sc_tot_cltr *100)-50 ) ))
show_debug_message("5 - "+string( real(sc_state_cltr)/real(sc_tot_cltr) ))
show_debug_message("6 - "+string( real(string(sc_state_cltr))/real(string(sc_tot_cltr)) ))
sc_state_cltr: 310 is real? 0 is string? 0
sc_tot_cltr: 359 is real? 0 is string? 0
0 - 310/359
1 - 0
2 - 0
3 - 0
4 - -100
5 - 0.86
6 - 0.86
________________________________________________________________
UPDATE:
After tracking the "path" of these variables to see at what point they became corrupted, i found out the potential buggy cause.
At one point these variables values are transferred to the client via a buffer ( multiplayer game ).
The corruption seems to be originating from the buffer_read function, when setting the variable's value on the client from the received buffer.
These variables were of the buffer_s16 type.
It seemed to affect only some specific types of values and not all. Maybe even just buffer_s16. hard to tell at this point.
I'll add a " real" failsafe on all these functions to try fixing the issue for now.
buggy function:
changed to this to fix, adding real() as a failsafe to uncorrupt the buffer_read results:buffer_read(sc_buffer,buffer_s16)
real(buffer_read(sc_buffer,buffer_s16))
Last edited: