id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,phab_field 4868,Unify VFS script functions,elexis,,"`ReadJSONFile` is called by `simulation/`, globalscripts/` and `maps/` of the public mod. `ai/` might want to use it eventually too. This and other JSON functions are registered by the following files: {{{ MapGenerator.cpp source/ps/scripting/JSInterface_VFS.cpp simulation2/system/ComponentManager.cpp }}} They all proxies to `ScriptInterface.ReadJSONFile`. `JSInterface_VFS.cpp` has recently been split from the gui `ScriptFunctions.cpp`. Since it contains all JSON relevant functions, it could just be included from the other c++ files and the incomplete, differently named proxy copies can be deleted. This way we can add the missing JSON functions to rmgen interface by removing code. Unfortunately the functions have naming differences, so there is also some JS modification needed. Additionally, `GetCivData` seems pointless if JS can load arbitrary JSON files. `source/` should become as agnostic of 0ad vocabulary as possible without removing useful features. The naming unification will solve multiple old `resources.js` and possibly `ai/` problems too: {{{ /** * Since the AI context can't access JSON functions, it gets passed an object * containing the information from `GuiInterface.js::GetSimulationState()`. */ function Resources() { let jsonFiles = []; // Simulation context if (Engine.FindJSONFiles) { jsonFiles = Engine.FindJSONFiles(""resources"", false); for (let file in jsonFiles) jsonFiles[file] = ""resources/"" + jsonFiles[file] + "".json""; } // GUI context else if (Engine.BuildDirEntList) jsonFiles = Engine.BuildDirEntList(""simulation/data/resources/"", ""*.json"", false); else { error(""Resources: JSON functions are not available""); return; } }}}",defect,closed,Should Have,Alpha 23,Core engine,fixed,,,