Steemnova - error in deut consumption calculation

in #utopian-io6 years ago

Project Information

  • Repository: Steemnova
  • Project Name: steemnova
  • Publisher (if applicable): @mys

Expected behavior

When I want to send ships around, it is expected that I can do this as long as the deut consumption does not exceed the deut in the storage or in the cargo capacity.

Actual behavior

If the deut consumption for a fleet mission is zero, the cargo capacity gets shown as zero as well, even though it should be much higher. Also, if one presses continue, steemnova throws the following error:

WARNING
--
Message: Division by zero
File: /includes/classes/class.FleetFunctions.php
Line: 187
URL: https://steemnova.intinte.org/game.php?page=fleetStep2
PHP-Version: 7.0.30-2
PHP-API: fpm-fcgi
2Moons Version: 1.8.git
Debug Backtrace:
#0 /includes/classes/class.FleetFunctions.php(187): errorHandler(2, 'Division by zer...', 'FILEPATH ...', 187, Array)
#1 /includes/pages/game/ShowFleetStep2Page.class.php(88): FleetFunctions::GetFleetConsumption(Array, 5, 5, Array, 2)
#2 /game.php(58): ShowFleetStep2Page->show()
#3 {main}

As the error message states, this is caused by a division by zero. I think this is caused by the very high speed of spy drones, causing the duration of the of the flight to be rounded down to zero in the round expression in that line. Maybe this bug could be fixed by adding a max() statement in there. (so changing round($MissionDuration, 0) to max(round($MissionDuration, 0), 1))

How to reproduce

(These steps assume you know how to play the game and how it works a bit.) If these need to be more detailed for you, hit me up in the comments or in discord and I'll edit them

  1. Get a running steemnova environment to test on. (Here's a tutorial for setting up a local steemnova instance)
  2. Get a moon besides one of your planets. (This can be done with the admin tools if you have admin permissions or by having some luck while playing the game)
  3. Build some Spy Probes.
  4. Try to send them to your moon.
  • Browser/App version: Vivaldi | 1.15.1147.55 (Stable channel) (64-Bit)
  • Operating system: Windows 10
Communication with Project Owner

When I first encountered this bug and verified it was replicable I hit up @mys on discord and asked him if that was already known. After he said no I opened a GitHub issue. Mys answered in that issue, and already fixed that bug in this pull request

GitHub Account

Flugschwein

Sort:  

Hello @flugschwein,
Sorry for the delay in the review.

It seems your fix is already accepted and appreciated by the PO's :)
There's not much to review for me. But, I'll leave feedback from my side.

  • I loved how detailed your post was, It helped me understand your bug and score you accordingly.
  • It was a nice technical bug, and your report helped the project become more stable for users.

Thank you for reporting this. Keep contributing to Open Source

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hey @flugschwein
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.22
TRX 0.20
JST 0.034
BTC 98504.77
ETH 3362.26
USDT 1.00
SBD 3.06