Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tweaks before 4.4.0 #3472

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/base/shaders/terrain_combined_medium.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion data/base/shaders/vk/terrain_combined_medium.frag
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
16 changes: 12 additions & 4 deletions src/qtscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding)
bool loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, 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<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding)
bool scripting_engine::loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame)
{
int groupidx = -1;

Expand Down Expand Up @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions src/qtscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ struct generic_script_object
};

/// Load map labels
bool loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding);
bool loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame);

/// Write map labels to savegame
bool writeLabels(const char *filename);
Expand Down Expand Up @@ -319,7 +319,7 @@ class scripting_engine
// MARK: LABELS
public:
/// Load map labels
bool loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding);
bool loadLabels(const char *filename, const std::unordered_map<UDWORD, UDWORD>& fixedMapIdToGeneratedId, std::array<std::unordered_map<UDWORD, UDWORD>, MAX_PLAYER_SLOTS>& moduleToBuilding, bool UserSaveGame);

/// Write map labels to savegame
bool writeLabels(const char *filename);
Expand Down
Loading