Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fixed "Auto-sort infinite loop/game hang #29573" (rebased) #33710

Closed

Conversation

ipcyborg
Copy link
Contributor

Summary

SUMMARY: Bugfixes "Auto-sort infinite loop/game hang #29573"

Purpose of change

Fixes #29573
Rebased from PR #32876

Describe the solution

The solution was adopted for new generic_multi_activity_handler.

The sorting loop was still reproducible even after this fix "Zone Sorting Loop #31895".
I have tried to rewrite activity_on_turn_move_loot with the idea of different sorting stages:

  1. Initial stage: determine all possible sources of items in the unsorted zones. Remember all sources in the player activity.
  2. Move player stage: search for the next appropriate source and start to move there.
  3. Move items stage: get all items from the source and move to appropriate destination.

Note that this algorithm relies completely on the activity instance and does not require any cache from zone_manager.
So in theory now it could be safely applied to multiple NPC & player in parallel.

Added save/load for coord_set in player_activity (required in generic handler and other places like fish_do_turn).

TODO: Test on the save provided in #29573.

Describe alternatives you've considered

I have tried to keep the original code intact as much as possible. But it would probably be better to use separate activities instead of stages for the same activity?

Additional context

This fix should improve performance of the sorting process.

Added save/load for "coord_set" in "player_activity".
@ghost
Copy link

ghost commented Aug 31, 2019

I've moved the activity_on_turn_move_loot() function out of generic_multi_activity_handler() , that was the fix, the fix was putting the loot sorting function back to the way it was previously.
If that still dosnt work - then please try and fix it within the activity_on_turn_move_loot() function, please dont try and bring it back into generic_multi_activity_handler(), ive still got PRs that are building upon that function and I've already had to do a massive rebase that took 4 hours to adapt them to ##33673

Most of these changes here seem unrelated to actually fixing the loot sorting loop, and instead are changing around the structure of the generic activity function again.

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones labels Aug 31, 2019
@ipcyborg
Copy link
Contributor Author

ipcyborg commented Sep 2, 2019

Most of these changes here seem unrelated to actually fixing the loot sorting loop, and instead are changing around the structure of the generic activity function again.

The purpose is still to fix the loop. Well, yes, it's got quite complex. I will rewrite the PR description to reflect it.

I will get the latest changes from master and re-apply this PR changes again, trying to minimize it as much as possible. The key changes are:

  1. Do not nuke player activity. It enables player to do sub-tasks and resume previous generic activities seamlessly.
  2. Use activity stages for optimization.
  3. Avoid loops: enumerate the list of point only once, remove bad points, etc.

@ipcyborg
Copy link
Contributor Author

Closing by PR #34024 and PR #33864.

@ipcyborg ipcyborg closed this Sep 14, 2019
@ipcyborg ipcyborg deleted the fix-29573-auto-sort-loop-v2 branch October 17, 2019 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-sort infinite loop/game hang
2 participants