mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Use rand_s for MINGW
This commit is contained in:
parent
0c4a86b8c6
commit
54a1c4a65c
|
@ -1,3 +1,7 @@
|
||||||
|
#ifdef MINGW
|
||||||
|
#define _CRT_RAND_S
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -28,6 +32,17 @@ NoiseTexture::NoiseTexture()
|
||||||
|
|
||||||
typedef std::array<std::vector<u8>, NOISE_TEX_NUM> NoiseTexturesData;
|
typedef std::array<std::vector<u8>, NOISE_TEX_NUM> NoiseTexturesData;
|
||||||
|
|
||||||
|
static
|
||||||
|
u32 Rand(u32 rand_value)
|
||||||
|
{
|
||||||
|
#ifdef MINGW
|
||||||
|
rand_s(&rand_value);
|
||||||
|
#else
|
||||||
|
rand_value = rand();
|
||||||
|
#endif
|
||||||
|
return rand_value;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void FillTextureData(u32 _seed, NoiseTexturesData * _pData, u32 _start, u32 _stop)
|
void FillTextureData(u32 _seed, NoiseTexturesData * _pData, u32 _start, u32 _stop)
|
||||||
{
|
{
|
||||||
|
@ -35,8 +50,11 @@ void FillTextureData(u32 _seed, NoiseTexturesData * _pData, u32 _start, u32 _sto
|
||||||
for (u32 i = _start; i < _stop; ++i) {
|
for (u32 i = _start; i < _stop; ++i) {
|
||||||
auto & vec = _pData->at(i);
|
auto & vec = _pData->at(i);
|
||||||
const size_t sz = vec.size();
|
const size_t sz = vec.size();
|
||||||
for (size_t t = 0; t < sz; ++t)
|
u32 rand_value;
|
||||||
vec[t] = rand() & 0xFF;
|
for (size_t t = 0; t < sz; ++t) {
|
||||||
|
rand_value = Rand(rand_value);
|
||||||
|
vec[t] = rand_value & 0xFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,8 +161,11 @@ void NoiseTexture::update()
|
||||||
if (m_DList == dwnd().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
|
if (m_DList == dwnd().getBuffersSwapCount() || config.generalEmulation.enableNoise == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (m_currTex == m_prevTex)
|
u32 rand_value;
|
||||||
m_currTex = rand() % NOISE_TEX_NUM;
|
while (m_currTex == m_prevTex) {
|
||||||
|
rand_value = Rand(rand_value);
|
||||||
|
m_currTex = rand_value % NOISE_TEX_NUM;
|
||||||
|
}
|
||||||
m_prevTex = m_currTex;
|
m_prevTex = m_currTex;
|
||||||
if (m_pTexture[m_currTex] == nullptr)
|
if (m_pTexture[m_currTex] == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user