Bug 374696 - Integer Overflow for large number of ships
Summary: Integer Overflow for large number of ships
Status: RESOLVED FIXED
Alias: None
Product: konquest
Classification: Applications
Component: general (other bugs)
Version First Reported In: 2.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Pierre Ducroquet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-07 14:50 UTC by Thomas Kent
Modified: 2017-04-22 02:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Shows negative ship count. (1017.52 KB, image/png)
2017-01-07 14:50 UTC, Thomas Kent
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Kent 2017-01-07 14:50:21 UTC
Created attachment 103261 [details]
Shows negative ship count.

After running a very long game (just toying with an AI opponent that was nearly wiped out), I saw that my total ship count (bottom right of the screen shot) wrapped around and went negative.
Comment 1 Andrius Štikonas 2017-04-22 02:54:38 UTC
Git commit 064c74d30e7a94554c27980e2934441f1b03d6c0 by Andrius Štikonas.
Committed on 22/04/2017 at 02:54.
Pushed by stikonas into branch 'master'.

Use long long for fleet size to avoid integer overflow.

Well, with the number of ships in the fleet rising exponentially,
it will still eventually overflow but a bit later...

M  +6    -6    fleet.cc
M  +8    -8    fleet.h
M  +1    -1    game.cpp
M  +1    -1    game.h
M  +1    -1    gameview.h
M  +1    -1    mainwin.cc
M  +1    -1    players/ai/becai/becai.cpp
M  +22   -22   players/player.h

https://commits.kde.org/konquest/064c74d30e7a94554c27980e2934441f1b03d6c0