Implement function inlining for menu legacy mode

This commit is contained in:
Jan 2021-10-24 10:35:57 +02:00
parent 9184c0265e
commit 4e5e6d05bd

View File

@ -7,6 +7,7 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "ObjWriting.h"
#include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/GameAssetPoolIW4.h"
#include "Menu/MenuDumper.h" #include "Menu/MenuDumper.h"
#include "Parsing/Impl/ParserInputStream.h" #include "Parsing/Impl/ParserInputStream.h"
@ -509,6 +510,41 @@ class MenuDumperIw4 : public MenuDumper
} }
} }
void WriteStatementOperandFunction(const Statement_s* statement, const size_t currentPos) const
{
const auto& operand = statement->entries[currentPos].data.operand;
if (operand.internals.function == nullptr)
return;
if(!ObjWriting::Configuration.MenuLegacyMode)
{
int functionIndex = -1;
if (statement->supportingData && statement->supportingData->uifunctions.functions)
{
for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; supportingFunctionIndex++)
{
if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function)
{
functionIndex = supportingFunctionIndex;
break;
}
}
}
if (functionIndex >= 0)
m_stream << "FUNC_" << functionIndex;
else
m_stream << "INVALID_FUNC";
}
else
{
m_stream << "(";
WriteStatementSkipInitialUnnecessaryParenthesis(operand.internals.function);
m_stream << ")";
}
}
void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const
{ {
const auto& expEntry = statement->entries[currentPos]; const auto& expEntry = statement->entries[currentPos];
@ -533,27 +569,8 @@ class MenuDumperIw4 : public MenuDumper
break; break;
case VAL_FUNCTION: case VAL_FUNCTION:
{ WriteStatementOperandFunction(statement, currentPos);
int functionIndex = -1;
if (statement->supportingData && statement->supportingData->uifunctions.functions)
{
for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; supportingFunctionIndex++)
{
if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function)
{
functionIndex = supportingFunctionIndex;
break; break;
}
}
}
if (functionIndex >= 0)
m_stream << "FUNC_" << functionIndex;
else
m_stream << "INVALID_FUNC";
break;
}
default: default:
break; break;