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

Method AddFile

src/script/script_scanner.cpp:26–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include "../safeguards.h"
25
26bool ScriptScanner::AddFile(const std::string &filename, size_t, const std::string &tar_filename)
27{
28 this->main_script = filename;
29 this->tar_file = tar_filename;
30
31 auto p = this->main_script.find_last_of(PATHSEPCHAR);
32 this->main_script.erase(p != std::string::npos ? p + 1 : 0);
33 this->main_script += "main.nut";
34
35 if (!FioCheckFileExists(filename, this->subdir) || !FioCheckFileExists(this->main_script, this->subdir)) return false;
36
37 this->ResetEngine();
38 try {
39 this->engine->LoadScript(filename);
40 } catch (Script_FatalError &e) {
41 Debug(script, 0, "Fatal error '{}' when trying to load the script '{}'.", e.GetErrorMessage(), filename);
42 return false;
43 }
44 return true;
45}
46
47ScriptScanner::ScriptScanner() = default;
48

Callers 2

IsSameScriptFunction · 0.45
AfterDownloadMethod · 0.45

Calls 5

ResetEngineMethod · 0.95
FioCheckFileExistsFunction · 0.85
LoadScriptMethod · 0.80
GetErrorMessageMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected