From e0583c514b18b0cf66b5948a56f9a5807ffb1aee Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Wed, 8 Aug 2018 01:01:56 +0200 Subject: [PATCH] Fix adding arguments multiple times when reloading a gamedata file If the Functions section was parsed before and the gamedata file is loaded again, the arguments were all added again instead of keeping the old number of arguments. --- signatures.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/signatures.cpp b/signatures.cpp index f82c0f5..1433649 100644 --- a/signatures.cpp +++ b/signatures.cpp @@ -380,7 +380,20 @@ SMCResult SignatureGameConfig::ReadSMC_LeavingSection(const SMCStates *states) if (g_CurrentArgumentInfo.info.pass_type == SourceHook::PassInfo::PassType::PassType_Unknown) g_CurrentArgumentInfo.info.pass_type = GetParamTypePassType(g_CurrentArgumentInfo.info.type); - g_CurrentSignature->args.append(g_CurrentArgumentInfo); + // See if we were changing an existing argument. + bool changed = false; + for (auto &arg : g_CurrentSignature->args) + { + if (!arg.name.compare(g_CurrentArgumentInfo.name)) + { + arg.info = g_CurrentArgumentInfo.info; + changed = true; + break; + } + } + // This was a new argument. Add it to the end of the list. + if (!changed) + g_CurrentSignature->args.append(g_CurrentArgumentInfo); g_CurrentArgumentInfo.name = nullptr; break;