[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.28,1.29 gfx.cpp,1.69,1.70 saveload.cpp,1.22,1.23 script_v1.cpp,1.35,1.36 script_v2.cpp,1.55,1.56 scumm.h,1.66,1.67 scummvm.cpp,1.85,1.86
Oliver Kiehl
olki at users.sourceforge.net
Sun Dec 1 06:58:49 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv21709/scumm
Modified Files:
akos.cpp gfx.cpp saveload.cpp script_v1.cpp script_v2.cpp
scumm.h scummvm.cpp
Log Message:
moved RNG to common/util.cpp
Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- akos.cpp 19 Nov 2002 01:45:08 -0000 1.28
+++ akos.cpp 1 Dec 2002 14:57:49 -0000 1.29
@@ -1419,7 +1419,7 @@
continue;
case AKC_Random:
- a->setAnimVar(GB(6), getRandomNumberRng(GW(2), GW(4)));
+ a->setAnimVar(GB(6), _rnd.getRandomNumberRng(GW(2), GW(4)));
continue;
case AKC_SkipGE:
case AKC_SkipG:
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- gfx.cpp 1 Dec 2002 02:11:19 -0000 1.69
+++ gfx.cpp 1 Dec 2002 14:57:50 -0000 1.70
@@ -2076,7 +2076,7 @@
for (i = 1; i < w * h; i++) {
int j;
- j = getRandomNumber(i - 1);
+ j = _rnd.getRandomNumber(i - 1);
offsets[i] = offsets[j];
offsets[j] = i;
}
@@ -2099,7 +2099,7 @@
for (i = 1; i < w * h; i++) {
int j;
- j = getRandomNumber(i - 1);
+ j = _rnd.getRandomNumber(i - 1);
offsets[i] = offsets[j];
offsets[j] = offsets2[i];
}
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- saveload.cpp 29 Nov 2002 15:13:27 -0000 1.22
+++ saveload.cpp 1 Dec 2002 14:57:50 -0000 1.23
@@ -431,6 +431,7 @@
MKLINE(Scumm, _screenEffectFlag, sleByte),
+ // FIXME: remove when new savegame system is implemented
MKLINE(Scumm, _randSeed1, sleUint32),
MKLINE(Scumm, _randSeed2, sleUint32),
@@ -545,6 +546,7 @@
MKLINE(Scumm, _screenEffectFlag, sleByte),
+ // FIXME: remove when new savegame system is implemented
MKLINE(Scumm, _randSeed1, sleUint32),
MKLINE(Scumm, _randSeed2, sleUint32),
Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v1.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- script_v1.cpp 1 Dec 2002 13:06:15 -0000 1.35
+++ script_v1.cpp 1 Dec 2002 14:57:50 -0000 1.36
@@ -1134,7 +1134,7 @@
void Scumm::o5_getRandomNr()
{
getResultPos();
- setResult(getRandomNumber(getVarOrDirectByte(0x80)));
+ setResult(_rnd.getRandomNumber(getVarOrDirectByte(0x80)));
}
void Scumm::o5_getScriptRunning()
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- script_v2.cpp 30 Nov 2002 23:16:19 -0000 1.55
+++ script_v2.cpp 1 Dec 2002 14:57:50 -0000 1.56
@@ -1209,7 +1209,7 @@
void Scumm::o6_getRandomNumber()
{
int rnd;
- rnd = getRandomNumber(pop());
+ rnd = _rnd.getRandomNumber(pop());
_vars[VAR_V6_RANDOM_NR] = rnd;
push(rnd);
}
@@ -1218,7 +1218,7 @@
{
int max = pop();
int min = pop();
- int rnd = getRandomNumberRng(min, max);
+ int rnd = _rnd.getRandomNumberRng(min, max);
_vars[VAR_V6_RANDOM_NR] = rnd;
push(rnd);
}
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- scumm.h 29 Nov 2002 18:27:35 -0000 1.66
+++ scumm.h 1 Dec 2002 14:57:50 -0000 1.67
@@ -27,6 +27,7 @@
#include "common/gameDetector.h"
#include "common/timer.h"
#include "common/file.h"
+#include "common/util.h"
class GameDetector;
class NewGui;
@@ -351,10 +352,8 @@
void convertKeysToClicks();
/* Random number generation */
- uint32 _randSeed1, _randSeed2;
- void initRandSeeds();
- uint getRandomNumber(uint max);
- uint getRandomNumberRng(uint min, uint max);
+ uint32 _randSeed1, _randSeed2; // FIXME: can be removed when new savegame system is implemented
+ RandomSource _rnd;
/* Core variable definitions */
byte _gameId;
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- scummvm.cpp 30 Nov 2002 16:47:16 -0000 1.85
+++ scummvm.cpp 1 Dec 2002 14:57:50 -0000 1.86
@@ -73,25 +73,6 @@
return engine;
}
-void Scumm::initRandSeeds()
-{
- _randSeed1 = 0xA943DE33;
- _randSeed2 = 0x37A9ED29;
-}
-
-uint Scumm::getRandomNumber(uint max)
-{
- /* TODO: my own random number generator */
- _randSeed1 = 0xDEADBF03 * (_randSeed1 + 1);
- _randSeed1 = (_randSeed1 >> 13) | (_randSeed1 << 19);
- return _randSeed1 % (max + 1);
-}
-
-uint Scumm::getRandomNumberRng(uint min, uint max)
-{
- return getRandomNumber(max - min) + min;
-}
-
Scumm::Scumm (GameDetector *detector, OSystem *syst)
: Engine(detector, syst), _pauseDialog(0), _optionsDialog(0), _saveLoadDialog(0)
{
@@ -118,6 +99,10 @@
_dynamicRoomOffsets = 0;
_shakeEnabled = 0;
+ // FIXME: remove when new savegame system is implemented
+ _randSeed1 = 0xA943DE33;
+ _randSeed2 = 0x37A9ED29;
+
if (_gameId == GID_ZAK256) { // FmTowns is 320x240
_realWidth = 320;
_realHeight = 240;
@@ -404,7 +389,7 @@
// Randomize the PRNG by calling it at regular intervals. This ensures
// that it will be in a different state each time you run the program.
- getRandomNumber(2);
+ _rnd.getRandomNumber(2);
_vars[VAR_TMR_1] += delta;
_vars[VAR_TMR_2] += delta;
@@ -1588,8 +1573,6 @@
}
readIndexFile();
-
- initRandSeeds();
if (_features & GF_NEW_OPCODES)
setupOpcodes2();
More information about the Scummvm-git-logs
mailing list