Resolve issue with multithreading when trying to get a base type from Angelscript.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b5ea856443
commit
592552cb72
|
@ -2,6 +2,7 @@
|
|||
#define PKMNLIB_ANGELSCRIPTRESOLVER_HPP
|
||||
|
||||
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
|
||||
#include <mutex>
|
||||
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
|
||||
#include "../../Battling/Library/BattleLibrary.hpp"
|
||||
#include "AngelScriptEvolutionScript.hpp"
|
||||
|
@ -23,6 +24,8 @@ private:
|
|||
|
||||
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> _typeDatabase;
|
||||
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _baseTypes;
|
||||
std::mutex _baseTypesLock;
|
||||
|
||||
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _itemUseTypes;
|
||||
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _evolutionTypes;
|
||||
ArbUt::Dictionary<const CreatureLib::Library::Item*, AngelScriptItemUseScript*> _itemUseScripts;
|
||||
|
@ -92,6 +95,7 @@ public:
|
|||
|
||||
asITypeInfo* GetBaseType(const ArbUt::StringView& name) {
|
||||
asITypeInfo* t;
|
||||
auto lock = std::lock_guard(_baseTypesLock);
|
||||
auto v = _baseTypes.TryGet(name);
|
||||
if (!v.has_value()) {
|
||||
t = _mainModule->GetTypeInfoByName(name.c_str());
|
||||
|
|
Loading…
Reference in New Issue