[Scummvm-git-logs] scummvm master -> 9831b91c1d7d161acfc41bcc9f760b66be67a064
mduggan
noreply at scummvm.org
Sat Jan 14 06:42:07 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9831b91c1d ULTIMA8: Fix possible random number overflow
Commit: 9831b91c1d7d161acfc41bcc9f760b66be67a064
https://github.com/scummvm/scummvm/commit/9831b91c1d7d161acfc41bcc9f760b66be67a064
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-01-14T15:41:50+09:00
Commit Message:
ULTIMA8: Fix possible random number overflow
The uint result was cast to int, sometimes giving negative values.
Changed paths:
engines/ultima/ultima8/world/actors/npc_dat.cpp
engines/ultima/ultima8/world/item.cpp
diff --git a/engines/ultima/ultima8/world/actors/npc_dat.cpp b/engines/ultima/ultima8/world/actors/npc_dat.cpp
index 3ae3d468b3a..55f8f473e3a 100644
--- a/engines/ultima/ultima8/world/actors/npc_dat.cpp
+++ b/engines/ultima/ultima8/world/actors/npc_dat.cpp
@@ -91,7 +91,7 @@ uint16 NPCDat::randomlyGetStrongerWeaponTypes(uint shapeno) {
// Some shapes are only valid in each game, but that's ok.
Common::RandomSource &rs = Ultima8Engine::get_instance()->getRandomSource();
- int rnd = rs.getRandomNumber(UINT_MAX);
+ uint rnd = rs.getRandomNumber(UINT_MAX);
switch (shapeno) {
case 899: /* shape 899 - android */
diff --git a/engines/ultima/ultima8/world/item.cpp b/engines/ultima/ultima8/world/item.cpp
index 76a7756bd07..c1015b030d2 100644
--- a/engines/ultima/ultima8/world/item.cpp
+++ b/engines/ultima/ultima8/world/item.cpp
@@ -2169,7 +2169,7 @@ void Item::explode(int explosion_type, bool destroy_item, bool cause_damage) {
int32 cx, cy, cz;
getCentre(cx, cy, cz);
static const int expshapes[] = {0x31C, 0x31F, 0x326, 0x320, 0x321, 0x324, 0x323, 0x325};
- int rnd = rs.getRandomNumber(UINT_MAX);
+ uint rnd = rs.getRandomNumber(UINT_MAX);
int spriteno;
// NOTE: The game does some weird 32-bit stuff to decide what
// shapenum to use. Just simplified to a random.
More information about the Scummvm-git-logs
mailing list