mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 12:40:21 +02:00
Fix a crash releasing your own caught Pikachu in Yellow
BoxMenu.lua's release() pushes both its "Once released...OK?" prompt and its Yellow-only "Pikachu looks unhappy" message through TextBox.new(game, (t._X or Strings(...)):gsub(...)) -- gsub returns two values (the text and a substitution count), and since the gsub call is the last argument in the TextBox.new(...) call with nothing after it, Lua expands both into the call: the count lands in TextBox.new's third parameter, onDone. TextBox.lua later calls onDone() once the box is dismissed; a number is not callable, so every release of your own caught Pikachu in Yellow crashed -- regardless of its nickname (unlike the separate %-escape gsub bug, this one needs no special save content, ordinary play reaches it every time). Fixed by wrapping the gsub call in an extra pair of parens, which truncates it to its first return value only -- the same fix already applied to the neighboring _OnceReleasedText/_MonWasReleasedText lines on the (separate, unmerged) fix/route-more-messages-through-romtext branch, where this exact bug shape was first noticed while adding a third callsite with the same pattern. tests/engine/pikachu_unhappy_release_crash.lua: registers a fake Data.pokemon.PIKACHU cloned from the fixture species (ROM-free) so the species == "PIKACHU" check can be exercised, drives the real interactive release flow in Yellow on a mon owned by the player, and confirms the crash. Verified failing pre-fix (exact same "attempt to call field 'onDone' (a number value)" error) and passing post-fix.
This commit is contained in:
+2
-2
@@ -180,8 +180,8 @@ local function release(game)
|
||||
and mon.ot == game.save.player.name then
|
||||
require("src.core.Sound").playCry(game.data, mon.species)
|
||||
game.stack:push(TextBox.new(game,
|
||||
(t._PikachuUnhappyText or Strings("%s looks\nunhappy about it!", name))
|
||||
:gsub("{RAM:wNameBuffer}", name)))
|
||||
((t._PikachuUnhappyText or Strings("%s looks\nunhappy about it!", name))
|
||||
:gsub("{RAM:wNameBuffer}", name))))
|
||||
return
|
||||
end
|
||||
game.stack:push(TextBox.new(game,
|
||||
|
||||
Reference in New Issue
Block a user