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.
This commit is contained in:
Peace-Maker 2018-08-08 01:01:56 +02:00
parent 46682568f5
commit e0583c514b

View File

@ -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;