2025-06-14 04:58 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0005358Spring engineGeneralpublic2017-04-30 01:07
Reporterabma 
Assigned ToKloot 
PrioritynormalSeveritycrashReproducibilityhave not tried
StatusresolvedResolutionfixed 
Product Version 
Target Version104.0Fixed in Version103.0 +git 
Summary0005358: theoretical desync with strtod / atof
Descriptionthese functions depend on the current locale, so imo they could cause desyncs.

Additional Informationin rts/Sim:
$ grep -R strto *
Projectiles/ExplosionGenerator.cpp: const float v = (float)strtod(&script.c_str()[p], &endp);
Projectiles/ExplosionGenerator.cpp: const int v = std::max(0, std::min(16, (int)strtol(&script.c_str()[p], &endp, 10)));



grep -R atof *
Misc/AllyTeam.cpp: startRectTop = std::atof(value.c_str());
Misc/AllyTeam.cpp: startRectBottom = std::atof(value.c_str());
Misc/AllyTeam.cpp: startRectLeft = std::atof(value.c_str());
Misc/AllyTeam.cpp: startRectRight = std::atof(value.c_str());
Misc/TeamBase.cpp: SetAdvantage(std::atof(value.c_str()) / 100.0f);
Misc/TeamBase.cpp: SetAdvantage(std::atof(value.c_str()));
Misc/TeamBase.cpp: SetIncomeMultiplier(std::atof(value.c_str()));
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0016706

abma (administrator)

especially the conversation in Projectiles/ExplosionGenerator.cpp could lead to a desync?!

~0016707

abma (administrator)

as workarround we could set the locale to C?

i.e.:
setlocale( LC_NUMERIC, "C");

~0016708

abma (administrator)

Last edited: 2016-09-28 22:49

View 2 revisions

if i remember right we tapped into this already in lua code (and made a workarround for it)

$ lua
> print(os.setlocale("de_DE.utf-8"))
de_DE.utf-8
> print(tostring(tonumber("5.1")) .." - " .. tostring(tonumber("5,1")))
nil - 5,1
> print(os.setlocale("C"))
C
> print(tostring(tonumber("5.1")) .." - " .. tostring(tonumber("5,1")))
5.1 - nil

~0016709

abma (administrator)

added a test gadget in devgame:

https://github.com/spring/devgame.sdd/commit/588a70fc7bf4ed2fa4842cb6f7cb0b88fec31843
+Notes

-Issue History
Date Modified Username Field Change
2016-09-28 22:39 abma New Issue
2016-09-28 22:39 abma Note Added: 0016706
2016-09-28 22:42 abma Note Added: 0016707
2016-09-28 22:49 abma Note Added: 0016708
2016-09-28 22:49 abma Note Edited: 0016708 View Revisions
2016-09-28 23:07 abma Note Added: 0016709
2017-04-30 01:07 Kloot Assigned To => Kloot
2017-04-30 01:07 Kloot Status new => resolved
2017-04-30 01:07 Kloot Resolution open => fixed
2017-04-30 01:07 Kloot Fixed in Version => 103.0 +git
+Issue History