Commit 6a3499a5 authored by nanahira's avatar nanahira Committed by GitHub

Merge branch 'master' into patch-2

parents a6f86739 ea45f43d
...@@ -125,6 +125,8 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -125,6 +125,8 @@ void ClientCard::UpdateInfo(char* buf) {
base_defense = BufferIO::ReadInt32(buf); base_defense = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON) if(flag & QUERY_REASON)
reason = BufferIO::ReadInt32(buf); reason = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON_CARD)
buf += 4;
if(flag & QUERY_EQUIP_CARD) { if(flag & QUERY_EQUIP_CARD) {
int c = BufferIO::ReadInt8(buf); int c = BufferIO::ReadInt8(buf);
int l = BufferIO::ReadInt8(buf); int l = BufferIO::ReadInt8(buf);
...@@ -210,8 +212,14 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { ...@@ -210,8 +212,14 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
return c1->overlayTarget->sequence < c2->overlayTarget->sequence; return c1->overlayTarget->sequence < c2->overlayTarget->sequence;
else return c1->sequence < c2->sequence; else return c1->sequence < c2->sequence;
else { else {
if(c1->location & 0x71) if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
for(size_t i = 0; i < mainGame->dField.chains.size(); ++i) {
auto chit = mainGame->dField.chains[i];
if(c1 == chit.chain_card || chit.target.find(c1) != chit.target.end())
return true;
}
return c1->sequence > c2->sequence; return c1->sequence > c2->sequence;
}
else else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
......
...@@ -681,18 +681,26 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -681,18 +681,26 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnCancelOrFinish->setVisible(false); mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
time_t nowtime = time(NULL); time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime); tm* localedtime = localtime(&nowtime);
char timebuf[40]; wchar_t timetext[40];
strftime(timebuf, 40, "%Y-%m-%d %H-%M-%S", localedtime); wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime);
size_t size = strlen(timebuf) + 1;
wchar_t timetext[80];
mbstowcs(timetext, timebuf, size);
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->PopupElement(mainGame->wReplaySave); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->gMutex.Unlock(); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->replaySignal.Reset(); mainGame->gMutex.Unlock();
mainGame->replaySignal.Wait(); mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait();
}
else {
mainGame->actionParam = 1;
wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(30);
}
if(mainGame->actionParam || !is_host) { if(mainGame->actionParam || !is_host) {
char* prep = pdata; char* prep = pdata;
Replay new_replay; Replay new_replay;
......
...@@ -424,6 +424,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -424,6 +424,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->wCardSelect->setText(dataManager.GetSysString(568)); mainGame->wCardSelect->setText(dataManager.GetSysString(568));
list_command = COMMAND_OPERATION; list_command = COMMAND_OPERATION;
} }
std::sort(selectable_cards.begin(), selectable_cards.end(), ClientCard::client_card_sort);
ShowSelectCard(true, true); ShowSelectCard(true, true);
} }
break; break;
...@@ -580,6 +581,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -580,6 +581,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
} }
list_command = COMMAND_LIST; list_command = COMMAND_LIST;
std::sort(selectable_cards.begin(), selectable_cards.end(), ClientCard::client_card_sort);
ShowSelectCard(true); ShowSelectCard(true);
break; break;
} }
......
...@@ -273,6 +273,9 @@ bool Game::Initialize() { ...@@ -273,6 +273,9 @@ bool Game::Initialize() {
posY += 30; posY += 30;
chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299)); chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299));
chkQuickAnimation->setChecked(gameConf.quick_animation != 0); chkQuickAnimation->setChecked(gameConf.quick_animation != 0);
posY += 30;
chkAutoSaveReplay = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1366));
chkAutoSaveReplay->setChecked(gameConf.auto_save_replay != 0);
//system //system
irr::gui::IGUITab* tabSystem = wInfos->addTab(dataManager.GetSysString(1273)); irr::gui::IGUITab* tabSystem = wInfos->addTab(dataManager.GetSysString(1273));
posY = 20; posY = 20;
...@@ -871,7 +874,7 @@ void Game::LoadExpansionDB() { ...@@ -871,7 +874,7 @@ void Game::LoadExpansionDB() {
} }
void Game::LoadExpansionDBDirectry(const char* path) { void Game::LoadExpansionDBDirectry(const char* path) {
FileSystem::TraversalDir(path, [path](const char* name, bool isdir) { FileSystem::TraversalDir(path, [path](const char* name, bool isdir) {
if(!isdir && !mystrncasecmp(strrchr(name, '.'), ".cdb", 4)) { if(!isdir && strrchr(name, '.') && !mystrncasecmp(strrchr(name, '.'), ".cdb", 4)) {
char fpath[1024]; char fpath[1024];
sprintf(fpath, "%s/%s", path, name); sprintf(fpath, "%s/%s", path, name);
dataManager.LoadDB(fpath); dataManager.LoadDB(fpath);
...@@ -891,7 +894,7 @@ void Game::LoadExpansionStrings() { ...@@ -891,7 +894,7 @@ void Game::LoadExpansionStrings() {
void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) { void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear(); cbDeck->clear();
FileSystem::TraversalDir(L"./deck", [cbDeck](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./deck", [cbDeck](const wchar_t* name, bool isdir) {
if(!isdir && !mywcsncasecmp(wcsrchr(name, '.'), L".ydk", 4)) { if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".ydk", 4)) {
size_t len = wcslen(name); size_t len = wcslen(name);
wchar_t deckname[256]; wchar_t deckname[256];
wcsncpy(deckname, name, len - 4); wcsncpy(deckname, name, len - 4);
...@@ -909,14 +912,14 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) { ...@@ -909,14 +912,14 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
void Game::RefreshReplay() { void Game::RefreshReplay() {
lstReplayList->clear(); lstReplayList->clear();
FileSystem::TraversalDir(L"./replay", [this](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./replay", [this](const wchar_t* name, bool isdir) {
if(!isdir && !mywcsncasecmp(wcsrchr(name, '.'), L".yrp", 4) && Replay::CheckReplay(name)) if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".yrp", 4) && Replay::CheckReplay(name))
lstReplayList->addItem(name); lstReplayList->addItem(name);
}); });
} }
void Game::RefreshSingleplay() { void Game::RefreshSingleplay() {
lstSinglePlayList->clear(); lstSinglePlayList->clear();
FileSystem::TraversalDir(L"./single", [this](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(L"./single", [this](const wchar_t* name, bool isdir) {
if(!isdir && !mywcsncasecmp(wcsrchr(name, '.'), L".lua", 4)) if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".lua", 4))
lstSinglePlayList->addItem(name); lstSinglePlayList->addItem(name);
}); });
} }
...@@ -999,6 +1002,7 @@ void Game::LoadConfig() { ...@@ -999,6 +1002,7 @@ void Game::LoadConfig() {
gameConf.defaultOT = 1; gameConf.defaultOT = 1;
gameConf.enable_bot_mode = 0; gameConf.enable_bot_mode = 0;
gameConf.quick_animation = 0; gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0;
gameConf.enable_sound = true; gameConf.enable_sound = true;
gameConf.sound_volume = 0.5; gameConf.sound_volume = 0.5;
gameConf.enable_music = true; gameConf.enable_music = true;
...@@ -1068,6 +1072,8 @@ void Game::LoadConfig() { ...@@ -1068,6 +1072,8 @@ void Game::LoadConfig() {
gameConf.enable_bot_mode = atoi(valbuf); gameConf.enable_bot_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "quick_animation")) { } else if(!strcmp(strbuf, "quick_animation")) {
gameConf.quick_animation = atoi(valbuf); gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
} else if(!strcmp(strbuf, "enable_sound")) { } else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0; gameConf.enable_sound = atoi(valbuf) > 0;
...@@ -1141,6 +1147,7 @@ void Game::SaveConfig() { ...@@ -1141,6 +1147,7 @@ void Game::SaveConfig() {
fprintf(fp, "default_ot = %d\n", gameConf.defaultOT); fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode); fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation); fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0)); fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0)); fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
...@@ -1308,7 +1315,7 @@ void Game::ErrorLog(const char* msg) { ...@@ -1308,7 +1315,7 @@ void Game::ErrorLog(const char* msg) {
if(!fp) if(!fp)
return; return;
time_t nowtime = time(NULL); time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime); tm* localedtime = localtime(&nowtime);
char timebuf[40]; char timebuf[40];
strftime(timebuf, 40, "%Y-%m-%d %H:%M:%S", localedtime); strftime(timebuf, 40, "%Y-%m-%d %H:%M:%S", localedtime);
fprintf(fp, "[%s]%s\n", timebuf, msg); fprintf(fp, "[%s]%s\n", timebuf, msg);
......
...@@ -43,6 +43,7 @@ struct Config { ...@@ -43,6 +43,7 @@ struct Config {
int defaultOT; int defaultOT;
int enable_bot_mode; int enable_bot_mode;
int quick_animation; int quick_animation;
int auto_save_replay;
bool enable_sound; bool enable_sound;
bool enable_music; bool enable_music;
double sound_volume; double sound_volume;
...@@ -244,6 +245,7 @@ public: ...@@ -244,6 +245,7 @@ public:
irr::gui::IGUICheckBox* chkAutoChain; irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain; irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkQuickAnimation; irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkHideSetname; irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton; irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges; irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
......
...@@ -439,7 +439,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -439,7 +439,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
std::wstring repinfo; std::wstring repinfo;
time_t curtime = ReplayMode::cur_replay.pheader.seed; time_t curtime = ReplayMode::cur_replay.pheader.seed;
tm* st = localtime(&curtime); tm* st = localtime(&curtime);
myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec); wcsftime(infobuf, 256, L"%Y/%m/%d %H:%M:%S\n", st);
repinfo.append(infobuf); repinfo.append(infobuf);
wchar_t namebuf[4][20]; wchar_t namebuf[4][20];
ReplayMode::cur_replay.ReadName(namebuf[0]); ReplayMode::cur_replay.ReadName(namebuf[0]);
...@@ -454,7 +454,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -454,7 +454,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]);
repinfo.append(infobuf); repinfo.append(infobuf);
mainGame->ebRepStartTurn->setText(L"1"); mainGame->ebRepStartTurn->setText(L"1");
mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, (wchar_t*)repinfo.c_str()); mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, repinfo.c_str());
break; break;
} }
case LISTBOX_BOT_LIST: { case LISTBOX_BOT_LIST: {
......
...@@ -131,18 +131,25 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -131,18 +131,25 @@ int SingleMode::SinglePlayThread(void* param) {
} }
last_replay.EndRecord(); last_replay.EndRecord();
time_t nowtime = time(NULL); time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime); tm* localedtime = localtime(&nowtime);
char timebuf[40]; wchar_t timetext[40];
strftime(timebuf, 40, "%Y-%m-%d %H-%M-%S", localedtime); wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime);
size_t size = strlen(timebuf) + 1;
wchar_t timetext[80];
mbstowcs(timetext, timebuf, size);
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->PopupElement(mainGame->wReplaySave); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->gMutex.Unlock(); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->replaySignal.Reset(); mainGame->gMutex.Unlock();
mainGame->replaySignal.Wait(); mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait();
} else {
mainGame->actionParam = 1;
wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(30);
}
if(mainGame->actionParam) if(mainGame->actionParam)
last_replay.SaveReplay(mainGame->ebRSName->getText()); last_replay.SaveReplay(mainGame->ebRSName->getText());
end_duel(pduel); end_duel(pduel);
......
...@@ -38,7 +38,7 @@ void SoundManager::RefreshBGMList() { ...@@ -38,7 +38,7 @@ void SoundManager::RefreshBGMList() {
void SoundManager::RefershBGMDir(std::wstring path, int scene) { void SoundManager::RefershBGMDir(std::wstring path, int scene) {
std::wstring search = L"./sound/BGM/" + path; std::wstring search = L"./sound/BGM/" + path;
FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) {
if(!isdir && (!mywcsncasecmp(wcsrchr(name, '.'), L".mp3", 4) || !mywcsncasecmp(wcsrchr(name, '.'), L".ogg", 4))) { if(!isdir && wcsrchr(name, '.') && (!mywcsncasecmp(wcsrchr(name, '.'), L".mp3", 4) || !mywcsncasecmp(wcsrchr(name, '.'), L".ogg", 4))) {
std::wstring filename = path + L"/" + name; std::wstring filename = path + L"/" + name;
BGMList[BGM_ALL].push_back(filename); BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename); BGMList[scene].push_back(filename);
......
...@@ -386,6 +386,8 @@ ...@@ -386,6 +386,8 @@
!system 1363 是否删除这个录像? !system 1363 是否删除这个录像?
!system 1364 重命名录像 !system 1364 重命名录像
!system 1365 重命名失败,可能存在同名文件 !system 1365 重命名失败,可能存在同名文件
!system 1366 自动保存录像
!system 1367 录像已自动保存为%ls.yrp
!system 1370 星数↑ !system 1370 星数↑
!system 1371 攻击↑ !system 1371 攻击↑
!system 1372 守备↑ !system 1372 守备↑
...@@ -923,3 +925,4 @@ ...@@ -923,3 +925,4 @@
!setname 0x121 魔妖 !setname 0x121 魔妖
!setname 0x122 女武神 Valkyrie !setname 0x122 女武神 Valkyrie
!setname 0x123 蔷薇龙 ローズ・ドラゴン !setname 0x123 蔷薇龙 ローズ・ドラゴン
!setname 0x124 机械天使 機械天使
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