Skip to content

Commit

Permalink
foerr: Fix Windows build
Browse files Browse the repository at this point in the history
MSVC doesn't know what an uint is. Add missing includes for consts.hpp
where it is typedefed.

Don't use designated initializers, as apparently this feature is C++20
and MSVC really doesn't like it.

Initialize some random bool variable which causes a runtime error on
Windows.

Signed-off-by: h67ma <[email protected]>
  • Loading branch information
h67ma committed Nov 27, 2023
1 parent 80e2b84 commit 30f5540
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
8 changes: 8 additions & 0 deletions deps/sfml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ set(SFML_BUILD_TEST_SUITE OFF)
message(STATUS "Fetching SFML...")
FetchContent_MakeAvailable(sfml)

if(WIN32)
# /EHsc is to somehow mitigate warning C4530 (being treated as an error)
target_compile_options(sfml-audio PRIVATE /EHsc)
target_compile_options(sfml-graphics PRIVATE /EHsc)
target_compile_options(sfml-system PRIVATE /EHsc)
target_compile_options(sfml-window PRIVATE /EHsc)
endif()

# TODO copy openal.dll from sfml-src/extlibs/bin/{x64/x86} to root dir or somehow add it to PATH
3 changes: 2 additions & 1 deletion src/campaigns/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <SFML/Graphics/Rect.hpp>
#include <SFML/Graphics/RenderTexture.hpp>

#include "../consts.hpp"
#include "../hud/log.hpp"
#include "../objects/back_obj.hpp"
#include "../settings/settings_manager.hpp"
Expand Down Expand Up @@ -354,7 +355,7 @@ void Room::setupBackHoleObjects(ResourceManager& resMgr, const ObjectManager& ob
}

// both backObjMain and backObjHole are expected to have textures, don't check if they are nullptr
this->backHoleObjectsMain.push_back({ .spriteRes = backObjMain, .blend = blend });
this->backHoleObjectsMain.push_back({ backObjMain, blend });
this->backHoleObjectsHoles.push_back(backObjHole);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/campaigns/room_cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Transformable.hpp>

#include "../consts.hpp"
#include "../materials/material_manager.hpp"
#include "../resources/resource_manager.hpp"
#include "../resources/sprite_resource.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/hud/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/System/Clock.hpp>

#include "../consts.hpp"
#include "../hud/hud.hpp"
#include "../settings/settings_manager.hpp"
#include "../util/util.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/hud/sliders/slider_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Transformable.hpp>

#include "../../consts.hpp"
#include "../configurable_gui_component.hpp"

constexpr float SLIDER_HANDLE_HEIGHT = 15;
Expand Down
1 change: 1 addition & 0 deletions src/hud/text_label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Text.hpp>

#include "../consts.hpp"
#include "configurable_gui_component.hpp"

/**
Expand Down
18 changes: 9 additions & 9 deletions src/materials/material_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool MaterialManager::loadMap(const nlohmann::json& root, std::unordered_map<cha
maskTexturePath = pathCombine(PATH_TEXT_CELLS, maskTexturePath + ".png");
}

bool matIsRight;
bool matIsRight = false;
if (matType == MAT_LADDER || matType == MAT_STAIRS)
{
if (!parseJsonKey<bool>(matNode.value(), std::string(PATH_MATERIALS), FOERR_JSON_KEY_IS_RIGHT, matIsRight))
Expand All @@ -93,14 +93,14 @@ bool MaterialManager::loadMap(const nlohmann::json& root, std::unordered_map<cha
color.loadFromColorString(colorString);
color.a = LIQUID_OPACITY;

theMap.emplace(matSymbol, material { .type = matType,
.texturePath = texturePath,
.textureDelimPath = textureDelimPath,
.maskTexturePath = maskTexturePath,
.isRight = matIsRight,
.offsetLeft = offsetLeft,
.delimOffset = delimOffset,
.color = color });
theMap.emplace(matSymbol, material { matType,
texturePath,
textureDelimPath,
maskTexturePath,
matIsRight,
offsetLeft,
delimOffset,
color });
}

return true;
Expand Down
2 changes: 2 additions & 0 deletions src/util/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <SFML/System/Vector2.hpp>

#include "../consts.hpp"

#define STR(thing) #thing
#define STR_EXP(thing) STR(thing) // "the double expansion trick"

Expand Down

0 comments on commit 30f5540

Please sign in to comment.