Skip to content
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

Stray floating point characters #78800

Open
CassiLags opened this issue Dec 27, 2024 · 10 comments
Open

Stray floating point characters #78800

CassiLags opened this issue Dec 27, 2024 · 10 comments
Labels
(S2 - Confirmed) Bug that's been confirmed to exist

Comments

@CassiLags
Copy link

Describe the bug

The following shows up when loading the save:

DEBUG : Stray characters at end of floating point value 0.000000 in item::get_var

FUNCTION : get_var
FILE : D:\a\Cataclysm-DDA\Cataclysm-DDA\src\item.cpp
LINE : 1894
VERSION : 44b3817

Save was created on stable 0.H and then ported to version 44b3817

Attach save file

Wayside-trimmed.tar.gz

Steps to reproduce

Load the save.

Expected behavior

Not seeing an error.

Screenshots

No response

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.22631.4602 (23H2)
  • Game Version: 44b3817 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

Additional context

No response

@CassiLags CassiLags added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Dec 27, 2024
@kasanryukin
Copy link
Contributor

kasanryukin commented Dec 27, 2024

Unable to reproduce on 124c494

Edit: Also unable to reproduce on a014c17

@moxian
Copy link
Contributor

moxian commented Dec 27, 2024

Confirm unable to reproduce on specified version 44b3817. I would guess the wrong var got overwritten the next time the game was saved.

For reference, debug log (provided in discord) ``` ----------------------------------------- 19:37:20.895 : Starting log. 19:37:20.895 INFO : Cataclysm DDA version 44b3817 19:37:20.896 INFO : [main] C locale set to Portuguese_Brazil.utf8 19:37:20.896 INFO : [main] C++ locale set to 19:37:20.896 INFO : SDL version used during compile is 2.30.10 19:37:20.896 INFO : SDL version used during linking and in runtime is 2.30.10 19:37:20.985 INFO : SDL render devices: direct3d, direct3d11, direct3d12, opengl, opengles2, software 19:37:21.019 INFO : [options] C locale set to en_US.UTF-8 19:37:21.019 INFO : [options] C++ locale set to en_US.UTF-8 19:37:21.019 INFO : Setting language to: 'en' 19:37:21.019 INFO : [i18n] Scanning core translations from lang/mo/ 19:37:21.195 INFO : Active renderer: 1/direct3d11 19:37:21.411 INFO : USE_COLOR_MODULATED_TEXTURES is set to 0 19:37:21.444 INFO : Setting language to: 'en' 19:37:41.012 INFO : Loaded tileset: UltimateCataclysm 19:37:41.150 INFO : Loaded tileset: Larwick Overmap 19:37:55.850 ERROR : (error message will follow backtrace) #0 (dbghelp: debug_write_backtrace+0xb5@00007FF667E77A05[cataclysm-tiles.exe+0x557a05]), #1 (dbghelp: DebugLog+0x2b8@00007FF667E76768[cataclysm-tiles.exe+0x556768]), #2 (dbghelp: realDebugmsg+0x1fd@00007FF667E79ABD[cataclysm-tiles.exe+0x559abd]), #3 (dbghelp: item::get_var+0x3b1@00007FF668711EA1[cataclysm-tiles.exe+0xdf1ea1]), #4 (dbghelp: item::processing_speed+0x120@00007FF6687373D0[cataclysm-tiles.exe+0xe173d0]), #5 (dbghelp: active_item_cache::add+0x1e7@00007FF668FE8267[cataclysm-tiles.exe+0x16c8267]), #6 (dbghelp: vehicle::refresh_active_item_cache+0x415@00007FF6685B2E75[cataclysm-tiles.exe+0xc92e75]), #7 (dbghelp: vehicle::refresh+0x2093@00007FF6685B2983[cataclysm-tiles.exe+0xc92983]), #8 (dbghelp: vehicle::deserialize+0x1102@00007FF66805B322[cataclysm-tiles.exe+0x73b322]), #9 (dbghelp: submap::load+0x24a6@00007FF66806E9C6[cataclysm-tiles.exe+0x74e9c6]), #10 (dbghelp: mapbuffer::deserialize+0xb28@00007FF66854B038[cataclysm-tiles.exe+0xc2b038]), #11 (dbghelp: std::_Func_impl_no_alloc<,void,JsonValue const &>::_Do_call+0x2f@00007FF66854A26F[cataclysm-tiles.exe+0xc2a26f]), #12 (dbghelp: read_from_file_json+0x41@00007FF668090681[cataclysm-tiles.exe+0x770681]), #13 (dbghelp: read_from_file_optional_json+0x42@00007FF668090852[cataclysm-tiles.exe+0x770852]), #14 (dbghelp: mapbuffer::unserialize_submaps+0x4d8@00007FF66854CDA8[cataclysm-tiles.exe+0xc2cda8]), #15 (dbghelp: mapbuffer::submap_exists+0x8c@00007FF66854C6DC[cataclysm-tiles.exe+0xc2c6dc]), #16 (dbghelp: map::generate+0x226@00007FF668C04976[cataclysm-tiles.exe+0x12e4976]), #17 (dbghelp: map::loadn+0x289@00007FF6682C6389[cataclysm-tiles.exe+0x9a6389]), #18 (dbghelp: map::load+0x2b6@00007FF6682C6026[cataclysm-tiles.exe+0x9a6026]), #19 (dbghelp: game::unserialize+0xa55@00007FF668AFEC75[cataclysm-tiles.exe+0x11dec75]), #20 (dbghelp: read_from_file+0x58@00007FF6680905D8[cataclysm-tiles.exe+0x7705d8]), #21 (dbghelp: read_from_file+0x45@00007FF668090565[cataclysm-tiles.exe+0x770565]), #22 (dbghelp: ::operator()+0xf4@00007FF667EDB3E4[cataclysm-tiles.exe+0x5bb3e4]), #23 (dbghelp: game::load+0xe5f@00007FF667F2084F[cataclysm-tiles.exe+0x60084f]), #24 (dbghelp: main_menu::load_game+0x18f@00007FF667FFCC4F[cataclysm-tiles.exe+0x6dcc4f]), #25 (dbghelp: main_menu::load_character_tab+0xa00@00007FF667FFCA70[cataclysm-tiles.exe+0x6dca70]), #26 (dbghelp: main_menu::opening_screen+0x1e43@00007FF668000983[cataclysm-tiles.exe+0x6e0983]), #27 (dbghelp: WinMain+0xdfd@00007FF667CFA6CD[cataclysm-tiles.exe+0x3da6cd]), #28 (dbghelp: __scrt_common_main_seh+0x106@00007FF669528FB6[cataclysm-tiles.exe+0x1c08fb6]), #29 (dbghelp: BaseThreadInitThunk+0x1d@00007FFF667F259D[KERNEL32.DLL+0x1259d]), #30 (dbghelp: RtlUserThreadStart+0x28@00007FFF6742AF38[ntdll.dll+0x5af38]), Backtrace emission took 1 seconds. (continued from above) ERROR : D:\a\Cataclysm-DDA\Cataclysm-DDA\src\item.cpp:1894 [get_var] Stray characters at end of floating point value 0.000000 in item::get_var ```
pointing to the var in question being `gun_heat` inside a vehicle, somewhere.

