Skip to content

Commit

Permalink
Register Handicap profile config entry
Browse files Browse the repository at this point in the history
  • Loading branch information
cylonicboom committed Dec 20, 2024
1 parent a19b035 commit 3bd8075
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/game/challenge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/game/chraction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/game/menutick.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -632,7 +638,6 @@ void mpPlayerSetDefaults(s32 playernum, bool autonames)
| OPTION_SHOWZOOMRANGE;

updateNewGuids(autonames);
g_PlayerConfigsArray[playernum].handicap = 128;

switch (playernum) {
case 0:
Expand Down Expand Up @@ -3877,7 +3882,6 @@ s32 mpplayerfileLoad(s32 playernum, s32 device, s32 fileid, u16 deviceserial)

updateExtendedMpProfileOnFileOperation(playernum);

g_PlayerConfigsArray[playernum].handicap = 0x80;
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/game/mplayer/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4050,7 +4050,7 @@ struct mpplayerconfig {
/*0x95*/ u8 title;
/*0x96*/ u8 newtitle;
/*0x97*/ u8 gunfuncs[6];
/*0x9d*/ u8 handicap;
/*0x9d*/ u8* handicap;
s32 configindex;
};

Expand Down

0 comments on commit 3bd8075

Please sign in to comment.