The GUI, simulation, AI and random map generation run in separate threads with different custom functions exposed to JS.
This meant that we couldn't write one piece of code that works for all contexts.
rP20576 unified ReadJSONFile, this patch unified the listing of files and thus allows removing of these hacks noone could look at lightheartedly.
Details
- Reviewers
s0600204 - Commits
- rP20586: Expose the same file listing function to JS GUI, simulation and rmgen, refs…
- Trac Tickets
- #4868
ComponentManager.cpp registers simulation/ functions. Notice that it doesn't fall into pieces when running the game.
Optionally notice that you get an error message when trying to list files from gui/ when calling it from the simulation.
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Branch
- /ps/trunk
- Lint
Lint OK - Unit
No Unit Test Coverage - Build Status
Buildable 3953 Build 6920: Vulcan Build (Windows) Jenkins Build 6919: Vulcan Build Jenkins Build 6918: arc lint + arc unit
Event Timeline
Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/globalscripts/Templates.js | 91| » » ····················||·(c[0]·!=·"!"·&&·classes.indexOf(c)·!=·-1))) | | [NORMAL] JSHintBear: | | Misleading line break before '||'; readers may interpret this as an expression boundary.
binaries/data/mods/public/globalscripts/Resources.js | ||
---|---|---|
3 | This GUI Interface copying can be nuked too by just including JSInterface_VFS.cpp from the CCmpAIManager.cpp. In some later diff. |
binaries/data/mods/public/simulation/components/DataTemplateManager.js | ||
---|---|---|
59 | See P97 where this is going |
Maybe it's just me but "builddirentlist" has no meaning whatsoever. I'd prefer "ListDirectoryFiles" or something.
binaries/data/mods/public/gui/common/functions_utility.js | ||
---|---|---|
38 | This is the same function used in the DataTemplateManager (see reasons why unifying is good). It should be in globalscripts/vfs.js P97. Same for getCheatsData() in messages.js. |
Successful build - Chance fights ever on the side of the prudent.
Updating workspaces... Build (release)... Build (debug)... Running release tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Checking XML files...
Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/globalscripts/Templates.js | 91| » » ····················||·(c[0]·!=·"!"·&&·classes.indexOf(c)·!=·-1))) | | [NORMAL] JSHintBear: | | Misleading line break before '||'; readers may interpret this as an expression boundary.
Looks good, with a little bit of tidying work to do which can be done before commit.
binaries/data/mods/public/gui/common/functions_utility.js | ||
---|---|---|
38 | (Out-of-scope observation: getCheatsData() could use Engine.ListDirectoryFiles directly - no point stripping path and extension if they're just going to be added back.) | |
source/ps/scripting/JSInterface_VFS.cpp | ||
87 | Don't forget to update this function's block comment as appropriate. (And there's a copy in the .h file to deal with as well.) | |
source/simulation2/system/ComponentManager.cpp | ||
1195 | Don't forget to remove appropriate definitions in ComponentManager.h if they're no longer being used. (lines 118-22, 336-9) |