From 5165a828a5f322c00ab25c11d22db328dff9385f Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Fri, 21 Jul 2023 11:25:08 -0400 Subject: [PATCH] [jak2] Fix overlord related crash (#2834) This fixes the crash reported in https://github.com/open-goal/jak-project/issues/2833 There was a memory bug here for a long time where our array of `VagCmd` in `iso_queue.cpp` was too small. This caused GetVagCommand to return bogus pointers, and sound code would write over other parts of memory. --- game/overlord/jak2/iso_queue.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/game/overlord/jak2/iso_queue.cpp b/game/overlord/jak2/iso_queue.cpp index 76cd212672..47d04f0096 100644 --- a/game/overlord/jak2/iso_queue.cpp +++ b/game/overlord/jak2/iso_queue.cpp @@ -33,8 +33,12 @@ u32 NextBuffer = 0; u32 AllocdStrBuffersCount = 0; u32 NextStrBuffer = 0; int sSema = 0; + +// note that these are different vag commands from the VagCmds array. +// These are used for the return values of GetVagCommand, and are used for queued commands. +// The VagCmds array is used for commands that are actually running. u32 vag_cmd_cnt = 0; -VagCmd vag_cmds[N_VAG_CMDS]; +VagCmd vag_cmds[32]; u32 vag_cmd_used = 0; u32 max_vag_cmd_cnt = 0;