UniEngine icon indicating copy to clipboard operation
UniEngine copied to clipboard

Resources recalculation does not apply negative income when storage is full

Open mdziekon opened this issue 4 years ago • 3 comments

Steps to reproduce

  1. Fill up deuterium storage
  2. Set deuterium production to 0% and deuterium consumption (reactor) to >0%

What should happen

  • Deuterium should slowly be drained from the storage

What actually happens

  • Deuterium is stuck at the full storage capacity amount

Regression tracking

Caused by (PR):

  • https://github.com/mdziekon/UniEngine/pull/56 (most likely offender)

Caused by (relevant code pieces):

https://github.com/mdziekon/UniEngine/blob/1cfbf0ec7cac5272e00a830caa035718cd9363ca/includes/helpers/planets/functions.php#L582-L587

mdziekon avatar Mar 20 '20 01:03 mdziekon

Hi, regarding the https://github.com/mdziekon/UniEngine/issues/88. How about changing the line 582 from if ($resourceCurrentAmount >= $resourceMaxStorage) to if ($resourceCurrentAmount > $resourceMaxStorage) ? this way it does not block the resource mysql recalculation when the values are equal. Worked for me.

theGroom66 avatar Mar 25 '22 10:03 theGroom66

Hi @theGroom66, thanks for your suggestion, really appreciate it! I haven't touched this bug in a long time, so I'll have to read that code through again and try to validate if your proposal works fine - resource calculation code can be tricky, especially when it comes to stacked updates. I hope I can get this validated in a couple of days.

As an additional question, what did you do to validate this fix on your end? Did you run some extensive tests? What about your testing environment, if you don't mind sharing that info? Did you run it locally, or on some public/semi-public instance where other people than yourself play the game on a regular basis?

mdziekon avatar Mar 25 '22 12:03 mdziekon

Hi @mdziekon , You're welcome. I was just interested in Your project, so I cloned and ran it to give it a try. I've seen some of Your issues and tried to figure one out. The instance is living on my personal server to used only by me. It is a nice reading, the code, must have been a lot of work. Appreciate it man!

theGroom66 avatar Mar 25 '22 18:03 theGroom66