mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Fix not respecting case-insensitive functions when converting menus
This commit is contained in:
parent
0b1120f26f
commit
82f3d4925f
@ -12,6 +12,7 @@
|
|||||||
#include "Parsing/Simple/Expression/SimpleExpressionConditionalOperator.h"
|
#include "Parsing/Simple/Expression/SimpleExpressionConditionalOperator.h"
|
||||||
#include "Parsing/Simple/Expression/SimpleExpressionUnaryOperation.h"
|
#include "Parsing/Simple/Expression/SimpleExpressionUnaryOperation.h"
|
||||||
#include "Utils/ClassUtils.h"
|
#include "Utils/ClassUtils.h"
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -204,12 +205,15 @@ namespace IW4
|
|||||||
const CommonMenuDef* menu,
|
const CommonMenuDef* menu,
|
||||||
const CommonItemDef* item) const
|
const CommonItemDef* item) const
|
||||||
{
|
{
|
||||||
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(functionCall->m_function_name);
|
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
||||||
|
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
||||||
|
|
||||||
|
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (functionStatement == nullptr)
|
if (functionStatement == nullptr)
|
||||||
{
|
{
|
||||||
// Function was not converted yet: Convert it now
|
// Function was not converted yet: Convert it now
|
||||||
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(functionCall->m_function_name);
|
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
||||||
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "Parsing/Simple/Expression/SimpleExpressionConditionalOperator.h"
|
#include "Parsing/Simple/Expression/SimpleExpressionConditionalOperator.h"
|
||||||
#include "Parsing/Simple/Expression/SimpleExpressionUnaryOperation.h"
|
#include "Parsing/Simple/Expression/SimpleExpressionUnaryOperation.h"
|
||||||
#include "Utils/ClassUtils.h"
|
#include "Utils/ClassUtils.h"
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -204,18 +205,21 @@ namespace IW5
|
|||||||
const CommonMenuDef* menu,
|
const CommonMenuDef* menu,
|
||||||
const CommonItemDef* item) const
|
const CommonItemDef* item) const
|
||||||
{
|
{
|
||||||
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(functionCall->m_function_name);
|
std::string lowerCaseFunctionName(functionCall->m_function_name);
|
||||||
|
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
||||||
|
|
||||||
|
Statement_s* functionStatement = m_conversion_zone_state->FindFunction(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (functionStatement == nullptr)
|
if (functionStatement == nullptr)
|
||||||
{
|
{
|
||||||
// Function was not converted yet: Convert it now
|
// Function was not converted yet: Convert it now
|
||||||
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(functionCall->m_function_name);
|
const auto foundCommonFunction = m_parsing_zone_state->m_functions_by_name.find(lowerCaseFunctionName);
|
||||||
|
|
||||||
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
if (foundCommonFunction == m_parsing_zone_state->m_functions_by_name.end())
|
||||||
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
throw MenuConversionException("Failed to find definition for custom function \"" + functionCall->m_function_name + "\"", menu, item);
|
||||||
|
|
||||||
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
functionStatement = ConvertExpression(foundCommonFunction->second->m_value.get(), menu, item);
|
||||||
functionStatement = m_conversion_zone_state->AddFunction(foundCommonFunction->second->m_name, functionStatement);
|
functionStatement = m_conversion_zone_state->AddFunction(lowerCaseFunctionName, functionStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionEntry functionEntry{};
|
expressionEntry functionEntry{};
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
#include "MenuAssetZoneState.h"
|
#include "MenuAssetZoneState.h"
|
||||||
|
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
using namespace menu;
|
using namespace menu;
|
||||||
|
|
||||||
void MenuAssetZoneState::AddFunction(std::unique_ptr<CommonFunctionDef> function)
|
void MenuAssetZoneState::AddFunction(std::unique_ptr<CommonFunctionDef> function)
|
||||||
{
|
{
|
||||||
m_functions_by_name.emplace(std::make_pair(function->m_name, function.get()));
|
std::string lowerCaseFunctionName(function->m_name);
|
||||||
|
utils::MakeStringLowerCase(lowerCaseFunctionName);
|
||||||
|
|
||||||
|
m_functions_by_name.emplace(std::make_pair(lowerCaseFunctionName, function.get()));
|
||||||
m_functions.emplace_back(std::move(function));
|
m_functions.emplace_back(std::move(function));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "MenuFileParserState.h"
|
#include "MenuFileParserState.h"
|
||||||
|
|
||||||
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
using namespace menu;
|
using namespace menu;
|
||||||
|
|
||||||
MenuFileParserState::EventHandlerConditionState::EventHandlerConditionState(CommonEventHandlerCondition* condition)
|
MenuFileParserState::EventHandlerConditionState::EventHandlerConditionState(CommonEventHandlerCondition* condition)
|
||||||
@ -32,7 +34,9 @@ MenuFileParserState::MenuFileParserState(const FeatureLevel featureLevel, const
|
|||||||
{
|
{
|
||||||
for (const auto& function : zoneState->m_functions)
|
for (const auto& function : zoneState->m_functions)
|
||||||
{
|
{
|
||||||
m_functions_by_name.emplace(std::make_pair(function->m_name, function.get()));
|
std::string lowerCaseName(function->m_name);
|
||||||
|
utils::MakeStringLowerCase(lowerCaseName);
|
||||||
|
m_functions_by_name.emplace(std::make_pair(lowerCaseName, function.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& menu : zoneState->m_menus)
|
for (const auto& menu : zoneState->m_menus)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user