Avoid overflowing dividend products before division (by Codex)
Use 64-bit products in actual monthly fund/property settlement, monthly and annual previews, and weekly dividend offers. Retain per-unit rounding, recipient policy and final native fields. Test representable high-value settlements against their forecasts. Full 32-bit money storage overflow remains unresolved. Refs: #46
This commit is contained in:
1 parent
5caf23c452
commit
feb6ca2717
8 files changed
+90
-7
No files matched your search
@@ -88,7 +88,7 @@ int32_t original_share_adjustment(const GameState& game, int manager, bool incom
|
||||
if (income) {
|
||||
for (int k = 0; k < 6; ++k) {
|
||||
const uint32_t shares = game.memory.u32(::bmh::layout::FundBlock + uint32_t(k) * 0x1c);
|
||||
const uint32_t unit = uint32_t(shares) * uint32_t(kShareUnits[size_t(k)]) / 10000;
|
||||
const uint32_t unit = uint32_t((uint64_t(shares) * uint32_t(kShareUnits[size_t(k)])) / 10000);
|
||||
const uint32_t owned = game.memory.u16(::bmh::layout::Advertising_OriginalShareAdjustment_RuntimeField + uint32_t(manager) * 2 + uint32_t(k) * 0x1c);
|
||||
amount = wrap_add(amount, signed32(unit * owned));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user