Commit dd9f5bd0 authored by mercury233's avatar mercury233

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

parents c437d24b 19fbe73c
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
#include <unordered_map> #include <unordered_map>
namespace ygo { namespace ygo {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "image_manager.h" #include "image_manager.h"
#include "game.h" #include "game.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
...@@ -590,6 +590,55 @@ void ClientField::ShowLocationCard() { ...@@ -590,6 +590,55 @@ void ClientField::ShowLocationCard() {
mainGame->btnDisplayOK->setVisible(true); mainGame->btnDisplayOK->setVisible(true);
mainGame->PopupElement(mainGame->wCardDisplay); mainGame->PopupElement(mainGame->wCardDisplay);
} }
void ClientField::ShowSelectOption(int select_hint) {
selected_option = 0;
wchar_t textBuffer[256];
int count = select_options.size();
bool quickmode = (count <= 5);
mainGame->gMutex.Lock();
for(int i = 0; (i < count) && quickmode; i++) {
const wchar_t* option = dataManager.GetDesc(select_options[i]);
irr::core::dimension2d<unsigned int> dtxt = mainGame->guiFont->getDimension(option);
if(dtxt.Width > 310) {
quickmode = false;
break;
}
mainGame->btnOption[i]->setText(option);
}
if(quickmode) {
mainGame->stOptions->setVisible(false);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(false);
mainGame->btnOptionOK->setVisible(false);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(i < count);
recti pos = mainGame->wOptions->getRelativePosition();
int newheight = 30 + 40 * count;
int oldheight = pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y;
pos.UpperLeftCorner.Y = pos.UpperLeftCorner.Y + (oldheight - newheight) / 2;
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + newheight;
mainGame->wOptions->setRelativePosition(pos);
} else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont,
(wchar_t*)dataManager.GetDesc(select_options[0]));
mainGame->stOptions->setVisible(true);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(count > 1);
mainGame->btnOptionOK->setVisible(true);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(false);
recti pos = mainGame->wOptions->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 140;
mainGame->wOptions->setRelativePosition(pos);
}
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else
myswprintf(textBuffer, dataManager.GetSysString(555));
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
}
void ClientField::ReplaySwap() { void ClientField::ReplaySwap() {
std::swap(deck[0], deck[1]); std::swap(deck[0], deck[1]);
std::swap(hand[0], hand[1]); std::swap(hand[0], hand[1]);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
namespace ygo { namespace ygo {
...@@ -96,6 +97,7 @@ public: ...@@ -96,6 +97,7 @@ public:
void ShowSelectCard(bool buttonok = false, bool chain = false); void ShowSelectCard(bool buttonok = false, bool chain = false);
void ShowChainCard(); void ShowChainCard();
void ShowLocationCard(); void ShowLocationCard();
void ShowSelectOption(int select_hint = 0);
void ReplaySwap(); void ReplaySwap();
void RefreshAllCards(); void RefreshAllCards();
...@@ -137,6 +139,7 @@ public: ...@@ -137,6 +139,7 @@ public:
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable); void SetShowMark(ClientCard* pcard, bool enable);
void SetResponseSelectedCards() const; void SetResponseSelectedCards() const;
void SetResponseSelectedOption() const;
void CancelOrFinish(); void CancelOrFinish();
}; };
......
...@@ -68,7 +68,7 @@ inline int _wtoi(const wchar_t * s) { ...@@ -68,7 +68,7 @@ inline int _wtoi(const wchar_t * s) {
#include "mysignal.h" #include "mysignal.h"
#include "mythread.h" #include "mythread.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "deck_manager.h" #include "deck_manager.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "duelclient.h" #include "duelclient.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include "image_manager.h" #include "image_manager.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "game.h" #include "game.h"
#include "replay.h" #include "replay.h"
#include "replay_mode.h" #include "replay_mode.h"
#include <algorithm>
namespace ygo { namespace ygo {
...@@ -1323,21 +1323,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1323,21 +1323,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.select_options.clear(); mainGame->dField.select_options.clear();
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
mainGame->dField.select_options.push_back(BufferIO::ReadInt32(pbuf)); mainGame->dField.select_options.push_back(BufferIO::ReadInt32(pbuf));
mainGame->gMutex.Lock(); mainGame->dField.ShowSelectOption(select_hint);
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont,
(wchar_t*)dataManager.GetDesc(mainGame->dField.select_options[0]));
mainGame->btnOptionp->setVisible(false);
if(count > 1)
mainGame->btnOptionn->setVisible(true);
else mainGame->btnOptionn->setVisible(false);
mainGame->dField.selected_option = 0;
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(555));
select_hint = 0; select_hint = 0;
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
return false; return false;
} }
case MSG_SELECT_CARD: { case MSG_SELECT_CARD: {
...@@ -3622,7 +3609,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3622,7 +3609,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf); ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
if(val) { if(val) {
for(int xyz = 0; xyz < val; ++xyz) { for(int xyz = 0; xyz < val; ++xyz) {
...@@ -3632,7 +3618,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3632,7 +3618,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
xcard->overlayTarget = ccard; xcard->overlayTarget = ccard;
xcard->location = 0x80; xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1; xcard->sequence = ccard->overlayed.size() - 1;
mainGame->dField.GetCardLocation(xcard, &xcard->curPos, &xcard->curRot, true); xcard->owner = p;
xcard->controler = p;
} }
} }
} }
...@@ -3643,49 +3630,39 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3643,49 +3630,39 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf); ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq); mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq); mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
} }
// Use another loop to refresh the hand locations to prevent incorrect positioning
for (int seq = 0; seq < val; ++seq) {
ClientCard* ccard = mainGame->dField.hand[p][seq];
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq); mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq); mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) { for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard; ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq); mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
} }
val = BufferIO::ReadInt8(pbuf); val = BufferIO::ReadInt8(pbuf);
mainGame->dField.extra_p_count[p] = val; mainGame->dField.extra_p_count[p] = val;
} }
val = BufferIO::ReadInt8(pbuf); //chains mainGame->dField.RefreshAllCards();
val = BufferIO::ReadInt8(pbuf); //chains, always 0 in single mode
if(!mainGame->dInfo.isSingleMode) {
for(int i = 0; i < val; ++i) { for(int i = 0; i < val; ++i) {
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf); unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
...@@ -3707,11 +3684,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3707,11 +3684,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.current_chain.solved = false; mainGame->dField.current_chain.solved = false;
int chc = 0; int chc = 0;
for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) { for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) {
if (cl == 0x10 || cl == 0x20) { if(cl == 0x10 || cl == 0x20) {
if (chit->controler == cc && chit->location == cl) if(chit->controler == cc && chit->location == cl)
chc++; chc++;
} else { } else {
if (chit->controler == cc && chit->location == cl && chit->sequence == cs) if(chit->controler == cc && chit->location == cl && chit->sequence == cs)
chc++; chc++;
} }
} }
...@@ -3725,6 +3702,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3725,6 +3702,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code)); myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->dField.last_chain = true; mainGame->dField.last_chain = true;
} }
}
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
} }
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
#include "replay_mode.h" #include "replay_mode.h"
#include "single_mode.h" #include "single_mode.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
#include <algorithm>
namespace ygo { namespace ygo {
...@@ -290,22 +291,39 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -290,22 +291,39 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option])); mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[selected_option]));
break; break;
} }
case BUTTON_OPTION_OK: { case BUTTON_OPTION_0: {
soundManager.PlaySoundEffect(SOUND_BUTTON); soundManager.PlaySoundEffect(SOUND_BUTTON);
if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { selected_option = 0;
DuelClient::SetResponseI(selected_option); SetResponseSelectedOption();
} else { break;
int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
DuelClient::SetResponseI(index << 16);
} else {
DuelClient::SetResponseI(index);
} }
case BUTTON_OPTION_1: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 1;
SetResponseSelectedOption();
break;
} }
mainGame->HideElement(mainGame->wOptions, true); case BUTTON_OPTION_2: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 2;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_3: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 3;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_4: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 4;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
SetResponseSelectedOption();
break; break;
} }
case BUTTON_ANNUMBER_OK: { case BUTTON_ANNUMBER_OK: {
...@@ -359,12 +377,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -359,12 +377,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
DuelClient::SendResponse(); DuelClient::SendResponse();
} else { } else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[0]));
selected_option = 0;
command_card = clicked_card; command_card = clicked_card;
mainGame->btnOptionp->setVisible(false); ShowSelectOption();
mainGame->btnOptionn->setVisible(true);
mainGame->ShowElement(mainGame->wOptions);
} }
} else { } else {
selectable_cards.clear(); selectable_cards.clear();
...@@ -644,12 +658,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -644,12 +658,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
mainGame->HideElement(mainGame->wCardSelect, true); mainGame->HideElement(mainGame->wCardSelect, true);
} else { } else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[0]));
selected_option = 0;
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(true);
mainGame->wCardSelect->setVisible(false); mainGame->wCardSelect->setVisible(false);
mainGame->ShowElement(mainGame->wOptions); ShowSelectOption();
} }
break; break;
} }
...@@ -2241,6 +2251,22 @@ void ClientField::SetResponseSelectedCards() const { ...@@ -2241,6 +2251,22 @@ void ClientField::SetResponseSelectedCards() const {
respbuf[i + 1] = selected_cards[i]->select_seq; respbuf[i + 1] = selected_cards[i]->select_seq;
DuelClient::SetResponseB(respbuf, selected_cards.size() + 1); DuelClient::SetResponseB(respbuf, selected_cards.size() + 1);
} }
void ClientField::SetResponseSelectedOption() const {
if(mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option);
} else {
int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI((index << 16) + 5);
} else if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
DuelClient::SetResponseI(index << 16);
} else {
DuelClient::SetResponseI(index);
}
}
mainGame->HideElement(mainGame->wOptions, true);
}
void ClientField::CancelOrFinish() { void ClientField::CancelOrFinish() {
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
case MSG_WAITING: { case MSG_WAITING: {
......
...@@ -364,6 +364,9 @@ bool Game::Initialize() { ...@@ -364,6 +364,9 @@ bool Game::Initialize() {
btnOptionOK = env->addButton(rect<s32>(130, 105, 220, 130), wOptions, BUTTON_OPTION_OK, dataManager.GetSysString(1211)); btnOptionOK = env->addButton(rect<s32>(130, 105, 220, 130), wOptions, BUTTON_OPTION_OK, dataManager.GetSysString(1211));
btnOptionp = env->addButton(rect<s32>(20, 105, 60, 130), wOptions, BUTTON_OPTION_PREV, L"<<<"); btnOptionp = env->addButton(rect<s32>(20, 105, 60, 130), wOptions, BUTTON_OPTION_PREV, L"<<<");
btnOptionn = env->addButton(rect<s32>(290, 105, 330, 130), wOptions, BUTTON_OPTION_NEXT, L">>>"); btnOptionn = env->addButton(rect<s32>(290, 105, 330, 130), wOptions, BUTTON_OPTION_NEXT, L">>>");
for(int i = 0; i < 5; ++i) {
btnOption[i] = env->addButton(rect<s32>(10, 30 + 40 * i, 340, 60 + 40 * i), wOptions, BUTTON_OPTION_0 + i, L"");
}
//pos select //pos select
wPosSelect = env->addWindow(rect<s32>(340, 200, 935, 410), false, dataManager.GetSysString(561)); wPosSelect = env->addWindow(rect<s32>(340, 200, 935, 410), false, dataManager.GetSysString(561));
wPosSelect->getCloseButton()->setVisible(false); wPosSelect->getCloseButton()->setVisible(false);
......
...@@ -374,6 +374,7 @@ public: ...@@ -374,6 +374,7 @@ public:
irr::gui::IGUIButton* btnOptionp; irr::gui::IGUIButton* btnOptionp;
irr::gui::IGUIButton* btnOptionn; irr::gui::IGUIButton* btnOptionn;
irr::gui::IGUIButton* btnOptionOK; irr::gui::IGUIButton* btnOptionOK;
irr::gui::IGUIButton* btnOption[5];
//pos selection //pos selection
irr::gui::IGUIWindow* wPosSelect; irr::gui::IGUIWindow* wPosSelect;
irr::gui::CGUIImageButton* btnPSAU; irr::gui::CGUIImageButton* btnPSAU;
...@@ -576,6 +577,11 @@ extern Game* mainGame; ...@@ -576,6 +577,11 @@ extern Game* mainGame;
#define BUTTON_OPTION_PREV 220 #define BUTTON_OPTION_PREV 220
#define BUTTON_OPTION_NEXT 221 #define BUTTON_OPTION_NEXT 221
#define BUTTON_OPTION_OK 222 #define BUTTON_OPTION_OK 222
#define BUTTON_OPTION_0 223
#define BUTTON_OPTION_1 224
#define BUTTON_OPTION_2 225
#define BUTTON_OPTION_3 226
#define BUTTON_OPTION_4 227
#define BUTTON_CARD_0 230 #define BUTTON_CARD_0 230
#define BUTTON_CARD_1 231 #define BUTTON_CARD_1 231
#define BUTTON_CARD_2 232 #define BUTTON_CARD_2 232
......
#include "replay.h" #include "replay.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include <algorithm> #include <algorithm>
#include "lzma/LzmaLib.h" #include "lzma/LzmaLib.h"
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#include "netserver.h" #include "netserver.h"
#include "game.h" #include "game.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
......
#include "single_mode.h" #include "single_mode.h"
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -724,72 +723,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -724,72 +723,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_RELOAD_FIELD: { case MSG_RELOAD_FIELD: {
mainGame->gMutex.Lock(); pbuf++;
mainGame->dField.Clear();
mainGame->dInfo.duel_rule = BufferIO::ReadInt8(pbuf);
int val = 0;
for(int p = 0; p < 2; ++p) { for(int p = 0; p < 2; ++p) {
mainGame->dInfo.lp[p] = BufferIO::ReadInt32(pbuf); pbuf += 4;
myswprintf(mainGame->dInfo.strLP[p], L"%d", mainGame->dInfo.lp[p]);
for(int seq = 0; seq < 7; ++seq) { for(int seq = 0; seq < 7; ++seq) {
val = BufferIO::ReadInt8(pbuf); int val = BufferIO::ReadInt8(pbuf);
if(val) { if(val)
ClientCard* ccard = new ClientCard; pbuf += 2;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
val = BufferIO::ReadInt8(pbuf);
if(val) {
for(int xyz = 0; xyz < val; ++xyz) {
ClientCard* xcard = new ClientCard;
ccard->overlayed.push_back(xcard);
mainGame->dField.overlay_cards.insert(xcard);
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1;
xcard->owner = p;
xcard->controler = p;
}
} }
for(int seq = 0; seq < 8; ++seq) {
int val = BufferIO::ReadInt8(pbuf);
if(val)
pbuf++;
} }
pbuf += 6;
} }
for(int seq = 0; seq < 8; ++seq) { pbuf++;
val = BufferIO::ReadInt8(pbuf); DuelClient::ClientAnalyze(offset, pbuf - offset);
if(val) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
}
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
}
val = BufferIO::ReadInt8(pbuf);
mainGame->dField.extra_p_count[p] = val;
}
BufferIO::ReadInt8(pbuf); //chain count, always 0
SinglePlayReload(); SinglePlayReload();
mainGame->gMutex.Lock();
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#include "netserver.h" #include "netserver.h"
#include "game.h" #include "game.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
......
Subproject commit 7da0970abec7155fe7de65e86e905a971c56db79 Subproject commit df9a103a856a1f7cc425feb9e50eb92ef2c343ed
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