Support serializing item use scripts.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-03-07 18:11:18 +01:00
parent 27dd8a8202
commit 7216d9d71b
2 changed files with 34 additions and 9 deletions

View File

@@ -292,7 +292,7 @@ void AngelScriptResolver::WriteByteCodeToFile(const char* file, bool stripDebugI
// We grab the current position of the written file. This is the position the types will be written on. So we need
// to know this.
uint64_t bytecodeSize = (uint64_t)ftell(wFile);
stream->WriteTypes(_typeDatabase);
stream->WriteTypes(_typeDatabase, _itemUseTypes);
// Go back to the start of the file
fsetpos(wFile, &startPos);
@@ -334,7 +334,7 @@ uint8_t* AngelScriptResolver::WriteByteCodeToMemory(size_t& size, bool stripDebu
auto result = _mainModule->SaveByteCode(stream, stripDebugInfo);
Ensure(result == asSUCCESS);
byteCodeSize[0] = (uint64_t)stream->GetWrittenSize();
stream->WriteTypes(_typeDatabase);
stream->WriteTypes(_typeDatabase, _itemUseTypes);
stream->WriteToPosition(byteCodeSize, sizeof(uint64_t), 0);
auto arr = stream->GetOut();
size = stream->GetWrittenSize();
@@ -369,13 +369,21 @@ void AngelScriptResolver::InitializeByteCode(
}
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> typeDatabase;
for (const auto& innerDb : types) {
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> newInnerDb;
for (const auto& val : innerDb.second) {
auto decl = val.second;
auto type = objectTypes[decl];
newInnerDb.Set(val.first, new AngelScriptTypeInfo(val.first, type));
if (innerDb.first != (ScriptCategory)-1) {
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> newInnerDb;
for (const auto& val : innerDb.second) {
auto decl = val.second;
auto type = objectTypes[decl];
newInnerDb.Set(val.first, new AngelScriptTypeInfo(val.first, type));
}
typeDatabase.Set(innerDb.first, newInnerDb);
} else {
for (const auto& val : innerDb.second) {
auto decl = val.second;
auto type = objectTypes[decl];
_itemUseTypes[val.first] = type;
}
}
typeDatabase.Set(innerDb.first, newInnerDb);
}
_typeDatabase = typeDatabase;
}