Commit 14bd1f7f authored by salix5's avatar salix5

remove rand(), random_shuffle()

parent b62918d8
......@@ -35,6 +35,7 @@ ClientField::ClientField() {
mzone[p].resize(7, 0);
szone[p].resize(8, 0);
}
rnd.reset(std::random_device()());
}
void ClientField::Clear() {
for(int i = 0; i < 2; ++i) {
......@@ -409,7 +410,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
}
}
if(has_card_in_grave) {
std::random_shuffle(selectable_cards.begin(), selectable_cards.end());
rnd.shuffle_vector(selectable_cards);
}
}
int startpos;
......
......@@ -2,6 +2,7 @@
#define CLIENT_FIELD_H
#include "config.h"
#include "../ocgcore/mtrandom.h"
#include <vector>
#include <set>
#include <map>
......@@ -83,6 +84,7 @@ public:
bool deck_reversed;
bool conti_selecting;
bool cant_check_grave;
mt19937 rnd;
ClientField();
void Clear();
......
......@@ -2172,7 +2172,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_SHUFFLE);
for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
(*cit)->dPos = irr::core::vector3df(rand() * 0.4f / RAND_MAX - 0.2f, 0, 0);
(*cit)->dPos = irr::core::vector3df(rnd.rand() * 0.4f / rnd.rand_max - 0.2f, 0, 0);
(*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true;
(*cit)->aniFrame = 3;
......@@ -2244,7 +2244,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) {
if(!((*cit)->position & POS_FACEUP)) {
(*cit)->dPos = irr::core::vector3df(rand() * 0.4f / RAND_MAX - 0.2f, 0, 0);
(*cit)->dPos = irr::core::vector3df(rnd.rand() * 0.4f / rnd.rand_max - 0.2f, 0, 0);
(*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true;
(*cit)->aniFrame = 3;
......
......@@ -11,6 +11,7 @@ bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG
bgm_scene = -1;
RefreshBGMList();
rnd.reset((unsigned int)time(nullptr));
engineSound = irrklang::createIrrKlangDevice();
engineMusic = irrklang::createIrrKlangDevice();
if(!engineSound || !engineMusic) {
......@@ -222,7 +223,7 @@ void SoundManager::PlayBGM(int scene) {
if(count <= 0)
return;
bgm_scene = scene;
int bgm = rand() % count;
int bgm = rnd.get_random_integer(0, count -1);
auto name = BGMList[scene][bgm].c_str();
wchar_t fname[1024];
myswprintf(fname, L"./sound/BGM/%ls", name);
......
......@@ -2,6 +2,7 @@
#define SOUNDMANAGER_H
#include "game.h"
#include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h>
#endif
......@@ -12,6 +13,7 @@ class SoundManager {
private:
std::vector<std::wstring> BGMList[8];
int bgm_scene;
mt19937 rnd;
#ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment