Update to latest CreatureLib
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d9badefb07
commit
b5a1d74bdb
|
@ -12,6 +12,10 @@ 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.")
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
add_compile_options(-fconcepts)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
SET(CMAKE_SYSTEM_NAME Windows)
|
SET(CMAKE_SYSTEM_NAME Windows)
|
||||||
ADD_DEFINITIONS(-D WINDOWS=1)
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||||
|
|
|
@ -34,7 +34,7 @@ float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib:
|
||||||
case 4: return 6.0 / 2;
|
case 4: return 6.0 / 2;
|
||||||
case 5: return 7.0 / 2;
|
case 5: return 7.0 / 2;
|
||||||
case 6: return 8.0 / 2;
|
case 6: return 8.0 / 2;
|
||||||
default: throw CreatureException("Stat boost was out of expected range of -6 till 6.");
|
default: throw ArbUt::Exception("Stat boost was out of expected range of -6 till 6.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CreatureLib::Library::StatisticSet<uint32_t>
|
CreatureLib::Library::StatisticSet<uint32_t>
|
||||||
|
|
|
@ -40,13 +40,13 @@ namespace PkmnLib::Battling {
|
||||||
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) {
|
||||||
std::stringstream err;
|
std::stringstream err;
|
||||||
err << "Invalid species '" << _species << "'.";
|
err << "Invalid species '" << _species << "'.";
|
||||||
throw CreatureException(err.str());
|
throw ArbUt::Exception(err.str());
|
||||||
}
|
}
|
||||||
ArbUt::BorrowedPtr<const PkmnLib::Library::PokemonForme> forme;
|
ArbUt::BorrowedPtr<const PkmnLib::Library::PokemonForme> forme;
|
||||||
if (!species->TryGetForme(this->_forme, forme)) {
|
if (!species->TryGetForme(this->_forme, forme)) {
|
||||||
std::stringstream err;
|
std::stringstream err;
|
||||||
err << "Invalid forme '" << _forme << "' for species '" << _forme << "'.";
|
err << "Invalid forme '" << _forme << "' for species '" << _forme << "'.";
|
||||||
throw CreatureException(err.str());
|
throw ArbUt::Exception(err.str());
|
||||||
}
|
}
|
||||||
AssertNotNull(forme);
|
AssertNotNull(forme);
|
||||||
CreatureLib::Library::TalentIndex ability;
|
CreatureLib::Library::TalentIndex ability;
|
||||||
|
@ -151,7 +151,7 @@ namespace PkmnLib::Battling {
|
||||||
THROW_CREATURE("Invalid Move given: " << moveName.std_str());
|
THROW_CREATURE("Invalid Move given: " << moveName.std_str());
|
||||||
}
|
}
|
||||||
if (_currentMove >= _library->GetSettings()->GetMaximalAttacks()) {
|
if (_currentMove >= _library->GetSettings()->GetMaximalAttacks()) {
|
||||||
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
throw ArbUt::Exception("This pokemon already has the maximal allowed moves.");
|
||||||
}
|
}
|
||||||
Assert(move != nullptr);
|
Assert(move != nullptr);
|
||||||
_attacks.Append(ToLearnMethod(move, method));
|
_attacks.Append(ToLearnMethod(move, method));
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace PkmnLib::Library {
|
||||||
return v.first;
|
return v.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw CreatureException("Nature not found.");
|
throw ArbUt::Exception("Nature not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetNatureCount() const noexcept { return _items.size(); }
|
size_t GetNatureCount() const noexcept { return _items.size(); }
|
||||||
|
|
|
@ -56,7 +56,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg)
|
||||||
|
|
||||||
int32_t r = _engine->SetMessageCallback(asFUNCTION(MessageCallback), nullptr, asCALL_CDECL);
|
int32_t r = _engine->SetMessageCallback(asFUNCTION(MessageCallback), nullptr, asCALL_CDECL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
throw CreatureException("Registering message callback failed.");
|
throw ArbUt::Exception("Registering message callback failed.");
|
||||||
|
|
||||||
_engine->SetEngineProperty(asEP_DISALLOW_EMPTY_LIST_ELEMENTS, true);
|
_engine->SetEngineProperty(asEP_DISALLOW_EMPTY_LIST_ELEMENTS, true);
|
||||||
_engine->SetEngineProperty(asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, false);
|
_engine->SetEngineProperty(asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, false);
|
||||||
|
@ -75,7 +75,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg)
|
||||||
|
|
||||||
r = _engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(Print), asCALL_CDECL);
|
r = _engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(Print), asCALL_CDECL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
throw CreatureException("Registering print function failed.");
|
throw ArbUt::Exception("Registering print function failed.");
|
||||||
RegisterScriptHandle(_engine);
|
RegisterScriptHandle(_engine);
|
||||||
|
|
||||||
_builder.StartNewModule(_engine, "pkmn");
|
_builder.StartNewModule(_engine, "pkmn");
|
||||||
|
@ -148,7 +148,7 @@ CreatureLib::Battling::Script* AngelScriptResolver::LoadScript(ScriptCategory ca
|
||||||
void AngelScriptResolver::FinalizeModule() {
|
void AngelScriptResolver::FinalizeModule() {
|
||||||
int r = _builder.BuildModule();
|
int r = _builder.BuildModule();
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
throw CreatureException("Building Script Module failed.");
|
throw ArbUt::Exception("Building Script Module failed.");
|
||||||
asUINT count = _mainModule->GetObjectTypeCount();
|
asUINT count = _mainModule->GetObjectTypeCount();
|
||||||
std::regex metadataMatcher(R"(^\s*(\w+)([\w\s=]*)$)", std::regex_constants::icase);
|
std::regex metadataMatcher(R"(^\s*(\w+)([\w\s=]*)$)", std::regex_constants::icase);
|
||||||
std::regex variableMatcher(R"(\s*(\w+)=(\w+))", std::regex_constants::icase);
|
std::regex variableMatcher(R"(\s*(\w+)=(\w+))", std::regex_constants::icase);
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
} else { \
|
} else { \
|
||||||
ctx->PopState(); \
|
ctx->PopState(); \
|
||||||
} \
|
} \
|
||||||
throw CreatureException(err.str()); \
|
throw ArbUt::Exception(err.str()); \
|
||||||
} \
|
} \
|
||||||
if (newContext) { \
|
if (newContext) { \
|
||||||
_ctxPool->ReturnContextToPool(ctx); \
|
_ctxPool->ReturnContextToPool(ctx); \
|
||||||
} else { \
|
} else { \
|
||||||
ctx->PopState(); \
|
ctx->PopState(); \
|
||||||
} \
|
} \
|
||||||
throw CreatureException("Script didn't finish properly; message " + std::to_string(scriptResult)); \
|
throw ArbUt::Exception("Script didn't finish properly; message " + std::to_string(scriptResult)); \
|
||||||
} \
|
} \
|
||||||
if (newContext) { \
|
if (newContext) { \
|
||||||
_ctxPool->ReturnContextToPool(ctx); \
|
_ctxPool->ReturnContextToPool(ctx); \
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
#define PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
||||||
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
|
#include <CreatureLib/Battling/ScriptHandling/Script.hpp>
|
||||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||||
#include <CreatureLib/Library/Exceptions/NotImplementedException.hpp>
|
|
||||||
#include <angelscript.h>
|
#include <angelscript.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "../../../extern/angelscript_addons/scriptarray/scriptarray.h"
|
#include "../../../extern/angelscript_addons/scriptarray/scriptarray.h"
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
ctx->Prepare(factory);
|
ctx->Prepare(factory);
|
||||||
auto result = ctx->Execute();
|
auto result = ctx->Execute();
|
||||||
if (result != asEXECUTION_FINISHED) {
|
if (result != asEXECUTION_FINISHED) {
|
||||||
throw CreatureException("Instantiation failed.");
|
throw ArbUt::Exception("Instantiation failed.");
|
||||||
}
|
}
|
||||||
asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue();
|
asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue();
|
||||||
obj->AddRef();
|
obj->AddRef();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
_capacity += MEM_STEPS;
|
_capacity += MEM_STEPS;
|
||||||
auto newLoc = realloc(_out, _capacity * sizeof(uint8_t));
|
auto newLoc = realloc(_out, _capacity * sizeof(uint8_t));
|
||||||
if (newLoc == nullptr) {
|
if (newLoc == nullptr) {
|
||||||
throw CreatureException("Out of memory.");
|
throw ArbUt::Exception("Out of memory.");
|
||||||
}
|
}
|
||||||
_out = (uint8_t*)newLoc;
|
_out = (uint8_t*)newLoc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue