| 305 | } |
| 306 | |
| 307 | GDScriptDecompVersion GDScriptDecompVersion::create_version_from_custom_def(Dictionary p_custom_def){ |
| 308 | static constexpr int CUSTOM_PREFIX = 0xf0000000; |
| 309 | int revision = GDScriptDecompVersion::number_of_custom_versions | CUSTOM_PREFIX; |
| 310 | String rev_str = String::num_int64(static_cast<uint32_t>(revision), 16).to_lower(); |
| 311 | p_custom_def["bytecode_rev"] = rev_str; |
| 312 | GDScriptDecompVersion decomp_version; |
| 313 | String custom_prefix = "-custom." + itos(GDScriptDecompVersion::number_of_custom_versions); |
| 314 | decomp_version.commit = revision; |
| 315 | decomp_version.min_version = p_custom_def.get("engine_version", "").operator String().split("-")[0] + custom_prefix; |
| 316 | decomp_version.bytecode_version = p_custom_def.get("bytecode_version", 0); |
| 317 | String parent_str = p_custom_def.get("parent", ""); |
| 318 | decomp_version.parent = parent_str.hex_to_int(); |
| 319 | decomp_version.is_dev = true; |
| 320 | decomp_version.max_version = p_custom_def.get("max_engine_version", ""); |
| 321 | if (!decomp_version.max_version.is_empty()) { |
| 322 | decomp_version.max_version = decomp_version.max_version.split("-")[0] + custom_prefix; |
| 323 | } |
| 324 | int engine_ver_major = p_custom_def.get("engine_ver_major", 0); |
| 325 | if (engine_ver_major <= 0) { |
| 326 | engine_ver_major = decomp_version.min_version.get_slice(".", 0).to_int(); |
| 327 | p_custom_def.set("engine_ver_major", engine_ver_major); |
| 328 | } |
| 329 | int variant_ver_major = p_custom_def.get("variant_ver_major", engine_ver_major); |
| 330 | |
| 331 | if (decomp_version.min_version.is_empty()) { |
| 332 | ERR_FAIL_V_MSG(GDScriptDecompVersion(), "engine_version is required"); |
| 333 | } |
| 334 | if (decomp_version.bytecode_version == 0) { |
| 335 | ERR_FAIL_V_MSG(GDScriptDecompVersion(), "bytecode_version is required"); |
| 336 | } |
| 337 | if (engine_ver_major <= 0) { |
| 338 | ERR_FAIL_V_MSG(GDScriptDecompVersion(), "engine_ver_major is required"); |
| 339 | } |
| 340 | if (variant_ver_major <= 0) { |
| 341 | ERR_FAIL_V_MSG(GDScriptDecompVersion(), "variant_ver_major is required"); |
| 342 | } |
| 343 | static constexpr const char *nameforamt = "%s (%s / UNKNOWN / Bytecode version: %d) - User defined bytecode based on %s"; |
| 344 | decomp_version.name = vformat(nameforamt, decomp_version.min_version, rev_str, decomp_version.bytecode_version, parent_str); |
| 345 | decomp_version.custom = p_custom_def; |
| 346 | Ref<GDScriptDecomp> decomp = decomp_version.create_decomp(); |
| 347 | if (decomp.is_null()) { |
| 348 | ERR_FAIL_V_MSG(GDScriptDecompVersion(), "Invalid custom definition"); |
| 349 | } |
| 350 | return decomp_version; |
| 351 | } |
| 352 | |
| 353 | GDScriptDecompVersion GDScriptDecompVersion::create_derived_version_from_custom_def(int revision, Dictionary p_custom_def){ |
| 354 | Ref<GDScriptDecomp> decomp = create_decomp_for_commit(revision); |
nothing calls this directly
no test coverage detected