Commit 03a3fad4 authored by edo9300's avatar edo9300

Updated custom rule cards handling

parent bebd0326
......@@ -643,10 +643,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_WHEEL: {
if(!mainGame->scrFilter->isVisible())
break;
if(mainGame->env->hasFocus(mainGame->scrFilter))
break;
irr::gui::IGUIElement* root = mainGame->env->getRootGUIElement();
if(root->getElementFromPoint(mouse_pos) != root)
if(!mainGame->Resize(805, 160, 1020, 630).isPointInside(mouse_pos))
break;
if(event.MouseInput.Wheel < 0) {
if(mainGame->scrFilter->getPos() < mainGame->scrFilter->getMax())
......
......@@ -137,26 +137,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
cscg.info.no_shuffle_deck = mainGame->chkNoShuffleDeck->isChecked();
cscg.info.check = 2;
cscg.info.forbiddentypes = mainGame->forbiddentypes;
cscg.info.sealed = mainGame->chkRules[0]->isChecked();
cscg.info.booster = mainGame->chkRules[1]->isChecked();
cscg.info.destiny_draw = mainGame->chkRules[2]->isChecked();
cscg.info.speed = mainGame->chkRules[3]->isChecked();
cscg.info.concentration = mainGame->chkRules[4]->isChecked();
cscg.info.boss = mainGame->chkRules[5]->isChecked();
cscg.info.city = mainGame->chkRules[6]->isChecked();
cscg.info.kingdom = mainGame->chkRules[7]->isChecked();
cscg.info.dimension = mainGame->chkRules[8]->isChecked();
cscg.info.doubled = mainGame->chkRules[9]->isChecked();
cscg.info.turbo2 = mainGame->chkRules[10]->isChecked();
cscg.info.turbo1 = mainGame->chkRules[11]->isChecked();
cscg.info.command = mainGame->chkRules[12]->isChecked();
cscg.info.master = mainGame->chkRules[13]->isChecked();
cscg.info.rule_count = 0;
for (int i = 0; i < 14; ++i) {
if (mainGame->chkRules[i]->isChecked() && i != 3 && i != 11) {
cscg.info.rule_count++;
}
}
cscg.info.extra_rules = mainGame->extra_rules;
SendPacketToServer(CTOS_CREATE_GAME, cscg);
} else {
CTOS_JoinGame csjg;
......@@ -432,9 +413,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_JOIN_GAME: {
temp_ver = 0;
STOC_JoinGame* pkt = (STOC_JoinGame*)pdata;
std::wstring str;
std::wstring str2;
bool host2 = false;
std::wstring str, str2;
wchar_t msgbuf[256];
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist));
str.append(msgbuf);
......@@ -470,84 +449,20 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
if (pkt->info.duel_flag & filter) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1631 + i));
str2.append(msgbuf);
host2 = true;
}
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1630));
str.append(msgbuf);
} else if (rule != DEFAULT_DUEL_RULE) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1260 + rule - 1));
str.append(msgbuf);
}
mainGame->dInfo.lua64 = pkt->info.check == 2;
if(pkt->info.check == 2) {
if (pkt->info.destiny_draw) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1134));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.sealed) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1132));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.booster) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1133));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.speed) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1135));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.concentration) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1136));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.boss) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1137));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.city) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1138));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.kingdom) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1139));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.dimension) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1140));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.doubled) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1141));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.turbo2) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1142));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.turbo1) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1143));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.command) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1144));
str2.append(msgbuf);
host2 = true;
}
if (pkt->info.master) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1145));
str2.append(msgbuf);
host2 = true;
}
for(int flag = SEALED_DUEL, i = 0; flag < DECK_MASTER + 1; flag = flag << 1, i++)
if(pkt->info.extra_rules & flag) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1132 + i));
str2.append(msgbuf);
}
}
if(pkt->info.no_check_deck) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1229));
......@@ -645,7 +560,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->RefreshDeck(mainGame->cbDeckSelect);
mainGame->RefreshDeck(mainGame->cbDeckSelect2);
mainGame->cbDeckSelect->setEnabled(true);
if (pkt->info.check == 2 && pkt->info.doubled) {
if (pkt->info.check == 2 && pkt->info.extra_rules & DOUBLE_DECK) {
mainGame->cbDeckSelect2->setVisible(true);
mainGame->cbDeckSelect2->setEnabled(true);
} else {
......@@ -657,11 +572,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if (mainGame->wLanWindow->isVisible())
mainGame->HideElement(mainGame->wLanWindow);
mainGame->ShowElement(mainGame->wHostPrepare);
if(host2)
if(str2.size())
mainGame->ShowElement(mainGame->wHostPrepare2);
mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock();
mainGame->dInfo.extraval = (pkt->info.check == 2 && pkt->info.speed) ? 1 : 0;
mainGame->dInfo.extraval = (pkt->info.check == 2 && pkt->info.extra_rules & DUEL_SPEED) ? 1 : 0;
if(mainGame->dInfo.isRelay)
mainGame->dInfo.isFirst = mainGame->dInfo.player_type < 3;
else if (mainGame->dInfo.isTag)
......@@ -4241,8 +4156,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
hoststr.append(L"][");
if(pHP->host.draw_count == 1 && pHP->host.start_hand == 5 && pHP->host.start_lp == 8000
&& !pHP->host.no_check_deck && !pHP->host.no_shuffle_deck
&& rule == DEFAULT_DUEL_RULE && !pHP->host.destiny_draw
&& pHP->host.rule_count==0)
&& rule == DEFAULT_DUEL_RULE && pHP->host.extra_rules==0)
hoststr.append(dataManager.GetSysString(1280));
else hoststr.append(dataManager.GetSysString(1281));
hoststr.append(L"]");
......
......@@ -170,8 +170,9 @@ bool Game::Initialize() {
wRules->setDraggable(true);
wRules->setVisible(false);
btnRulesOK = env->addButton(rect<s32>(135, 175, 235, 200), wRules, BUTTON_RULE_OK, dataManager.GetSysString(1211));
for(int i = 0; i < 14; ++i)
chkRules[i] = env->addCheckBox(false, recti(10 + (i % 2) * 150, 10 + (i / 2) * 20, 200 + (i % 2) * 120, 30 + (i / 2) * 20), wRules, 353+i, dataManager.GetSysString(1132 + i));
for(int i = 0; i < 13; ++i)
chkRules[i] = env->addCheckBox(false, recti(10 + (i % 2) * 150, 10 + (i / 2) * 20, 200 + (i % 2) * 120, 30 + (i / 2) * 20), wRules, CHECKBOX_EXTRA_RULE, dataManager.GetSysString(1132 + i));
mainGame->extra_rules = 0;
env->addStaticText(dataManager.GetSysString(1236), rect<s32>(20, 180, 220, 200), false, false, wCreateHost);
cbDuelRule = env->addComboBox(rect<s32>(140, 175, 300, 200), wCreateHost, COMBOBOX_DUEL_RULE);
cbDuelRule->addItem(dataManager.GetSysString(1260));
......@@ -1542,6 +1543,39 @@ void Game::UpdateDuelParam() {
duel_param = flag;
forbiddentypes = flag2;
}
void Game::UpdateExtraRules() {
for(int i = 0; i < 13; i++)
chkRules[i]->setEnabled(true);
if(chkRules[0]->isChecked()) {
chkRules[1]->setEnabled(false);
chkRules[5]->setEnabled(false);
}
if(chkRules[1]->isChecked()) {
chkRules[0]->setEnabled(false);
chkRules[5]->setEnabled(false);
}
if(chkRules[5]->isChecked()) {
chkRules[0]->setEnabled(false);
chkRules[1]->setEnabled(false);
}
if(chkRules[6]->isChecked()) {
chkRules[7]->setEnabled(false);
chkRules[8]->setEnabled(false);
}
if(chkRules[7]->isChecked()) {
chkRules[6]->setEnabled(false);
chkRules[8]->setEnabled(false);
}
if(chkRules[8]->isChecked()) {
chkRules[6]->setEnabled(false);
chkRules[7]->setEnabled(false);
}
extra_rules = 0;
for(int flag = 1, i = 0; i < 13; i++, flag = flag << 1) {
if(chkRules[i]->isChecked())
extra_rules |= flag;
}
}
int Game::GetMasterRule(uint32 param, uint32 forbiddentypes, int* truerule) {
switch(param) {
case MASTER_RULE_1: {
......
......@@ -139,6 +139,7 @@ public:
int LocalPlayer(int player);
const wchar_t* LocalName(int local_player);
void UpdateDuelParam();
void UpdateExtraRules();
int GetMasterRule(uint32 param, uint32 forbidden, int* truerule = 0);
void SetPhaseButtons();
......@@ -201,6 +202,7 @@ public:
bool is_building;
bool is_siding;
int forbiddentypes;
unsigned short extra_rules;
uint32 duel_param;
uint32 showingcard;
......@@ -283,7 +285,7 @@ public:
irr::gui::IGUIEditBox* ebServerPass;
irr::gui::IGUIButton* btnRuleCards;
irr::gui::IGUIWindow* wRules;
irr::gui::IGUICheckBox* chkRules[14];
irr::gui::IGUICheckBox* chkRules[13];
irr::gui::IGUIButton* btnRulesOK;
irr::gui::IGUIComboBox* cbDuelRule;
irr::gui::IGUIButton* btnCustomRule;
......@@ -648,23 +650,10 @@ extern Game* mainGame;
#define LISTBOX_SINGLEPLAY_LIST 350
#define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECK_SEALED_DUEL 353
#define CHECK_BOOSTER_DUEL 354
#define CHECK_DESTINY_DRAW 355
#define CHECK_SPEED_DUEL 356
#define CHECK_CONCENTRATION_DUEL 357
#define CHECK_BOSS_DUEL 358
#define CHECK_BATTLE_CITY 359
#define CHECK_DUELIST_KINGDOM 360
#define CHECK_DIMENSION_DUEL 361
#define CHECK_DOUBLE_DECK 362
#define CHECK_TURBO_DUEL_2 363
#define CHECK_TURBO_DUEL_1 364
#define CHECK_COMMAND_DUEL 365
#define CHECK_DECK_MASTER_DUEL 366
#define CHECKBOX_ENABLE_MUSIC 361
#define SCROLL_VOLUME 362
#define CHECKBOX_SHOW_ANIME 363
#define CHECKBOX_EXTRA_RULE 353
#define CHECKBOX_ENABLE_MUSIC 366
#define SCROLL_VOLUME 367
#define CHECKBOX_SHOW_ANIME 368
#define COMBOBOX_SORTTYPE 370
#define BUTTON_MARKS_FILTER 380
......
......@@ -32,7 +32,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
s32 id = caller->getID();
if(mainGame->wRules->isVisible() && (id != BUTTON_RULE_OK && (id < CHECK_SEALED_DUEL || id > CHECK_DECK_MASTER_DUEL)))
if(mainGame->wRules->isVisible() && (id != BUTTON_RULE_OK && id != CHECKBOX_EXTRA_RULE))
break;
if(mainGame->wCustomRules->isVisible() && id != BUTTON_CUSTOM_RULE_OK && (id < CHECKBOX_OBSOLETE || id > CHECKBOX_EMZONE))
break;
......@@ -526,91 +526,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case CHECK_SEALED_DUEL: {
if (static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
for (int i = 1; i < 14; ++i)
if (i != 2 && i != 3 && i != 9)
mainGame->chkRules[i]->setEnabled(false);
}
else {
for (int i = 1; i < 14; ++i)
if (i != 2 && i != 3 && i != 9)
mainGame->chkRules[i]->setEnabled(true);
}
break;
}
case CHECK_BOOSTER_DUEL: {
if (static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
for (int i = 0; i < 14; ++i)
if(i != 1 && i != 2 && i != 3 && i != 9)
mainGame->chkRules[i]->setEnabled(false);
}
else {
for (int i = 0; i < 14; ++i)
if (i != 1 && i != 2 && i != 3 && i != 9)
mainGame->chkRules[i]->setEnabled(true);
}
break;
}
case CHECK_CONCENTRATION_DUEL:
case CHECK_BOSS_DUEL:
case CHECK_BATTLE_CITY:
case CHECK_DUELIST_KINGDOM:
case CHECK_COMMAND_DUEL:
case CHECK_DECK_MASTER_DUEL: {
if (static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
for (int i = 0; i < 2; ++i)
mainGame->chkRules[i]->setEnabled(false);
}
else {
for (int i = 0; i < 2; ++i)
mainGame->chkRules[i]->setEnabled(true);
for (int i = 0; i < 14; ++i) {
if (mainGame->chkRules[i]->isChecked() && i != 3 && i != 9)
for (int i = 0; i < 2; ++i)
mainGame->chkRules[i]->setEnabled(false);
}
}
break;
}
case CHECK_TURBO_DUEL_1: {
if (static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
for (int i = 0; i < 3; ++i)
mainGame->chkRules[i]->setEnabled(false);
mainGame->chkRules[10]->setEnabled(false);
}
else {
for (int i = 0; i < 3; ++i)
mainGame->chkRules[i]->setEnabled(true);
mainGame->chkRules[10]->setEnabled(true);
for (int i = 0; i < 14; ++i) {
if (mainGame->chkRules[i]->isChecked() && i != 3 && i != 9)
for (int i = 0; i < 1; ++i)
mainGame->chkRules[i]->setEnabled(false);
}
}
break;
}
case CHECK_TURBO_DUEL_2: {
if (static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
for (int i = 0; i < 3; ++i)
mainGame->chkRules[i]->setEnabled(false);
mainGame->chkRules[11]->setEnabled(false);
}
else {
for (int i = 0; i < 3; ++i)
mainGame->chkRules[i]->setEnabled(true);
mainGame->chkRules[11]->setEnabled(true);
for (int i = 0; i < 14; ++i) {
if (mainGame->chkRules[i]->isChecked() && i != 3 && i != 9)
for (int i = 0; i < 1; ++i)
mainGame->chkRules[i]->setEnabled(false);
}
}
case CHECKBOX_EXTRA_RULE: {
mainGame->UpdateExtraRules();
break;
}
case CHECKBOX_PZONE: {
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked())
if(mainGame->chkCustomRules[3]->isChecked())
mainGame->chkCustomRules[4]->setEnabled(true);
else {
mainGame->chkCustomRules[4]->setChecked(false);
......@@ -710,4 +631,4 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
return false;
}
}
}
\ No newline at end of file
......@@ -25,21 +25,7 @@ struct HostInfo {
unsigned char check;
unsigned int duel_flag;
int forbiddentypes;
bool destiny_draw;
bool sealed;
bool booster;
bool speed;
bool concentration;
bool boss;
bool city;
bool kingdom;
bool dimension;
bool turbo1;
bool turbo2;
bool doubled;
bool command;
bool master;
int rule_count;
unsigned short extra_rules;
};
struct HostPacket {
unsigned short identifier;
......@@ -242,4 +228,18 @@ public:
#define MODE_MATCH 0x1
#define MODE_TAG 0x2
#define MODE_RELAY 0x3
#define SEALED_DUEL 0x1
#define BOOSTER_DUEL 0x2
#define DESTINY_DRAW 0x4
#define DUEL_SPEED 0x8
#define CONCENTRATION_DUEL 0x10
#define BOSS_DUEL 0x20
#define BATTLE_CITY 0x40
#define DUELIST_KINGDOM 0x80
#define DIMENSTION_DUEL 0x100
#define TURBO_DUEL 0x200
#define DOUBLE_DECK 0x400
#define COMMAND_DUEL 0x800
#define DECK_MASTER 0x1000
#endif //NETWORK_H
......@@ -162,7 +162,7 @@ namespace ygo {
mainGame->dInfo.duel_field = 4;
else if (opt & DUEL_PZONE)
mainGame->dInfo.duel_field = 3;
mainGame->dInfo.extraval = (opt & SPEED_DUEL);
mainGame->dInfo.extraval = (opt & SPEED_DUEL) ? 1 : 0;
mainGame->SetPhaseButtons();
set_player_info(pduel, 0, start_lp, start_hand, draw_count);
set_player_info(pduel, 1, start_lp, start_hand, draw_count);
......
......@@ -224,7 +224,7 @@ void RelayDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
} else {
bool allow_ocg = host_info.rule == 0 || host_info.rule == 2;
bool allow_tcg = host_info.rule == 1 || host_info.rule == 2;
deckerror = deckManager.CheckDeck(players[dp->type].pdeck, host_info.lflist, allow_ocg, allow_tcg, host_info.doubled, host_info.forbiddentypes);
deckerror = deckManager.CheckDeck(players[dp->type].pdeck, host_info.lflist, allow_ocg, allow_tcg, host_info.extra_rules & DOUBLE_DECK, host_info.forbiddentypes);
}
}
if(deckerror) {
......@@ -258,7 +258,7 @@ void RelayDuel::UpdateDeck(DuelPlayer* dp, void* pdata) {
char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
players[dp->type].deck_error = deckManager.LoadDeck(players[dp->type].pdeck, (int*)deckbuf, mainc, sidec, 0, 0, host_info.doubled);
players[dp->type].deck_error = deckManager.LoadDeck(players[dp->type].pdeck, (int*)deckbuf, mainc, sidec, 0, 0, host_info.extra_rules & DOUBLE_DECK);
}
void RelayDuel::StartDuel(DuelPlayer* dp) {
if(dp != host_player)
......@@ -430,7 +430,7 @@ void RelayDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
int opt = host_info.duel_flag;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
if(host_info.speed)
if(host_info.extra_rules & DUEL_SPEED)
opt |= SPEED_DUEL;
opt |= DUEL_RELAY_MODE;
new_replay.WriteInt32((mainGame->GetMasterRule(opt, 0)) | (opt & SPEED_DUEL) << 8);
......@@ -440,60 +440,39 @@ void RelayDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteInt32(opt, false);
last_replay.Flush();
//
last_replay.WriteInt32(players[startp[0]].pdeck.main.size() + host_info.rule_count, false);
std::vector<unsigned int> extracards;
if(host_info.extra_rules & SEALED_DUEL)
extracards.push_back(511005092);
if(host_info.extra_rules & BOOSTER_DUEL)
extracards.push_back(511005093);
if(host_info.extra_rules & CONCENTRATION_DUEL)
extracards.push_back(511004322);
if(host_info.extra_rules & BOSS_DUEL)
extracards.push_back(95000000);
if(host_info.extra_rules & BATTLE_CITY)
extracards.push_back(511004014);
if(host_info.extra_rules & DUELIST_KINGDOM)
extracards.push_back(511002621);
if(host_info.extra_rules & DIMENSTION_DUEL)
extracards.push_back(511600002);
if(host_info.extra_rules & TURBO_DUEL)
extracards.push_back(302);
if(host_info.extra_rules & COMMAND_DUEL)
extracards.push_back(95200000);
if(host_info.extra_rules & DECK_MASTER)
extracards.push_back(300);
if(host_info.extra_rules & DESTINY_DRAW)
extracards.push_back(511004000);
last_replay.WriteInt32(players[startp[0]].pdeck.main.size(), false);
for(int32 i = (int32)players[startp[0]].pdeck.main.size() - 1; i >= 0; --i) {
new_card(pduel, players[startp[0]].pdeck.main[i]->first, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
new_card(pduel, players[startp[0]].pdeck.main[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(players[startp[0]].pdeck.main[i]->first, false);
}
if(host_info.sealed) {
new_card(pduel, 511005092, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005092, false);
last_replay.WriteInt32(players[startp[0]].pdeck.extra.size() + extracards.size(), false);
for(int32 i = (int32)extracards.size() - 1; i >= 0; --i) {
new_card(pduel, extracards[i], 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(extracards[i], false);
}
if(host_info.booster) {
new_card(pduel, 511005093, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005093, false);
}
if(host_info.concentration) {
new_card(pduel, 511004322, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004322, false);
}
if(host_info.boss) {
new_card(pduel, 95000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95000000, false);
}
if(host_info.city) {
new_card(pduel, 511004014, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004014, false);
}
if(host_info.kingdom) {
new_card(pduel, 511002621, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002621, false);
}
if(host_info.dimension) {
new_card(pduel, 511600002, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511600002, false);
}
if(host_info.turbo1) {
new_card(pduel, 511002094, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002094, false);
}
if(host_info.turbo2) {
new_card(pduel, 110000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(110000000, false);
}
if(host_info.command) {
new_card(pduel, 95200000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95200000, false);
}
if(host_info.master) {
new_card(pduel, 300, 0, 0, 0, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(300, false);
}
if(host_info.destiny_draw) {
new_card(pduel, 511004000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004000, false);
}
last_replay.WriteInt32(players[startp[0]].pdeck.extra.size(), false);
for(int32 i = (int32)players[startp[0]].pdeck.extra.size() - 1; i >= 0; --i) {
new_card(pduel, players[startp[0]].pdeck.extra[i]->first, 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(players[startp[0]].pdeck.extra[i]->first, false);
......
......@@ -83,7 +83,7 @@ int ReplayMode::ReplayThread(void* param) {
}
int opt = cur_replay.ReadInt32();
mainGame->dInfo.duel_field = opt & 0xff;
mainGame->dInfo.extraval = (opt >> 8);
mainGame->dInfo.extraval = ((opt >> 8) & SPEED_DUEL) ? 1 : 0;
mainGame->SetPhaseButtons();
if(!cur_replay.ReadStream(&current_stream)) {
EndDuel();
......
......@@ -263,7 +263,7 @@ void SingleDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
} else {
bool allow_ocg = host_info.rule == 0 || host_info.rule == 2;
bool allow_tcg = host_info.rule == 1 || host_info.rule == 2;
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg, host_info.doubled, host_info.forbiddentypes);
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg, host_info.extra_rules & DOUBLE_DECK, host_info.forbiddentypes);
}
}
if(deckerror) {
......@@ -298,7 +298,7 @@ void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata) {
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
if(duel_count == 0) {
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec,0,0, host_info.doubled);
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec,0,0, host_info.extra_rules & DOUBLE_DECK);
} else {
if(deckManager.LoadSide(pdeck[dp->type], (int*)deckbuf, mainc, sidec)) {
ready[dp->type] = true;
......@@ -435,68 +435,47 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
int opt = host_info.duel_flag;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
if(host_info.speed)
if(host_info.extra_rules & DUEL_SPEED)
opt |= SPEED_DUEL;
new_replay.WriteInt32((mainGame->GetMasterRule(opt, 0)) | (opt & SPEED_DUEL) << 8);
new_replay.WriteInt32((mainGame->GetMasterRule(opt & ~SPEED_DUEL, 0)) | (opt & SPEED_DUEL) << 8);
last_replay.WriteInt32(host_info.start_lp, false);
last_replay.WriteInt32(host_info.start_hand, false);
last_replay.WriteInt32(host_info.draw_count, false);
last_replay.WriteInt32(opt, false);
last_replay.Flush();
last_replay.WriteInt32(pdeck[0].main.size() + host_info.rule_count, false);
if(host_info.sealed) {
new_card(pduel, 511005092, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005092, false);
}
if(host_info.booster) {
new_card(pduel, 511005093, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005093, false);
}
if(host_info.concentration) {
new_card(pduel, 511004322, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004322, false);
}
if(host_info.boss) {
new_card(pduel, 95000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95000000, false);
}
if(host_info.city) {
new_card(pduel, 511004014, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004014, false);
}
if(host_info.kingdom) {
new_card(pduel, 511002621, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002621, false);
}
if(host_info.dimension) {
new_card(pduel, 511600002, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511600002, false);
}
if(host_info.turbo1) {
new_card(pduel, 511002094, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002094, false);
}
if(host_info.turbo2) {
new_card(pduel, 110000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(110000000, false);
}
if(host_info.command) {
new_card(pduel, 95200000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95200000, false);
}
if(host_info.master) {
new_card(pduel, 300, 0, 0, 0, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(300, false);
}
if(host_info.destiny_draw) {
new_card(pduel, 511004000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004000, false);
}
std::vector<unsigned int> extracards;
if(host_info.extra_rules & SEALED_DUEL)
extracards.push_back(511005092);
if(host_info.extra_rules & BOOSTER_DUEL)
extracards.push_back(511005093);
if(host_info.extra_rules & CONCENTRATION_DUEL)
extracards.push_back(511004322);
if(host_info.extra_rules & BOSS_DUEL)
extracards.push_back(95000000);
if(host_info.extra_rules & BATTLE_CITY)
extracards.push_back(511004014);
if(host_info.extra_rules & DUELIST_KINGDOM)
extracards.push_back(511002621);
if(host_info.extra_rules & DIMENSTION_DUEL)
extracards.push_back(511600002);
if(host_info.extra_rules & TURBO_DUEL)
extracards.push_back(302);
if(host_info.extra_rules & COMMAND_DUEL)
extracards.push_back(95200000);
if(host_info.extra_rules & DECK_MASTER)
extracards.push_back(300);
if(host_info.extra_rules & DESTINY_DRAW)
extracards.push_back(511004000);
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_DEFENSE);
last_replay.WriteInt32(pdeck[0].main[i]->first, false);
}
last_replay.WriteInt32(pdeck[0].extra.size(), false);
last_replay.WriteInt32(pdeck[0].extra.size() + extracards.size(), false);
for(int32 i = (int32)extracards.size() - 1; i >= 0; --i) {
new_card(pduel, extracards[i], 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(extracards[i], 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_DEFENSE);
last_replay.WriteInt32(pdeck[0].extra[i]->first, false);
......
......@@ -229,7 +229,7 @@ void TagDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
} else {
bool allow_ocg = host_info.rule == 0 || host_info.rule == 2;
bool allow_tcg = host_info.rule == 1 || host_info.rule == 2;
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg, host_info.doubled, host_info.forbiddentypes);
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg, host_info.extra_rules & DOUBLE_DECK, host_info.forbiddentypes);
}
}
if(deckerror) {
......@@ -263,7 +263,7 @@ void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata) {
char* deckbuf = (char*)pdata;
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec, 0, 0, host_info.doubled);
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec, 0, 0, host_info.extra_rules & DOUBLE_DECK);
}
void TagDuel::StartDuel(DuelPlayer* dp) {
if(dp != host_player)
......@@ -402,7 +402,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
int opt = host_info.duel_flag;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
if(host_info.speed)
if(host_info.extra_rules & DUEL_SPEED)
opt |= SPEED_DUEL;
opt |= DUEL_TAG_MODE;
new_replay.WriteInt32((mainGame->GetMasterRule(opt, 0)) | (opt & SPEED_DUEL) << 8);
......@@ -412,60 +412,39 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteInt32(opt, false);
last_replay.Flush();
//
last_replay.WriteInt32(pdeck[0].main.size() + host_info.rule_count, false);
std::vector<unsigned int> extracards;
if(host_info.extra_rules & SEALED_DUEL)
extracards.push_back(511005092);
if(host_info.extra_rules & BOOSTER_DUEL)
extracards.push_back(511005093);
if(host_info.extra_rules & CONCENTRATION_DUEL)
extracards.push_back(511004322);
if(host_info.extra_rules & BOSS_DUEL)
extracards.push_back(95000000);
if(host_info.extra_rules & BATTLE_CITY)
extracards.push_back(511004014);
if(host_info.extra_rules & DUELIST_KINGDOM)
extracards.push_back(511002621);
if(host_info.extra_rules & DIMENSTION_DUEL)
extracards.push_back(511600002);
if(host_info.extra_rules & TURBO_DUEL)
extracards.push_back(302);
if(host_info.extra_rules & COMMAND_DUEL)
extracards.push_back(95200000);
if(host_info.extra_rules & DECK_MASTER)
extracards.push_back(300);
if(host_info.extra_rules & DESTINY_DRAW)
extracards.push_back(511004000);
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_DEFENSE);
last_replay.WriteInt32(pdeck[0].main[i]->first, false);
}
if(host_info.sealed) {
new_card(pduel, 511005092, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005092, false);
last_replay.WriteInt32(pdeck[0].extra.size() + extracards.size(), false);
for(int32 i = (int32)extracards.size() - 1; i >= 0; --i) {
new_card(pduel, extracards[i], 0, 0, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(extracards[i], false);
}
if(host_info.booster) {
new_card(pduel, 511005093, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511005093, false);
}
if(host_info.concentration) {
new_card(pduel, 511004322, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004322, false);
}
if(host_info.boss) {
new_card(pduel, 95000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95000000, false);
}
if(host_info.city) {
new_card(pduel, 511004014, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004014, false);
}
if(host_info.kingdom) {
new_card(pduel, 511002621, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002621, false);
}
if(host_info.dimension) {
new_card(pduel, 511600002, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511600002, false);
}
if(host_info.turbo1) {
new_card(pduel, 511002094, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511002094, false);
}
if(host_info.turbo2) {
new_card(pduel, 110000000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(110000000, false);
}
if(host_info.command) {
new_card(pduel, 95200000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(95200000, false);
}
if(host_info.master) {
new_card(pduel, 300, 0, 0, 0, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(300, false);
}
if(host_info.destiny_draw) {
new_card(pduel, 511004000, 0, 0, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(511004000, 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_DEFENSE);
last_replay.WriteInt32(pdeck[0].extra[i]->first, false);
......@@ -482,18 +461,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay.WriteInt32(pdeck[1].extra[i]->first, false);
}
//
if(host_info.master)
last_replay.WriteInt32(pdeck[3].main.size() + 1, false);
else
last_replay.WriteInt32(pdeck[3].main.size(), false);
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_DEFENSE);
last_replay.WriteInt32(pdeck[3].main[i]->first, false);
}
if(host_info.master) {
new_card(pduel, 51100567, 1, 1, LOCATION_DECK, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(51100567, 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_DEFENSE);
......
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