Skip to content

Sort Button#3184

Closed
Crepestrom wants to merge 6 commits into
PixelGuys:masterfrom
Crepestrom:Sort-Inventory-Button
Closed

Sort Button#3184
Crepestrom wants to merge 6 commits into
PixelGuys:masterfrom
Crepestrom:Sort-Inventory-Button

Conversation

@Crepestrom

@Crepestrom Crepestrom commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Sorts items in your inventory

Currently only compresses items in inventory but that will be changed

@Wunka Wunka moved this to WIP/not ready for review in PRs to review Jun 7, 2026

@Wunka Wunka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok after looking at your code again. I really think that this should be clientside where your swaps are then just DepositOrSwap (your move too).

Also I think this code should have comments explaining what you are exactly doing.
If I understand correcltly you first do compress (making for example 1 Slate, 1 Slate into 2 Slate. Then you sort first the ProcduralTools by: moving them to the start and then sorting them. Then you are doing the same for baseItems.

I also think that you don't need to sort this yourself.
For example if you look at https://ziglang.org/documentation/0.16.0/std/#std.sort.insertion you can define your own context struct with a lessThan and a swap method and zig will do the rest.
so something like:

const Context = struct {
        inventory: Inventory,

        pub fn lessThan(ctx: @This(), a: usize, b: usize) bool {
            // bla bla bla
        }

        pub fn swap(ctx: @This(), a: usize, b: usize) void {
            // use depositOrSwap to swap
        }
    };

and then you can just run std.sort.(whateEverAlgorithm which doens't use memory)Context(...)
It doesn't do compress for you so you would still need to do this but else this would make your code much better

@Crepestrom Crepestrom closed this Jun 8, 2026
@Crepestrom

Copy link
Copy Markdown
Contributor Author

closed due to a new pr with better changes #3194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants