Move script name to type.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-02-23 16:02:27 +01:00
parent 13a8228a44
commit 98e17a1eb8
7 changed files with 28 additions and 22 deletions

View File

@@ -85,18 +85,18 @@ void AngelScripResolver::RegisterTypes() {
BasicScriptClass::Register(_engine);
}
AngelScriptTypeInfo* AngelScripResolver::GetTypeInfo(const std::string& name) {
auto find = _types.find(name);
AngelScriptTypeInfo* AngelScripResolver::GetTypeInfo(const std::string& name, const std::string& decl) {
auto find = _types.find(decl);
if (find != _types.end()) {
return find->second;
}
auto type = _mainModule->GetTypeInfoByDecl(name.c_str());
auto type = _mainModule->GetTypeInfoByDecl(decl.c_str());
if (type == nullptr) {
_types.insert({name, nullptr});
_types.insert({decl, nullptr});
return nullptr;
}
auto typeinfo = new AngelScriptTypeInfo(type);
_types.insert({name, typeinfo});
auto typeinfo = new AngelScriptTypeInfo(name, type);
_types.insert({decl, typeinfo});
return typeinfo;
}
void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param) {
@@ -123,13 +123,13 @@ static constexpr const char* GetCategoryNamespace(ScriptCategory category) {
CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory category, const std::string& scriptName) {
std::stringstream decl;
decl << GetCategoryNamespace(category) << "::" << scriptName;
auto typeInfo = GetTypeInfo(decl.str());
auto typeInfo = GetTypeInfo(scriptName, decl.str());
if (typeInfo == nullptr)
return nullptr;
auto ctx = _contextPool->RequestContext();
auto obj = typeInfo->Instantiate(ctx);
_contextPool->ReturnContextToPool(ctx);
return new AngelScriptScript(scriptName, typeInfo, obj, _contextPool);
return new AngelScriptScript(typeInfo, obj, _contextPool);
}
void AngelScripResolver::FinalizeModule() {
int r = _builder.BuildModule();