These two sets of functions are not logically coupled, so it makes things a bit easier to comprehend, maintain or replace if they remain in separate interfaces, refs rP21759.
I'm late to the C++ party.
Details
Make sure that it still compiles.
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/differential/431/display/redirect
source/ps/scripting/JSInterface_ModIo.h | ||
---|---|---|
39 ↗ | (On Diff #6461) |
This looks fine to me iff you add the comment Vlad pointed out and move the strings back next to where they are used.
source/ps/scripting/JSInterface_ModIo.cpp | ||
---|---|---|
26 ↗ | (On Diff #6461) | I would keep this next to GetDownloadProgress. |
source/ps/scripting/JSInterface_Mod.h | ||
---|---|---|
36 ↗ | (On Diff #6461) | (Guess I can add it here too while at it) |
source/ps/scripting/JSInterface_ModIo.cpp | ||
26 ↗ | (On Diff #6461) | The idea was that the reader isn't surprised by the sudden occurrence of data after reading many functions. So these two from main.cpp should have been moved from the top to Frame() and RunGameOrAtlas() then? extern bool g_GameRestarted; extern CStrW g_UniqueLogPostfix; |
source/ps/scripting/JSInterface_ModIo.cpp | ||
---|---|---|
26 ↗ | (On Diff #6461) | Those are globals, used across the engine, I think it's nice that they are on top of the file. Whereas those status strings are just a constant, only used in this file, and actually tightly bound to GetDownloadProgress, since the function is about making the conversion between engine values and JS values, and that structure is the dictionary for that conversion. If I could I would have put this map inside the function, but that would allocate it everytime it is called, so I made a const. |
source/ps/scripting/JSInterface_ModIo.cpp | ||
---|---|---|
26 ↗ | (On Diff #6461) | And the three ones in VisualReplay.cpp? |
source/ps/scripting/JSInterface_ModIo.cpp | ||
---|---|---|
26 ↗ | (On Diff #6461) | Well those three ones look like they could have to be easily tweaked by devs in the future. Here the map should be changed only if DownloadProgressData is modified, in which case GetDownloadProgress would be changed accordingly. Frankly this is not a big issue, I just feel like this map should be strongly associated with GetDownloadProgress. |