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

Sort books in read menu #34266

Merged
merged 3 commits into from Sep 28, 2019
Merged

Sort books in read menu #34266

merged 3 commits into from Sep 28, 2019

Conversation

OzoneH3
Copy link
Member

@OzoneH3 OzoneH3 commented Sep 27, 2019

Summary

SUMMARY: Interface "Sort books in read menu"

Purpose of change

Fixes #33555

Additional context

if( !book_a.skill && !book_b.skill ) {
return ( book_a.fun == book_b.fun ) ? base_sort : book_a.fun > book_b.fun;
} else if( !book_a.skill || !book_a.skill ) {
return book_a.skill ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return book_a.skill ? true : false;
return book_a.skill.has_value();

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, doesn't have has_value() which seems to be a cata::optional thing but i get back a string_id<>.

Possible alternatives:
!book_a.skill.is_null()
!!book_a.skill

Copy link
Contributor

Choose a reason for hiding this comment

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

Stupid null ids. Use !book_a.skill.is_null() in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

I settled for static_cast() which uses the skill_id operator just in case.

src/game_inventory.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. labels Sep 27, 2019
src/game_inventory.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg merged commit 8d33113 into CleverRaven:master Sep 28, 2019
@OzoneH3 OzoneH3 deleted the read_sort branch October 9, 2019 08:14

if( !book_a.skill && !book_b.skill ) {
return ( book_a.fun == book_b.fun ) ? base_sort : book_a.fun > book_b.fun;
} else if( !book_a.skill || !book_a.skill ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't there an error?

Suggested change
} else if( !book_a.skill || !book_a.skill ) {
} else if( !book_a.skill || !book_b.skill ) {

@OzoneH3 OzoneH3 mentioned this pull request Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read Menu Auto-Sort
3 participants