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