From 71a9bdd993305082171c7b2642bda3a1616a4ddb Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:02:30 -0400 Subject: [PATCH 1/5] High terrain mode: improve lighting, unseen area darkness Remove workaround in avUpdateTiles --- data/base/shaders/terrain_combined_high.frag | 5 +++-- data/base/shaders/vk/terrain_combined_high.frag | 5 +++-- src/advvis.cpp | 12 +----------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/data/base/shaders/terrain_combined_high.frag b/data/base/shaders/terrain_combined_high.frag index 1bab7ef480e..ec2231376ac 100644 --- a/data/base/shaders/terrain_combined_high.frag +++ b/data/base/shaders/terrain_combined_high.frag @@ -131,8 +131,9 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { float adjustedTileBrightness = pow(lightmap_vec4.a, 2.f-lightmap_vec4.a); // ... * tile brightness / ambient occlusion (stored in lightmap.a) - vec4 light = (ambientLight*0.25f + visibility*ambientLight*0.75f + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; - light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) + vec4 adjustedAmbientLight = ambientLight*lightmap_vec4.a; + vec4 light = (ambientLight*0.30f + visibility*(adjustedAmbientLight*0.40f + adjustedAmbientLight*lambertTerm*0.30f + diffuseLight*lambertTerm)) * lightmap_vec4.a; + light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.4f)); // additive color (from environmental point lights / effects) vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness; light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.5f)); // additive color (from environmental point lights / effects) diff --git a/data/base/shaders/vk/terrain_combined_high.frag b/data/base/shaders/vk/terrain_combined_high.frag index 950e031af3e..a029b92db19 100644 --- a/data/base/shaders/vk/terrain_combined_high.frag +++ b/data/base/shaders/vk/terrain_combined_high.frag @@ -73,8 +73,9 @@ vec4 doBumpMapping(BumpData b, vec3 lightDir, vec3 halfVec) { float adjustedTileBrightness = pow(lightmap_vec4.a, 2.f-lightmap_vec4.a); // ... * tile brightness / ambient occlusion (stored in lightmap.a) - vec4 light = (ambientLight*0.25f + visibility*ambientLight*0.75f + visibility*diffuseLight*lambertTerm) * adjustedTileBrightness; - light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.5f)); // additive color (from environmental point lights / effects) + vec4 adjustedAmbientLight = ambientLight*lightmap_vec4.a; + vec4 light = (ambientLight*0.30f + visibility*(adjustedAmbientLight*0.40f + adjustedAmbientLight*lambertTerm*0.30f + diffuseLight*lambertTerm)) * lightmap_vec4.a; + light.rgb = blendAddEffectLighting(light.rgb, (lightmap_vec4.rgb / 1.4f)); // additive color (from environmental point lights / effects) vec4 light_spec = (visibility*specularLight*blinnTerm*lambertTerm) * adjustedTileBrightness; light_spec.rgb = blendAddEffectLighting(light_spec.rgb, (lightmap_vec4.rgb / 2.5f)); // additive color (from environmental point lights / effects) diff --git a/src/advvis.cpp b/src/advvis.cpp index 217b137d9d5..8ec84d6b917 100644 --- a/src/advvis.cpp +++ b/src/advvis.cpp @@ -61,8 +61,6 @@ void avUpdateTiles() PlayerMask playerAllianceBits = (selectedPlayer < MAX_PLAYER_SLOTS) ? alliancebits[selectedPlayer] : 0; - auto currentTerrainQuality = getTerrainShaderQuality(); - /* Go through the tiles */ for (; i < len; i++) { @@ -74,15 +72,7 @@ void avUpdateTiles() // If we are not omniscient, and we are not seeing the tile, and none of our allies see the tile... if (!godMode && !(playerAllianceBits & (satuplinkbits | psTile->sensorBits))) { - switch (currentTerrainQuality) - { - case TerrainShaderQuality::NORMAL_MAPPING: - maxLevel -= (maxLevel / 3); // seems to work better for high quality terrain renderer... - break; - default: - maxLevel /= 2; - break; - } + maxLevel /= 2; } if (psTile->level > maxLevel) { From 2bd0dd5cfbc7c799d6cfa2d43f8887f00e76b700 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:17:06 -0400 Subject: [PATCH 2/5] Reduce DEFAULT_RADARZOOM --- src/radar.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/radar.h b/src/radar.h index 3b6b0424a62..49d9e21c23b 100644 --- a/src/radar.h +++ b/src/radar.h @@ -32,7 +32,7 @@ void radarColour(UDWORD tileNumber, uint8_t r, uint8_t g, uint8_t b); ///< Set r #define MAX_RADARZOOM (64) #define MIN_RADARZOOM (8) -#define DEFAULT_RADARZOOM (32) +#define DEFAULT_RADARZOOM (24) #define RADARZOOM_STEP (4) bool InitRadar(); ///< Initialize minimap subsystem. From 66ae6a3abb3df7236b78a18dc9d09f4ceb431d50 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:23:39 -0400 Subject: [PATCH 3/5] kf_RadarZoom: Persist changed radar zoom to config --- src/keybind.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/keybind.cpp b/src/keybind.cpp index 17ceaf300d7..5f559373648 100644 --- a/src/keybind.cpp +++ b/src/keybind.cpp @@ -973,6 +973,7 @@ MappableFunction kf_RadarZoom(const int multiplier) { CONPRINTF(_("Setting radar zoom to %u"), newZoomLevel); SetRadarZoom(newZoomLevel); + war_SetRadarZoom(GetRadarZoom()); // persist changed setting to config audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5); } }; From 19cadbedfd5ba4daa54aa3818bd22778fbd89eae Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:59:19 -0400 Subject: [PATCH 4/5] replaceTexture: Tweak debug message --- lib/ivis_opengl/tex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ivis_opengl/tex.cpp b/lib/ivis_opengl/tex.cpp index eb5c7cfcf74..7ccc06b5582 100644 --- a/lib/ivis_opengl/tex.cpp +++ b/lib/ivis_opengl/tex.cpp @@ -246,7 +246,7 @@ bool replaceTexture(const WzString &oldfile, const WzString &newfile) pie_AddTexPage(pTexture, tmpname.c_str(), existingTextureType, page); return true; } - debug(LOG_ERROR, "Nothing to replace!"); + debug(LOG_TEXTURE, "Nothing to replace - old (not found): %s, new (not used): %s", oldfile.toUtf8().c_str(), newfile.toUtf8().c_str()); return false; } From 05048ff8bab61502a1eaddb35d3dc325cd26dffb Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:13:53 -0400 Subject: [PATCH 5/5] wzpropertyproviders: Additional property support --- src/wzpropertyproviders.cpp | 67 +++++++++++++++++++++++++++++++++++++ src/wzpropertyproviders.h | 2 ++ 2 files changed, 69 insertions(+) diff --git a/src/wzpropertyproviders.cpp b/src/wzpropertyproviders.cpp index b77d4fbb50a..cd5a75036db 100644 --- a/src/wzpropertyproviders.cpp +++ b/src/wzpropertyproviders.cpp @@ -53,6 +53,12 @@ #include #endif +// Includes for Unix +#if defined(WZ_OS_UNIX) +#include +#include +#endif + // MARK: - BuildPropertyProvider enum class BuildProperty { @@ -160,6 +166,64 @@ static std::string Get_WinPackageFullName() } #endif +enum class WZ_CONTAINER_TYPE +{ + NONE_DETECTED, + FLATPAK, + SNAP, + APPIMAGE, + WIN_PACKAGE // ex. MSIX package +}; + +static std::string to_string(const WZ_CONTAINER_TYPE& type) +{ + switch (type) + { + case WZ_CONTAINER_TYPE::NONE_DETECTED: + return ""; + case WZ_CONTAINER_TYPE::FLATPAK: + return "flatpak"; + case WZ_CONTAINER_TYPE::SNAP: + return "snap"; + case WZ_CONTAINER_TYPE::APPIMAGE: + return "appimage"; + case WZ_CONTAINER_TYPE::WIN_PACKAGE: + return "winpackage"; + } + return ""; // silence warning +} + +static WZ_CONTAINER_TYPE GetCurrentContainerType() +{ +#if defined(WZ_OS_WIN) + if (!Get_WinPackageFullName().empty()) + { + return WZ_CONTAINER_TYPE::WIN_PACKAGE; + } +#elif defined(WZ_OS_UNIX) + if (access("/.flatpak-info", F_OK) == 0) + { + return WZ_CONTAINER_TYPE::FLATPAK; + } + // Check multiple variables, as is done by both WebKit and SDL + // See: https://snapcraft.io/docs/environment-variables + if (std::getenv("SNAP") && std::getenv("SNAP_NAME") && std::getenv("SNAP_REVISION")) + { + return WZ_CONTAINER_TYPE::SNAP; + } + if (std::getenv("APPIMAGE")) + { + return WZ_CONTAINER_TYPE::APPIMAGE; + } +#endif + return WZ_CONTAINER_TYPE::NONE_DETECTED; +} + +static std::string GetCurrentContainerTypeStr() +{ + return to_string(GetCurrentContainerType()); +} + static std::string GetCurrentBuildPropertyValue(const BuildProperty& property) { using BP = BuildProperty; @@ -251,6 +315,7 @@ static const std::unordered_map