Commit 2f0b8df3 authored by mercury233's avatar mercury233
parents efe43032 1dc1e961
No preview for this file type
#include "client_card.h"
#include "client_field.h"
#include "data_manager.h"
#include "game.h"
namespace ygo {
......@@ -30,9 +31,9 @@ ClientCard::ClientCard() {
race = 0;
attribute = 0;
attack = 0;
defence = 0;
defense = 0;
base_attack = 0;
base_defence = 0;
base_defense = 0;
lscale = 0;
rscale = 0;
cHint = 0;
......@@ -99,18 +100,18 @@ void ClientCard::UpdateInfo(char* buf) {
} else
myswprintf(atkstring, L"%d", attack);
}
if(flag & QUERY_DEFENCE) {
defence = BufferIO::ReadInt32(buf);
if(defence < 0) {
if(flag & QUERY_DEFENSE) {
defense = BufferIO::ReadInt32(buf);
if(defense < 0) {
defstring[0] = '?';
defstring[1] = 0;
} else
myswprintf(defstring, L"%d", defence);
myswprintf(defstring, L"%d", defense);
}
if(flag & QUERY_BASE_ATTACK)
base_attack = BufferIO::ReadInt32(buf);
if(flag & QUERY_BASE_DEFENCE)
base_defence = BufferIO::ReadInt32(buf);
if(flag & QUERY_BASE_DEFENSE)
base_defense = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON)
reason = BufferIO::ReadInt32(buf);
if(flag & QUERY_EQUIP_CARD) {
......@@ -213,12 +214,62 @@ bool ClientCard::deck_sort_lv(code_pointer p1, code_pointer p2) {
return p1->second.level > p2->second.level;
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.defence != p2->second.defence)
return p1->second.defence > p2->second.defence;
else return p1->first < p2->first;
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
return p1->first < p2->first;
}
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8))
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8);
return p1->first < p2->first;
}
bool ClientCard::deck_sort_atk(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x8020c0) ? (p1->second.type & 0x8020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x8020c0) ? (p2->second.type & 0x8020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
}
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8))
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8);
return p1->first < p2->first;
}
bool ClientCard::deck_sort_def(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
if(p1->second.defense != p2->second.defense)
return p1->second.defense > p2->second.defense;
if(p1->second.attack != p2->second.attack)
return p1->second.attack > p2->second.attack;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x8020c0) ? (p1->second.type & 0x8020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x8020c0) ? (p2->second.type & 0x8020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
}
if((p1->second.type & 0xfffffff8) != (p2->second.type & 0xfffffff8))
return (p1->second.type & 0xfffffff8) < (p2->second.type & 0xfffffff8);
return p1->first < p2->first;
}
bool ClientCard::deck_sort_name(code_pointer p1, code_pointer p2) {
CardString cstr1;
CardString cstr2;
dataManager.GetString(p1->second.code, &cstr1);
dataManager.GetString(p2->second.code, &cstr2);
int res = wcscmp(cstr1.name, cstr2.name);
if(res != 0)
return res < 0;
return p1->first < p2->first;
}
}
......@@ -17,7 +17,7 @@ struct CardData {
unsigned int attribute;
unsigned int race;
int attack;
int defence;
int defense;
unsigned int lscale;
unsigned int rscale;
};
......@@ -30,7 +30,7 @@ struct CardDataC {
unsigned int attribute;
unsigned int race;
int attack;
int defence;
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int ot;
......@@ -74,9 +74,9 @@ public:
u32 attribute;
u32 race;
s32 attack;
s32 defence;
s32 defense;
s32 base_attack;
s32 base_defence;
s32 base_defense;
u32 lscale;
u32 rscale;
u32 reason;
......@@ -113,6 +113,9 @@ public:
void ClearTarget();
static bool client_card_sort(ClientCard* c1, ClientCard* c2);
static bool deck_sort_lv(code_pointer l1, code_pointer l2);
static bool deck_sort_atk(code_pointer l1, code_pointer l2);
static bool deck_sort_def(code_pointer l1, code_pointer l2);
static bool deck_sort_name(code_pointer l1, code_pointer l2);
*/
};
......
......@@ -91,7 +91,7 @@ void ClientField::Initial(int player, int deckc, int extrac) {
pcard->controler = player;
pcard->location = 0x40;
pcard->sequence = i;
pcard->position = POS_FACEDOWN_DEFENCE;
pcard->position = POS_FACEDOWN_DEFENSE;
GetCardLocation(pcard, &pcard->curPos, &pcard->curRot);
pcard->mTransform.setTranslation(pcard->curPos);
pcard->mTransform.setRotationRadians(pcard->curRot);
......@@ -878,7 +878,7 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
t->X = (matManager.vFields[16].Pos.X + matManager.vFields[17].Pos.X) / 2 + 1.1f * sequence;
t->Y = (matManager.vFields[16].Pos.Y + matManager.vFields[18].Pos.Y) / 2;
t->Z = 0.01f;
if (pcard->position & POS_DEFENCE) {
if (pcard->position & POS_DEFENSE) {
r->X = 0.0f;
r->Z = -3.1415926f / 2.0f;
if (pcard->position & POS_FACEDOWN)
......@@ -895,7 +895,7 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
t->X = (matManager.vFields[84].Pos.X + matManager.vFields[85].Pos.X) / 2 - 1.1f * sequence;
t->Y = (matManager.vFields[84].Pos.Y + matManager.vFields[86].Pos.Y) / 2;
t->Z = 0.01f;
if (pcard->position & POS_DEFENCE) {
if (pcard->position & POS_DEFENSE) {
r->X = 0.0f;
r->Z = 3.1415926f / 2.0f;
if (pcard->position & POS_FACEDOWN)
......
......@@ -124,6 +124,7 @@ public:
virtual bool OnEvent(const irr::SEvent& event);
void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y);
void UpdateChainButtons();
void SetResponseSelectedCards() const;
};
......
......@@ -30,7 +30,7 @@ bool DataManager::LoadDB(const char* file) {
cd.setcode = sqlite3_column_int64(pStmt, 3);
cd.type = sqlite3_column_int(pStmt, 4);
cd.attack = sqlite3_column_int(pStmt, 5);
cd.defence = sqlite3_column_int(pStmt, 6);
cd.defense = sqlite3_column_int(pStmt, 6);
unsigned int level = sqlite3_column_int(pStmt, 7);
cd.level = level & 0xff;
cd.lscale = (level >> 24) & 0xff;
......
This diff is collapsed.
......@@ -12,7 +12,10 @@ class DeckBuilder: public irr::IEventReceiver {
public:
virtual bool OnEvent(const irr::SEvent& event);
void FilterCards();
void ClearFilter();
void ClearSearch();
void SortList();
long long filter_effect;
unsigned int filter_type;
unsigned int filter_type2;
......@@ -24,6 +27,8 @@ public:
int filter_def;
unsigned int filter_lvtype;
unsigned int filter_lv;
unsigned int filter_scltype;
unsigned int filter_scl;
int filter_lm;
int hovered_code;
int hovered_pos;
......
......@@ -232,4 +232,17 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
fclose(fp);
return true;
}
bool DeckManager::DeleteDeck(Deck& deck, const wchar_t* name) {
wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name);
#ifdef WIN32
BOOL result = DeleteFileW(file);
return !!result;
#else
char filefn[256];
BufferIO::EncodeUTF8(file, filefn);
int result = unlink(filefn);
return result == 0;
#endif
}
}
......@@ -42,6 +42,7 @@ public:
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadDeck(const wchar_t* file);
bool SaveDeck(Deck& deck, const wchar_t* name);
bool DeleteDeck(Deck& deck, const wchar_t* name);
};
extern DeckManager deckManager;
......
......@@ -415,7 +415,7 @@ void Game::DrawMisc() {
w = adFont->getDimension(pcard->defstring).Width;
adFont->draw(pcard->defstring, recti(m + 4, 416, m + 4 + w, 436), 0xff000000, false, false, 0);
adFont->draw(pcard->defstring, recti(m + 5, 417, m + 5 + w, 437),
pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
pcard->defense > pcard->base_defense ? 0xffffff00 : pcard->defense < pcard->base_defense ? 0xffff2090 : 0xffffffff , false, false, 0);
adFont->draw(pcard->lvstring, recti(473 + i * 80, 356, 475 + i * 80, 366), 0xff000000, false, false, 0);
adFont->draw(pcard->lvstring, recti(474 + i * 80, 357, 476 + i * 80, 367),
(pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
......@@ -434,7 +434,7 @@ void Game::DrawMisc() {
w = adFont->getDimension(pcard->defstring).Width;
adFont->draw(pcard->defstring, recti(m + 4, 235, m + 4 + w, 255), 0xff000000, false, false, 0);
adFont->draw(pcard->defstring, recti(m + 5, 236, m + 5 + w, 256),
pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
pcard->defense > pcard->base_defense ? 0xffffff00 : pcard->defense < pcard->base_defense ? 0xffff2090 : 0xffffffff , false, false, 0);
adFont->draw(pcard->lvstring, recti(779 - i * 71, 272, 800 - i * 71, 292), 0xff000000, false, false, 0);
adFont->draw(pcard->lvstring, recti(780 - i * 71, 273, 800 - i * 71, 293),
(pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
......@@ -847,7 +847,8 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
}
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
element->getParent()->bringToFront(element);
dField.panel = element;
if(!mainGame->is_building)
dField.panel = element;
env->setFocus(element);
if(!hideframe)
ShowElement(element);
......@@ -966,13 +967,13 @@ void Game::DrawDeckBd() {
myswprintf(textBuffer, L"%ls/%ls %c%d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), form, ptr->second.level);
textFont->draw(textBuffer, recti(859, 186 + i * 66, 955, 207 + i * 66), 0xff000000, false, false);
textFont->draw(textBuffer, recti(860, 187 + i * 66, 955, 207 + i * 66), 0xffffffff, false, false);
if(ptr->second.attack < 0 && ptr->second.defence < 0)
if(ptr->second.attack < 0 && ptr->second.defense < 0)
myswprintf(textBuffer, L"?/?");
else if(ptr->second.attack < 0)
myswprintf(textBuffer, L"?/%d", ptr->second.defence);
else if(ptr->second.defence < 0)
myswprintf(textBuffer, L"?/%d", ptr->second.defense);
else if(ptr->second.defense < 0)
myswprintf(textBuffer, L"%d/?", ptr->second.attack);
else myswprintf(textBuffer, L"%d/%d", ptr->second.attack, ptr->second.defence);
else myswprintf(textBuffer, L"%d/%d", ptr->second.attack, ptr->second.defense);
if(ptr->second.type & TYPE_PENDULUM) {
wchar_t scaleBuffer[16];
myswprintf(scaleBuffer, L" %d/%d", ptr->second.lscale, ptr->second.rscale);
......
......@@ -277,12 +277,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dField.Clear();
mainGame->is_building = true;
mainGame->is_siding = true;
mainGame->wChat->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->wDeckEdit->setVisible(false);
mainGame->wFilter->setVisible(false);
mainGame->wSort->setVisible(false);
mainGame->btnSideOK->setVisible(true);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
......@@ -501,6 +506,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
case STOC_DUEL_END: {
mainGame->gMutex.Lock();
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
......@@ -527,6 +537,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->wPhase->setVisible(false);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
......@@ -892,7 +905,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
extrac = BufferIO::ReadInt16(pbuf);
mainGame->dField.Initial(mainGame->LocalPlayer(1), deckc, extrac);
mainGame->dInfo.turn = 0;
mainGame->dInfo.strTurn[0] = 0;
mainGame->dInfo.is_shuffling = false;
mainGame->gMutex.Unlock();
return true;
......@@ -1214,7 +1226,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
panelmode = true;
}
}
if(!forced && (mainGame->ignore_chain || ((count == 0 || specount == 0) && !mainGame->always_chain))) {
if(!forced && (mainGame->ignore_chain || ((count == 0 || specount == 0) && !mainGame->always_chain)) && (count == 0 || !mainGame->chain_when_avail)) {
SetResponseI(-1);
mainGame->dField.ClearChainSelect();
if(mainGame->chkWaitChain->isChecked() && !mainGame->ignore_chain) {
......@@ -1223,7 +1235,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
DuelClient::SendResponse();
return true;
}
if(mainGame->chkAutoChain->isChecked() && forced) {
if(mainGame->chkAutoChain->isChecked() && forced && !(mainGame->always_chain || mainGame->chain_when_avail)) {
SetResponseI(0);
mainGame->dField.ClearChainSelect();
DuelClient::SendResponse();
......@@ -1836,6 +1848,19 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
mainGame->btnLeaveGame->setVisible(true);
}
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
if(!mainGame->chkHideChainButton->isChecked()) {
mainGame->btnChainIgnore->setVisible(true);
mainGame->btnChainAlways->setVisible(true);
mainGame->btnChainWhenAvail->setVisible(true);
mainGame->dField.UpdateChainButtons();
}
else {
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
}
}
if(mainGame->dInfo.isTag && mainGame->dInfo.turn != 1) {
if(player == 0)
mainGame->dInfo.tag_player[0] = !mainGame->dInfo.tag_player[0];
......@@ -1843,7 +1868,6 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.tag_player[1] = !mainGame->dInfo.tag_player[1];
}
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
myswprintf(mainGame->dInfo.strTurn, L"Turn:%d", mainGame->dInfo.turn);
mainGame->showcardcode = 10;
mainGame->showcarddif = 30;
mainGame->showcardp = 0;
......@@ -2754,8 +2778,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->attack = aatk;
myswprintf(pcard->atkstring, L"%d", aatk);
}
if(adef != pcard->defence) {
pcard->defence = adef;
if(adef != pcard->defense) {
pcard->defense = adef;
myswprintf(pcard->defstring, L"%d", adef);
}
if(ld) {
......@@ -2764,8 +2788,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->attack = datk;
myswprintf(pcard->atkstring, L"%d", datk);
}
if(ddef != pcard->defence) {
pcard->defence = ddef;
if(ddef != pcard->defense) {
pcard->defense = ddef;
myswprintf(pcard->defstring, L"%d", ddef);
}
}
......
......@@ -50,6 +50,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->btnReplayStart->setVisible(false);
mainGame->btnReplayPause->setVisible(true);
mainGame->btnReplayStep->setVisible(false);
mainGame->btnReplayUndo->setVisible(false);
ReplayMode::Pause(false, false);
break;
}
......@@ -59,6 +60,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->btnReplayStart->setVisible(true);
mainGame->btnReplayPause->setVisible(false);
mainGame->btnReplayStep->setVisible(true);
mainGame->btnReplayUndo->setVisible(true);
ReplayMode::Pause(true, false);
break;
}
......@@ -80,6 +82,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
ReplayMode::SwapField();
break;
}
case BUTTON_REPLAY_UNDO: {
if(!mainGame->dInfo.isReplay)
break;
ReplayMode::Undo();
break;
}
case BUTTON_REPLAY_SAVE: {
if(mainGame->ebRSName->getText()[0] == 0)
break;
......@@ -119,6 +127,27 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break;
}
case BUTTON_CHAIN_IGNORE: {
mainGame->ignore_chain = mainGame->btnChainIgnore->isPressed();
mainGame->always_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
break;
}
case BUTTON_CHAIN_ALWAYS: {
mainGame->always_chain = mainGame->btnChainAlways->isPressed();
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
break;
}
case BUTTON_CHAIN_WHENAVAIL: {
mainGame->chain_when_avail = mainGame->btnChainWhenAvail->isPressed();
mainGame->always_chain = false;
mainGame->ignore_chain = false;
UpdateChainButtons();
break;
}
case BUTTON_MSG_OK: {
mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set();
......@@ -190,12 +219,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_POS_DU: {
DuelClient::SetResponseI(POS_FACEUP_DEFENCE);
DuelClient::SetResponseI(POS_FACEUP_DEFENSE);
mainGame->HideElement(mainGame->wPosSelect, true);
break;
}
case BUTTON_POS_DD: {
DuelClient::SetResponseI(POS_FACEDOWN_DEFENCE);
DuelClient::SetResponseI(POS_FACEDOWN_DEFENSE);
mainGame->HideElement(mainGame->wPosSelect, true);
break;
}
......@@ -876,8 +905,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
irr::core::position2di pos(x, y);
if(x < 300)
break;
if(mainGame->gameConf.control_mode == 1)
if(mainGame->gameConf.control_mode == 1) {
mainGame->always_chain = event.MouseInput.isLeftPressed();
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(pos))
mainGame->wCmdMenu->setVisible(false);
if(panel && panel->isVisible())
......@@ -1211,8 +1244,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_RMOUSE_LEFT_UP: {
if(mainGame->dInfo.isReplay)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300) {
mainGame->ignore_chain = event.MouseInput.isRightPressed();
mainGame->always_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size())
break;
......@@ -1510,15 +1547,23 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300) {
mainGame->always_chain = event.MouseInput.isLeftPressed();
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
break;
}
case irr::EMIE_RMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300) {
mainGame->ignore_chain = event.MouseInput.isRightPressed();
mainGame->always_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
break;
}
default:
......@@ -1529,13 +1574,30 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_A: {
if(mainGame->gameConf.control_mode == 0)
if(mainGame->gameConf.control_mode == 0) {
mainGame->always_chain = event.KeyInput.PressedDown;
mainGame->ignore_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
break;
}
case irr::KEY_KEY_S: {
if(mainGame->gameConf.control_mode == 0)
if(mainGame->gameConf.control_mode == 0) {
mainGame->ignore_chain = event.KeyInput.PressedDown;
mainGame->always_chain = false;
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
break;
}
case irr::KEY_KEY_D: {
if(mainGame->gameConf.control_mode == 0) {
mainGame->chain_when_avail = event.KeyInput.PressedDown;
mainGame->always_chain = false;
mainGame->ignore_chain = false;
UpdateChainButtons();
}
break;
}
case irr::KEY_KEY_R: {
......@@ -1844,7 +1906,13 @@ void ClientField::ShowMenu(int flag, int x, int y) {
mainGame->wCmdMenu->setVisible(true);
mainGame->wCmdMenu->setRelativePosition(irr::core::recti(x - 20 , y - 20 - height, x + 80, y - 20));
}
void ClientField::UpdateChainButtons() {
if(mainGame->btnChainAlways->isVisible()) {
mainGame->btnChainIgnore->setPressed(mainGame->ignore_chain);
mainGame->btnChainAlways->setPressed(mainGame->always_chain);
mainGame->btnChainWhenAvail->setPressed(mainGame->chain_when_avail);
}
}
void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[64];
respbuf[0] = selected_cards.size();
......
This diff is collapsed.
......@@ -32,8 +32,10 @@ struct Config {
int chkIgnore1;
int chkIgnore2;
int chkHideSetname;
int chkHideChainButton;
int control_mode;
int draw_field_spell;
int separate_clear_button;
};
struct DuelInfo {
......@@ -53,7 +55,6 @@ struct DuelInfo {
wchar_t hostname_tag[20];
wchar_t clientname_tag[20];
wchar_t strLP[2][16];
wchar_t strTurn[8];
wchar_t* vic_string;
unsigned char player_type;
unsigned char time_player;
......@@ -157,6 +158,7 @@ public:
wchar_t* lpcstring;
bool always_chain;
bool ignore_chain;
bool chain_when_avail;
bool is_building;
bool is_siding;
......@@ -196,6 +198,7 @@ public:
irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideChainButton;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
......@@ -350,8 +353,8 @@ public:
irr::gui::IGUIButton* btnSortDeck;
irr::gui::IGUIButton* btnShuffleDeck;
irr::gui::IGUIButton* btnSaveDeck;
irr::gui::IGUIButton* btnDeleteDeck;
irr::gui::IGUIButton* btnSaveDeckAs;
irr::gui::IGUIButton* btnDBExit;
irr::gui::IGUIButton* btnSideOK;
irr::gui::IGUIEditBox* ebDeckname;
//filter
......@@ -363,14 +366,19 @@ public:
irr::gui::IGUIComboBox* cbAttribute;
irr::gui::IGUIComboBox* cbLimit;
irr::gui::IGUIEditBox* ebStar;
irr::gui::IGUIEditBox* ebScale;
irr::gui::IGUIEditBox* ebAttack;
irr::gui::IGUIEditBox* ebDefence;
irr::gui::IGUIEditBox* ebDefense;
irr::gui::IGUIEditBox* ebCardName;
irr::gui::IGUIButton* btnEffectFilter;
irr::gui::IGUIButton* btnStartFilter;
irr::gui::IGUIButton* btnClearFilter;
irr::gui::IGUIWindow* wCategories;
irr::gui::IGUICheckBox* chkCategory[32];
irr::gui::IGUIButton* btnCategoryOK;
//sort type
irr::gui::IGUIStaticText* wSort;
irr::gui::IGUIComboBox* cbSortType;
//replay save
irr::gui::IGUIWindow* wReplaySave;
irr::gui::IGUIEditBox* ebRSName;
......@@ -381,10 +389,15 @@ public:
irr::gui::IGUIButton* btnReplayStart;
irr::gui::IGUIButton* btnReplayPause;
irr::gui::IGUIButton* btnReplayStep;
irr::gui::IGUIButton* btnReplayUndo;
irr::gui::IGUIButton* btnReplayExit;
irr::gui::IGUIButton* btnReplaySwap;
//surrender/leave
irr::gui::IGUIButton* btnLeaveGame;
//chain control
irr::gui::IGUIButton* btnChainIgnore;
irr::gui::IGUIButton* btnChainAlways;
irr::gui::IGUIButton* btnChainWhenAvail;
*/
};
......@@ -479,6 +492,9 @@ extern unsigned char draw_count;
#define BUTTON_M2 261
#define BUTTON_EP 262
#define BUTTON_LEAVE_GAME 263
#define BUTTON_CHAIN_IGNORE 264
#define BUTTON_CHAIN_ALWAYS 265
#define BUTTON_CHAIN_WHENAVAIL 266
#define BUTTON_CLEAR_LOG 270
#define LISTBOX_LOG 271
#define SCROLL_CARDTEXT 280
......@@ -495,23 +511,27 @@ extern unsigned char draw_count;
#define BUTTON_CLEAR_DECK 303
#define BUTTON_SAVE_DECK 304
#define BUTTON_SAVE_DECK_AS 305
#define BUTTON_DBEXIT 306
#define BUTTON_SORT_DECK 307
#define BUTTON_SIDE_OK 308
#define BUTTON_SHUFFLE_DECK 309
#define COMBOBOX_MAINTYPE 310
#define BUTTON_EFFECT_FILTER 311
#define BUTTON_START_FILTER 312
#define BUTTON_DELETE_DECK 306
#define BUTTON_DBEXIT 307
#define BUTTON_SORT_DECK 308
#define BUTTON_SIDE_OK 309
#define BUTTON_SHUFFLE_DECK 310
#define COMBOBOX_MAINTYPE 311
#define BUTTON_EFFECT_FILTER 312
#define BUTTON_START_FILTER 313
#define SCROLL_FILTER 314
#define EDITBOX_KEYWORD 315
#define BUTTON_CLEAR_FILTER 316
#define BUTTON_REPLAY_START 320
#define BUTTON_REPLAY_PAUSE 321
#define BUTTON_REPLAY_STEP 322
#define BUTTON_REPLAY_EXIT 323
#define BUTTON_REPLAY_SWAP 324
#define BUTTON_REPLAY_UNDO 323
#define BUTTON_REPLAY_EXIT 324
#define BUTTON_REPLAY_SWAP 325
#define BUTTON_REPLAY_SAVE 330
#define BUTTON_REPLAY_CANCEL 331
#define LISTBOX_SINGLEPLAY_LIST 350
#define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352
#define COMBOBOX_SORTTYPE 370
#endif // GAME_H
......@@ -45,14 +45,14 @@ Materials::Materials() {
vFieldSpell[1] = S3DVertex(vector3df(6.7f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell[2] = S3DVertex(vector3df(1.2f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell[3] = S3DVertex(vector3df(6.7f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell1[0] = S3DVertex(vector3df(1.2f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vFieldSpell1[1] = S3DVertex(vector3df(6.7f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell1[2] = S3DVertex(vector3df(1.2f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell1[3] = S3DVertex(vector3df(6.7f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell2[0] = S3DVertex(vector3df(1.2f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
vFieldSpell2[1] = S3DVertex(vector3df(6.7f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0));
vFieldSpell2[2] = S3DVertex(vector3df(1.2f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 1));
vFieldSpell2[3] = S3DVertex(vector3df(6.7f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 1));
vFieldSpell1[0] = S3DVertex(vector3df(1.2f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0.2f));
vFieldSpell1[1] = S3DVertex(vector3df(6.7f, 0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0.2f));
vFieldSpell1[2] = S3DVertex(vector3df(1.2f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0.63636f));
vFieldSpell1[3] = S3DVertex(vector3df(6.7f, 3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0.63636f));
vFieldSpell2[0] = S3DVertex(vector3df(1.2f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0.63636f));
vFieldSpell2[1] = S3DVertex(vector3df(6.7f, -3.2f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0.63636f));
vFieldSpell2[2] = S3DVertex(vector3df(1.2f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(1, 0.2f));
vFieldSpell2[3] = S3DVertex(vector3df(6.7f, -0.8f, 0), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0.2f));
//background grids
for (int i = 0; i < 6; ++i) {
vBackLine[i * 6 + 0] = S3DVertex(vector3df(1.2f + i * 1.1f, 0.5f, -0.01f), vector3df(0, 0, 1), SColor(255, 255, 255, 255), vector2df(0, 0));
......
......@@ -178,6 +178,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnReplayStart->setVisible(false);
mainGame->btnReplayPause->setVisible(true);
mainGame->btnReplayStep->setVisible(false);
mainGame->btnReplayUndo->setVisible(false);
mainGame->wPhase->setVisible(true);
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
......@@ -219,6 +220,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->wCardImg->setVisible(true);
mainGame->wDeckEdit->setVisible(true);
mainGame->wFilter->setVisible(true);
mainGame->wSort->setVisible(true);
mainGame->btnLeaveGame->setVisible(true);
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1306));
mainGame->btnSideOK->setVisible(false);
mainGame->deckBuilder.filterList = deckManager._lfList[0].content;
mainGame->cbDBLFList->setSelected(0);
......@@ -227,14 +231,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->cbAttribute->setSelected(0);
mainGame->cbRace->setSelected(0);
mainGame->ebAttack->setText(L"");
mainGame->ebDefence->setText(L"");
mainGame->ebDefense->setText(L"");
mainGame->ebStar->setText(L"");
mainGame->ebScale->setText(L"");
mainGame->cbCardType2->setEnabled(false);
mainGame->cbAttribute->setEnabled(false);
mainGame->cbRace->setEnabled(false);
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefence->setEnabled(false);
mainGame->ebDefense->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
mainGame->deckBuilder.filter_effect = 0;
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
......
......@@ -257,5 +257,8 @@ char Replay::ReadInt8() {
return -1;
return *pdata++;
}
void Replay::Rewind() {
pdata = replay_data;
}
}
......@@ -41,6 +41,7 @@ public:
int ReadInt32();
short ReadInt16();
char ReadInt8();
void Rewind();
FILE* fp;
ReplayHeader pheader;
......
......@@ -14,8 +14,11 @@ bool ReplayMode::is_closing = false;
bool ReplayMode::is_pausing = false;
bool ReplayMode::is_paused = false;
bool ReplayMode::is_swaping = false;
bool ReplayMode::is_restarting = false;
bool ReplayMode::exit_pending = false;
int ReplayMode::skip_turn = 0;
int ReplayMode::current_step = 0;
int ReplayMode::skip_step = 0;
bool ReplayMode::StartReplay(int skipturn) {
skip_turn = skipturn;
......@@ -52,7 +55,7 @@ bool ReplayMode::ReadReplayResponse() {
return result;
}
int ReplayMode::ReplayThread(void* param) {
ReplayHeader rh = cur_replay.pheader;
const ReplayHeader& rh = cur_replay.pheader;
mainGame->dInfo.isFirst = true;
mtrandom rnd;
int seed = rh.seed;
......@@ -63,6 +66,8 @@ int ReplayMode::ReplayThread(void* param) {
cur_replay.ReadData(mainGame->dInfo.clientname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
mainGame->dInfo.isTag = true;
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
} else {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
......@@ -81,29 +86,28 @@ int ReplayMode::ReplayThread(void* param) {
myswprintf(mainGame->dInfo.strLP[0], L"%d", mainGame->dInfo.lp[0]);
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
mainGame->dInfo.turn = 0;
mainGame->dInfo.strTurn[0] = 0;
if(!(opt & DUEL_TAG_MODE)) {
int main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
} else {
int main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
......@@ -113,10 +117,10 @@ int ReplayMode::ReplayThread(void* param) {
new_tag_card(pduel, cur_replay.ReadInt32(), 0, LOCATION_EXTRA);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
......@@ -135,6 +139,8 @@ int ReplayMode::ReplayThread(void* param) {
char engineBuffer[0x1000];
is_continuing = true;
exit_pending = false;
current_step = 0;
skip_step = 0;
if(skip_turn < 0)
skip_turn = 0;
if(skip_turn) {
......@@ -181,21 +187,130 @@ int ReplayMode::ReplayThread(void* param) {
}
return 0;
}
void ReplayMode::Restart(bool refresh) {
end_duel(pduel);
mainGame->dInfo.isStarted = false;
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay.Rewind();
const ReplayHeader& rh = cur_replay.pheader;
//mainGame->dInfo.isFirst = true;
mtrandom rnd;
int seed = rh.seed;
rnd.reset(seed);
if(rh.flag & REPLAY_TAG) {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.hostname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
mainGame->dInfo.isTag = true;
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
} else {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
}
//set_card_reader((card_reader)DataManager::CardReader);
//set_message_handler((message_handler)MessageHandler);
pduel = create_duel(rnd.rand());
int start_lp = cur_replay.ReadInt32();
int start_hand = cur_replay.ReadInt32();
int draw_count = cur_replay.ReadInt32();
int opt = cur_replay.ReadInt32();
set_player_info(pduel, 0, start_lp, start_hand, draw_count);
set_player_info(pduel, 1, start_lp, start_hand, draw_count);
mainGame->dInfo.lp[0] = start_lp;
mainGame->dInfo.lp[1] = start_lp;
myswprintf(mainGame->dInfo.strLP[0], L"%d", mainGame->dInfo.lp[0]);
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
mainGame->dInfo.turn = 0;
if(!(opt & DUEL_TAG_MODE)) {
int main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
} else {
int main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
int extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(0, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 0, LOCATION_DECK);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 0, LOCATION_EXTRA);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_card(pduel, cur_replay.ReadInt32(), 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
mainGame->dField.Initial(1, main, extra);
main = cur_replay.ReadInt32();
for(int i = 0; i < main; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 1, LOCATION_DECK);
extra = cur_replay.ReadInt32();
for(int i = 0; i < extra; ++i)
new_tag_card(pduel, cur_replay.ReadInt32(), 1, LOCATION_EXTRA);
}
start_duel(pduel, opt);
if(refresh) {
mainGame->dField.RefreshAllCards();
mainGame->dInfo.isStarted = true;
//mainGame->dInfo.isReplay = true;
}
skip_turn = 0;
is_restarting = true;
}
void ReplayMode::Undo() {
Restart(false);
skip_step = current_step - 1;
if(skip_step < 0)
skip_step = 0;
current_step = 0;
if(skip_step) {
mainGame->dInfo.isReplaySkiping = true;
mainGame->gMutex.Lock();
Pause(false, false);
} else
mainGame->dInfo.isReplaySkiping = false;
}
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
char* offset, *pbuf = msg;
char* pbuf = msg;
int player, count;
bool pauseable;
is_restarting = false;
while (pbuf - msg < (int)len) {
if(is_closing)
return false;
if(is_restarting) {
is_restarting = false;
return true;
}
if(is_swaping) {
mainGame->gMutex.Lock();
mainGame->dField.ReplaySwap();
mainGame->gMutex.Unlock();
is_swaping = false;
}
offset = pbuf;
pauseable = true;
char* offset = pbuf;
bool pauseable = true;
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
switch (mainGame->dInfo.curMsg) {
case MSG_RETRY: {
......@@ -662,11 +777,24 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
break;
}
}
if(pauseable && is_pausing) {
is_paused = true;
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
is_paused = false;
if(pauseable) {
if(skip_step) {
skip_step--;
if(skip_step == 0) {
Pause(true, false);
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
}
}
if(is_pausing) {
is_paused = true;
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
is_paused = false;
}
current_step++;
}
}
return true;
......
......@@ -17,8 +17,11 @@ private:
static bool is_pausing;
static bool is_paused;
static bool is_swaping;
static bool is_restarting;
static bool exit_pending;
static int skip_turn;
static int current_step;
static int skip_step;
public:
static Replay cur_replay;
......@@ -30,6 +33,8 @@ public:
static void Pause(bool is_pause, bool is_step);
static bool ReadReplayResponse();
static int ReplayThread(void* param);
static void Restart(bool refresh);
static void Undo();
static bool ReplayAnalyze(char* msg, unsigned int len);
static void ReplayRefresh(int flag = 0x781fff);
......
......@@ -474,22 +474,22 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.Flush();
last_replay.WriteInt32(pdeck[0].main.size(), false);
for(int32 i = (int32)pdeck[0].main.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[0].main[i]->first, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[0].main[i]->first, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[0].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[0].extra.size(), false);
for(int32 i = (int32)pdeck[0].extra.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[0].extra[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[0].extra[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[0].extra[i]->first, false);
}
last_replay.WriteInt32(pdeck[1].main.size(), false);
for(int32 i = (int32)pdeck[1].main.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[1].main[i]->first, 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[1].main[i]->first, 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[1].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[1].extra.size(), false);
for(int32 i = (int32)pdeck[1].extra.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[1].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[1].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[1].extra[i]->first, false);
}
last_replay.Flush();
......@@ -959,11 +959,19 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
break;
}
case MSG_SWAP: {
int c1 = pbuf[4];
int l1 = pbuf[5];
int s1 = pbuf[6];
int c2 = pbuf[12];
int l2 = pbuf[13];
int s2 = pbuf[14];
pbuf += 16;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
RefreshSingle(c1, l1, s1);
RefreshSingle(c2, l2, s2);
break;
}
case MSG_FIELD_DISABLED: {
......
......@@ -47,7 +47,6 @@ int SingleMode::SinglePlayThread(void* param) {
BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20);
mainGame->dInfo.clientname[0] = 0;
mainGame->dInfo.turn = 0;
mainGame->dInfo.strTurn[0] = 0;
if(!preload_script(pduel, fname2, slen)) {
end_duel(pduel);
return 0;
......
......@@ -450,12 +450,12 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
//
last_replay.WriteInt32(pdeck[0].main.size(), false);
for(int32 i = (int32)pdeck[0].main.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[0].main[i]->first, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[0].main[i]->first, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[0].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[0].extra.size(), false);
for(int32 i = (int32)pdeck[0].extra.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[0].extra[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[0].extra[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[0].extra[i]->first, false);
}
//
......@@ -472,12 +472,12 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
//
last_replay.WriteInt32(pdeck[3].main.size(), false);
for(int32 i = (int32)pdeck[3].main.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[3].main[i]->first, 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[3].main[i]->first, 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[3].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[3].extra.size(), false);
for(int32 i = (int32)pdeck[3].extra.size() - 1; i >= 0; --i) {
new_card(pduel, pdeck[3].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENCE);
new_card(pduel, pdeck[3].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[3].extra[i]->first, false);
}
//
......@@ -932,6 +932,12 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
break;
}
case MSG_SWAP: {
int c1 = pbuf[4];
int l1 = pbuf[5];
int s1 = pbuf[6];
int c2 = pbuf[12];
int l2 = pbuf[13];
int s2 = pbuf[14];
pbuf += 16;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
......@@ -939,6 +945,8 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(players[3]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
RefreshSingle(c1, l1, s1);
RefreshSingle(c2, l2, s2);
break;
}
case MSG_FIELD_DISABLED: {
......
Subproject commit db298072153b0ff5c0d287172681ca1f9c3a6a04
Subproject commit 8f6ed154785a9bac433feaffda147c1def53e708
Subproject commit 37f6152e1c5361511b6a2efc31c4019baad1df38
Subproject commit 9f812e233303463fc4f1b91e7764022a951882c1
......@@ -279,6 +279,9 @@
!system 1281 自定义
!system 1290 忽略对方发言
!system 1291 忽略观战者发言
!system 1292 忽略时点
!system 1293 显示时点
!system 1294 可用时点
!system 1300 禁限卡表:
!system 1301 卡组列表:
!system 1302 保存
......@@ -287,6 +290,7 @@
!system 1305 排序
!system 1306 退出编辑
!system 1307 打乱
!system 1308 删除
!system 1310 (无)
!system 1311 种类:
!system 1312 怪兽
......@@ -303,8 +307,7 @@
!system 1324 星数:
!system 1325 关键字:
!system 1326 效果
!system 1327 重新搜索
!system 1328 结果中搜索
!system 1327 搜索
!system 1329 系列:
!system 1330 主卡组:
!system 1331 额外卡组:
......@@ -312,6 +315,9 @@
!system 1333 搜索结果:
!system 1334 副卡组更换完成
!system 1335 保存成功
!system 1336 刻度:
!system 1337 是否删除这个卡组?
!system 1338 删除成功
!system 1340 是否保存录像?
!system 1341 保存
!system 1342 录像文件:
......@@ -327,6 +333,12 @@
!system 1352 主要信息:
!system 1353 播放起始于回合:
!system 1354 不显示卡片系列
!system 1355 不显示询问连锁按钮
!system 1360 上一步
!system 1370 星数↑
!system 1371 攻击↑
!system 1372 守备↑
!system 1373 名称↓
!system 1390 等待行动中...
!system 1391 等待行动中....
!system 1392 等待行动中.....
......@@ -434,7 +446,7 @@
!counter 0x27 指示物(死亡蚊)
!counter 0x28 指示物(暗黑投射手)
!counter 0x29 指示物(气球蜥蜴)
!counter 0x2a 指示物(魔法防护器)
!counter 0x102a 指示物(魔法防护器)
!counter 0x2b 命运指示物
!counter 0x2c 遵命指示物
!counter 0x2d 指示物(踢火)
......@@ -449,6 +461,8 @@
!counter 0x36 娱乐法师指示物
!counter 0x37 大怪兽指示物
!counter 0x1038 方界指示物
!counter 0x1039 咕咚指示物
!counter 0x40 指示物(No.51 怪腕之必杀摔角手)
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......@@ -641,6 +655,7 @@
!setname 0x92 纹章 メダリオン
!setname 0x93 电子 サイバー
!setname 0x1093 电子龙 サイバー・ドラゴン
!setname 0x2093 电子化天使 サイバー・エンジェル
!setname 0x94 电子科技 サイバネティック
!setname 0x95 升阶魔法 RUM
!setname 0x96 电子鱼人 フィッシュボーグ
......@@ -662,7 +677,8 @@
!setname 0x20a2 魔术少女 マジシャン・ガール
!setname 0x30a2 黑魔术少女 ブラック・マジシャン・ガール
!setname 0xa3 星尘 スターダスト
!setname 0xa4 羽翼栗子球 ハネクリボー
!setname 0xa4 栗子球 クリボー
!setname 0x10a4 羽翼栗子球 ハネクリボー
!setname 0xa5 变化 チェンジ
!setname 0xa6 幼芽 スプラウト
!setname 0xa7 阿托利斯 アルトリウス
......@@ -735,3 +751,7 @@
!setname 0xe2 三形金字塔 トラミッド
!setname 0xe3 方界
!setname 0xe4 精灵剑士 エルフの剣士
!setname 0xe5 光波 サイファー
!setname 0xe6 花札卫 花札衛
!setname 0xe7 沉默剑士 サイレント・ソードマン
!setname 0xe8 沉默魔术师 サイレント・マジシャン
......@@ -18,6 +18,7 @@ waitchain = 0
mute_opponent = 0
mute_spectators = 0
hide_setname = 0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
hide_chain_button = 0
#control_mode = 0: Key A/S/D/R. control_mode = 1: MouseLeft/MouseRight/NULL/F9
control_mode = 0
draw_field_spell = 1
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