ngld / OverlayPlugin

Yet another OverlayPlugin fork.
Other
231 stars 39 forks source link

PartyChanged event desync issues when players disconnect and reconnect #261

Open valarnin opened 2 years ago

valarnin commented 2 years ago

Description

In a given instance, if a player disconnects and reconnects, the PartyChanged event either doesn't fire or doesn't have the reconnected player's details, causing raidboss trigger data.party.details object no longer knows about them.

Additional information

I use the following helper function for custom triggers:

const getRole = (data, targetId) => {
  const detail = data.party.details.find(d => d.id === targetId);
  const job = Util.jobEnumToJob(detail.job);
  return Util.jobToRole(job);
};

This is being used in the following trigger:

    {
      id: 'Custom - P4S Curtain Call Callouts',
      // Durations could be 12s, 22s, 32s, and 42s
      type: 'GainsEffect',
      netRegex: NetRegexes.gainsEffect({ effectId: 'AF4', capture: true }),
      condition: (data) => data.act === 'curtain' && ['Some Main', 'Some Alt'].includes(data.me),
      delaySeconds: (data, matches) => parseFloat(matches.duration) - (getRole(data, matches.targetId) === 'dps' ? 12 : 7),
      alertText: (_data, matches) => matches.target,
    }

This results in the following error stack when that trigger fires for the given player after they've disconnected and reconnected (trimmed irrelevant lines):

[2022-04-26 23:29:06] Info: cactbot2: BrowserConsole: Error in trigger: Custom - P4S Curtain Call Callouts (C:\Stuff\Games\ACT\Plugins\cactbot-0.23.10\cactbot\user\raidboss\custom-p4s.js) (Source: http://localhost:8080/ui/raidboss/raidboss.bundle.js, Line: 14512)
[2022-04-26 23:29:06] Info: cactbot2: BrowserConsole: TypeError: Cannot read properties of undefined (reading 'job') (Source: http://localhost:8080/ui/raidboss/raidboss.bundle.js, Line: 14519)
[2022-04-26 23:29:06] Info: cactbot2: BrowserConsole:     at getRole (C:\Stuff\Games\ACT\Plugins\cactbot-0.23.10\cactbot\user\raidboss\custom-p4s.js:26:40) (Source: http://localhost:8080/ui/raidboss/raidboss.bundle.js, Line: 14519)

Possibly related to #151.

Relevant Cactbot code segments:

https://github.com/quisquous/cactbot/blob/ed9b3b912a3107f3481cc5d92fa9b81349c68f5a/ui/raidboss/popup-text.ts#L519-L521

https://github.com/quisquous/cactbot/blob/ed9b3b912a3107f3481cc5d92fa9b81349c68f5a/resources/party.ts#L28-L48