Skip to content

Commit 32239d4

Browse files
committed
Merge pull request godotengine#97769 from dalexeev/gds-fix-gdscript-cache-path
GDScript: Fix `GDScriptCache::get_full_script()` uses non-remapped path
2 parents c28dd31 + 6286f9d commit 32239d4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/gdscript/gdscript_cache.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ Vector<uint8_t> GDScriptCache::get_binary_tokens(const String &p_path) {
297297

298298
Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_error, const String &p_owner) {
299299
MutexLock lock(singleton->mutex);
300+
300301
if (!p_owner.is_empty()) {
301302
singleton->dependencies[p_owner].insert(p_path);
302303
}
@@ -307,7 +308,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_e
307308
return singleton->shallow_gdscript_cache[p_path];
308309
}
309310

310-
String remapped_path = ResourceLoader::path_remap(p_path);
311+
const String remapped_path = ResourceLoader::path_remap(p_path);
311312

312313
Ref<GDScript> script;
313314
script.instantiate();
@@ -332,6 +333,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_e
332333
}
333334

334335
singleton->shallow_gdscript_cache[p_path] = script;
336+
335337
return script;
336338
}
337339

@@ -359,16 +361,18 @@ Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_erro
359361
}
360362
}
361363

364+
const String remapped_path = ResourceLoader::path_remap(p_path);
365+
362366
if (p_update_from_disk) {
363-
if (p_path.get_extension().to_lower() == "gdc") {
364-
Vector<uint8_t> buffer = get_binary_tokens(p_path);
367+
if (remapped_path.get_extension().to_lower() == "gdc") {
368+
Vector<uint8_t> buffer = get_binary_tokens(remapped_path);
365369
if (buffer.is_empty()) {
366370
r_error = ERR_FILE_CANT_READ;
367371
return script;
368372
}
369373
script->set_binary_tokens_source(buffer);
370374
} else {
371-
r_error = script->load_source_code(p_path);
375+
r_error = script->load_source_code(remapped_path);
372376
if (r_error) {
373377
return script;
374378
}

0 commit comments

Comments
 (0)