magefree / magefree/mage

Network: some user commands must be synced (GameController->sendPlayerAction, related to ConcurrentModificationException)

Open
#11,460 2 comments 0 reactions 1 assignee Claimed by @JayDi85 View on GitHub
bug refactoring server
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

From #11458 and #11437, related to random `ConcurrentModificationException` errors and other random bugs (e.g. with undo/rollback usage).

Original problem:
* game executes by one thread (GAME xxx) but almost all user commands executes by another thread (CALL xxx) at random time. So if command thread changes game data (example: undo/rollback) then it can broke game in random time (user can call it in the middle of the slow game calculation and raise `ConcurrentModificationException`).

Recommended fixes:
* move game changes commands to GAME thread (example: undo) -- need sync code, see `asyncWantConcede` and `asyncWantCheat`. Maybe needs more easy sync code (there are too much client commands);
* keep other commands in original thread (example: updates of user skip settings -- it keep data inside game object, but it's hard to catch concurrent modification with it unlike the game changes from a previous point);

![shot_231124_215707](https://github.com/magefree/mage/assets/8344157/80afa086-943b-4dbe-96a0-cb2f89499276)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.