[Scummvm-git-logs] scummvm master -> 7cbd2455b7d8a0166b11607c7021f357766dff5e
sev-
sev at scummvm.org
Tue Jul 6 14:26:58 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f032f05032 SAGA2: Replace rand() with _random
7cbd2455b7 SAGA2: Replaced rest of rand() calls
Commit: f032f050325e6388ebda9599bab8c23b32007ce7
https://github.com/scummvm/scummvm/commit/f032f050325e6388ebda9599bab8c23b32007ce7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:23:06+02:00
Commit Message:
SAGA2: Replace rand() with _random
Changed paths:
engines/saga2/motion.cpp
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index ae9359dd13..873e37d18e 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -161,7 +161,7 @@ int32 getPathFindIQ(GameObject *obj) {
pfIQ = 250;
else
pfIQ = 100;
- if (rand() % 10 == 5)
+ if (g_vm->_rnd->getRandomNumber(9) == 5)
pfIQ += 200;
}
@@ -245,9 +245,9 @@ bool unstickObject(GameObject *obj) {
TilePoint bestPos;
for (int tries = 128; tries >= 0; tries--) {
- int32 dx = rand() % (radius * 2 + 1) - radius,
- dy = rand() % (radius * 2 + 1) - radius,
- dz = rand() % (radius * 2 + 1) - radius;
+ int32 dx = g_vm->_rnd->getRandomNumber(radius * 2) - radius,
+ dy = g_vm->_rnd->getRandomNumber(radius * 2) - radius,
+ dz = g_vm->_rnd->getRandomNumber(radius * 2) - radius;
int16 tHeight;
// Compute the actual _data.location of the new point
@@ -1187,7 +1187,7 @@ void MotionTask::remove(int16 returnVal) {
Actor *a = (Actor *)object;
a->moveTask = NULL;
- a->cycleCount = rand() % 20;
+ a->cycleCount = g_vm->_rnd->getRandomNumber(19);
// Make sure the actor is not left in a permanently
// uninterruptable state with no motion task to reset it
@@ -2822,8 +2822,8 @@ void MotionTask::walkAction(void) {
// direction for a random duration
flags |= agitated | reset;
- direction = rand() & 0x7;
- actionCounter = 8 + (rand() & 0x7);
+ direction = g_vm->_rnd->getRandomNumber(7);
+ actionCounter = 8 + g_vm->_rnd->getRandomNumber(7);
// Discard the path
if (flags & pathFind) {
@@ -3230,7 +3230,7 @@ struct CombatMotionSet {
// Select randome element from the array
uint8 selectRandom(void) const {
- return list[rand() % listSize];
+ return list[g_vm->_rnd->getRandomNumber(listSize - 1)];
}
};
@@ -3911,7 +3911,7 @@ void MotionTask::acceptHitAction(void) {
a->setActionPoints(animationFrames + 1);
- if (rand() & 0x1) {
+ if (g_vm->_rnd->getRandomNumber(1)) {
// Calculate the new position to knock the actor back to
newLoc += dirTable[(a->currentFacing - 4) & 0x7];
@@ -3971,7 +3971,7 @@ void MotionTask::fallDownAction(void) {
a->setActionPoints(animationFrames + 1);
- if (rand() & 0x1) {
+ if (g_vm->_rnd->getRandomNumber(1)) {
// Calculate the new position to knock the actor back to
newLoc += dirTable[(a->currentFacing - 4) & 0x7];
newLoc.z = tileSlopeHeight(newLoc, a, &sti);
@@ -4192,7 +4192,7 @@ void MotionTask::updatePositions(void) {
if (mt->flags & reset) {
a->setAction(actionStand, 0);
- a->cycleCount = rand() & 0x3;
+ a->cycleCount = g_vm->_rnd->getRandomNumber(3);
mt->flags &= ~(reset | nextAnim);
}
if (a->cycleCount == 0) {
@@ -4202,7 +4202,7 @@ void MotionTask::updatePositions(void) {
} else if (mt->flags & nextAnim) {
if (a->nextAnimationFrame()) {
a->setAction(actionStand, 0);
- a->cycleCount = rand() & 0x3;
+ a->cycleCount = g_vm->_rnd->getRandomNumber(3);
mt->flags &= ~nextAnim;
}
} else
Commit: 7cbd2455b7d8a0166b11607c7021f357766dff5e
https://github.com/scummvm/scummvm/commit/7cbd2455b7d8a0166b11607c7021f357766dff5e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T16:26:32+02:00
Commit Message:
SAGA2: Replaced rest of rand() calls
Changed paths:
engines/saga2/objects.cpp
engines/saga2/player.cpp
engines/saga2/sagafunc.cpp
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 7c26cfa0a9..5f2d4217d2 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1640,7 +1640,7 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
Direction startDir,
dir;
- startDir = dir = rand() & 0x7;
+ startDir = dir = g_vm->_rnd->getRandomNumber(7);
do {
TilePoint probeLoc;
@@ -1648,8 +1648,8 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
// Compute a _data.location to place the object
probeLoc = _data.location + incDirTable[dir] * dist;
- probeLoc.u += (rand() & 0x3) - 2;
- probeLoc.v += (rand() & 0x3) - 2;
+ probeLoc.u += g_vm->_rnd->getRandomNumber(3) - 2;
+ probeLoc.v += g_vm->_rnd->getRandomNumber(3) - 2;
probeLoc.z = tileSlopeHeight(probeLoc, mapNum, obj, &sti);
// If _data.location is not blocked, drop the object
@@ -4157,28 +4157,6 @@ GameObject *objectCollision(GameObject *obj, GameWorld *world, const TilePoint &
return nullptr;
}
-/* ======================================================================= *
- Randomly Scatter Object Location In World
- * ======================================================================= */
-
-//void GameWorld::randomScatter()
-//{
-// ObjectIterator objIter( this );
-// GameObject *objPtr;
-// ObjectID id;
-// TilePoint randLoc;
-// Point16 maxUV(100,100);//Temp Test
-
-// Iterate through each object in the world
-
-// while ( ( id = objIter.next( &objPtr ) ) != Nothing )
-// {
-// Select a random Location.
-// randLoc.u = rand() % maxUV.x;
-// randLoc.v = rand() % maxUV.y;
-// objPtr->move(randLoc);
-// }
-//}
/* ======================================================================= *
Test for line of sight between two objects
* ======================================================================= */
@@ -4560,7 +4538,7 @@ void doBackgroundSimulation(void) {
if (obj->isScavengable()
&& !obj->isActivated()
&& isWorld(obj->IDParent())
- && rand() % MIN(objectLimboCount / 2, 60) == 0) {
+ && g_vm->_rnd->getRandomNumber(MIN(objectLimboCount / 2, 60) - 1) == 0) {
obj->deleteObjectRecursive();
}
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index a6c83b9789..382b6ee887 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -311,7 +311,7 @@ void PlayerActor::skillAdvance(uint8 stat,
uint8 points,
uint8 useMult) {
// roll percentile dice
- if (rand() % 100 < advanceChance) {
+ if (g_vm->_rnd->getRandomNumber(99) < advanceChance) {
uint8 increase;
int16 oldValue = baseStats.skill(stat) / ActorAttributes::skillFracPointsPerLevel;
@@ -354,7 +354,7 @@ void PlayerActor::skillAdvance(uint8 stat,
void PlayerActor::vitalityAdvance(uint8 points) {
while (points-- > 0) {
- if (rand() % ActorAttributes::vitalityLimit > baseStats.vitality) {
+ if (g_vm->_rnd->getRandomNumber(ActorAttributes::vitalityLimit - 1) > baseStats.vitality) {
if (++vitalityMemory >= vitalityLevelBump) {
vitalityMemory -= vitalityLevelBump;
baseStats.vitality++;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 68eea60f19..2950276bb9 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -3430,7 +3430,7 @@ int16 scriptPickRandomLivingActor(int16 *args) {
if (livingCount <= 0) return Nothing;
- livingCount = rand() % livingCount;
+ livingCount = g_vm->_rnd->getRandomNumber(livingCount - 1);
for (i = 0; i < thisThread->argCount; i++) {
if (isActor(args[i])) {
More information about the Scummvm-git-logs
mailing list