Adds a bunch of helpers for evolution, as well as custom script evolution methods.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-07-09 13:54:42 +02:00
parent 8fc29d925b
commit 9424a209ec
16 changed files with 281 additions and 86 deletions

View File

@@ -15,7 +15,8 @@ protected:
public:
virtual void WriteTypes(
const ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>>& types,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> itemUseTypes) {
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*>& itemUseTypes,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*>& evolutionTypes) {
// We serialize our types in the format
// "[category(byte)][name(str)]\2[decl(str)]\2[name(str)]\2[decl(str)]\1[category(byte)]...."
@@ -23,7 +24,7 @@ public:
for (const auto& dic : types) {
// Write the category
categoryArr[0] = dic.first;
Write(categoryArr, sizeof(ScriptCategory));
Write(categoryArr, sizeof(i16));
for (const auto& inner : dic.second) {
// Write the script name
Write(inner.first.c_str(), sizeof(char) * inner.first.Length());
@@ -40,7 +41,7 @@ public:
}
categoryArr[0] = (ScriptCategory)-1;
Write(categoryArr, sizeof(ScriptCategory));
Write(categoryArr, sizeof(i16));
for (const auto& inner : itemUseTypes) {
// Write the script name
Write(inner.first.c_str(), sizeof(char) * inner.first.Length());
@@ -54,15 +55,31 @@ public:
}
// Write the divider between categories.
Write("\1", sizeof(char));
categoryArr[0] = (ScriptCategory)-2;
Write(categoryArr, sizeof(i16));
for (const auto& inner : evolutionTypes) {
// Write the script name
Write(inner.first.c_str(), sizeof(char) * inner.first.Length());
// Write the divider
Write("\2", sizeof(char));
// Write the declaration of the script
auto decl = inner.second->GetName();
Write(decl, sizeof(char) * strlen(decl));
// Write another divider.
Write("\2", sizeof(char));
}
// Write the divider between categories.
Write("\1", sizeof(char));
}
virtual ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> ReadTypes() {
virtual ArbUt::Dictionary<i16, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> ReadTypes() {
_angelScriptBound = SIZE_MAX;
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> types;
ScriptCategory categoryArr[1];
ArbUt::Dictionary<i16, ArbUt::Dictionary<ArbUt::StringView, uint32_t>> types;
i16 categoryArr[1];
while (true) {
// Every inner database starts with the category, of known size. Read that.
auto read = Read(categoryArr, sizeof(ScriptCategory));
auto read = Read(categoryArr, sizeof(i16));
// If we haven't read anything, we are finished.
if (read == 0) {
break;