mdziekon / UniEngine

OGame-like Game Engine
GNU Affero General Public License v3.0
105 stars 35 forks source link

Resources recalculation does not apply negative income when storage is full #88

Open mdziekon opened 4 years ago

mdziekon commented 4 years ago

Steps to reproduce

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

What should happen

What actually happens

Regression tracking

Caused by (PR):

Caused by (relevant code pieces):

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

theGroom66 commented 2 years ago

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.

mdziekon commented 2 years ago

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?

theGroom66 commented 2 years ago

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!