Browse Source

Inline rand

pull/570/head
Anders Jenbo 6 years ago
parent
commit
3ab9b7f2d3
  1. 1
      CMakeLists.txt
  2. 5
      Source/codec.cpp
  3. 1
      Source/diablo.cpp
  4. 1
      SourceS/miniwin.h
  5. 8
      SourceS/miniwin/rand.h
  6. 20
      SourceX/miniwin/rand.cpp

1
CMakeLists.txt

@ -251,7 +251,6 @@ set(devilutionx_SRCS
SourceX/controls/touch.cpp
SourceX/display.cpp
SourceX/miniwin/misc_msg.cpp
SourceX/miniwin/rand.cpp
SourceX/miniwin/thread.cpp
SourceX/sound.cpp
SourceX/soundsample.cpp

5
Source/codec.cpp

@ -61,11 +61,12 @@ void codec_init_key(int unused, char *pszPassword)
char digest[SHA1HashSize];
char *keyInit;
srand(0x7058);
uint32_t rand_state = 0x7058;
keyInit = key;
for (i = 0; i < 136; i++) {
*keyInit = rand();
rand_state = rand_state * 214013 + 2531011;
*keyInit = (rand_state >> 16) & 0x7FFF;
keyInit++;
}
ch = 0;

1
Source/diablo.cpp

@ -266,7 +266,6 @@ void diablo_init()
ReadOnlyTest();
srand(SDL_GetTicks());
InitHash();
diablo_init_screen();

1
SourceS/miniwin.h

@ -23,7 +23,6 @@
#include "miniwin/misc.h"
#include "miniwin/thread.h"
#include "miniwin/rand.h"
#include "storm_full.h"
#ifndef MAX_PATH

8
SourceS/miniwin/rand.h

@ -1,8 +0,0 @@
#pragma once
namespace dvl {
int rand(void);
void srand(uint32_t seed);
} // namespace dvl

20
SourceX/miniwin/rand.cpp

@ -1,20 +0,0 @@
#include <cstdint>
#include "devilution.h"
namespace dvl {
static uint32_t rand_state = 0;
int rand(void)
{
rand_state = rand_state * 214013 + 2531011;
return (rand_state >> 16) & 0x7FFF;
}
void srand(uint32_t seed)
{
rand_state = seed;
}
} // namespace dvl
Loading…
Cancel
Save