Skip to content

Commit

Permalink
Fix the multiworld collect mode bug that maybe softlocked dragonc0
Browse files Browse the repository at this point in the history
Using a global var to set the collect mode of the next treasure that
spawns when receiving an item from another player probably caused a
chest item to use the wrong mode, which is very bad.
  • Loading branch information
jangler committed May 24, 2020
1 parent 7a968a5 commit 3fae7a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
13 changes: 5 additions & 8 deletions asm/collect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ common:
pop bc
ret
# return a spawning item's collection mode in a and e, based on current room,
# or based on the net collection mode if one is stored (and then clears it).
# return a spawning item's collection mode in a and e, based on current room.
# the table format is (group, room, mode), and modes 80+ are used to index a
# jump table for special cases. if no match is found, it returns the regular,
# non-overriden mode. this also handles network items.
# non-overriden mode. does nothing if the item's collect mode is already set.
06/lookupCollectMode_body: |
ld hl,wNetCollect
ld e,(hl)
xor a
ld (hl),a
ld a,e
ld e,71
ld a,(de)
ld e,a
and a
ret nz
ld a,(wActiveGroup)
Expand Down
1 change: 0 additions & 1 deletion asm/defines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ common:
define wMapMenu_cursorIndex,cbb6
define wInventorySubmenu1CursorPos,cbd1
define wRingMenu_mode,cbd3
define wNetCollect,cbfa
define wNetTreasureIn,cbfb
define wNetPlayerOut,cbfd
define wNetTreasureOut,cbfe
Expand Down
28 changes: 24 additions & 4 deletions asm/multi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ floating:
ret z
jp interactionCode60
# if var 71 is already nonzero, use that as the collect mode instead of
# whatever this is.
keepNonzeroCollectMode: |
ld e,71
ld a,(de)
and a
jr nz,.next
ld a,b
.next
ld b,a
swap a
and a,07
ld (de),a
ret
common:
00/multiPlayerNumber: db 00

Expand All @@ -118,8 +133,9 @@ common:
ret
# if the item buffer is nonzero, spawn the item at link and reset the buffer.
# var INTERAC_MULTI_BYTE is used to signal the destination player number.
# this manually upgrades feather to cape based on wFeatherLevel to avoid
# var INTERAC_MULTI_BYTE is used to signal the destination player number, and
# var 71 is set to override normal collect/player properties lookup. this
# manually upgrades feather to cape based on wFeatherLevel to avoid
# softlocking by receiving feather during hide and seek.
05/checkNetItemBuffer: |
push bc
Expand Down Expand Up @@ -158,10 +174,10 @@ common:
ld a,(multiPlayerNumber)
ld l,INTERAC_MULTI_BYTE
ld (hl),a
ld l,71
ld (hl),02
ld hl,wNetCountIn
inc (hl)
ld hl,wNetCollect
ld (hl),02
ld hl,wNetTreasureIn
xor a
ldi (hl),a
Expand Down Expand Up @@ -190,6 +206,8 @@ seasons:
15/subMultiworldText: /include subMultiworldText
15/getMultiworldItemDest: /include getMultiworldItemDest
15/setTextNumberSubstitution: /include setTextNumberSubstitution
15/keepNonzeroCollectMode: /include keepNonzeroCollectMode
15/465f/: call keepNonzeroCollectMode
15/466f/: call subMultiworldText

# don't set file to completed when saving after credits in multiworld
Expand Down Expand Up @@ -224,4 +242,6 @@ ages:
16/subMultiworldText: /include subMultiworldText
16/getMultiworldItemDest: /include getMultiworldItemDest
16/setTextNumberSubstitution: /include setTextNumberSubstitution
16/keepNonzeroCollectMode: /include keepNonzeroCollectMode
16/453e/: call keepNonzeroCollectMode
16/454e/: call subMultiworldText

0 comments on commit 3fae7a2

Please sign in to comment.