[Tasks] Avoid removing client tasks from memory on load #4052
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a task was deleted or had new elements added to it without updating character states to match changes, client state for the task was not loaded into memory and a "contact a GM" warning was sent to the client.
This caused an issue if a client later accepted a new task because it could be placed in the same client state slot as a non-loaded task. The table does not have constraints so this was also inserted into the db.
The next time client task state was reloaded after zoning, the new task would not be loaded since it occupied a used slot, even though that used slot was also not being loaded. The client could not remove or reacquire the original task without GM intervention and an entry was left in the db for the new task.
This makes the following changes to client task state loading:
If a task id no longer exists it is deleted from client state tables instead of only being removed from memory.
If a task occupies the same client state slot as another task, it is deleted from client state tables instead of being ignored.
If new elements have been added to a task, client state will keep the task in memory. The new activity states will be inserted into the db when necessary for updates (may not be immediate).
These changes also fix two smaller bugs as a consequence:
If a character was at the 20 quest limit the last quest wasn't being processed for activity count changes. The task would continue to show to clients but any added new elements couldn't be completed.
Deleted tasks that occupied slot 0 in client state would fallback to loading it as a solo task of type 0. This prevented a client's real solo task from being loaded if the deleted task was processed first.
Note clients may receive or lose credit for completed elements if new ones are added in the middle of tasks. Server ops will still need to update character state tables manually on task changes to prevent this.