Make AngelScript effect attributes case insensitive.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-19 12:17:58 +02:00
parent aa1e6ae5b3
commit af737cf8b8
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 32 additions and 25 deletions

View File

@ -156,14 +156,14 @@ void AngelScripResolver::FinalizeModule() {
for (size_t m = 0; m < metadata.size(); m++) {
auto data = metadata[m];
if (std::regex_match(data, base_match, metadataMatcher)) {
auto metadataKind = base_match[1].str();
auto metadataKind = Arbutils::CaseInsensitiveConstString(base_match[1].str());
auto metadataVariables = base_match[2].str();
if (!std::regex_match(metadataVariables, base_match, variableMatcher)) {
continue;
}
ConstString effectName;
for (size_t variableIndex = 1; variableIndex < base_match.size(); variableIndex += 2) {
if (base_match[variableIndex] == "effect") {
if (Arbutils::CaseInsensitiveConstString::GetHash(base_match[variableIndex]) == "effect"_cnc) {
auto val = base_match[variableIndex + 1].str();
effectName = ConstString(val);
}
@ -171,28 +171,35 @@ void AngelScripResolver::FinalizeModule() {
if (effectName.Empty()) {
continue;
}
if (metadataKind == "Move") {
_typeDatabase[ScriptCategory::Attack].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Pokemon") {
_typeDatabase[ScriptCategory::Creature].Insert(effectName,
switch (metadataKind) {
case "Move"_cnc:
_typeDatabase[ScriptCategory::Attack].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Pokemon"_cnc:
_typeDatabase[ScriptCategory::Creature].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Ability"_cnc:
_typeDatabase[ScriptCategory::Talent].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Status"_cnc:
_typeDatabase[ScriptCategory::Status].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Battle"_cnc:
_typeDatabase[ScriptCategory::Battle].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Side"_cnc:
_typeDatabase[ScriptCategory::Side].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Ability") {
_typeDatabase[ScriptCategory::Talent].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Status") {
_typeDatabase[ScriptCategory::Status].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Battle") {
_typeDatabase[ScriptCategory::Battle].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Side") {
_typeDatabase[ScriptCategory::Side].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
} else if (metadataKind == "Weather") {
_typeDatabase[static_cast<ScriptCategory>(PkmnScriptCategory::Weather)].Insert(effectName,
new AngelScriptTypeInfo(effectName, typeInfo));
break;
case "Weather"_cnc:
_typeDatabase[static_cast<ScriptCategory>(PkmnScriptCategory::Weather)].Insert(
effectName, new AngelScriptTypeInfo(effectName, typeInfo));
break;
}
}
}
@ -236,8 +243,8 @@ void AngelScripResolver::LoadByteCodeFromMemory(
InitializeByteCode(stream, types);
delete stream;
}
void AngelScripResolver::InitializeByteCode(asIBinaryStream* stream,
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
void AngelScripResolver::InitializeByteCode(
asIBinaryStream* stream, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
int result = _mainModule->LoadByteCode(stream);
Assert(result == asSUCCESS);