Fixes for growth rates, forces shared library to be dll on Windows.

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2021-03-07 09:43:10 +01:00
parent 7aa31a838d
commit d70c6a224a
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 7 additions and 4 deletions

View File

@ -68,7 +68,6 @@ if (IPO_SUPPORTED)
set_property(TARGET CreatureLib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) set_property(TARGET CreatureLib PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif () endif ()
# If we are building for Windows we need to set some specific variables.
if (WINDOWS) if (WINDOWS)
MESSAGE(WARNING, "Using Windows Build.") MESSAGE(WARNING, "Using Windows Build.")
# Add a definition for the compiler, so we can use it in C++ as well. # Add a definition for the compiler, so we can use it in C++ as well.
@ -76,8 +75,12 @@ if (WINDOWS)
# -m64: Build a 64 bit library # -m64: Build a 64 bit library
add_compile_options(-m64) add_compile_options(-m64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition")
if (SHARED)
set_target_properties(CreatureLib PROPERTIES SUFFIX ".dll")
endif (SHARED)
endif (WINDOWS) endif (WINDOWS)
# Set up links to all relevant libraries. # Set up links to all relevant libraries.
SET(_LIBRARYLINKS Arbutils) SET(_LIBRARYLINKS Arbutils)
if (NOT WINDOWS) if (NOT WINDOWS)

View File

@ -14,8 +14,8 @@ namespace CreatureLib::Library {
virtual ~GrowthRateLibrary() = default; virtual ~GrowthRateLibrary() = default;
[[nodiscard]] uint8_t CalculateLevel(const ArbUt::BasicStringView& growthRate, uint32_t experience) const; [[nodiscard]] level_int_t CalculateLevel(const ArbUt::BasicStringView& growthRate, uint32_t experience) const;
[[nodiscard]] uint8_t CalculateLevel(uint32_t hash, uint32_t experience) const; [[nodiscard]] level_int_t CalculateLevel(uint32_t hash, uint32_t experience) const;
[[nodiscard]] uint32_t CalculateExperience(const ArbUt::BasicStringView& growthRate, level_int_t level) const; [[nodiscard]] uint32_t CalculateExperience(const ArbUt::BasicStringView& growthRate, level_int_t level) const;
[[nodiscard]] uint32_t CalculateExperience(uint32_t hash, level_int_t level) const; [[nodiscard]] uint32_t CalculateExperience(uint32_t hash, level_int_t level) const;

View File

@ -17,7 +17,7 @@ namespace CreatureLib::Library {
return i; return i;
} }
} }
return _experience[_experience.Count() - 1]; return _experience.Count() - 1;
} }
uint32_t CalculateExperience(level_int_t level) const override { return _experience[level - 1]; } uint32_t CalculateExperience(level_int_t level) const override { return _experience[level - 1]; }