Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Hunger display is broken again

Open KHeket opened this issue 1 year ago • 2 comments

Describe the bug

@RenechCDDA in #74318 fixed food warning, but this cause the display of your hunger to be broken Before this update, when you are full, you will have the next display image So you understand, that your character is full But after #74318 was merged we have next display image And you go from "satisfied" to "engorged" image

Attach save file

N/A

Steps to reproduce

Download https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2024-06-15-1417 Start game Spawn apples Eat and see hunger display working good

Download https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2024-06-15-1717 or the latest experimental https://github.com/CleverRaven/Cataclysm-DDA/releases/tag/cdda-experimental-2024-07-22-0629 (I tested both) Start game Spawn apples Eat and see hunger display does not working good

Expected behavior

Hunger display working right

Screenshots

No response

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.4651 (22H2)
  • Game Version: cdda-experimental-2024-07-22-0629 ee4058b [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [ Dark Days Ahead [dda], Disable NPC Needs [no_npc_food], Portal Storms Ignore NPCs [personal_portal_storms], Slowdown Fungal Growth [no_fungal_growth] ]

Additional context

No response

KHeket avatar Jul 22 '24 16:07 KHeket

Can confirm same behaviour, traceable to same change/experimental.

qtquazar avatar Jul 28 '24 19:07 qtquazar

@RenechCDDA can you check pls? I pinged you a several times, but dont have any respond

KHeket avatar Oct 06 '24 11:10 KHeket

@RenechCDDA can you answer something? Because the thing was worked fine before changes in your pr, and I pinged you several times in this pr, but have no answer

KHeket avatar Dec 26 '24 22:12 KHeket

I assume the error is in this line: https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L344

It should be:

--  return ( calorie_deficit && fullness_ratio >= 11.0 / 20.0 ) || ( fullness_ratio >= 3.0 / 4.0 );
++  return ( calorie_deficit && fullness_ratio >= 3.0 / 4.0 ) || ( fullness_ratio >= 11.0 / 20.0 );

The second possible candidate:

  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/character_body.cpp#L1050
  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/character_body.cpp#L1052
  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/character_body.cpp#L1075
  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/character_body.cpp#L1077

The second argument of these functions must have a value:

  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L333-L334
  • https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L340-L341

If I understand correctly, this is the volume of what you want to eat. Because then it is added to what you have already eaten and compared to the capacity. And with us, it's always 0ml.

P.S. I don't understand the point of replacing if-then with functions that do the same thing.

IdleSol avatar Dec 26 '24 23:12 IdleSol

And here's a third candidate for the problem.

Let's take a closer look at what these functions calculate: https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L337 If I understand it correctly, it is written like this:

( calorie_deficit AND fullness_ratio >= 1.0 ) OR ( fullness_ratio >= 5.0 / 6.0 )

But if fullness_ratio >= 5.0 / 6.0 is true, we no longer care what value it takes (calorie_deficit AND fullness_ratio >= 1.0).

But if it is false, then fullness_ratio < 5.0 / 6.0. And therefore less than 1. And the first condition will also be false.

And that brings us to the error in this part: https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/character_body.cpp#L1050-L1051

The effect_hunger_engorged should occur if calorie_deficit = true and fullness_ratio >= 1.0 (in the old version contains >= cap).

We get this effect when fullness_ratio >= 5.0 / 6.0

IdleSol avatar Dec 27 '24 00:12 IdleSol

I would suggest checking out a fix like this:

https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L337

--  return ( calorie_deficit && fullness_ratio >= 1.0 ) || ( fullness_ratio >= 5.0 / 6.0 );
++  return ( !calorie_deficit && fullness_ratio >= 5.0 / 6.0 ) || ( calorie_deficit && fullness_ratio >= 1.0 );

https://github.com/CleverRaven/Cataclysm-DDA/blob/8bd4c5d584e6fd06a4de00414d4214ed72f81487/src/stomach.cpp#L344

--  return ( calorie_deficit && fullness_ratio >= 11.0 / 20.0 ) || ( fullness_ratio >= 3.0 / 4.0 );
++  return ( !calorie_deficit && fullness_ratio >= 11.0 / 20.0 ) || ( calorie_deficit && fullness_ratio >= 3.0 / 4.0 ) ;

And it seems like it could be simplified to:

  return ( !calorie_deficit && fullness_ratio >= 5.0 / 6.0 ) || ( fullness_ratio >= 1.0 );
  return ( !calorie_deficit && fullness_ratio >= 11.0 / 20.0 ) || ( fullness_ratio >= 3.0 / 4.0 ) ;

IdleSol avatar Dec 27 '24 07:12 IdleSol

@RenechCDDA I apologize for the distraction. Is there an error in your code? https://github.com/CleverRaven/Cataclysm-DDA/issues/75162#issuecomment-2563415965

IdleSol avatar Jan 21 '25 19:01 IdleSol

@RenechCDDA I apologize for the distraction. Is there an error in your code? #75162 (comment)

If you've got the fix and you've tested it and it works a PR should be fine to put in.

Maleclypse avatar May 10 '25 16:05 Maleclypse

@KHeket

can you check pls? I pinged you a several times, but dont have any respond

Contributors are not "on call" to respond to issues. One ping is fine to request attention if you think the issue is of interest to that person, but repeated pings and demands for attention are not.

kevingranade avatar May 10 '25 17:05 kevingranade