voxeltycoon / issues

18 stars 4 forks source link

Rounding error in passenger calculations #768

Closed MizardX closed 2 years ago

MizardX commented 3 years ago

Describe the bug When calculating how many passengers a house will produce (VoxelTycoon.Buildings.House.Update() method), the calculation is Mathf.CeilToInt((float) (this.Population / 2)). This results in rounding down (integer division) instead of the intended rounding up (assumed from the call to Mathf.CeilToInt).

To fix it, either divide by 2.0f or change the whole expression to (this.Population + 1) / 2

Build version 0.86.0.0 steam

Platform Microsoft Windows 10 version 21H1 (OS Build 19043.985)

andrewpey commented 2 years ago

Thanks! Fix is live on the beta branch.