Skip to content

Commit

Permalink
Fix char swap crash (closes #1774)
Browse files Browse the repository at this point in the history
  • Loading branch information
LordMonoxide committed Dec 6, 2024
1 parent 03a4746 commit 12d3fa3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/main/java/legend/game/inventory/screens/CharSwapScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected InputPropagation mouseMove(final int x, final int y) {

if(this.loadingStage == 2) {
for(int i = 0; i < 3; i++) {
if((CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || (gameState_800babc8.charData_32c[gameState_800babc8.charIds_88[i]].partyFlags_04 & 0x20) == 0) && this.primaryCharIndex != i && MathHelper.inBox(x, y, 8, this.getSlotY(i), 174, 65)) {
if((CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || gameState_800babc8.charIds_88[i] != -1 && (gameState_800babc8.charData_32c[gameState_800babc8.charIds_88[i]].partyFlags_04 & 0x20) == 0) && this.primaryCharIndex != i && MathHelper.inBox(x, y, 8, this.getSlotY(i), 174, 65)) {
playMenuSound(1);
this.primaryCharIndex = i;
this.primaryCharHighlight.y_44 = this.getSlotY(i);
Expand Down Expand Up @@ -179,16 +179,20 @@ protected InputPropagation mouseClick(final int x, final int y, final int button
if(this.loadingStage == 2) {
for(int i = 0; i < 3; i++) {
if(MathHelper.inBox(x, y, 8, this.getSlotY(i), 174, 65)) {
playMenuSound(2);
this.primaryCharIndex = i;
this.primaryCharHighlight.y_44 = this.getSlotY(i);

final int charIndex = gameState_800babc8.charIds_88[this.primaryCharIndex];
if(CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || charIndex == -1 || (gameState_800babc8.charData_32c[charIndex].partyFlags_04 & 0x20) == 0) {
if(gameState_800babc8.charIds_88[i] != -1) {
playMenuSound(2);
this.secondaryCharHighlight = allocateUiElement(0x80, 0x80, this.getSecondaryCharX(this.secondaryCharIndex), this.getSecondaryCharY(this.secondaryCharIndex));
FUN_80104b60(this.secondaryCharHighlight);
this.loadingStage = 3;
this.primaryCharIndex = i;
this.primaryCharHighlight.y_44 = this.getSlotY(i);

final int charIndex = gameState_800babc8.charIds_88[this.primaryCharIndex];
if(CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || charIndex == -1 || (gameState_800babc8.charData_32c[charIndex].partyFlags_04 & 0x20) == 0) {
playMenuSound(2);
this.secondaryCharHighlight = allocateUiElement(0x80, 0x80, this.getSecondaryCharX(this.secondaryCharIndex), this.getSecondaryCharY(this.secondaryCharIndex));
FUN_80104b60(this.secondaryCharHighlight);
this.loadingStage = 3;
} else {
playMenuSound(40);
}
} else {
playMenuSound(40);
}
Expand Down Expand Up @@ -256,7 +260,7 @@ private void menuStage2NavigateDown() {

private void menuStage2Select() {
final int charIndex = gameState_800babc8.charIds_88[this.primaryCharIndex];
if(CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || charIndex == -1 || (gameState_800babc8.charData_32c[charIndex].partyFlags_04 & 0x20) == 0) {
if(charIndex != -1 && (CONFIG.getConfig(CoreMod.UNLOCK_PARTY_CONFIG.get()) || (gameState_800babc8.charData_32c[charIndex].partyFlags_04 & 0x20) == 0)) {
playMenuSound(2);
this.secondaryCharHighlight = allocateUiElement(0x80, 0x80, this.getSecondaryCharX(this.secondaryCharIndex), this.getSecondaryCharY(this.secondaryCharIndex));
FUN_80104b60(this.secondaryCharHighlight);
Expand Down

0 comments on commit 12d3fa3

Please sign in to comment.