Skip to content

fix(reducer): Fix stateID increment & build deltalog on server only#817

Merged
delucis merged 4 commits into
masterfrom
delucis/fix/795
Oct 7, 2020
Merged

fix(reducer): Fix stateID increment & build deltalog on server only#817
delucis merged 4 commits into
masterfrom
delucis/fix/795

Conversation

@delucis
Copy link
Copy Markdown
Member

@delucis delucis commented Oct 6, 2020

Fixes #795

The move reducer currently increments _stateID before events (and other plugins) are processed, potentially resulting in deltalogs as follows:

[
  { action: { type: 'MAKE_MOVE' }, _stateID: 2 },
  { action: { type: 'GAME_EVENT' }, _stateID: 3, automatic: true }
]

This was causing bugs on the client, because the next move might produce a deltalog like:

[
  { action: { type: 'MAKE_MOVE' }, _stateID: 3 }
]

This is filtered out by the client because the _stateID is considered stale.

This fix ensures that _stateID is only incremented after plugins run, so that log entries for a single action all share the same ID. For multiplayer clients, events aren’t run locally, so we can’t send an optimistic deltalog here, because the “automatic” events would now be filtered out, so instead, deltalog is now only produced on the master (for multiplayer clients).

@delucis delucis requested a review from nicolodavis October 6, 2020 16:22
@delucis delucis removed the request for review from nicolodavis October 7, 2020 18:06
@delucis delucis merged commit 197a9bb into master Oct 7, 2020
@delucis delucis deleted the delucis/fix/795 branch October 7, 2020 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The move executed after any end turn or phase move does not show in opponent logs.

1 participant