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

Now using size_t in item grids and accompanying classes #5478

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

12xx12
Copy link
Member

@12xx12 12xx12 commented Mar 21, 2023

Well that escalated quickly.

This PR takes over #4979. And changes cItemGrid completely to use std::size_t to index everything. Since -1 was used to indicate illegal slot stuff, the best alternative seems std::numeric_limits<std::size_t>::max()

bibo38 and others added 3 commits March 21, 2023 13:33
As STL-Containers want to use unsigned indexes it is better to migrate
everything to size_t in the long run to avoid static_cast's.
Signed integers may still be used for special indexes, which may have some
special values, e.g. -1 if no index was found. This has the benefit that the
compiler will throw an error, if somebody always valid indexes and indexes that
may have a special value, as both distinguish in the signedness.
@12xx12 12xx12 marked this pull request as draft March 21, 2023 20:33
@12xx12 12xx12 marked this pull request as ready for review March 26, 2023 14:28
@madmaxoft
Copy link
Member

This breaks plugins, as they expect -1 slot value in several cases.

@12xx12
Copy link
Member Author

12xx12 commented May 8, 2023

(╯°□°)╯︵ ┻━┻

@12xx12
Copy link
Member Author

12xx12 commented May 8, 2023

So, how do we deal with this?

  • Use a static cast where needed and keep using int.
  • Manually change the output of the API from the new constant
  • other?

@Janmm14
Copy link
Contributor

Janmm14 commented May 8, 2023

Why use size_t at all for slots when we know slot index will always fit into a single byte (or maybe into a short to be on the safe side).

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.

None yet

4 participants