MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DoCommandPrep

Method DoCommandPrep

src/script/api/script_object.cpp:263–283  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

261}
262
263/* static */ std::tuple<bool, bool, bool, bool> ScriptObject::DoCommandPrep()
264{
265 if (!ScriptObject::CanSuspend()) {
266 throw Script_FatalError("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.");
267 }
268
269 /* Are we only interested in the estimate costs? */
270 bool estimate_only = GetDoCommandMode() != nullptr && !GetDoCommandMode()();
271
272 /* Should the command be executed asynchronously? */
273 bool asynchronous = GetDoCommandAsyncMode() != nullptr && GetDoCommandAsyncMode()();
274
275 bool networking = _networking && !_generating_world;
276
277 if (!ScriptCompanyMode::IsDeity() && !ScriptCompanyMode::IsValid()) {
278 ScriptObject::SetLastError(ScriptError::ERR_PRECONDITION_INVALID_COMPANY);
279 return { true, estimate_only, asynchronous, networking };
280 }
281
282 return { false, estimate_only, asynchronous, networking };
283}
284
285/* static */ bool ScriptObject::DoCommandProcessResult(const CommandCost &res, Script_SuspendCallbackProc *callback, bool estimate_only, bool asynchronous)
286{

Callers

nothing calls this directly

Calls 1

Script_FatalErrorClass · 0.85

Tested by

no test coverage detected