From a1f35b033a6bc65db2fd467c249ad54faa94b9df Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:18:06 -0500 Subject: [PATCH 1/2] loadLabels: Tweak logging --- src/game.cpp | 2 +- src/qtscript.cpp | 16 ++++++++++++---- src/qtscript.h | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 1e7ef71a316..f92fb5cd75a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3271,7 +3271,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User // Load labels aFileName[fileExten] = '\0'; strcat(aFileName, "labels.json"); - loadLabels(aFileName, fixedMapIdToGeneratedId, moduleToBuilding); + loadLabels(aFileName, fixedMapIdToGeneratedId, moduleToBuilding, UserSaveGame); //if user save game then reset the time - BEWARE IF YOU USE IT if ((gameType == GTYPE_SAVE_START) || diff --git a/src/qtscript.cpp b/src/qtscript.cpp index 27b9addd52d..e8923b8235a 100644 --- a/src/qtscript.cpp +++ b/src/qtscript.cpp @@ -2019,13 +2019,13 @@ bool scripting_engine::saveGroups(nlohmann::json &result, wzapi::scripting_insta // Label system (function defined in qtscript.h header) // -bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding) +bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame) { - return scripting_engine::instance().loadLabels(filename, fixedMapIdToGeneratedId, moduleToBuilding); + return scripting_engine::instance().loadLabels(filename, fixedMapIdToGeneratedId, moduleToBuilding, UserSaveGame); } // Load labels -bool scripting_engine::loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding) +bool scripting_engine::loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame) { int groupidx = -1; @@ -2106,7 +2106,15 @@ bool scripting_engine::loadLabels(const char *filename, const std::unordered_map p.player = player; p.triggered = ini.value("triggered", -1).toInt(); // deactivated by default p.subscriber = ini.value("subscriber", ALL_PLAYERS).toInt(); - ASSERT(IdToObject((OBJECT_TYPE)p.type, p.id, p.player) != nullptr, "Failed to find object that label references: %s", label.c_str()); + auto checkFoundObject = IdToObject((OBJECT_TYPE)p.type, p.id, p.player); + if (!UserSaveGame) + { + ASSERT(checkFoundObject != nullptr, "Failed to find object that label references: %s", label.c_str()); + } + else if (checkFoundObject == nullptr) + { + debug(LOG_SAVEGAME, "Failed to find object that label references (probably destroyed before save): %s", label.c_str()); + } labels[label] = p; } else if (list[i].startsWith("group")) diff --git a/src/qtscript.h b/src/qtscript.h index 3d577e8a713..87c30bcc0ff 100644 --- a/src/qtscript.h +++ b/src/qtscript.h @@ -221,7 +221,7 @@ struct generic_script_object }; /// Load map labels -bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding); +bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame); /// Write map labels to savegame bool writeLabels(const char *filename); @@ -319,7 +319,7 @@ class scripting_engine // MARK: LABELS public: /// Load map labels - bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding); + bool loadLabels(const char *filename, const std::unordered_map& fixedMapIdToGeneratedId, std::array, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame); /// Write map labels to savegame bool writeLabels(const char *filename); From 604d5c740125ac4f59ef990f9b26a1e9c0cfc2bc Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sun, 5 Nov 2023 16:08:47 -0500 Subject: [PATCH 2/2] Tweak medium terrain shader to better match the previous shader --- data/base/shaders/terrain_combined_medium.frag | 2 +- data/base/shaders/vk/terrain_combined_medium.frag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base/shaders/terrain_combined_medium.frag b/data/base/shaders/terrain_combined_medium.frag index 99b009e306e..aa7b34bb83d 100644 --- a/data/base/shaders/terrain_combined_medium.frag +++ b/data/base/shaders/terrain_combined_medium.frag @@ -111,7 +111,7 @@ vec4 main_medium() { vec3 N = vec3(0.f,0.f,1.f); float lambertTerm = max(dot(N, L), 0.0); // diffuse lighting vec4 lightmap_vec4 = texture(lightmap_tex, uvLightmap, 0.f); - vec4 light = (visibility*diffuseLight*0.75*lambertTerm + ambientLight*0.25) * lightmap_vec4.a; // ... * tile brightness / ambient occlusion (stored in lightmap.a) + vec4 light = (visibility*diffuseLight*0.8*(lambertTerm*lambertTerm) + ambientLight*0.2) * lightmap_vec4.a; // ... * tile brightness / ambient occlusion (stored in lightmap.a) light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) light.a = 1.f; diff --git a/data/base/shaders/vk/terrain_combined_medium.frag b/data/base/shaders/vk/terrain_combined_medium.frag index 6cff7addcc5..f6d586d1471 100644 --- a/data/base/shaders/vk/terrain_combined_medium.frag +++ b/data/base/shaders/vk/terrain_combined_medium.frag @@ -53,7 +53,7 @@ vec4 main_medium() { vec3 N = vec3(0.f,0.f,1.f); float lambertTerm = max(dot(N, L), 0.0); // diffuse lighting vec4 lightmap_vec4 = texture(lightmap_tex, frag.uvLightmap); - vec4 light = (visibility*diffuseLight*0.75*lambertTerm + ambientLight*0.25) * lightmap_vec4.a; // ... * tile brightness / ambient occlusion (stored in lightmap.a) + vec4 light = (visibility*diffuseLight*0.8*(lambertTerm*lambertTerm) + ambientLight*0.2) * lightmap_vec4.a; // ... * tile brightness / ambient occlusion (stored in lightmap.a) light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) light.a = 1.f;