[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.108,1.109

Eugene Sandulenko sev at users.sourceforge.net
Sat Mar 12 14:54:52 CET 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5254/saga

Modified Files:
	actor.cpp 
Log Message:
rand() -> _rnd.getRandomNumber() in SAGA code.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- actor.cpp	9 Mar 2005 07:29:15 -0000	1.108
+++ actor.cpp	12 Mar 2005 22:54:15 -0000	1.109
@@ -569,7 +569,7 @@
 			}
 		}
 		if (actor->sceneNumber == _vm->_scene->currentSceneNumber()) {
-			actor->actionCycle = (rand() & 7) * 4;
+			actor->actionCycle = (_vm->_rnd.getRandomNumber(7) & 0x7) * 4; // 1/8th chance
 		}
 	}
 	
@@ -725,7 +725,7 @@
 			actor = getActor(_activeSpeech.actorIds[0]);
 			if (!(_activeSpeech.speechFlags & kSpeakNoAnimate)) {
 				actor->currentAction = kActionSpeak;
-				actor->actionCycle = rand() % 64;
+				actor->actionCycle = _vm->_rnd.getRandomNumber(63);
 			}
 		}
 		_activeSpeech.playing = true;			
@@ -831,7 +831,7 @@
 					frameRange = getActorFrameRange(actor->id, kFrameStand);
 
 				if (frameRange->frameCount) {
-					actor->frameNumber = frameRange->frameIndex + (uint16)rand() % frameRange->frameCount;
+					actor->frameNumber = frameRange->frameIndex + (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
 				} else {
 					actor->frameNumber = frameRange->frameIndex;
 				}
@@ -1010,7 +1010,7 @@
 					break;
 				frameRange = getActorFrameRange(actor->id, kFrameSpeak);
 
-				state = (uint16)rand() % (frameRange->frameCount + 1);
+				state = (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount);
 
 				if (state == 0) {
 					frameRange = getActorFrameRange(actor->id, kFrameStand);
@@ -1067,7 +1067,7 @@
 			}
 
 			if (frameRange->frameCount && (actor->actorFlags & kActorRandom)) {
-				state = rand() % frameRange->frameCount;
+				state = _vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
 			}
 
 			if (actor->actorFlags & kActorBackwards) {
@@ -1347,8 +1347,8 @@
 			newU = clamp( -prefU, delta.u(), prefU ) + protagonistLocation.u();
 			newV = clamp( -prefV, delta.v(), prefV ) + protagonistLocation.v();
 
-			newLocation.u() = newU + (rand() % prefU) - prefU / 2;
-			newLocation.v() = newV + (rand() % prefV) - prefV / 2;
+			newLocation.u() = newU + _vm->_rnd.getRandomNumber(prefU - 1) - prefU / 2;
+			newLocation.v() = newV + _vm->_rnd.getRandomNumber(prefV - 1) - prefV / 2;
 			newLocation.z = 0;
 
 			return actorWalkTo(actor->id, newLocation);
@@ -1384,7 +1384,7 @@
 			}
 		}
 
-		if ((rand() & 0x7) == 0)
+		if ((_vm->_rnd.getRandomNumber(7) & 0x7) == 0) // 1/8th chance
 			actor->actorFlags &= ~kActorNoFollow;
 
 		if (actor->actorFlags & kActorNoFollow) {
@@ -1412,8 +1412,8 @@
 				newLocation.z = 0;
 
 				if (protagonistBGMaskType != 3) {
-					newLocation.x += (rand() % prefer1.x) - prefer1.x / 2;
-					newLocation.y += (rand() % prefer1.y) - prefer1.y / 2;
+					newLocation.x += _vm->_rnd.getRandomNumber(prefer1.x - 1) - prefer1.x / 2;
+					newLocation.y += _vm->_rnd.getRandomNumber(prefer1.y - 1) - prefer1.y / 2;
 				}
 
 				newLocation.x = clamp(-31*4, newLocation.x, (_vm->getDisplayWidth() + 31) * 4); //fixme





More information about the Scummvm-git-logs mailing list