A hint added on top of another hint can cause the whole queued hint system to stop working

Issue #443 resolved
Matt Hands created an issue

The problem is when a hint is added to the queue with the bForceNext option, meaning it is pushed to the front of the hint queue. Most hints use that option.

If that happens while another hint is on screen, or during the post hint 'standstill' 10 second period (a pause before displaying any other queued hint), the queued hint system failed.

The problem is caused because the current/recent hint is still in the queue system at that point, in the index 0 array slot. When the new bForceNext hint gets added, it is inserted as a new index 0. Then when the old hint gets cleared, index 0 is deleted from the array, but instead of the old hint being deleted, the intended new hints is removed. The array gets scrambled and the system fails.

Comments (1)

  1. Matt Hands reporter

    Fixed as part of commit 8d5f3e9.

    When adding a hint using bForceNext, I've added a check whether a hint is already being displayed or was recently displayed (meaning it will still be at the front of the queue). If so, we simply insert the new hint in array index 1 instead 1 index 0, so it comes up next.

        // bForceNext means our new hint needs to go to the front of the queue
        if (bForceNext)
        {
            // If already displaying a hint, or in the PostHintDisplayDelay period immediately after, then insert our new hint as next one due after current/recent hint (index 1)
            if (IsInState('DisplayingHint') || IsInState('PostDisplay'))
            {
                QueuedHintIndices.Insert(1, 1);
                QueuedHintIndices[1] = HintIndex;
            }
            // Otherwise insert our new hint at the front of the queue (index 0)
            else
            {
                QueuedHintIndices.Insert(0, 1);
                QueuedHintIndices[0] = HintIndex;
            }
        }
    
  2. Log in to comment