Commit 98b56b0c authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into server

parents ba5af7f5 caad336e
Pipeline #5312 passed with stages
in 4 minutes and 4 seconds
No preview for this file type
...@@ -35,6 +35,7 @@ ClientField::ClientField() { ...@@ -35,6 +35,7 @@ ClientField::ClientField() {
mzone[p].resize(7, 0); mzone[p].resize(7, 0);
szone[p].resize(8, 0); szone[p].resize(8, 0);
} }
rnd.reset(std::random_device()());
} }
void ClientField::Clear() { void ClientField::Clear() {
for(int i = 0; i < 2; ++i) { for(int i = 0; i < 2; ++i) {
...@@ -409,7 +410,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -409,7 +410,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
} }
} }
if(has_card_in_grave) { if(has_card_in_grave) {
std::random_shuffle(selectable_cards.begin(), selectable_cards.end()); rnd.shuffle_vector(selectable_cards);
} }
} }
int startpos; int startpos;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define CLIENT_FIELD_H #define CLIENT_FIELD_H
#include "config.h" #include "config.h"
#include "../ocgcore/mtrandom.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
...@@ -83,6 +84,7 @@ public: ...@@ -83,6 +84,7 @@ public:
bool deck_reversed; bool deck_reversed;
bool conti_selecting; bool conti_selecting;
bool cant_check_grave; bool cant_check_grave;
mt19937 rnd;
ClientField(); ClientField();
void Clear(); void Clear();
......
...@@ -1105,27 +1105,32 @@ void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map< ...@@ -1105,27 +1105,32 @@ void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<
break; break;
} }
} }
bool showAvail = false;
bool showNotAvail = false;
int filter_lm = cbLimit->getSelected(); int filter_lm = cbLimit->getSelected();
bool avail = !((filter_lm == 4 && !(cp->second.ot & AVAIL_OCG)
|| (filter_lm == 5 && !(cp->second.ot & AVAIL_TCG))
|| (filter_lm == 6 && !(cp->second.ot & AVAIL_SC))
|| (filter_lm == 7 && !(cp->second.ot & AVAIL_CUSTOM))
|| (filter_lm == 8 && (cp->second.ot & AVAIL_OCGTCG) != AVAIL_OCGTCG)));
if(filter_lm >= 4) { if(filter_lm >= 4) {
bool avail = !((filter_lm == 4 && !(cp->second.ot & AVAIL_OCG) showAvail = avail;
|| (filter_lm == 5 && !(cp->second.ot & AVAIL_TCG)) showNotAvail = !avail;
|| (filter_lm == 6 && !(cp->second.ot & AVAIL_SC)) } else if(!(cp->second.ot & gameConf.defaultOT)) {
|| (filter_lm == 7 && !(cp->second.ot & AVAIL_CUSTOM)) showNotAvail = true;
|| (filter_lm == 8 && (cp->second.ot & AVAIL_OCGTCG) != AVAIL_OCGTCG))); }
if(avail) { if(showAvail) {
if((cp->second.ot & AVAIL_OCG) && !(cp->second.ot & AVAIL_TCG)) if((cp->second.ot & AVAIL_OCG) && !(cp->second.ot & AVAIL_TCG))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 128, 128, 192), 0, 0, true); driver->draw2DImage(imageManager.tOT, otloc, recti(0, 128, 128, 192), 0, 0, true);
else if((cp->second.ot & AVAIL_TCG) && !(cp->second.ot & AVAIL_OCG)) else if((cp->second.ot & AVAIL_TCG) && !(cp->second.ot & AVAIL_OCG))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 192, 128, 256), 0, 0, true); driver->draw2DImage(imageManager.tOT, otloc, recti(0, 192, 128, 256), 0, 0, true);
} } else if(showNotAvail) {
else { if(cp->second.ot & AVAIL_OCG)
if(cp->second.ot & AVAIL_OCG) driver->draw2DImage(imageManager.tOT, otloc, recti(0, 0, 128, 64), 0, 0, true);
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 0, 128, 64), 0, 0, true); else if(cp->second.ot & AVAIL_TCG)
else if(cp->second.ot & AVAIL_TCG) driver->draw2DImage(imageManager.tOT, otloc, recti(0, 64, 128, 128), 0, 0, true);
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 64, 128, 128), 0, 0, true); else if(!avail)
else driver->draw2DImage(imageManager.tLim, otloc, recti(0, 0, 64, 64), 0, 0, true);
driver->draw2DImage(imageManager.tLim, otloc, recti(0, 0, 64, 64), 0, 0, true);
}
} }
} }
void Game::DrawDeckBd() { void Game::DrawDeckBd() {
......
...@@ -2172,7 +2172,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2172,7 +2172,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_SHUFFLE); soundManager.PlaySoundEffect(SOUND_SHUFFLE);
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) { 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)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true; (*cit)->is_moving = true;
(*cit)->aniFrame = 3; (*cit)->aniFrame = 3;
...@@ -2244,7 +2244,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2244,7 +2244,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) { for (auto cit = mainGame->dField.extra[player].begin(); cit != mainGame->dField.extra[player].end(); ++cit) {
if(!((*cit)->position & POS_FACEUP)) { 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)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true; (*cit)->is_moving = true;
(*cit)->aniFrame = 3; (*cit)->aniFrame = 3;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "single_mode.h" #include "single_mode.h"
#endif //YGOPRO_SERVER_MODE #endif //YGOPRO_SERVER_MODE
const unsigned short PRO_VERSION = 0x1352; const unsigned short PRO_VERSION = 0x1353;
namespace ygo { namespace ygo {
...@@ -715,7 +715,7 @@ bool Game::Initialize() { ...@@ -715,7 +715,7 @@ bool Game::Initialize() {
stLimit = env->addStaticText(dataManager.GetSysString(1315), rect<s32>(205, 2 + 25 / 6, 280, 22 + 25 / 6), false, false, wFilter); stLimit = env->addStaticText(dataManager.GetSysString(1315), rect<s32>(205, 2 + 25 / 6, 280, 22 + 25 / 6), false, false, wFilter);
cbLimit = env->addComboBox(rect<s32>(260, 25 / 6, 390, 20 + 25 / 6), wFilter, COMBOBOX_LIMIT); cbLimit = env->addComboBox(rect<s32>(260, 25 / 6, 390, 20 + 25 / 6), wFilter, COMBOBOX_LIMIT);
cbLimit->setMaxSelectionRows(10); cbLimit->setMaxSelectionRows(10);
cbLimit->addItem(dataManager.GetSysString(1486)); cbLimit->addItem(dataManager.GetSysString(1310));
cbLimit->addItem(dataManager.GetSysString(1316)); cbLimit->addItem(dataManager.GetSysString(1316));
cbLimit->addItem(dataManager.GetSysString(1317)); cbLimit->addItem(dataManager.GetSysString(1317));
cbLimit->addItem(dataManager.GetSysString(1318)); cbLimit->addItem(dataManager.GetSysString(1318));
......
...@@ -309,7 +309,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -309,7 +309,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int extra = replay.ReadInt32(); int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j) for(int j = 0; j < extra; ++j)
tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32())); tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32()));
myswprintf(filename, L"%ls %ls", ex_filename, namebuf[i]); myswprintf(filename, L"deck/%ls-%d %ls.ydk", ex_filename, i + 1, namebuf[i]);
deckManager.SaveDeck(tmp_deck, filename); deckManager.SaveDeck(tmp_deck, filename);
} }
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(dataManager.GetSysString(1335));
......
...@@ -11,6 +11,7 @@ bool SoundManager::Init() { ...@@ -11,6 +11,7 @@ bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
bgm_scene = -1; bgm_scene = -1;
RefreshBGMList(); RefreshBGMList();
rnd.reset((unsigned int)time(nullptr));
engineSound = irrklang::createIrrKlangDevice(); engineSound = irrklang::createIrrKlangDevice();
engineMusic = irrklang::createIrrKlangDevice(); engineMusic = irrklang::createIrrKlangDevice();
if(!engineSound || !engineMusic) { if(!engineSound || !engineMusic) {
...@@ -222,7 +223,7 @@ void SoundManager::PlayBGM(int scene) { ...@@ -222,7 +223,7 @@ void SoundManager::PlayBGM(int scene) {
if(count <= 0) if(count <= 0)
return; return;
bgm_scene = scene; bgm_scene = scene;
int bgm = rand() % count; int bgm = rnd.get_random_integer(0, count -1);
auto name = BGMList[scene][bgm].c_str(); auto name = BGMList[scene][bgm].c_str();
wchar_t fname[1024]; wchar_t fname[1024];
myswprintf(fname, L"./sound/BGM/%ls", name); myswprintf(fname, L"./sound/BGM/%ls", name);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define SOUNDMANAGER_H #define SOUNDMANAGER_H
#include "game.h" #include "game.h"
#include "../ocgcore/mtrandom.h"
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
#include <irrKlang.h> #include <irrKlang.h>
#endif #endif
...@@ -12,6 +13,7 @@ class SoundManager { ...@@ -12,6 +13,7 @@ class SoundManager {
private: private:
std::vector<std::wstring> BGMList[8]; std::vector<std::wstring> BGMList[8];
int bgm_scene; int bgm_scene;
mt19937 rnd;
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
irrklang::ISoundEngine* engineSound; irrklang::ISoundEngine* engineSound;
irrklang::ISoundEngine* engineMusic; irrklang::ISoundEngine* engineMusic;
......
Subproject commit 99934ac7ca0eec057eb7a9a29da5cccdc5f7fdaa Subproject commit eccfcfb8e150c400a032e3f484ab478a34bcdfd9
Subproject commit 967a69444572c9ab9ec3cd54ab5bf8d984e37239 Subproject commit ffaa1d435ea6175f3ec055db3dbc14c3de9cf38b
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