Commit 98b56b0c authored by mercury233's avatar mercury233

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

parents ba5af7f5 caad336e
No preview for this file type
......@@ -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();
......
......@@ -1105,27 +1105,32 @@ void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<
break;
}
}
bool showAvail = false;
bool showNotAvail = false;
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) {
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(avail) {
if((cp->second.ot & AVAIL_OCG) && !(cp->second.ot & AVAIL_TCG))
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))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 192, 128, 256), 0, 0, true);
}
else {
if(cp->second.ot & AVAIL_OCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 0, 128, 64), 0, 0, true);
else if(cp->second.ot & AVAIL_TCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 64, 128, 128), 0, 0, true);
else
driver->draw2DImage(imageManager.tLim, otloc, recti(0, 0, 64, 64), 0, 0, true);
}
showAvail = avail;
showNotAvail = !avail;
} else if(!(cp->second.ot & gameConf.defaultOT)) {
showNotAvail = true;
}
if(showAvail) {
if((cp->second.ot & AVAIL_OCG) && !(cp->second.ot & AVAIL_TCG))
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))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 192, 128, 256), 0, 0, true);
} else if(showNotAvail) {
if(cp->second.ot & AVAIL_OCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 0, 128, 64), 0, 0, true);
else if(cp->second.ot & AVAIL_TCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 64, 128, 128), 0, 0, true);
else if(!avail)
driver->draw2DImage(imageManager.tLim, otloc, recti(0, 0, 64, 64), 0, 0, true);
}
}
void Game::DrawDeckBd() {
......
......@@ -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;
......
......@@ -16,7 +16,7 @@
#include "single_mode.h"
#endif //YGOPRO_SERVER_MODE
const unsigned short PRO_VERSION = 0x1352;
const unsigned short PRO_VERSION = 0x1353;
namespace ygo {
......@@ -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);
cbLimit = env->addComboBox(rect<s32>(260, 25 / 6, 390, 20 + 25 / 6), wFilter, COMBOBOX_LIMIT);
cbLimit->setMaxSelectionRows(10);
cbLimit->addItem(dataManager.GetSysString(1486));
cbLimit->addItem(dataManager.GetSysString(1310));
cbLimit->addItem(dataManager.GetSysString(1316));
cbLimit->addItem(dataManager.GetSysString(1317));
cbLimit->addItem(dataManager.GetSysString(1318));
......
......@@ -309,7 +309,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j)
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);
}
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
......
......@@ -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;
......
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