From 2483d4fc35dafceb97c865bfbd1e71f93eef8ab4 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Tue, 26 Mar 2024 00:53:57 +0900 Subject: [PATCH 1/3] port: add auto random mp weapon option --- src/game/mplayer/mplayer.c | 18 ++++++++++++ src/game/mplayer/setup.c | 60 ++++++++++++++++++++++++++++++++++++++ src/include/constants.h | 2 ++ 3 files changed, 80 insertions(+) diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 20270b1ed..851a2d1c5 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -184,6 +184,15 @@ void mpStartMatch(void) s32 numplayers = 0; s32 stagenum; +#ifndef PLATFORM_N64 + if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) { + if (g_MpWeaponSetNum == WEAPONSET_RANDOM + || g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { + mpApplyWeaponSet(); + } + } +#endif + mpConfigureQuickTeamSimulants(); if (!challengeIsFeatureUnlocked(MPFEATURE_ONEHITKILLS)) { @@ -2458,6 +2467,15 @@ void mpEndMatch(void) challengeConsiderMarkingComplete(); } +#ifndef PLATFORM_N64 + if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) { + if (g_MpWeaponSetNum == WEAPONSET_RANDOM + || g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { + mpApplyWeaponSet(); + } + } +#endif + func0f0f820c(NULL, -6); } diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 87b99860d..37061aad9 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -31,6 +31,10 @@ struct menudialogdef g_MpChangeTeamNameMenuDialog; struct menudialogdef g_MpEditSimulantMenuDialog; struct menudialogdef g_MpSaveSetupNameMenuDialog; +#ifndef PLATFORM_N64 +extern s32 g_MpWeaponSetNum; +#endif + MenuItemHandlerResult menuhandlerMpDropOut(s32 operation, struct menuitem *item, union handlerdata *data) { if (operation == MENUOP_SET) { @@ -1160,6 +1164,52 @@ struct menudialogdef g_MpSaveSetupExistsMenuDialog = { NULL, }; +#ifndef PLATFORM_N64 +MenuItemHandlerResult menuhandlerMpAutoRandomWeapon(s32 operation, struct menuitem *item, union handlerdata *data) +{ + const char *labels[] = { + "Off", + "Start", + "End", + }; + + switch (operation) { + case MENUOP_CHECKDISABLED: + case MENUOP_CHECKHIDDEN: + if (g_MpWeaponSetNum == WEAPONSET_RANDOM + || g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { + return false; + } + return true; + case MENUOP_GETOPTIONCOUNT: + data->dropdown.value = 3; + break; + case MENUOP_GETOPTIONTEXT: + return (intptr_t)labels[data->dropdown.value]; + case MENUOP_SET: + g_MpSetup.options &= ~(MPOPTION_AUTORANDOMWEAPON_START | MPOPTION_AUTORANDOMWEAPON_END); + + if (data->dropdown.value == 1) { + g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_START; + } else if (data->dropdown.value == 2) { + g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_END; + } + break; + case MENUOP_GETSELECTEDINDEX: + if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) { + data->dropdown.value = 2; + } else if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) { + data->dropdown.value = 1; + } else { + data->dropdown.value = 0; + } + break; + } + + return 0; +} +#endif + struct menuitem g_MpWeaponsMenuItems[] = { { MENUITEMTYPE_DROPDOWN, @@ -1169,6 +1219,16 @@ struct menuitem g_MpWeaponsMenuItems[] = { 0, menuhandlerMpWeaponSetDropdown, }, +#ifndef PLATFORM_N64 + { + MENUITEMTYPE_DROPDOWN, + 0, + MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Auto Random\n", + 0, + menuhandlerMpAutoRandomWeapon, + }, +#endif { MENUITEMTYPE_SEPARATOR, 0, diff --git a/src/include/constants.h b/src/include/constants.h index e51ec894a..70c0384d4 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2890,6 +2890,8 @@ #define MPOPTION_PAC_HIGHLIGHTTARGET 0x00080000 #define MPOPTION_PAC_SHOWONRADAR 0x00100000 #define MPOPTION_SPAWNWITHWEAPON 0x00200000 +#define MPOPTION_AUTORANDOMWEAPON_START 0x00400000 +#define MPOPTION_AUTORANDOMWEAPON_END 0x00800000 #define MPPAUSEMODE_UNPAUSED 0 #define MPPAUSEMODE_PAUSED 1 From c9a14f090bebbc33b8abb486f05e613bba63c237 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Tue, 26 Mar 2024 23:41:57 +0900 Subject: [PATCH 2/3] port: add constants --- src/game/mplayer/setup.c | 14 +++++++------- src/include/constants.h | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 37061aad9..94c422eb0 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -1167,7 +1167,7 @@ struct menudialogdef g_MpSaveSetupExistsMenuDialog = { #ifndef PLATFORM_N64 MenuItemHandlerResult menuhandlerMpAutoRandomWeapon(s32 operation, struct menuitem *item, union handlerdata *data) { - const char *labels[] = { + static const char *labels[] = { "Off", "Start", "End", @@ -1182,26 +1182,26 @@ MenuItemHandlerResult menuhandlerMpAutoRandomWeapon(s32 operation, struct menuit } return true; case MENUOP_GETOPTIONCOUNT: - data->dropdown.value = 3; + data->dropdown.value = ARRAYCOUNT(labels); break; case MENUOP_GETOPTIONTEXT: return (intptr_t)labels[data->dropdown.value]; case MENUOP_SET: g_MpSetup.options &= ~(MPOPTION_AUTORANDOMWEAPON_START | MPOPTION_AUTORANDOMWEAPON_END); - if (data->dropdown.value == 1) { + if (data->dropdown.value == AUTORANDOM_START) { g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_START; - } else if (data->dropdown.value == 2) { + } else if (data->dropdown.value == AUTORANDOM_END) { g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_END; } break; case MENUOP_GETSELECTEDINDEX: if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) { - data->dropdown.value = 2; + data->dropdown.value = AUTORANDOM_END; } else if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) { - data->dropdown.value = 1; + data->dropdown.value = AUTORANDOM_START; } else { - data->dropdown.value = 0; + data->dropdown.value = AUTORANDOM_OFF; } break; } diff --git a/src/include/constants.h b/src/include/constants.h index 70c0384d4..733484616 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3804,6 +3804,10 @@ #define SLOWMOTION_ON 1 #define SLOWMOTION_SMART 2 +#define AUTORANDOM_OFF 0 +#define AUTORANDOM_START 1 +#define AUTORANDOM_END 2 + #define SMOKETYPE_NONE 0 #define SMOKETYPE_ELECTRICAL 1 // Dr Caroll, mainframes in Infiltration bunker #define SMOKETYPE_MINI 2 // Phoenix, Laptop sentry From 7580ebcaf96e3b8bc00eac603cbda29f07977a70 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Tue, 26 Mar 2024 23:45:55 +0900 Subject: [PATCH 3/3] port: rename constants --- src/game/mplayer/setup.c | 10 +++++----- src/include/constants.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 94c422eb0..44834bbfb 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -1189,19 +1189,19 @@ MenuItemHandlerResult menuhandlerMpAutoRandomWeapon(s32 operation, struct menuit case MENUOP_SET: g_MpSetup.options &= ~(MPOPTION_AUTORANDOMWEAPON_START | MPOPTION_AUTORANDOMWEAPON_END); - if (data->dropdown.value == AUTORANDOM_START) { + if (data->dropdown.value == AUTORANDOMWEAPON_START) { g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_START; - } else if (data->dropdown.value == AUTORANDOM_END) { + } else if (data->dropdown.value == AUTORANDOMWEAPON_END) { g_MpSetup.options |= MPOPTION_AUTORANDOMWEAPON_END; } break; case MENUOP_GETSELECTEDINDEX: if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) { - data->dropdown.value = AUTORANDOM_END; + data->dropdown.value = AUTORANDOMWEAPON_END; } else if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) { - data->dropdown.value = AUTORANDOM_START; + data->dropdown.value = AUTORANDOMWEAPON_START; } else { - data->dropdown.value = AUTORANDOM_OFF; + data->dropdown.value = AUTORANDOMWEAPON_OFF; } break; } diff --git a/src/include/constants.h b/src/include/constants.h index 733484616..c94999b60 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3804,9 +3804,9 @@ #define SLOWMOTION_ON 1 #define SLOWMOTION_SMART 2 -#define AUTORANDOM_OFF 0 -#define AUTORANDOM_START 1 -#define AUTORANDOM_END 2 +#define AUTORANDOMWEAPON_OFF 0 +#define AUTORANDOMWEAPON_START 1 +#define AUTORANDOMWEAPON_END 2 #define SMOKETYPE_NONE 0 #define SMOKETYPE_ELECTRICAL 1 // Dr Caroll, mainframes in Infiltration bunker