diff --git a/Source/engine.cpp b/Source/engine.cpp index 432e3919c..9535402bf 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -16,20 +16,20 @@ DEVILUTION_BEGIN_NAMESPACE /** Seed value before the most recent call to SetRndSeed() */ -int orgseed; +Sint32 orgseed; /** Current game seed */ -int sglGameSeed; +Sint32 sglGameSeed; static CCritSect sgMemCrit; /** * Specifies the increment used in the Borland C/C++ pseudo-random. */ -const int RndInc = 1; +const Uint32 RndInc = 1; /** * Specifies the multiplier used in the Borland C/C++ pseudo-random number generator algorithm. */ -const int RndMult = 0x015A4E35; +const Uint32 RndMult = 0x015A4E35; void CelDrawTo(CelOutputBuffer out, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { @@ -634,7 +634,7 @@ int GetDirection(int x1, int y1, int x2, int y2) * @brief Set the RNG seed * @param s RNG seed */ -void SetRndSeed(int s) +void SetRndSeed(Sint32 s) { sglGameSeed = s; orgseed = s; @@ -644,9 +644,9 @@ void SetRndSeed(int s) * @brief Advance the internal RNG seed and return the new value * @return RNG seed */ -int AdvanceRndSeed() +Sint32 AdvanceRndSeed() { - sglGameSeed = static_cast(RndMult) * sglGameSeed + RndInc; + sglGameSeed = (RndMult * static_cast(sglGameSeed)) + RndInc; return abs(sglGameSeed); } @@ -654,7 +654,7 @@ int AdvanceRndSeed() * @brief Get the current RNG seed * @return RNG seed */ -int GetRndSeed() +Sint32 GetRndSeed() { return abs(sglGameSeed); } @@ -665,7 +665,7 @@ int GetRndSeed() * @param v The upper limit for the return value * @return A random number from 0 to (v-1) */ -int random_(BYTE idx, int v) +Sint32 random_(BYTE idx, Sint32 v) { if (v <= 0) return 0; diff --git a/Source/engine.h b/Source/engine.h index bb61a42be..0b626d404 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -323,9 +323,9 @@ void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, i int GetDirection(int x1, int y1, int x2, int y2); void SetRndSeed(int s); -int AdvanceRndSeed(); -int GetRndSeed(); -int random_(BYTE idx, int v); +Sint32 AdvanceRndSeed(); +Sint32 GetRndSeed(); +Sint32 random_(BYTE idx, int v); BYTE *DiabloAllocPtr(DWORD dwBytes); void mem_free_dbg(void *p); BYTE *LoadFileInMem(const char *pszName, DWORD *pdwFileLen);