MCPcopy Create free account
hub / github.com/SnowyMouse/chimera / load_map_script

Function load_map_script

src/chimera/lua/lua_script.cpp:153–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151 }
152
153 void load_map_script() noexcept {
154 auto &map_header = get_map_header();
155 auto lua_directory = get_chimera().get_path() / "lua";
156 auto script_path = lua_directory / "scripts" / "map" / (std::string(map_header.name) + ".lua");
157 if(fs::exists(script_path)) {
158 auto script = read_script_file(script_path);
159 if(!script.empty()) {
160 auto script_name = script_path.filename().string();
161 load_lua_script(script_name.c_str(), script.c_str(), script.size(), false, false);
162 }
163 }
164 // Load script embbended in tag data if allowed. We do not support this on Halo Trial.
165 else if((global_fix_flags.embedded_lua || get_chimera().get_ini()->get_value_bool("memory.load_embedded_lua").value_or(false)) && game_engine() != GameEngine::GAME_ENGINE_DEMO) {
166 auto *script = reinterpret_cast<const char *>(map_header.lua_script_data);
167 auto script_size = map_header.lua_script_size;
168 if(script && script_size) {
169 // Check that the TNT is where we expect it to be.
170 auto &tag_data_header = get_tag_data_header();
171 auto *tag_data_address = reinterpret_cast<const char *>(&tag_data_header);
172 auto *tag_data_address_end = tag_data_address + (64 * 1024 * 1024);
173 if (script >= tag_data_address && script + script_size < tag_data_address_end) {
174 // Light the fuse.
175 auto map_filename = std::string(map_header.name) + ".map";
176 load_lua_script(map_filename.c_str(), script, script_size, true, false);
177 }
178 else {
179 console_error("Unable to load embedded Lua script: Invalid location");
180 }
181 }
182 }
183 }
184
185 void load_global_scripts() noexcept {
186 auto lua_directory = get_chimera().get_path() / "lua";

Callers 3

reload_scripts_commandFunction · 0.85
map_load_callbackFunction · 0.85
setup_lua_scriptingFunction · 0.85

Calls 7

read_script_fileFunction · 0.85
load_lua_scriptFunction · 0.85
game_engineFunction · 0.85
console_errorFunction · 0.85
get_pathMethod · 0.80
get_value_boolMethod · 0.80
get_iniMethod · 0.80

Tested by

no test coverage detected