From 3bd807506353b3b09ea56a92d5d958dfa4a55a9b Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Thu, 19 Dec 2024 21:59:01 -0800 Subject: [PATCH] Register `Handicap` profile config entry --- src/game/challenge.c | 2 +- src/game/chraction.c | 6 +++--- src/game/menutick.c | 2 +- src/game/mplayer/mplayer.c | 8 ++++++-- src/game/mplayer/setup.c | 8 ++++---- src/include/types.h | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/game/challenge.c b/src/game/challenge.c index ca809ca99..b5a39e2c8 100644 --- a/src/game/challenge.c +++ b/src/game/challenge.c @@ -244,7 +244,7 @@ void challengePerformSanityChecks(void) // Reset player handicaps for (i = 0; i < MAX_PLAYERS; i++) { if (g_MpSetup.chrslots & (1 << i)) { - g_PlayerConfigsArray[i].handicap = 0x80; + *g_PlayerConfigsArray[i].handicap = 0x80; numplayers++; } } diff --git a/src/game/chraction.c b/src/game/chraction.c index 1ea0b8b72..988f5e1cc 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -4549,9 +4549,9 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse if (g_Vars.normmplayerisrunning) { #if VERSION >= VERSION_PAL_FINAL // Fixing a @bug? - damage = damage * mpHandicapToDamageScale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); + damage = damage * mpHandicapToDamageScale(*g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); #else - damage /= mpHandicapToDamageScale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); + damage /= mpHandicapToDamageScale(*g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); #endif } @@ -4756,7 +4756,7 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse setCurrentPlayerNum(playermgrGetPlayerNumByProp(vprop)); if (g_Vars.normmplayerisrunning) { - damage /= mpHandicapToDamageScale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); + damage /= mpHandicapToDamageScale(*g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); } if (g_Vars.currentplayer->isdead == false && !g_PlayerInvincible) { diff --git a/src/game/menutick.c b/src/game/menutick.c index 5a795da9d..ad0521c29 100644 --- a/src/game/menutick.c +++ b/src/game/menutick.c @@ -360,7 +360,7 @@ void menuTick(void) } if (canjoin && (buttons & START_BUTTON)) { - g_PlayerConfigsArray[i].handicap = 128; + // g_PlayerConfigsArray[i].handicap = 128; if (g_Vars.mpsetupmenu == MPSETUPMENU_GENERAL) { // Joining from a general area such as the Combat diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 8e7c8572c..10f8f75e5 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -183,7 +183,13 @@ struct extprofileproperty { void (*initfunc)(s32, s32); }; +static void mpExtendedProfileInitHandicap(s32 profileindex, s32 playernum) +{ + g_PlayerConfigsArray[playernum].handicap = &g_ExtendedProfiles[profileindex].handicap; +} + struct extprofileproperty g_ExtendedProfileProperties[] = { + { CFG_U8, "Handicap", 0x80, 0, 255, &mpExtendedProfileInitHandicap}, }; // these must be in the same order as the extendedprofile struct, ignoring the fileguid static inline s32 getExtendedProfileIndexFromFileGuid(const struct fileguid* fileguid) @@ -632,7 +638,6 @@ void mpPlayerSetDefaults(s32 playernum, bool autonames) | OPTION_SHOWZOOMRANGE; updateNewGuids(autonames); - g_PlayerConfigsArray[playernum].handicap = 128; switch (playernum) { case 0: @@ -3877,7 +3882,6 @@ s32 mpplayerfileLoad(s32 playernum, s32 device, s32 fileid, u16 deviceserial) updateExtendedMpProfileOnFileOperation(playernum); - g_PlayerConfigsArray[playernum].handicap = 0x80; return 0; } diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 380c1b283..d7ab04cba 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -2341,13 +2341,13 @@ MenuItemHandlerResult menuhandlerMpHandicapPlayer(s32 operation, struct menuitem } break; case MENUOP_GETSLIDER: - data->slider.value = g_PlayerConfigsArray[item->param].handicap; + data->slider.value = *g_PlayerConfigsArray[item->param].handicap; break; case MENUOP_SET: - g_PlayerConfigsArray[item->param].handicap = (u16)data->slider.value; + *g_PlayerConfigsArray[item->param].handicap = (u16)data->slider.value; break; case MENUOP_GETSLIDERLABEL: - sprintf(data->slider.label, "%s%s%.00f%%\n", "", "", mpHandicapToDamageScale(g_PlayerConfigsArray[item->param].handicap) * 100); + sprintf(data->slider.label, "%s%s%.00f%%\n", "", "", mpHandicapToDamageScale(*g_PlayerConfigsArray[item->param].handicap) * 100); break; } @@ -2369,7 +2369,7 @@ MenuItemHandlerResult menuhandlerMpRestoreHandicapDefaults(s32 operation, struct s32 i; for (i = 0; i < MAX_PLAYERS; i++) { - g_PlayerConfigsArray[i].handicap = 0x80; + if (g_PlayerConfigsArray[i].handicap) *g_PlayerConfigsArray[i].handicap = 0x80; } } diff --git a/src/include/types.h b/src/include/types.h index 58934c240..b06be1f45 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4050,7 +4050,7 @@ struct mpplayerconfig { /*0x95*/ u8 title; /*0x96*/ u8 newtitle; /*0x97*/ u8 gunfuncs[6]; - /*0x9d*/ u8 handicap; + /*0x9d*/ u8* handicap; s32 configindex; };