Skip to content

implement inventory sorting by item type - #8630

Open
romanstingler wants to merge 1 commit into
diasurgical:masterfrom
romanstingler:feature/sort-inventory-by-itemtype
Open

implement inventory sorting by item type#8630
romanstingler wants to merge 1 commit into
diasurgical:masterfrom
romanstingler:feature/sort-inventory-by-itemtype

Conversation

@romanstingler

@romanstingler romanstingler commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Introduce a new sorting mechanism for the player inventory that groups
items by their type (e.g., gold, misc, weapons, armor) before sorting by
size. This improves visual organization by ensuring similar items are
placed together.

Unsorted
image
Current Sort
image
New Sort
image

PS:
Running clang-format -i introduced that change because the WebKit base style sets SpaceBeforeCpp11BracedList: true, which gives return { };

Used std::ranges::*

PS2: I Will have a look at the failed stuff

The WebKit style guide is explicit:

"Any empty braces should contain a space."
https://webkit.org/code-style-guidelines/#empty-braces-space

So return { }; (with space) is the correct form, and return {}; (no space) is the wrong one for the WebKit preset. clang-format 18 (currently pinned in CI) flips this and demands {}, which directly contradicts the guide.

This is a long-standing bug, tracked and fixed upstream:

Verified behaviour across versions

I ran a minimal reproducer (echo "int main() { return {}; }") through clang-format -style=webkit for every version that has a published Docker image:

clang-format Output for return {}; Matches WebKit guide?
18 return {}; X
19 return {}; X
20 return {}; X
21 return {}; X
22 return { }; Y

Reproduced with the official ghcr.io/jidicula/clang-format:<v> images (project default) and also locally against the v18 and v20 binaries installed on a CachyOS/Arch system

furthermore, we should be more consistent and clear about what we want to have as minimum requirement.

CMakeLists.txt:336-337

set(CMAKE_CXX_STANDARD 23)

Which means CLANG 17 (15 started having partial support) \ GCC 13 (11 partial support)

.devcontainer/Dockerfile:1-2

ARG VARIANT=debian-12

Debian12 comes with clang-format 14 but supports up to clang-format-19
https://packages.debian.org/search?suite=bookworm&section=all&arch=any&searchon=names&keywords=clang-format

❯ docker run --rm devilutionx-devcontainer bash -c 'echo "gcc:      $(gcc --version | head -1)"; echo "g++:      $(g++ --version | head -1)"; echo "clang:    $(clang --version 2>/dev/null | head -1 || echo NOT INSTALLED)"; echo "clang++:  $(clang++ --version 2>/dev/null | head -1 || echo NOT INSTALLED)"; echo "clang-format: $(clang-format --version | head -1)"; echo "clang-tidy:   $(clang-tidy --version | head -1)"; echo "cmake:    $(cmake --version | head -1)"'
gcc:      gcc (Debian 12.2.0-14+deb12u1) 12.2.0
g++:      g++ (Debian 12.2.0-14+deb12u1) 12.2.0
clang:    
clang++:  
clang-format: Debian clang-format version 14.0.6
clang-tidy:   Debian LLVM version 14.0.6
cmake:    cmake version 3.25.1

Another discrepancy is the Amiga container image tag says gcc10 but CMake reports GNU 13.2.0.

@glebm

glebm commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Don't worry about Xbox and PS4 builds, we're disabling them soon.

@romanstingler
romanstingler force-pushed the feature/sort-inventory-by-itemtype branch from 04dc796 to cb08830 Compare July 17, 2026 14:53
@romanstingler

Copy link
Copy Markdown
Contributor Author

Don't worry about Xbox and PS4 builds, we're disabling them soon.

Ahh thanks, I just spent some time checking regarding PS4 because it has Clang12
but there is a llvm18 toolchain ... so I was not sure.

Workflow Compiler / toolchain Version
Linux x86_64 (x86_64-linux-gnu) GCC g++ (ubuntu-24.04) 13.3.0 (inferred)
Linux x86 (i386-linux-gnu) GCC g++-13-multilib 13.3.0
Linux AArch64 (aarch64-linux-gnu) GCC (aarch64 cross) 13.3.0 (exact)
Linux x64 Tests GCC g++ (ubuntu-24.04) 13.3.0 (inferred)
Linux x64 SDL3 Tests GCC g++ (ubuntu-24.04) 13.3.0 (inferred)
Linux x64 SDL1 GCC g++ (ubuntu-24.04) 13.3.0 (inferred)
Windows MSVC x64 MSVC (VS 2026, vcpkg) 19.44.35228.0 (exact)
Windows MinGW x64 MinGW-w64 GCC (apt) 13.0.0 (CMake) / 13.2.0 (apt base)
Windows MinGW x86 MinGW-w64 GCC (apt) 13.0.0 (CMake) / 13.2.0 (apt base)
Windows XP MinGW MinGW-w64 GCC (custom cached) 16.1.0 (exact)
Windows 9x MinGW MinGW-w64 GCC (custom cached) 16.1.0 (exact)
macOS arm64 AppleClang (macos-14-arm64) *inferred, not printed
macOS x86_64 AppleClang (macos-15) 17.0.0.17000013 (exact)
iOS Apple clang (Xcode 15.4) Xcode 15.4 (clang ver. inferred)
Android Clang (NDK r29) NDK 29.0.14206865 (clang ver. inferred)
Nintendo Switch GCC — devkitA64 (devkitpro/devkita64) 15.2.0 (exact)
Nintendo 3DS GCC — devkitARM (devkitpro/devkitarm) 16.1.0 (exact)
Sony PlayStation Vita GCC — vitasdk (vitasdk/vitasdk) 15.2.0 (exact)
Amiga M68K GCC — m68k-amigaos (amigadev/crosstools) 13.2.0 (exact)
PS4 Clang — OpenOrbis SDK (pacbrew) 12.0.1 (exact)
PS5 (ps5-payload-dev) Clang — prospero-clang (SDK v0.27) 18.1.3 (exact)
Xbox (original Xbox, nxdk) Clang — nxdk nxdk-cc 18.1.3 (exact)
Xbox One / Series MSVC (Microsoft GDK, VS 2026) 19.51.36248.0 (exact)
clang-format check clang-format (ghcr.io/jidicula/clang-format:18) 18.1.8 (exact)
clang-tidy check clang-tidy (cpp-linter, LLVM apt -20) 20.1.2 (exact)

The rest is partially-full C++23 compat, so I guess we are fine without PS4

@glebm

glebm commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

The C++23 PR has been merged, so you should get better results once you've rebased. And yeah currently it's not full C++23 but rather ~GCC13.

We can go to GCC14 once it is available for Amiga (this would get us std::generator).

@romanstingler

Copy link
Copy Markdown
Contributor Author

Nice thanks, but I think for now everything works fine

@romanstingler
romanstingler force-pushed the feature/sort-inventory-by-itemtype branch from cb08830 to ded0d22 Compare July 25, 2026 20:13
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.

2 participants