I am struggling with the varargs situation of some functions. Sometimes I needed to pass on the varargs ... to a downstream function (e.g. Print functions). Therefore, I refactored ... as va_list. However, va_list is a mandatory argument.
This gives problems in functions that call vararg functions, such as is the case in ShowProgressBarSaveLoadDialog. In actuality, the below code has a jmp to MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic. The 0 argument is moved into the first arg location on the stack, right before. So I am starting to doubt whether these MenuItemActionHandler functions are/should be varargs. If I recall correctly, they are currently varargs because a MenuItemActionHandler that is a callback for a scrollhandler receives 4 parameters, whereas most other functionality just receives a single parameter. How about we use a Union to differentiate the two callback types and clean up the MenuItemHandler declarations to not be vararg?
// FUNCTION: STRONGHOLDCRUSADER 0x00495800
void UI::ShowProgressBarSaveLoadDialog(int param_1)
{
DAT_MenuTextInputState::instance.DAT_MenuOptionsActionParameter = (-(uint)(param_1 != 0) & 0xe) + 0x20;
MACRO_CALL_MEMBER(OpenSHC::UI::MenuModalComposition_Func::activateModalDialog2, DAT_MenuModalComposition1::ptr)(
OpenSHC::UI::Enums::MMT_PROGRESS_BAR_BOX);
DAT_MenuModalComposition1::instance.activeModalDialogID = OpenSHC::UI::Enums::MMT_PROGRESS_BAR_BOX;
MACRO_CALL(OpenSHC::UI_Func::MenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic)(0);
return;
}
I am struggling with the varargs situation of some functions. Sometimes I needed to pass on the varargs
...to a downstream function (e.g. Print functions). Therefore, I refactored...asva_list. However,va_listis a mandatory argument.This gives problems in functions that call vararg functions, such as is the case in
ShowProgressBarSaveLoadDialog. In actuality, the below code has ajmptoMenuItemActionHandler_ProgressBarBox_LoadAndSaveGameButtonLogic. The0argument is moved into the first arg location on the stack, right before. So I am starting to doubt whether these MenuItemActionHandler functions are/should be varargs. If I recall correctly, they are currently varargs because a MenuItemActionHandler that is a callback for a scrollhandler receives 4 parameters, whereas most other functionality just receives a single parameter. How about we use a Union to differentiate the two callback types and clean up the MenuItemHandler declarations to not be vararg?