codefaux / persistence

Add some Lite to your Rogue
MIT License
1 stars 0 forks source link

[BUG] Stashed money overflow #9

Open monbon234 opened 2 months ago

monbon234 commented 2 months ago

If too much money is stashed, upon respawn the stashed value will become extremely small (3 gold in my experience (I stashed all my money twice whilst at the max value so thats how high it was, probably important info to include))

codefaux commented 1 month ago

I'll look into this. I have a few ideas, but the upcoming release will still suffer the same failure. I have an idea how to work around it. I'll leave this open until I resolve it. Overflows, especially with money, might be a recurring theme..

monbon234 commented 1 month ago

would it be possible to change all deposit options to only allow up to 99% of the max gold value to be stashed, preventing overflows?

codefaux commented 1 month ago

The resulting value would still increase, which would overflow. An overflow is any time you're trying to store a number bigger than the maximum a number can be in a given space. I have an idea how to work around it, though.

monbon234 commented 1 month ago

I meant a way for the actual options to change their deposit values eg if overflow was 1000 when the player clicks stash, calculate the safe amount left to stash (lets say 10 less than overflow) then check to see if the value the player is attempting to stash is greater than that amount (in this case (1000-10)-stashedvalue) and if the value is greater than that amount, just overwrite the amount being stashed to the safe amount this way any attempt to stash more than is able to be stored, it would just end up adding 0 to the stashedvalue

codefaux commented 1 month ago

My intent is to deny transactions which would pass a certain limit. To avoid making it too easy to overflow the player, I've set limited the amount Persistence can give the player, and the amount it can put into a stash, separately.

The max amount a player can get from Persistence (stash, etc) is limited to well below the overflow amount, so that a player must work to overflow their money (infinite money)

The max amount a player can put into stash is limited to considerably higher, but still a wide margin away from the overflow limit, so if you have an excessively large stash amount when switching, it will not allow deposits until you withdraw enough.

If you need to fix your stash money due to the overflow, I can help you with that process.

codefaux commented 1 month ago

I've pushed v3 into the wild. Stash and player money should not overflow. Already-overflowed stashes will not resolve. Player or stash balance above transaction limits will deny deposit but allow withdraw, so players with "too much money" will see disabled buttons until they spend some. Closing this issue.

Reopen if the problem crops back up!