18 #include "precompiled.h"
41 m_ScriptInterface(scriptInterface)
52 GetAIsHelper*
self = (GetAIsHelper*)cbData;
55 fs::wpath components = pathname.
string();
56 fs::wpath::iterator it = components.begin();
61 self->m_ScriptInterface.Eval(
"({})", ai);
62 self->m_ScriptInterface.SetProperty(ai.
get(),
"id", dirname,
true);
63 self->m_ScriptInterface.SetProperty(ai.
get(),
"data",
self->m_ScriptInterface.ReadJSONFile(pathname),
true);
64 self->m_AIs.push_back(ai);
69 std::vector<CScriptValRooted>
m_AIs;
75 GetAIsHelper helper(scriptInterface);
#define NONCOPYABLE(className)
GetAIsHelper(ScriptInterface &scriptInterface)
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
static std::vector< CScriptValRooted > GetAIs(ScriptInterface &scriptInterface)
Returns a vector of {"id":"value-for-AddPlayer", "name":"Human readable name"} objects, based on all the available AI scripts.
#define DEFINE_INTERFACE_METHOD_3(scriptname, rettype, classname, methodname, arg1, arg2, arg3)
#define END_INTERFACE_WRAPPER(iname)
std::vector< CScriptValRooted > m_AIs
std::wstring GetWstringFromWpath(const fs::wpath &path)
Helper function to handle API differences between Boost Filesystem v2 and v3.
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
#define DEFINE_INTERFACE_METHOD_0(scriptname, rettype, classname, methodname)
static Status Callback(const VfsPath &pathname, const CFileInfo &fileInfo, const uintptr_t cbData)
ScriptInterface & m_ScriptInterface
const String & string() const
i64 Status
Error handling system.
Status ForEachFile(const PIVFS &fs, const VfsPath &startPath, FileCallback cb, uintptr_t cbData, const wchar_t *pattern, size_t flags)
call back for each file in a directory tree
jsval get() const
Returns the current value (or JSVAL_VOID if uninitialised).
Abstraction around a SpiderMonkey JSContext.
#define BEGIN_INTERFACE_WRAPPER(iname)