-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
optimize sorting loot activity #79229
Conversation
If this commit is applied it will prevent PC running to sorted zones. It was made because PC was running across the map when there was not items to move
bool unload_corpses = false; | ||
|
||
std::vector<zone_data const *> const zones = mgr.get_zones_at( src, zone_type_UNLOAD_ALL, | ||
_fac_id( you ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
_fac_id( you ) ); | |
_fac_id( you ) ); |
for( zone_data const *zone : zones ) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
for( zone_data const *zone : zones ) | |
{ | |
for( zone_data const *zone : zones ) { |
if( vp ) | ||
{ | ||
for( const item& it : vp->items() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
if( vp ) | |
{ | |
for( const item& it : vp->items() ) { | |
if( vp ) { | |
for( const item &it : vp->items() ) { |
} else | ||
{ | ||
for( const item& it : here.i_at( src_loc ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
} else | |
{ | |
for( const item& it : here.i_at( src_loc ) ) { | |
} else { | |
for( const item &it : here.i_at( src_loc ) ) { |
for( const item * it : items ) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
for( const item * it : items ) | |
{ | |
for( const item *it : items ) { |
if( !has_items_to_work_on ) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JSON & C++ formatters] reported by reviewdog 🐶
if( !has_items_to_work_on ) | |
{ | |
if( !has_items_to_work_on ) { |
Why close? |
@Zireael07 I need to update master first |
If this commit is applied it will prevent PC running to sorted zones.
It was made because PC was running across the map when there was no items to move
Summary
Bugfixes "Sorting loot: stop player running to items that's not going to be moved"
Purpose of change
Player or NPC were travelling all across the map to unsorted loot zone with items that does not have a valid destination stockpile. This was annoying and time consuming. NPCs were perceived as being dumb
Describe the solution
The issue was there because we did not check in the "THINK" stage of activity if unsorted zone tile has any items that require action. I copied all the logic from the "DO" stage carefully to predict if we need to run to the source tile at all.
Describe alternatives you've considered
I thought about extracting the logic to separate function instead of mimicking it but it would require a full rewrite of the DO stage. And I'm not yet comfortable with tasks of this size.
Testing
I did the ./tests/cata_test and a lot of manual testing to prevent any regressions:
I checked cases with disabling source and target zones, stripping corpses, unloading containers, custom loot target zones, removing mods from a gun
Additional context
After this change NPC will think better about his destination and stop wasting his time running between stockpiles. This makes him 'smarter' for the player.