]> git.pond.sub.org Git - empserver/commit
build: Stop abuse of construction material random rounding
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 12 Jan 2014 17:24:06 +0000 (18:24 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 16 Feb 2014 10:44:43 +0000 (11:44 +0100)
commit1227d2c931ed4c33e03946847aa237c2ef4d4420
treeeb42eef3c96c1464629ba3a217ee9a10a7b5904f
parent5dd068bbf824844f37fe6a5ee183592376026ab0
build: Stop abuse of construction material random rounding

Construction materials required for building a ship, plane or land
unit are rounded randomly.  Crafty players exploit this to save
materials: they put just enough materials there so that build succeeds
when it rounds down.  Then they simply keep trying until it succeeds.

Planes and land units are built at 10%, so rounding happens when
materials for 100% aren't multiples of ten.  If they're below ten, you
can even build without materials.  In the stock game, this is the case
for linf, and many plane types.

Ships are built at 20%, so multiples of five aren't rounded.  Ship
building never rounds in the stock game.

Prevent the abuse of random rounding by requiring the required
fractional amount rounded up to be present.  Don't change the actual
charging of materials; that's still randomly rounded.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/buil.c
tests/build/final.xdump
tests/build/journal.log
tests/build/units/02-planes-2
tests/build/units/03-lands-3
tests/smoke/final.xdump
tests/smoke/journal.log