Skip to content

Conversation

@Architector4
Copy link
Contributor

This prevents AIs from messing up the inventory order whenever a player switches away from a unit while holding a tool or something.

This has been bugging me for months.

This prevents AIs from messing up the inventory order whenever a player switches away from a unit while holding a tool or something.

This has been bugging me for months.
@Architector4
Copy link
Contributor Author

...oh wait, there's also EquipNamedDevice that has the exact same code verbatim except for a different target it looks for. Just a minute, let me apply change to it too...

@Architector4
Copy link
Contributor Author

Decided to properly check after a bunker breach session....There are 5 more times code like this is duplicated in this file. aAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

@Architector4
Copy link
Contributor Author

...oh hold on there's now a crash when GetMass() enumerates mass of inventory items oops, lemme fix lmao

Forgot to put this down in the various places oops lmao
@Architector4
Copy link
Contributor Author

I needed to just, record a video showing the inventory staying consistent despite the AI switching the inventory multiple times and equipping shields and stuff. The relief that I can just switch from a character in the middle of digging a tunnel to check up on another one, then come back and have the inventory ordered exactly as it was, is palpable.

wasd.mp4

@Architector4 Architector4 changed the title Preserve inventory order in AHuman::EquipFirearm Preserve inventory order when AI switches weapons Oct 20, 2025
Causeless
Causeless previously approved these changes Oct 23, 2025
Copy link
Contributor

@Causeless Causeless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Causeless Causeless enabled auto-merge October 23, 2025 21:55
@Architector4
Copy link
Contributor Author

WAIT DON'T MERGE YET, i just discovered one more slight issue here 😭😭😭😭😭😭😭

The new code, when it finds an item at itr, it stores the old one into inventory, potentially causing a reallocation that invalidates itr, then uses itr for the rotation.

Suboptimal! Had this crash exactly once a few days ago and couldn't find the issue until now lol

Gimme a few minutes to figure out and push a fix.

auto-merge was automatically disabled October 24, 2025 15:51

Head branch was pushed to by a user without write access

@Architector4
Copy link
Contributor Author

all good now 👍

@Firepal
Copy link

Firepal commented Oct 24, 2025

*stares in awe and incomprehension at the scary C pointer magics*
:trollface: LGTM :trollface:

@Causeless Causeless merged commit 07bb70b into cortex-command-community:development Oct 28, 2025
@Causeless
Copy link
Contributor

@Architector4 Are you on the Discord by any chance? Really nice to see your contributions!

@Architector4
Copy link
Contributor Author

@Architector4 Are you on the Discord by any chance? Really nice to see your contributions!

I do have Discord, but I'm not active there at all. I do have a Telegram though that I'm active on lol

https://t.me/Architector_4

@Architector4 Architector4 deleted the patch-2 branch October 29, 2025 01:10
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.

3 participants