Regardless, I'm not sure this is debuggable without a repro save, unfortunately...

@IdleSol
Copy link
Contributor

IdleSol commented Dec 28, 2024

@CassiLags What language do you play in? I assume Russian?

@CassiLags
Copy link
Author

I play in English

Is the trimmed save not enough? Im putting the full save here.

Still the same message in a078529
Wayside.zip

@PatrikLundell
Copy link
Contributor

PatrikLundell commented Dec 28, 2024

/Confirmed

I see this kind of report from time to time loading saves (typically from bug reports). They seem to typically be one offs, i.e. won't repeat after the game has been saved again, and so I haven't bothered with them.
I don't know if it's a matter of using the system decimal separator rather than a canonical one (I think my system separator is ',' rather than '.'), or attempts to read floating point values as integers.

When loading this save (the one originally supplied: I didn't need the full one) the debug report is issued by item.cpp operation item::get_var at the end if the if statement (logical, as '.' isn't ','). For whatever reason, strtod returns with end pointing to '.', so it might be that strtod uses the system setting rather than a canonical game one, or does so some times (possibly before something is set internally).

According to a quick search, strtod parses according to the locale settings, and thus is unsuitable for usage by the game. There are two calls to it in this operation.

Edit:
Apart from those two instances, strtod is also used by cata_utility.cpp operation svtod. svtod is used 7 times (including its declaration and implementation), and doesn't have any handling of other number formats. Its usages are in debug_menu, math_parsers and math_parser_diag_value, so that functionality should probably be checked with a locale not using a period as the decimal separation mark.
The item.cpp operation could be made to work if the "legacy" code was complemented with one checking '.' vs ',', i.e. the reverse of the existing check. That's provided there aren't other number schemes apart from those two.

@github-actions github-actions bot added (S2 - Confirmed) Bug that's been confirmed to exist and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Dec 28, 2024
@IdleSol
Copy link
Contributor

IdleSol commented Dec 28, 2024

I play in English

I usually get this error when switching languages between Russian and English. And saving in a language other than the language in which the world is created.

Although the error itself occurs very rarely.

But since you're not changing the language, it's clearly something else.

@PatrikLundell
Copy link
Contributor

I think we may have a more serious issue if JSON math is parsed using the local settings. I don't know if that's the case, but it looks like it may be.

@IdleSol
Copy link
Contributor

IdleSol commented Dec 28, 2024

By the way, is this part of the code that causes the error not related to the output of numeric values in the item description?

@CassiLags
Copy link
Author

my system settings are in brazillian portuguese, so maybe its only reproductible on machines with non-US locales.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

No branches or pull requests

6 participants
@moxian @kasanryukin @PatrikLundell @CassiLags @IdleSol and others