Commit 41bcf377 authored by mercury233's avatar mercury233

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

parents 196f886b 07223d1a
...@@ -38,6 +38,7 @@ ClientCard::ClientCard() { ...@@ -38,6 +38,7 @@ ClientCard::ClientCard() {
lscale = 0; lscale = 0;
rscale = 0; rscale = 0;
link_marker = 0; link_marker = 0;
position = 0;
cHint = 0; cHint = 0;
chValue = 0; chValue = 0;
atkstring[0] = 0; atkstring[0] = 0;
...@@ -70,8 +71,12 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -70,8 +71,12 @@ void ClientCard::UpdateInfo(char* buf) {
code = pdata; code = pdata;
} }
if(flag & QUERY_POSITION) { if(flag & QUERY_POSITION) {
pdata = BufferIO::ReadInt32(buf); pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff;
position = (pdata >> 24) & 0xff; if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) {
position = pdata;
mainGame->dField.MoveCard(this, 1);
} else
position = pdata;
} }
if(flag & QUERY_ALIAS) if(flag & QUERY_ALIAS)
alias = BufferIO::ReadInt32(buf); alias = BufferIO::ReadInt32(buf);
......
...@@ -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 {
...@@ -374,6 +374,7 @@ void ClientField::ClearChainSelect() { ...@@ -374,6 +374,7 @@ void ClientField::ClearChainSelect() {
(*cit)->is_selected = false; (*cit)->is_selected = false;
} }
conti_cards.clear(); conti_cards.clear();
deck_act = false;
grave_act = false; grave_act = false;
remove_act = false; remove_act = false;
extra_act = false; extra_act = false;
...@@ -589,6 +590,55 @@ void ClientField::ShowLocationCard() { ...@@ -589,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();
}; };
......
...@@ -73,7 +73,7 @@ inline int _wtoi(const wchar_t * s) { ...@@ -73,7 +73,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;
......
...@@ -774,15 +774,6 @@ void DeckBuilder::StartFilter() { ...@@ -774,15 +774,6 @@ void DeckBuilder::StartFilter() {
void DeckBuilder::FilterCards() { void DeckBuilder::FilterCards() {
results.clear(); results.clear();
const wchar_t* pstr = mainGame->ebCardName->getText(); const wchar_t* pstr = mainGame->ebCardName->getText();
int trycode = BufferIO::GetVal(pstr);
if(dataManager.GetData(trycode, 0)) {
auto ptr = dataManager.GetCodePointer(trycode); // verified by GetData()
results.push_back(ptr);
mainGame->scrFilter->setVisible(false);
mainGame->scrFilter->setPos(0);
myswprintf(result_string, L"%d", results.size());
return;
}
unsigned int set_code = 0; unsigned int set_code = 0;
if(pstr[0] == L'@') if(pstr[0] == L'@')
set_code = dataManager.GetSetCode(&pstr[1]); set_code = dataManager.GetSetCode(&pstr[1]);
...@@ -870,9 +861,14 @@ void DeckBuilder::FilterCards() { ...@@ -870,9 +861,14 @@ void DeckBuilder::FilterCards() {
} else if(pstr[0] == L'@' && set_code) { } else if(pstr[0] == L'@' && set_code) {
if(!check_set_code(data, set_code)) continue; if(!check_set_code(data, set_code)) continue;
} else { } else {
if(!CardNameContains(text.name.c_str(), pstr) && text.text.find(pstr) == std::wstring::npos int trycode = BufferIO::GetVal(pstr);
bool tryresult = dataManager.GetData(trycode, 0);
if(!tryresult && !CardNameContains(text.name.c_str(), pstr) && text.text.find(pstr) == std::wstring::npos
&& (!set_code || !check_set_code(data, set_code))) && (!set_code || !check_set_code(data, set_code)))
continue; continue;
if (tryresult && data.code != trycode
&& !(data.alias == trycode && (data.alias - data.code < CARD_ARTWORK_VERSIONS_OFFSET || data.code - data.alias < CARD_ARTWORK_VERSIONS_OFFSET)))
continue;
} }
} }
results.push_back(ptr); results.push_back(ptr);
......
...@@ -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: {
...@@ -1518,7 +1505,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1518,7 +1505,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->cmdFlag |= COMMAND_RESET; pcard->cmdFlag |= COMMAND_RESET;
else else
pcard->cmdFlag |= COMMAND_ACTIVATE; pcard->cmdFlag |= COMMAND_ACTIVATE;
if(l == LOCATION_GRAVE) if(pcard->location == LOCATION_DECK) {
pcard->SetCode(code);
mainGame->dField.deck_act = true;
} else if(l == LOCATION_GRAVE)
mainGame->dField.grave_act = true; mainGame->dField.grave_act = true;
else if(l == LOCATION_REMOVED) else if(l == LOCATION_REMOVED)
mainGame->dField.remove_act = true; mainGame->dField.remove_act = true;
...@@ -3619,7 +3609,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3619,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) {
...@@ -3629,7 +3618,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3629,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;
} }
} }
} }
...@@ -3640,87 +3630,78 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3640,87 +3630,78 @@ 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();
for(int i = 0; i < val; ++i) { val = BufferIO::ReadInt8(pbuf); //chains, always 0 in single mode
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf); if(!mainGame->dInfo.isSingleMode) {
int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); for(int i = 0; i < val; ++i) {
int pcl = BufferIO::ReadInt8(pbuf); unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int pcs = BufferIO::ReadInt8(pbuf); int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int subs = BufferIO::ReadInt8(pbuf); int pcl = BufferIO::ReadInt8(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int pcs = BufferIO::ReadInt8(pbuf);
int cl = BufferIO::ReadInt8(pbuf); int subs = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf); int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int desc = BufferIO::ReadInt32(pbuf); int cl = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(pcc, pcl, pcs, subs); int cs = BufferIO::ReadInt8(pbuf);
mainGame->dField.current_chain.chain_card = pcard; int desc = BufferIO::ReadInt32(pbuf);
mainGame->dField.current_chain.code = code; ClientCard* pcard = mainGame->dField.GetCard(pcc, pcl, pcs, subs);
mainGame->dField.current_chain.desc = desc; mainGame->dField.current_chain.chain_card = pcard;
mainGame->dField.current_chain.controler = cc; mainGame->dField.current_chain.code = code;
mainGame->dField.current_chain.location = cl; mainGame->dField.current_chain.desc = desc;
mainGame->dField.current_chain.sequence = cs; mainGame->dField.current_chain.controler = cc;
mainGame->dField.GetChainLocation(cc, cl, cs, &mainGame->dField.current_chain.chain_pos); mainGame->dField.current_chain.location = cl;
mainGame->dField.current_chain.solved = false; mainGame->dField.current_chain.sequence = cs;
int chc = 0; mainGame->dField.GetChainLocation(cc, cl, cs, &mainGame->dField.current_chain.chain_pos);
for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) { mainGame->dField.current_chain.solved = false;
if (cl == 0x10 || cl == 0x20) { int chc = 0;
if (chit->controler == cc && chit->location == cl) for(auto chit = mainGame->dField.chains.begin(); chit != mainGame->dField.chains.end(); ++chit) {
chc++; if(cl == 0x10 || cl == 0x20) {
} else { if(chit->controler == cc && chit->location == cl)
if (chit->controler == cc && chit->location == cl && chit->sequence == cs) chc++;
chc++; } else {
if(chit->controler == cc && chit->location == cl && chit->sequence == cs)
chc++;
}
} }
if(cl == LOCATION_HAND)
mainGame->dField.current_chain.chain_pos.X += 0.35f;
else
mainGame->dField.current_chain.chain_pos.Y += chc * 0.25f;
mainGame->dField.chains.push_back(mainGame->dField.current_chain);
}
if(val) {
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->dField.last_chain = true;
} }
if(cl == LOCATION_HAND)
mainGame->dField.current_chain.chain_pos.X += 0.35f;
else
mainGame->dField.current_chain.chain_pos.Y += chc * 0.25f;
mainGame->dField.chains.push_back(mainGame->dField.current_chain);
}
if(val) {
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
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_0: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 0;
SetResponseSelectedOption();
break;
}
case BUTTON_OPTION_1: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
selected_option = 1;
SetResponseSelectedOption();
break;
}
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: { case BUTTON_OPTION_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON); soundManager.PlaySoundEffect(SOUND_BUTTON);
if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { SetResponseSelectedOption();
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);
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;
} }
...@@ -2212,6 +2222,22 @@ void ClientField::SetResponseSelectedCards() const { ...@@ -2212,6 +2222,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: {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <io.h> #include <io.h>
#endif #endif
const unsigned short PRO_VERSION = 0x1344; const unsigned short PRO_VERSION = 0x1345;
namespace ygo { namespace ygo {
...@@ -353,11 +353,14 @@ bool Game::Initialize() { ...@@ -353,11 +353,14 @@ bool Game::Initialize() {
wOptions = env->addWindow(rect<s32>(490, 200, 840, 340), false, L""); wOptions = env->addWindow(rect<s32>(490, 200, 840, 340), false, L"");
wOptions->getCloseButton()->setVisible(false); wOptions->getCloseButton()->setVisible(false);
wOptions->setVisible(false); wOptions->setVisible(false);
stOptions = env->addStaticText(L"", rect<s32>(20, 20, 350, 100), false, true, wOptions, -1, false); stOptions = env->addStaticText(L"", rect<s32>(20, 20, 350, 100), false, true, wOptions, -1, false);
stOptions->setTextAlignment(irr::gui::EGUIA_UPPERLEFT, irr::gui::EGUIA_CENTER); stOptions->setTextAlignment(irr::gui::EGUIA_UPPERLEFT, irr::gui::EGUIA_CENTER);
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);
...@@ -713,7 +716,7 @@ void Game::MainLoop() { ...@@ -713,7 +716,7 @@ void Game::MainLoop() {
atkdy = (float)sin(atkframe); atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0)); driver->beginScene(true, true, SColor(0, 0, 0, 0));
gMutex.Lock(); gMutex.Lock();
if(dInfo.isStarted || dInfo.isReplaySkiping) { if(dInfo.isStarted) {
if(dInfo.isFinished && showcardcode == 1) if(dInfo.isFinished && showcardcode == 1)
soundManager.PlayBGM(BGM_WIN); soundManager.PlayBGM(BGM_WIN);
else if(dInfo.isFinished && (showcardcode == 2 || showcardcode == 3)) else if(dInfo.isFinished && (showcardcode == 2 || showcardcode == 3))
...@@ -1215,7 +1218,7 @@ void Game::ShowCardInfo(int code) { ...@@ -1215,7 +1218,7 @@ void Game::ShowCardInfo(int code) {
memset(&cd, 0, sizeof(CardData)); memset(&cd, 0, sizeof(CardData));
imgCard->setImage(imageManager.GetTexture(code)); imgCard->setImage(imageManager.GetTexture(code));
imgCard->setScaleImage(true); imgCard->setScaleImage(true);
if(cd.alias != 0 && (cd.alias - code < 10 || code - cd.alias < 10)) if(cd.alias != 0 && (cd.alias - code < CARD_ARTWORK_VERSIONS_OFFSET || code - cd.alias < CARD_ARTWORK_VERSIONS_OFFSET))
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias); myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code); else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code);
stName->setText(formatBuffer); stName->setText(formatBuffer);
......
...@@ -345,6 +345,7 @@ public: ...@@ -345,6 +345,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;
...@@ -536,6 +537,11 @@ extern Game* mainGame; ...@@ -536,6 +537,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
...@@ -625,4 +631,6 @@ extern Game* mainGame; ...@@ -625,4 +631,6 @@ extern Game* mainGame;
#define BUTTON_MARKERS_OK 381 #define BUTTON_MARKERS_OK 381
#define DEFAULT_DUEL_RULE 4 #define DEFAULT_DUEL_RULE 4
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif // GAME_H #endif // GAME_H
#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 {
...@@ -65,11 +64,11 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -65,11 +64,11 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->dInfo.tag_player[0] = false; mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false; mainGame->dInfo.tag_player[1] = false;
if(mainGame->dInfo.isSingleMode) { if(mainGame->dInfo.isSingleMode) {
set_script_reader((script_reader)SingleMode::ScriptReader); set_script_reader((script_reader)SingleMode::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
} else { } else {
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
} }
...@@ -106,6 +105,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -106,6 +105,7 @@ int ReplayMode::ReplayThread(void* param) {
get_message(pduel, (byte*)engineBuffer); get_message(pduel, (byte*)engineBuffer);
is_continuing = ReplayAnalyze(engineBuffer, len); is_continuing = ReplayAnalyze(engineBuffer, len);
if(is_restarting) { if(is_restarting) {
mainGame->gMutex.Lock();
is_restarting = false; is_restarting = false;
int step = current_step - 1; int step = current_step - 1;
if(step < 0) if(step < 0)
...@@ -280,7 +280,6 @@ void ReplayMode::Undo() { ...@@ -280,7 +280,6 @@ void ReplayMode::Undo() {
return; return;
mainGame->dInfo.isReplaySkiping = true; mainGame->dInfo.isReplaySkiping = true;
Restart(false); Restart(false);
mainGame->gMutex.Lock();
Pause(false, false); Pause(false, false);
} }
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...@@ -936,6 +935,15 @@ void ReplayMode::ReplayReload() { ...@@ -936,6 +935,15 @@ void ReplayMode::ReplayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0); /*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer); mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
byte* ReplayMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int ReplayMode::MessageHandler(long fduel, int type) { int ReplayMode::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload(); static void ReplayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
}; };
......
...@@ -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 {
...@@ -408,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -408,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)SingleDuel::MessageHandler); set_message_handler((message_handler)SingleDuel::MessageHandler);
rnd.reset(seed); rnd.reset(seed);
...@@ -1547,6 +1545,15 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag) ...@@ -1547,6 +1545,15 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
} }
byte* SingleDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int SingleDuel::MessageHandler(long fduel, int type) { int SingleDuel::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -37,7 +37,8 @@ public: ...@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg); static void SingleTimer(evutil_socket_t fd, short events, void* arg);
......
#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 {
...@@ -39,7 +38,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -39,7 +38,7 @@ int SingleMode::SinglePlayThread(void* param) {
mtrandom rnd; mtrandom rnd;
time_t seed = time(0); time_t seed = time(0);
rnd.reset(seed); rnd.reset(seed);
set_script_reader((script_reader)ScriptReader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
...@@ -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) { for(int seq = 0; seq < 8; ++seq) {
val = BufferIO::ReadInt8(pbuf); int val = BufferIO::ReadInt8(pbuf);
if(val) { if(val)
ClientCard* ccard = new ClientCard; pbuf++;
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); pbuf += 6;
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 pbuf++;
DuelClient::ClientAnalyze(offset, pbuf - offset);
SinglePlayReload(); SinglePlayReload();
mainGame->gMutex.Lock();
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
...@@ -897,6 +849,14 @@ void SingleMode::SinglePlayReload() { ...@@ -897,6 +849,14 @@ void SingleMode::SinglePlayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0); /*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer); mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
if(ScriptReader(sname, slen))
return buffer;
else
return ScriptReader(script_name, slen);
}
byte* SingleMode::ScriptReader(const char* script_name, int* slen) { byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
FILE *fp; FILE *fp;
#ifdef _WIN32 #ifdef _WIN32
......
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload(); static void SinglePlayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen); static byte* ScriptReader(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
......
...@@ -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 {
...@@ -383,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -383,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)TagDuel::MessageHandler); set_message_handler((message_handler)TagDuel::MessageHandler);
rnd.reset(seed); rnd.reset(seed);
...@@ -1664,6 +1662,15 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) { ...@@ -1664,6 +1662,15 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
} }
} }
} }
byte* TagDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int TagDuel::MessageHandler(long fduel, int type) { int TagDuel::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -37,7 +37,8 @@ public: ...@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
static void TagTimer(evutil_socket_t fd, short events, void* arg); static void TagTimer(evutil_socket_t fd, short events, void* arg);
......
Subproject commit fdc826fa34f103cf8dbda3bffbc5775ef2ce9bff Subproject commit 1be62b3d400e9b1a0e06c8ea8a9c1d38deaec663
Subproject commit f4fc8334903586b7ab0e316d7652b5238efde512 Subproject commit fa9a0e7ba5c6eb54a0c330bf90f83e90a6d187b0
...@@ -243,6 +243,9 @@ ...@@ -243,6 +243,9 @@
!system 1164 同调召唤 !system 1164 同调召唤
!system 1165 超量召唤 !system 1165 超量召唤
!system 1166 连接召唤 !system 1166 连接召唤
!system 1190 加入手卡
!system 1191 送去墓地
!system 1192 除外
#menu #menu
!system 1200 联机模式 !system 1200 联机模式
!system 1201 单人模式 !system 1201 单人模式
...@@ -907,3 +910,7 @@ ...@@ -907,3 +910,7 @@
!setname 0x11b 自奏圣乐 オルフェゴール !setname 0x11b 自奏圣乐 オルフェゴール
!setname 0x11c 雷龙 サンダー·ドラゴン !setname 0x11c 雷龙 サンダー·ドラゴン
!setname 0x11d 禁忌的 禁じられた !setname 0x11d 禁忌的 禁じられた
!setname 0x11e 危险! Danger!
!setname 0x11f 奈芙提斯 ネフティス
!setname 0x120 调皮宝贝 プランキッズ
!setname 0x121 魔妖
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