[Scummvm-cvs-logs] CVS: scummvm/common util.cpp,1.5,1.6 util.h,1.7,1.8
Oliver Kiehl
olki at users.sourceforge.net
Sun Dec 1 06:58:49 CET 2002
- Previous message: [Scummvm-cvs-logs] CVS: scummvm simon.dsp,1.11,1.12
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv21709/common
Modified Files:
util.cpp util.h
Log Message:
moved RNG to common/util.cpp
Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- util.cpp 16 Sep 2002 10:42:12 -0000 1.5
+++ util.cpp 1 Dec 2002 14:57:49 -0000 1.6
@@ -157,3 +157,27 @@
}
return num;
}
+
+RandomSource::RandomSource(uint32 seed)
+{
+ _randSeed = seed;
+}
+
+void RandomSource::setSeed(uint32 seed)
+{
+ _randSeed = seed;
+}
+
+uint RandomSource::getRandomNumber(uint max)
+{
+ /* TODO: my own random number generator */
+ _randSeed = 0xDEADBF03 * (_randSeed + 1);
+ _randSeed = (_randSeed >> 13) | (_randSeed << 19);
+ return _randSeed % (max + 1);
+}
+
+uint RandomSource::getRandomNumberRng(uint min, uint max)
+{
+ return getRandomNumber(max - min) + min;
+}
+
Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- util.h 30 Nov 2002 16:03:46 -0000 1.7
+++ util.h 1 Dec 2002 14:57:49 -0000 1.8
@@ -72,4 +72,16 @@
// Resource string length
int resStrLen(const char *src);
+
+class RandomSource {
+private:
+ uint32 _randSeed;
+
+public:
+ RandomSource(uint32 seed = 0xA943DE33);
+ void setSeed(uint32 seed);
+ uint getRandomNumber(uint max);
+ uint getRandomNumberRng(uint min, uint max);
+};
+
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm simon.dsp,1.11,1.12
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list