Use level_int_t for levels.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-08-22 12:24:52 +02:00
parent cc92cf1491
commit c6e2de6156
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
7 changed files with 34 additions and 6 deletions

View File

@ -11,6 +11,7 @@ option(SHARED "Whether we should build a shared library, instead of a static one
option(TESTS "Whether the test executable should be build as well." OFF) option(TESTS "Whether the test executable should be build as well." OFF)
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.") set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.")
set(LEVEL_SIZE "8" CACHE STRING "Number of bits to store the level as. Can be 8, 16, 32, or 64")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-fconcepts) add_compile_options(-fconcepts)
@ -33,6 +34,18 @@ message(STATUS "Using:
\t CXX ABI ${CMAKE_CXX_COMPILER_ABI} \t CXX ABI ${CMAKE_CXX_COMPILER_ABI}
\t C++ Version ${CMAKE_CXX_STANDARD}") \t C++ Version ${CMAKE_CXX_STANDARD}")
if (LEVEL_SIZE STREQUAL "8")
add_definitions(-DLEVEL_U8)
elseif (LEVEL_SIZE STREQUAL "16")
add_definitions(-DLEVEL_U16)
elseif (LEVEL_SIZE STREQUAL "32")
add_definitions(-DLEVEL_U32)
elseif (LEVEL_SIZE STREQUAL "64")
add_definitions(-DLEVEL_U64)
else ()
message(FATAL_ERROR, "Invalid level size was given.")
endif ()
include(CmakeConanSetup.cmake) include(CmakeConanSetup.cmake)
SetupConan() SetupConan()

View File

@ -11,10 +11,23 @@ function(SetupConan)
if (NOT WINDOWS) if (NOT WINDOWS)
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
-s compiler=clang -s compiler.libcxx=libstdc++11 -o *:shared=True -o *:staticC=${CONAN_STATIC_C} -o AngelScript:link_std_statically=True) -s compiler=clang
-s compiler.libcxx=libstdc++11
-o *:shared=True
-o *:staticC=${CONAN_STATIC_C}
-o AngelScript:link_std_statically=True
-o CreatureLib:level_size=${LEVEL_SIZE}
)
else () else ()
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s os=Windows -o *:shared=True -o *:staticC=${CONAN_STATIC_C} -o AngelScript:link_std_statically=True) -s compiler=gcc
-s compiler.libcxx=libstdc++11
-s os=Windows
-o *:shared=True
-o *:staticC=${CONAN_STATIC_C}
-o AngelScript:link_std_statically=True
-o CreatureLib:level_size=${LEVEL_SIZE}
)
endif () endif ()
endif () endif ()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)

View File

@ -3,7 +3,7 @@
#include "../PkmnScriptHook.hpp" #include "../PkmnScriptHook.hpp"
#include "../Pokemon/Pokemon.hpp" #include "../Pokemon/Pokemon.hpp"
static inline uint32_t CalculateDynamicExperience(uint8_t level, float v1, static inline uint32_t CalculateDynamicExperience(level_int_t level, float v1,
ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> op, ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> op,
ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> faintedMon) { ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> faintedMon) {
float a = 2 * level + 10; float a = 2 * level + 10;

View File

@ -2,6 +2,8 @@
#define PKMNLIB_EXPERIENCELIBRARY_HPP #define PKMNLIB_EXPERIENCELIBRARY_HPP
#include <CreatureLib/Battling/Library/ExperienceLibrary.hpp> #include <CreatureLib/Battling/Library/ExperienceLibrary.hpp>
#include <CreatureLib/Defines.hpp>
namespace PkmnLib::Battling { namespace PkmnLib::Battling {
class ExperienceLibrary : public CreatureLib::Battling::ExperienceLibrary { class ExperienceLibrary : public CreatureLib::Battling::ExperienceLibrary {
public: public:

View File

@ -9,7 +9,7 @@ namespace PkmnLib::Battling {
ArbUt::BorrowedPtr<const BattleLibrary> _library; ArbUt::BorrowedPtr<const BattleLibrary> _library;
ArbUt::StringView _species = ""_cnc; ArbUt::StringView _species = ""_cnc;
ArbUt::StringView _forme = "default"_cnc; ArbUt::StringView _forme = "default"_cnc;
uint8_t _level; level_int_t _level;
std::string _nickname = ""; std::string _nickname = "";
ArbUt::StringView _ability = ""_cnc; ArbUt::StringView _ability = ""_cnc;

View File

@ -20,7 +20,7 @@ namespace PkmnLib::Battling {
public: public:
Pokemon(ArbUt::BorrowedPtr<const BattleLibrary> library, Pokemon(ArbUt::BorrowedPtr<const BattleLibrary> library,
const ArbUt::BorrowedPtr<const Library::PokemonSpecies>& species, const ArbUt::BorrowedPtr<const Library::PokemonSpecies>& species,
const ArbUt::BorrowedPtr<const Library::PokemonForme>& forme, uint8_t level, uint32_t experience, const ArbUt::BorrowedPtr<const Library::PokemonForme>& forme, level_int_t level, uint32_t experience,
uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring, uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring,
ArbUt::BorrowedPtr<const Library::Item> heldItem, const std::string& nickname, ArbUt::BorrowedPtr<const Library::Item> heldItem, const std::string& nickname,
const CreatureLib::Library::TalentIndex& talent, const CreatureLib::Library::TalentIndex& talent,

View File

@ -23,7 +23,7 @@ static uint8_t CalculateLevel(const CreatureLib::Library::GrowthRateLibrary* obj
return obj->CalculateLevel(str, experience); return obj->CalculateLevel(str, experience);
} }
static uint32_t CalculateExperience(const CreatureLib::Library::GrowthRateLibrary* obj, const ArbUt::StringView& str, static uint32_t CalculateExperience(const CreatureLib::Library::GrowthRateLibrary* obj, const ArbUt::StringView& str,
uint8_t level) { level_int_t level) {
return obj->CalculateExperience(str, level); return obj->CalculateExperience(str, level);
} }