Commit 6afd27b1 authored by edo9300's avatar edo9300

Merge remote-tracking branch 'refs/remotes/Fluorohydride/master'

parents b2d01a8f 6258542b
...@@ -1147,7 +1147,12 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1147,7 +1147,12 @@ bool ClientField::ShowSelectSum(bool panelmode) {
} else { } else {
select_ready = true; select_ready = true;
mainGame->wCardSelect->setVisible(false); mainGame->wCardSelect->setVisible(false);
mainGame->dField.ShowSelectCard(true); wchar_t wbuf[256], *pwbuf = wbuf;
BufferIO::CopyWStrRef(dataManager.GetSysString(209), pwbuf, 256);
*pwbuf++ = L'\n';
BufferIO::CopyWStrRef(dataManager.GetSysString(210), pwbuf, 256);
mainGame->stQMessage->setText(wbuf);
mainGame->PopupElement(mainGame->wQuery);
} }
} else { } else {
select_ready = false; select_ready = false;
...@@ -1176,11 +1181,10 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1176,11 +1181,10 @@ bool ClientField::ShowSelectSum(bool panelmode) {
} }
bool ClientField::CheckSelectSum() { bool ClientField::CheckSelectSum() {
std::set<ClientCard*> selable; std::set<ClientCard*> selable;
std::set<ClientCard*>::iterator sit; for(auto sit = selectsum_all.begin(); sit != selectsum_all.end(); ++sit) {
for(size_t i = 0; i < selectsum_all.size(); ++i) { (*sit)->is_selectable = false;
selectsum_all[i]->is_selectable = false; (*sit)->is_selected = false;
selectsum_all[i]->is_selected = false; selable.insert(*sit);
selable.insert(selectsum_all[i]);
} }
for(size_t i = 0; i < selected_cards.size(); ++i) { for(size_t i = 0; i < selected_cards.size(); ++i) {
if((int)i < must_select_count) if((int)i < must_select_count)
...@@ -1194,34 +1198,37 @@ bool ClientField::CheckSelectSum() { ...@@ -1194,34 +1198,37 @@ bool ClientField::CheckSelectSum() {
if (select_mode == 0) { if (select_mode == 0) {
bool ret = check_sel_sum_s(selable, 0, select_sumval); bool ret = check_sel_sum_s(selable, 0, select_sumval);
selectable_cards.clear(); selectable_cards.clear();
for(sit = selectsum_cards.begin(); sit != selectsum_cards.end(); ++sit) { for(auto sit = selectsum_cards.begin(); sit != selectsum_cards.end(); ++sit) {
(*sit)->is_selectable = true; (*sit)->is_selectable = true;
selectable_cards.push_back(*sit); selectable_cards.push_back(*sit);
} }
return ret; return ret;
} else { } else {
int op1, op2, mm = -1, ms, m, max = 0, sumc = 0, sums; int mm = -1, mx = -1, max = 0, sumc = 0;
bool ret = false; bool ret = false;
for (size_t i = 0; i < selected_cards.size(); ++i) { for (auto sit = selected_cards.begin(); sit != selected_cards.end(); ++sit) {
op1 = selected_cards[i]->opParam & 0xffff; int op1 = (*sit)->opParam & 0xffff;
op2 = selected_cards[i]->opParam >> 16; int op2 = (*sit)->opParam >> 16;
m = (op2 > 0 && op1 > op2) ? op2 : op1; int opmin = (op2 > 0 && op1 > op2) ? op2 : op1;
max += op2 > op1 ? op2 : op1; int opmax = op2 > op1 ? op2 : op1;
if (mm == -1 || m < mm) if (mm == -1 || opmin < mm)
mm = m; mm = opmin;
sumc += m; if (mx == -1 || opmax < mx)
mx = opmax;
sumc += opmin;
max += opmax;
} }
if (select_sumval <= sumc) if (select_sumval <= sumc)
return true; return true;
if (select_sumval <= max) if (select_sumval <= max && select_sumval > max - mx)
ret = true; ret = true;
for(sit = selable.begin(); sit != selable.end(); ++sit) { for(auto sit = selable.begin(); sit != selable.end(); ++sit) {
op1 = (*sit)->opParam & 0xffff; int op1 = (*sit)->opParam & 0xffff;
op2 = (*sit)->opParam >> 16; int op2 = (*sit)->opParam >> 16;
m = op1; int m = op1;
sums = sumc; int sums = sumc;
sums += m; sums += m;
ms = mm; int ms = mm;
if (ms == -1 || m < ms) if (ms == -1 || m < ms)
ms = m; ms = m;
if (sums >= select_sumval) { if (sums >= select_sumval) {
...@@ -1252,14 +1259,14 @@ bool ClientField::CheckSelectSum() { ...@@ -1252,14 +1259,14 @@ bool ClientField::CheckSelectSum() {
} }
} }
selectable_cards.clear(); selectable_cards.clear();
for(sit = selectsum_cards.begin(); sit != selectsum_cards.end(); ++sit) { for(auto sit = selectsum_cards.begin(); sit != selectsum_cards.end(); ++sit) {
(*sit)->is_selectable = true; (*sit)->is_selectable = true;
selectable_cards.push_back(*sit); selectable_cards.push_back(*sit);
} }
return ret; return ret;
} }
} }
bool ClientField::check_min(std::set<ClientCard*>& left, std::set<ClientCard*>::iterator index, int min, int max) { bool ClientField::check_min(const std::set<ClientCard*>& left, std::set<ClientCard*>::const_iterator index, int min, int max) {
if (index == left.end()) if (index == left.end())
return false; return false;
int op1 = (*index)->opParam & 0xffff; int op1 = (*index)->opParam & 0xffff;
...@@ -1491,8 +1498,13 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1491,8 +1498,13 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, declarable_type)) { if(is_declarable(cp->second, declarable_type)) {
mainGame->lstANCard->addItem(cit->second.name); if(wcscmp(pname, cit->second.name) == 0) { //exact match
ancard.push_back(cit->first); mainGame->lstANCard->insertItem(0, cit->second.name, -1);
ancard.insert(ancard.begin(), cit->first);
} else {
mainGame->lstANCard->addItem(cit->second.name);
ancard.push_back(cit->first);
}
} }
} }
} }
...@@ -1518,8 +1530,13 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1518,8 +1530,13 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings auto cp = dataManager.GetCodePointer(cit->first); //verified by _strings
//datas.alias can be double card names or alias //datas.alias can be double card names or alias
if(is_declarable(cp->second, opcode)) { if(is_declarable(cp->second, opcode)) {
mainGame->lstANCard->addItem(cit->second.name); if(wcscmp(pname, cit->second.name) == 0) { //exact match
ancard.push_back(cit->first); mainGame->lstANCard->insertItem(0, cit->second.name, -1);
ancard.insert(ancard.begin(), cit->first);
} else {
mainGame->lstANCard->addItem(cit->second.name);
ancard.push_back(cit->first);
}
} }
} }
} }
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
int select_sumval; int select_sumval;
int select_cancelable; int select_cancelable;
int select_mode; int select_mode;
bool select_panalmode;
bool select_ready; bool select_ready;
int announce_count; int announce_count;
int declarable_type; int declarable_type;
...@@ -102,7 +103,7 @@ public: ...@@ -102,7 +103,7 @@ public:
void FadeCard(ClientCard* pcard, int alpha, int frame); void FadeCard(ClientCard* pcard, int alpha, int frame);
bool ShowSelectSum(bool panelmode); bool ShowSelectSum(bool panelmode);
bool CheckSelectSum(); bool CheckSelectSum();
bool check_min(std::set<ClientCard*>& left, std::set<ClientCard*>::iterator index, int min, int max); bool check_min(const std::set<ClientCard*>& left, std::set<ClientCard*>::const_iterator index, int min, int max);
bool check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc); bool check_sel_sum_s(const std::set<ClientCard*>& left, int index, int acc);
void check_sel_sum_t(const std::set<ClientCard*>& left, int acc); void check_sel_sum_t(const std::set<ClientCard*>& left, int acc);
bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count); bool check_sum(std::set<ClientCard*>::const_iterator index, std::set<ClientCard*>::const_iterator end, int acc, int count);
......
...@@ -74,5 +74,7 @@ using namespace gui; ...@@ -74,5 +74,7 @@ using namespace gui;
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
extern int enable_log; extern int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
extern bool open_file;
extern wchar_t open_file_name[256];
#endif #endif
...@@ -9,7 +9,7 @@ DataManager dataManager; ...@@ -9,7 +9,7 @@ DataManager dataManager;
bool DataManager::LoadDB(const char* file) { bool DataManager::LoadDB(const char* file) {
sqlite3* pDB; sqlite3* pDB;
if(sqlite3_open(file, &pDB) != SQLITE_OK) if(sqlite3_open_v2(file, &pDB, SQLITE_OPEN_READONLY, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
sqlite3_stmt* pStmt; sqlite3_stmt* pStmt;
const char* sql = "select * from datas,texts where datas.id=texts.id"; const char* sql = "select * from datas,texts where datas.id=texts.id";
......
...@@ -88,7 +88,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -88,7 +88,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_SAVE_DECK: { case BUTTON_SAVE_DECK: {
if(deckManager.SaveDeck(deckManager.current_deck, mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()))) { int sel = mainGame->cbDBDecks->getSelected();
if(sel>-1 && deckManager.SaveDeck(deckManager.current_deck, mainGame->cbDBDecks->getItem(sel))) {
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
} }
...@@ -204,6 +205,11 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -204,6 +205,11 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf); DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
break; break;
} }
case BUTTON_MSG_OK: {
mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set();
break;
}
case BUTTON_YES: { case BUTTON_YES: {
mainGame->HideElement(mainGame->wQuery); mainGame->HideElement(mainGame->wQuery);
if(!mainGame->is_building || mainGame->is_siding) if(!mainGame->is_building || mainGame->is_siding)
......
...@@ -202,21 +202,28 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) { ...@@ -202,21 +202,28 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
deck = ndeck; deck = ndeck;
return true; return true;
} }
bool DeckManager::LoadDeck(const wchar_t* file) { FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
int sp = 0, ct = 0, mainc = 0, sidec = 0, code;
wchar_t deck[64];
myswprintf(deck, L"./deck/%ls.ydk", file);
int cardlist[128];
bool is_side = false;
#ifdef WIN32 #ifdef WIN32
FILE* fp = _wfopen(deck, L"r"); FILE* fp = _wfopen(file, (wchar_t*)mode);
#else #else
char deckfn[256]; char file2[256];
BufferIO::EncodeUTF8(deck, deckfn); BufferIO::EncodeUTF8(file, file2);
FILE* fp = fopen(deckfn, "r"); FILE* fp = fopen(file2, mode);
#endif #endif
return fp;
}
bool DeckManager::LoadDeck(const wchar_t* file) {
int sp = 0, ct = 0, mainc = 0, sidec = 0, code;
wchar_t localfile[64];
myswprintf(localfile, L"./deck/%ls.ydk", file);
FILE* fp = OpenDeckFile(localfile, "r");
if(!fp) {
fp = OpenDeckFile(file, "r");
}
if(!fp) if(!fp)
return false; return false;
int cardlist[128];
bool is_side = false;
char linebuf[256]; char linebuf[256];
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
int fsize = ftell(fp); int fsize = ftell(fp);
...@@ -312,13 +319,7 @@ bool DeckManager::LoadDeckDouble(const wchar_t* file, const wchar_t* file2) { ...@@ -312,13 +319,7 @@ bool DeckManager::LoadDeckDouble(const wchar_t* file, const wchar_t* file2) {
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) { bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
wchar_t file[64]; wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name); myswprintf(file, L"./deck/%ls.ydk", name);
#ifdef WIN32 FILE* fp = OpenDeckFile(file, "w");
FILE* fp = _wfopen(file, L"w");
#else
char filefn[256];
BufferIO::EncodeUTF8(file, filefn);
FILE* fp = fopen(filefn, "w");
#endif
if(!fp) if(!fp)
return false; return false;
fprintf(fp, "#created by ...\n#main\n"); fprintf(fp, "#created by ...\n#main\n");
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
int TypeCount(std::vector<code_pointer> cards, int type); int TypeCount(std::vector<code_pointer> cards, int type);
void LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, int mainc2=0, int sidec2=0, bool doubled = false); void LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, int mainc2=0, int sidec2=0, bool doubled = false);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec); bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
FILE* OpenDeckFile(const wchar_t * file, const char * mode);
bool LoadDeck(const wchar_t* file); bool LoadDeck(const wchar_t* file);
bool LoadDeckDouble(const wchar_t* file, const wchar_t* file2); bool LoadDeckDouble(const wchar_t* file, const wchar_t* file2);
bool SaveDeck(Deck& deck, const wchar_t* name); bool SaveDeck(Deck& deck, const wchar_t* name);
......
...@@ -616,6 +616,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -616,6 +616,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false);
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
...@@ -1042,7 +1044,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1042,7 +1044,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
desc = BufferIO::ReadInt32(pbuf); desc = BufferIO::ReadInt32(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq); pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.activatable_cards.push_back(pcard); mainGame->dField.activatable_cards.push_back(pcard);
mainGame->dField.activatable_descs.push_back(std::make_pair(desc,0)); mainGame->dField.activatable_descs.push_back(std::make_pair(desc, 0));
pcard->cmdFlag |= COMMAND_ACTIVATE; pcard->cmdFlag |= COMMAND_ACTIVATE;
if (pcard->location == LOCATION_GRAVE) if (pcard->location == LOCATION_GRAVE)
mainGame->dField.grave_act = true; mainGame->dField.grave_act = true;
...@@ -1548,7 +1550,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1548,7 +1550,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.selectsum_all.clear(); mainGame->dField.selectsum_all.clear();
mainGame->dField.selected_cards.clear(); mainGame->dField.selected_cards.clear();
mainGame->dField.selectsum_cards.clear(); mainGame->dField.selectsum_cards.clear();
bool panelmode = false; mainGame->dField.select_panalmode = false;
for (int i = 0; i < mainGame->dField.must_select_count; ++i) { for (int i = 0; i < mainGame->dField.must_select_count; ++i) {
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf); unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
...@@ -1574,20 +1576,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1574,20 +1576,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->select_seq = i; pcard->select_seq = i;
mainGame->dField.selectsum_all.push_back(pcard); mainGame->dField.selectsum_all.push_back(pcard);
if ((l & 0xe) == 0) if ((l & 0xe) == 0)
panelmode = true; mainGame->dField.select_panalmode = true;
} }
std::sort(mainGame->dField.selectsum_all.begin(), mainGame->dField.selectsum_all.end(), ClientCard::client_card_sort); std::sort(mainGame->dField.selectsum_all.begin(), mainGame->dField.selectsum_all.end(), ClientCard::client_card_sort);
if(select_hint) if(select_hint)
myswprintf(textBuffer, L"%ls(%d)", dataManager.GetDesc(select_hint), mainGame->dField.select_sumval); myswprintf(textBuffer, L"%ls(%d)", dataManager.GetDesc(select_hint), mainGame->dField.select_sumval);
else myswprintf(textBuffer, L"%ls(%d)", dataManager.GetSysString(560), mainGame->dField.select_sumval); else myswprintf(textBuffer, L"%ls(%d)", dataManager.GetSysString(560), mainGame->dField.select_sumval);
select_hint = 0; select_hint = 0;
if (panelmode) { if(mainGame->dField.select_panalmode) {
mainGame->wCardSelect->setText(textBuffer); mainGame->wCardSelect->setText(textBuffer);
} else { } else {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
} }
return mainGame->dField.ShowSelectSum(panelmode); return mainGame->dField.ShowSelectSum(mainGame->dField.select_panalmode);
} }
case MSG_SORT_CARD: case MSG_SORT_CARD:
case MSG_SORT_CHAIN: { case MSG_SORT_CHAIN: {
...@@ -1849,24 +1851,19 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1849,24 +1851,19 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_SWAP_GRAVE_DECK: { case MSG_SWAP_GRAVE_DECK: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int m = 0;
int e = mainGame->dField.extra[player].size();
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) {
mainGame->dField.grave[player].swap(mainGame->dField.deck[player]); mainGame->dField.grave[player].swap(mainGame->dField.deck[player]);
for (auto cit = mainGame->dField.grave[player].begin(); cit != mainGame->dField.grave[player].end(); ++cit) for (auto cit = mainGame->dField.grave[player].begin(); cit != mainGame->dField.grave[player].end(); ++cit)
(*cit)->location = LOCATION_GRAVE; (*cit)->location = LOCATION_GRAVE;
int m = 0;
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ) {
if ((*cit)->type & 0x802040) { if ((*cit)->type & 0x802040) {
(*cit)->location = LOCATION_EXTRA;
(*cit)->position = POS_FACEDOWN; (*cit)->position = POS_FACEDOWN;
(*cit)->sequence = e; mainGame->dField.AddCard(*cit, player, LOCATION_EXTRA, 0);
mainGame->dField.extra[player].push_back(*cit);
cit = mainGame->dField.deck[player].erase(cit); cit = mainGame->dField.deck[player].erase(cit);
e++;
} else { } else {
(*cit)->location = LOCATION_DECK; (*cit)->location = LOCATION_DECK;
(*cit)->sequence = m; (*cit)->sequence = m++;
m++;
++cit; ++cit;
} }
} }
...@@ -1877,19 +1874,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1877,19 +1874,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
(*cit)->location = LOCATION_GRAVE; (*cit)->location = LOCATION_GRAVE;
mainGame->dField.MoveCard(*cit, 10); mainGame->dField.MoveCard(*cit, 10);
} }
int m = 0;
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ) {
ClientCard* pcard = *cit; ClientCard* pcard = *cit;
if (pcard->type & 0x802040) { if (pcard->type & 0x802040) {
pcard->location = LOCATION_EXTRA;
pcard->position = POS_FACEDOWN; pcard->position = POS_FACEDOWN;
pcard->sequence = e; mainGame->dField.AddCard(pcard, player, LOCATION_EXTRA, 0);
mainGame->dField.extra[player].push_back(pcard);
cit = mainGame->dField.deck[player].erase(cit); cit = mainGame->dField.deck[player].erase(cit);
e++;
} else { } else {
pcard->location = LOCATION_DECK; pcard->location = LOCATION_DECK;
pcard->sequence = m; pcard->sequence = m++;
m++;
++cit; ++cit;
} }
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
...@@ -3396,7 +3390,7 @@ void DuelClient::SetResponseI(int respI) { ...@@ -3396,7 +3390,7 @@ void DuelClient::SetResponseI(int respI) {
*((int*)response_buf) = respI; *((int*)response_buf) = respI;
response_len = 4; response_len = 4;
} }
void DuelClient::SetResponseB(unsigned char * respB, unsigned char len) { void DuelClient::SetResponseB(void* respB, unsigned char len) {
memcpy(response_buf, respB, len); memcpy(response_buf, respB, len);
response_len = len; response_len = len;
} }
......
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
static void HandleSTOCPacketLan(char* data, unsigned int len); static void HandleSTOCPacketLan(char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len); static int ClientAnalyze(char* msg, unsigned int len);
static void SetResponseI(int respI); static void SetResponseI(int respI);
static void SetResponseB(unsigned char* respB, unsigned char len); static void SetResponseB(void* respB, unsigned char len);
static void SendResponse(); static void SendResponse();
static void SendPacketToServer(unsigned char proto) { static void SendPacketToServer(unsigned char proto) {
char* p = duel_client_write; char* p = duel_client_write;
......
...@@ -285,6 +285,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -285,6 +285,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case MSG_SELECT_TRIBUTE: case MSG_SELECT_TRIBUTE:
case MSG_SELECT_SUM: { case MSG_SELECT_SUM: {
mainGame->HideElement(mainGame->wQuery); mainGame->HideElement(mainGame->wQuery);
if(select_panalmode)
mainGame->dField.ShowSelectCard(true);
break; break;
} }
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
...@@ -369,18 +371,16 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -369,18 +371,16 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_OPTION_OK: { case BUTTON_OPTION_OK: {
if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) { if (mainGame->dInfo.curMsg == MSG_SELECT_OPTION) {
DuelClient::SetResponseI(selected_option); DuelClient::SetResponseI(selected_option);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
DuelClient::SetResponseI((index << 16) + 5);
} else if (mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
DuelClient::SetResponseI(index << 16);
} else { } else {
int index = 0; int index = 0;
while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++; while(activatable_cards[index] != command_card || activatable_descs[index].first != select_options[selected_option]) index++;
DuelClient::SetResponseI(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); mainGame->HideElement(mainGame->wOptions, true);
break; break;
...@@ -469,7 +469,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -469,7 +469,10 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break; break;
} }
case POSITION_HINT: { case POSITION_HINT: {
selectable_cards.insert(selectable_cards.end(), conti_cards.begin(), conti_cards.end()); selectable_cards = conti_cards;
std::sort(selectable_cards.begin(), selectable_cards.end());
auto eit = std::unique(selectable_cards.begin(), selectable_cards.end());
selectable_cards.erase(eit, selectable_cards.end());
conti_selecting = true; conti_selecting = true;
break; break;
} }
...@@ -881,6 +884,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -881,6 +884,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case LISTBOX_ANCARD: {
int sel = mainGame->lstANCard->getSelected();
if(sel != -1) {
mainGame->ShowCardInfo(ancard[sel]);
}
break;
}
} }
break; break;
} }
...@@ -1325,8 +1335,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1325,8 +1335,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
int command_flag = 0; int command_flag = 0;
if(conti_cards.size() == 0) if(conti_cards.size() == 0)
break; break;
if(conti_cards.size()) command_flag |= COMMAND_OPERATION;
command_flag |= COMMAND_OPERATION;
list_command = 1; list_command = 1;
ShowMenu(command_flag, x, y); ShowMenu(command_flag, x, y);
break; break;
...@@ -1445,12 +1454,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1445,12 +1454,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
clicked_card->is_selectable = false; clicked_card->is_selectable = false;
select_counter_count--; select_counter_count--;
if (select_counter_count == 0) { if (select_counter_count == 0) {
unsigned char respbuf[64]; unsigned short int respbuf[32];
for(size_t i = 0; i < selectable_cards.size(); ++i) for(size_t i = 0; i < selectable_cards.size(); ++i)
respbuf[i] = (selectable_cards[i]->opParam >> 16) - (selectable_cards[i]->opParam & 0xffff); respbuf[i] = (selectable_cards[i]->opParam >> 16) - (selectable_cards[i]->opParam & 0xffff);
mainGame->stHintMsg->setVisible(false); mainGame->stHintMsg->setVisible(false);
ClearSelect(); ClearSelect();
DuelClient::SetResponseB(respbuf, selectable_cards.size()); DuelClient::SetResponseB(respbuf, selectable_cards.size() * 2);
DuelClient::SendResponse(); DuelClient::SendResponse();
} else { } else {
wchar_t formatBuffer[2048]; wchar_t formatBuffer[2048];
...@@ -1835,24 +1844,30 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1835,24 +1844,30 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EET_KEY_INPUT_EVENT: { case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) { switch(event.KeyInput.Key) {
case irr::KEY_KEY_A: { case irr::KEY_KEY_A: {
mainGame->always_chain = event.KeyInput.PressedDown; if(!mainGame->HasFocus(EGUIET_EDIT_BOX)) {
mainGame->ignore_chain = false; mainGame->always_chain = event.KeyInput.PressedDown;
mainGame->chain_when_avail = false; mainGame->ignore_chain = false;
//UpdateChainButtons(); mainGame->chain_when_avail = false;
//UpdateChainButtons();
}
break; break;
} }
case irr::KEY_KEY_S: { case irr::KEY_KEY_S: {
mainGame->ignore_chain = event.KeyInput.PressedDown; if(!mainGame->HasFocus(EGUIET_EDIT_BOX)) {
mainGame->always_chain = false; mainGame->ignore_chain = event.KeyInput.PressedDown;
mainGame->chain_when_avail = false; mainGame->always_chain = false;
//UpdateChainButtons(); mainGame->chain_when_avail = false;
//UpdateChainButtons();
}
break; break;
} }
case irr::KEY_KEY_D: { case irr::KEY_KEY_D: {
mainGame->chain_when_avail = event.KeyInput.PressedDown; if(!mainGame->HasFocus(EGUIET_EDIT_BOX)) {
mainGame->always_chain = false; mainGame->chain_when_avail = event.KeyInput.PressedDown;
mainGame->ignore_chain = false; mainGame->always_chain = false;
//UpdateChainButtons(); mainGame->ignore_chain = false;
//UpdateChainButtons();
}
break; break;
} }
case irr::KEY_KEY_R: { case irr::KEY_KEY_R: {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
const unsigned short PRO_VERSION = 0x133A; const unsigned short PRO_VERSION = 0x133D;
namespace ygo { namespace ygo {
...@@ -69,11 +69,11 @@ bool Game::Initialize() { ...@@ -69,11 +69,11 @@ bool Game::Initialize() {
imageManager.SetDevice(device); imageManager.SetDevice(device);
if(!imageManager.Initial()) if(!imageManager.Initial())
return false; return false;
LoadExpansionDB();
if(!dataManager.LoadDB("cards.cdb")) if(!dataManager.LoadDB("cards.cdb"))
return false; return false;
if(!dataManager.LoadStrings("strings.conf")) if(!dataManager.LoadStrings("strings.conf"))
return false; return false;
RefreshExpansionDB();
dataManager.LoadStrings("./expansions/strings.conf"); dataManager.LoadStrings("./expansions/strings.conf");
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
...@@ -119,12 +119,12 @@ bool Game::Initialize() { ...@@ -119,12 +119,12 @@ bool Game::Initialize() {
lstHostList->setItemHeight(18); lstHostList->setItemHeight(18);
btnLanRefresh = env->addButton(rect<s32>(240, 325, 340, 350), wLanWindow, BUTTON_LAN_REFRESH, dataManager.GetSysString(1217)); btnLanRefresh = env->addButton(rect<s32>(240, 325, 340, 350), wLanWindow, BUTTON_LAN_REFRESH, dataManager.GetSysString(1217));
env->addStaticText(dataManager.GetSysString(1221), rect<s32>(10, 360, 220, 380), false, false, wLanWindow); env->addStaticText(dataManager.GetSysString(1221), rect<s32>(10, 360, 220, 380), false, false, wLanWindow);
ebJoinIP = env->addEditBox(gameConf.lastip, rect<s32>(110, 355, 250, 380), true, wLanWindow); ebJoinHost = env->addEditBox(gameConf.lasthost, rect<s32>(110, 355, 350, 380), true, wLanWindow);
ebJoinIP->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebJoinHost->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
ebJoinPort = env->addEditBox(gameConf.lastport, rect<s32>(260, 355, 320, 380), true, wLanWindow); ebJoinPort = env->addEditBox(gameConf.lastport, rect<s32>(360, 355, 420, 380), true, wLanWindow);
ebJoinPort->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebJoinPort->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
env->addStaticText(dataManager.GetSysString(1222), rect<s32>(10, 390, 220, 410), false, false, wLanWindow); env->addStaticText(dataManager.GetSysString(1222), rect<s32>(10, 390, 220, 410), false, false, wLanWindow);
ebJoinPass = env->addEditBox(gameConf.roompass, rect<s32>(110, 385, 320, 410), true, wLanWindow); ebJoinPass = env->addEditBox(gameConf.roompass, rect<s32>(110, 385, 420, 410), true, wLanWindow);
ebJoinPass->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebJoinPass->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
btnJoinHost = env->addButton(rect<s32>(460, 355, 570, 380), wLanWindow, BUTTON_JOIN_HOST, dataManager.GetSysString(1223)); btnJoinHost = env->addButton(rect<s32>(460, 355, 570, 380), wLanWindow, BUTTON_JOIN_HOST, dataManager.GetSysString(1223));
btnJoinCancel = env->addButton(rect<s32>(460, 385, 570, 410), wLanWindow, BUTTON_JOIN_CANCEL, dataManager.GetSysString(1212)); btnJoinCancel = env->addButton(rect<s32>(460, 385, 570, 410), wLanWindow, BUTTON_JOIN_CANCEL, dataManager.GetSysString(1212));
...@@ -789,7 +789,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -789,7 +789,7 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer] = 0; dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer); pControl->setText(dataManager.strBuffer);
} }
void Game::RefreshExpansionDB() { void Game::LoadExpansionDB() {
#ifdef _WIN32 #ifdef _WIN32
char fpath[1000]; char fpath[1000];
WIN32_FIND_DATAW fdataw; WIN32_FIND_DATAW fdataw;
...@@ -967,7 +967,7 @@ void Game::LoadConfig() { ...@@ -967,7 +967,7 @@ void Game::LoadConfig() {
gameConf.lastdeck[0] = 0; gameConf.lastdeck[0] = 0;
gameConf.numfont[0] = 0; gameConf.numfont[0] = 0;
gameConf.textfont[0] = 0; gameConf.textfont[0] = 0;
gameConf.lastip[0] = 0; gameConf.lasthost[0] = 0;
gameConf.lastport[0] = 0; gameConf.lastport[0] = 0;
gameConf.roompass[0] = 0; gameConf.roompass[0] = 0;
//settings //settings
...@@ -1010,9 +1010,9 @@ void Game::LoadConfig() { ...@@ -1010,9 +1010,9 @@ void Game::LoadConfig() {
BufferIO::CopyWStr(wstr, gameConf.numfont, 256); BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
} else if(!strcmp(strbuf, "serverport")) { } else if(!strcmp(strbuf, "serverport")) {
gameConf.serverport = atoi(valbuf); gameConf.serverport = atoi(valbuf);
} else if(!strcmp(strbuf, "lastip")) { } else if(!strcmp(strbuf, "lasthost")) {
BufferIO::DecodeUTF8(valbuf, wstr); BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastip, 20); BufferIO::CopyWStr(wstr, gameConf.lasthost, 100);
} else if(!strcmp(strbuf, "lastport")) { } else if(!strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, wstr); BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastport, 20); BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
...@@ -1085,8 +1085,8 @@ void Game::SaveConfig() { ...@@ -1085,8 +1085,8 @@ void Game::SaveConfig() {
BufferIO::EncodeUTF8(gameConf.numfont, linebuf); BufferIO::EncodeUTF8(gameConf.numfont, linebuf);
fprintf(fp, "numfont = %s\n", linebuf); fprintf(fp, "numfont = %s\n", linebuf);
fprintf(fp, "serverport = %d\n", gameConf.serverport); fprintf(fp, "serverport = %d\n", gameConf.serverport);
BufferIO::EncodeUTF8(gameConf.lastip, linebuf); BufferIO::EncodeUTF8(gameConf.lasthost, linebuf);
fprintf(fp, "lastip = %s\n", linebuf); fprintf(fp, "lasthost = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastport, linebuf); BufferIO::EncodeUTF8(gameConf.lastport, linebuf);
fprintf(fp, "lastport = %s\n", linebuf); fprintf(fp, "lastport = %s\n", linebuf);
//settings //settings
......
...@@ -17,7 +17,7 @@ struct Config { ...@@ -17,7 +17,7 @@ struct Config {
unsigned short antialias; unsigned short antialias;
unsigned short serverport; unsigned short serverport;
unsigned char textfontsize; unsigned char textfontsize;
wchar_t lastip[20]; wchar_t lasthost[100];
wchar_t lastport[10]; wchar_t lastport[10];
wchar_t nickname[20]; wchar_t nickname[20];
wchar_t gamename[20]; wchar_t gamename[20];
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0);
void RefreshExpansionDB(); void LoadExpansionDB();
void RefreshDeck(irr::gui::IGUIComboBox* cbDeck); void RefreshDeck(irr::gui::IGUIComboBox* cbDeck);
void RefreshReplay(); void RefreshReplay();
void RefreshSingleplay(); void RefreshSingleplay();
...@@ -237,7 +237,7 @@ public: ...@@ -237,7 +237,7 @@ public:
irr::gui::IGUIEditBox* ebNickName; irr::gui::IGUIEditBox* ebNickName;
irr::gui::IGUIListBox* lstHostList; irr::gui::IGUIListBox* lstHostList;
irr::gui::IGUIButton* btnLanRefresh; irr::gui::IGUIButton* btnLanRefresh;
irr::gui::IGUIEditBox* ebJoinIP; irr::gui::IGUIEditBox* ebJoinHost;
irr::gui::IGUIEditBox* ebJoinPort; irr::gui::IGUIEditBox* ebJoinPort;
irr::gui::IGUIEditBox* ebJoinPass; irr::gui::IGUIEditBox* ebJoinPass;
irr::gui::IGUIButton* btnJoinHost; irr::gui::IGUIButton* btnJoinHost;
......
...@@ -5,6 +5,32 @@ ...@@ -5,6 +5,32 @@
int enable_log = 0; int enable_log = 0;
bool exit_on_return = false; bool exit_on_return = false;
bool open_file = false;
wchar_t open_file_name[256] = L"";
void GetParameter(char* param, const char* arg) {
#ifdef _WIN32
wchar_t arg1[260];
MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260);
BufferIO::EncodeUTF8(arg1, param);
#else
strcpy(param, arg);
#endif
}
void GetParameterW(wchar_t* param, const char* arg) {
#ifdef _WIN32
MultiByteToWideChar(CP_ACP, 0, arg, -1, param, 260);
#else
BufferIO::DecodeUTF8(arg, param);
#endif
}
void ClickButton(irr::gui::IGUIElement* btn) {
irr::SEvent event;
event.EventType = irr::EET_GUI_EVENT;
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
event.GUIEvent.Caller = btn;
ygo::mainGame->device->postEventFromUser(event);
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifdef _WIN32 #ifdef _WIN32
...@@ -21,47 +47,79 @@ int main(int argc, char* argv[]) { ...@@ -21,47 +47,79 @@ int main(int argc, char* argv[]) {
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
bool keep_on_return = false;
for(int i = 1; i < argc; ++i) { for(int i = 1; i < argc; ++i) {
/*command line args:
* -j: join host (host info from system.conf)
* -d: deck edit
* -r: replay */
if(argv[i][0] == '-' && argv[i][1] == 'e') { if(argv[i][0] == '-' && argv[i][1] == 'e') {
#ifdef _WIN32 char param[128];
wchar_t fname[260]; GetParameter(param, &argv[i][2]);
MultiByteToWideChar(CP_ACP, 0, &argv[i][2], -1, fname, 260); ygo::dataManager.LoadDB(param);
char fname2[260]; }
BufferIO::EncodeUTF8(fname, fname2); if(!strcmp(argv[i], "-e")) { // extra database
ygo::dataManager.LoadDB(fname2); ++i;
#else char param[128];
ygo::dataManager.LoadDB(&argv[i][2]); GetParameter(param, &argv[i][0]);
#endif ygo::dataManager.LoadDB(param);
} else if(!strcmp(argv[i], "-j") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-r") || !strcmp(argv[i], "-s")) { continue;
exit_on_return = true; } else if(!strcmp(argv[i], "-n")) { // nickName
irr::SEvent event; ++i;
event.EventType = irr::EET_GUI_EVENT; wchar_t param[128];
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED; GetParameterW(param, &argv[i][0]);
if(!strcmp(argv[i], "-j")) { ygo::mainGame->ebNickName->setText(param);
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); continue;
event.GUIEvent.Caller = ygo::mainGame->btnJoinHost; } else if(!strcmp(argv[i], "-h")) { // Host address
ygo::mainGame->device->postEventFromUser(event); ++i;
} else if(!strcmp(argv[i], "-d")) { wchar_t param[128];
event.GUIEvent.Caller = ygo::mainGame->btnDeckEdit; GetParameterW(param, &argv[i][0]);
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->ebJoinHost->setText(param);
} else if(!strcmp(argv[i], "-r")) { continue;
event.GUIEvent.Caller = ygo::mainGame->btnReplayMode; } else if(!strcmp(argv[i], "-p")) { // host Port
ygo::mainGame->device->postEventFromUser(event); ++i;
ygo::mainGame->lstReplayList->setSelected(0); wchar_t param[128];
event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay; GetParameterW(param, &argv[i][0]);
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->ebJoinPort->setText(param);
} else if(!strcmp(argv[i], "-s")) { continue;
event.GUIEvent.Caller = ygo::mainGame->btnServerMode; } else if(!strcmp(argv[i], "-w")) { // host passWord
ygo::mainGame->device->postEventFromUser(event); ++i;
ygo::mainGame->lstSinglePlayList->setSelected(0); wchar_t param[128];
event.GUIEvent.Caller = ygo::mainGame->btnLoadSinglePlay; GetParameterW(param, &argv[i][0]);
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->ebJoinPass->setText(param);
continue;
} else if(!strcmp(argv[i], "-k")) { // Keep on return
exit_on_return = false;
keep_on_return = true;
} else if(!strcmp(argv[i], "-j")) { // Join host
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnLanMode);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(argv[i], "-d")) { // Deck
exit_on_return = !keep_on_return;
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
} }
ClickButton(ygo::mainGame->btnDeckEdit);
break;
} else if(!strcmp(argv[i], "-r")) { // Replay
exit_on_return = !keep_on_return;
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnReplayMode);
if(open_file)
ClickButton(ygo::mainGame->btnLoadReplay);
break;
} else if(!strcmp(argv[i], "-s")) { // Single
exit_on_return = !keep_on_return;
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnServerMode);
if(open_file)
ClickButton(ygo::mainGame->btnLoadSinglePlay);
break;
} }
} }
ygo::mainGame->MainLoop(); ygo::mainGame->MainLoop();
......
...@@ -31,38 +31,36 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -31,38 +31,36 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_JOIN_HOST: { case BUTTON_JOIN_HOST: {
#if WINVER >= 0x0600
struct addrinfo hints, *servinfo;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
hints.ai_protocol = 0; /* Any protocol */
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
int status;
char hostname[100];
char ip[20]; char ip[20];
const wchar_t* pstr = mainGame->ebJoinIP->getText(); const wchar_t* pstr = mainGame->ebJoinHost->getText();
BufferIO::CopyWStr(pstr, hostname, 100);
if ((status = getaddrinfo(hostname, NULL, &hints, &servinfo)) == -1) {
fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status));
//error handling
BufferIO::CopyWStr(pstr, ip, 16);
} else
inet_ntop(AF_INET, &(((struct sockaddr_in *)servinfo->ai_addr)->sin_addr), ip, 20);
freeaddrinfo(servinfo);
#else
char hostname[100];
char ip[20];
const wchar_t* pstr = mainGame->ebJoinIP->getText();
BufferIO::CopyWStr(pstr, hostname, 100);
BufferIO::CopyWStr(pstr, ip, 16); BufferIO::CopyWStr(pstr, ip, 16);
#endif
unsigned int remote_addr = htonl(inet_addr(ip)); unsigned int remote_addr = htonl(inet_addr(ip));
if(remote_addr == -1) {
char hostname[100];
char port[6];
BufferIO::CopyWStr(pstr, hostname, 100);
BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), port, 6);
struct evutil_addrinfo hints;
struct evutil_addrinfo *answer = NULL;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = EVUTIL_AI_ADDRCONFIG;
int status=evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) {
mainGame->gMutex.Lock();
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock();
break;
} else {
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
evutil_inet_ntop(AF_INET, &(sin->sin_addr), ip, 20);
remote_addr = htonl(inet_addr(ip));
}
}
unsigned int remote_port = _wtoi(mainGame->ebJoinPort->getText()); unsigned int remote_port = _wtoi(mainGame->ebJoinPort->getText());
BufferIO::CopyWStr(pstr, mainGame->gameConf.lastip, 20); BufferIO::CopyWStr(pstr, mainGame->gameConf.lasthost, 100);
BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), mainGame->gameConf.lastport, 20); BufferIO::CopyWStr(mainGame->ebJoinPort->getText(), mainGame->gameConf.lastport, 20);
if(DuelClient::StartClient(remote_addr, remote_port, false)) { if(DuelClient::StartClient(remote_addr, remote_port, false)) {
mainGame->btnCreateHost->setEnabled(false); mainGame->btnCreateHost->setEnabled(false);
...@@ -74,6 +72,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -74,6 +72,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case BUTTON_JOIN_CANCEL: { case BUTTON_JOIN_CANCEL: {
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->ShowElement(mainGame->wMainMenu); mainGame->ShowElement(mainGame->wMainMenu);
if(exit_on_return)
mainGame->device->closeDevice();
break; break;
} }
case BUTTON_LAN_REFRESH: { case BUTTON_LAN_REFRESH: {
...@@ -175,10 +175,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -175,10 +175,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LOAD_REPLAY: { case BUTTON_LOAD_REPLAY: {
if(mainGame->lstReplayList->getSelected() == -1) if(open_file) {
break; ReplayMode::cur_replay.OpenReplay(open_file_name);
if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected()))) open_file = false;
break; } else {
if(mainGame->lstReplayList->getSelected() == -1)
break;
if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected())))
break;
}
mainGame->imgCard->setImage(imageManager.tCover[0]); mainGame->imgCard->setImage(imageManager.tCover[0]);
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
...@@ -213,7 +218,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -213,7 +218,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
case BUTTON_LOAD_SINGLEPLAY: { case BUTTON_LOAD_SINGLEPLAY: {
if(mainGame->lstSinglePlayList->getSelected() == -1) if(!open_file && mainGame->lstSinglePlayList->getSelected() == -1)
break; break;
mainGame->singleSignal.SetNoWait(false); mainGame->singleSignal.SetNoWait(false);
SingleMode::StartPlay(); SingleMode::StartPlay();
...@@ -226,8 +231,32 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -226,8 +231,32 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_DECK_EDIT: { case BUTTON_DECK_EDIT: {
mainGame->RefreshDeck(mainGame->cbDBDecks); mainGame->RefreshDeck(mainGame->cbDBDecks);
if(mainGame->cbDBDecks->getSelected() != -1) if(open_file && deckManager.LoadDeck(open_file_name)) {
#ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\');
#else
wchar_t *dash = wcsrchr(open_file_name, L'/');
#endif
wchar_t *dot = wcsrchr(open_file_name, L'.');
if(dash && dot) {
wchar_t deck_name[256];
wcsncpy(deck_name, dash + 1, dot - dash - 1);
deck_name[dot - dash - 1] = L'\0';
mainGame->ebDeckname->setText(deck_name);
mainGame->cbDBDecks->setSelected(-1);
} else {
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) {
mainGame->cbDBDecks->setSelected(i);
break;
}
}
}
open_file = false;
} else if(mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected())); deckManager.LoadDeck(mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()));
mainGame->ebDeckname->setText(L"");
}
mainGame->HideElement(mainGame->wMainMenu); mainGame->HideElement(mainGame->wMainMenu);
mainGame->is_building = true; mainGame->is_building = true;
mainGame->is_siding = false; mainGame->is_siding = false;
...@@ -281,7 +310,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -281,7 +310,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int port = DuelClient::hosts[sel].port; int port = DuelClient::hosts[sel].port;
wchar_t buf[20]; wchar_t buf[20];
myswprintf(buf, L"%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, (addr >> 24) & 0xff); myswprintf(buf, L"%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, (addr >> 16) & 0xff, (addr >> 24) & 0xff);
mainGame->ebJoinIP->setText(buf); mainGame->ebJoinHost->setText(buf);
myswprintf(buf, L"%d", port); myswprintf(buf, L"%d", port);
mainGame->ebJoinPort->setText(buf); mainGame->ebJoinPort->setText(buf);
break; break;
......
...@@ -139,15 +139,24 @@ void Replay::SaveReplay(const wchar_t* name) { ...@@ -139,15 +139,24 @@ void Replay::SaveReplay(const wchar_t* name) {
fclose(fp); fclose(fp);
} }
bool Replay::OpenReplay(const wchar_t* name) { bool Replay::OpenReplay(const wchar_t* name) {
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name);
#ifdef WIN32 #ifdef WIN32
fp = _wfopen(fname, L"rb"); fp = _wfopen(name, L"rb");
#else #else
char fname2[256]; char name2[256];
BufferIO::EncodeUTF8(fname, fname2); BufferIO::EncodeUTF8(name, name2);
fp = fopen(fname2, "rb"); fp = fopen(name2, "rb");
#endif #endif
if(!fp) {
wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name);
#ifdef WIN32
fp = _wfopen(fname, L"rb");
#else
char fname2[256];
BufferIO::EncodeUTF8(fname, fname2);
fp = fopen(fname2, "rb");
#endif
}
if(!fp) if(!fp)
return false; return false;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
......
...@@ -185,6 +185,8 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -185,6 +185,8 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->ShowElement(mainGame->wReplay); mainGame->ShowElement(mainGame->wReplay);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
if(exit_on_return)
mainGame->device->closeDevice();
} }
return 0; return 0;
} }
......
...@@ -29,11 +29,17 @@ void SingleMode::SetResponse(unsigned char* resp) { ...@@ -29,11 +29,17 @@ void SingleMode::SetResponse(unsigned char* resp) {
set_responseb(pduel, resp); set_responseb(pduel, resp);
} }
int SingleMode::SinglePlayThread(void* param) { int SingleMode::SinglePlayThread(void* param) {
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(mainGame->lstSinglePlayList->getSelected());
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
char fname2[256]; char fname2[256];
size_t slen = BufferIO::EncodeUTF8(fname, fname2); size_t slen;
if(open_file) {
slen = BufferIO::EncodeUTF8(open_file_name, fname2);
open_file = false;
} else {
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(mainGame->lstSinglePlayList->getSelected());
wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name);
slen = BufferIO::EncodeUTF8(fname, fname2);
}
mtrandom rnd; mtrandom rnd;
time_t seed = time(0); time_t seed = time(0);
rnd.reset(seed); rnd.reset(seed);
...@@ -104,6 +110,8 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -104,6 +110,8 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
if(exit_on_return)
mainGame->device->closeDevice();
} }
return 0; return 0;
} }
......
#[2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1] #[2017.1][2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1]
!2017.1
#forbidden
20663556 0 --イレカエル
44910027 0 --ヴィクトリー・ドラゴン
20366274 0 --エルシャドール・ネフィリム
53804307 0 --焔征竜-ブラスター
68819554 0 --Emダメージ・ジャグラー
07563579 0 --Emヒグルミ
17330916 0 --EMモンキーボード
90411554 0 --巌征竜-レドックス
17412721 0 --旧神ノーデン
78010363 0 --黒き森のウィッチ
34124316 0 --サイバーポッド
21593977 0 --処刑人-マキュラ
16923472 0 --ゼンマイハンター
56570271 0 --DHERO ディスクガイ
18326736 0 --星守の騎士 プトレマイオス
33184167 0 --同族感染ウィルス
54719828 0 --No.16 色の支配者ショック・ルーラー
26400609 0 --瀑征竜-タイダル
78706415 0 --ファイバーポッド
93369354 0 --フィッシュボーグ-ガンナー
31178212 0 --マジェスペクター・ユニコーン
34206604 0 --魔導サイエンティスト
96782886 0 --メンタルマスター
03078576 0 --八汰烏
34086406 0 --ラヴァルバル・チェイン
89399912 0 --嵐征竜-テンペスト
57421866 0 --レベル・スティーラー
41482598 0 --悪夢の蜃気楼
44763025 0 --いたずら好きな双子悪魔
19613556 0 --大嵐
17375316 0 --押収
74191942 0 --苦渋の選択
42829885 0 --強引な番兵
45986603 0 --強奪
55144522 0 --強欲な壺
04031928 0 --心変わり
12580477 0 --サンダー·ボルト
23557835 0 --次元融合
57953380 0 --生還の宝札
60682203 0 --大寒波
69243953 0 --蝶の短剣-エルマ
79571449 0 --天使の施し
70828912 0 --早すぎた埋葬
42703248 0 --ハリケーン
34906152 0 --マスドライバー
46448938 0 --魔導書の神判
46411259 0 --突然変異
85602018 0 --遺言状
27174286 0 --異次元からの帰還
93016201 0 --王宮の弾圧
03280747 0 --第六感
64697231 0 --ダスト·シュート
80604091 0 --血の代償
35316708 0 --刻の封印
17178486 0 --ライフチェンジャー
28566710 0 --ラストバトル!
#limit
64034255 1 --A·ジェネクス·バードマン
40044918 1 --E·HERO エアーマン
50720316 1 --E·HERO シャドー·ミスト
40318957 1 --EMドクロバット・ジョーカー
47075569 1 --EMペンデュラム・マジシャン
07391448 1 --ゴヨウ·ガーディアン
74586817 1 --PSYフレームロード・Ω
06602300 1 --重爆撃禽 ボム・フェネクス
28985331 1 --終末の騎士
00423585 1 --召喚僧サモンプリースト
78868119 1 --深海のディーヴァ
81275020 1 --SRベイゴマックス
65192027 1 --ダーク·アームド·ドラゴン
90953320 1 --TG ハイパー·ライブラリアン
69015963 1 --デビル・フランケン
16226786 1 --深淵の暗殺者
90307777 1 --影霊衣の術士 シュリット
28297833 1 --ネクロフェイス
18239909 1 --爆竜剣士イグニスターP
84764038 1 --彼岸の悪鬼 スカラマリオン
83531441 1 --彼岸の旅人 ダンテ
70583986 1 --氷結界の虎王ドゥローレン
52687916 1 --氷結界の龍 トリシューラ
50321796 1 --氷結界の龍 ブリューナク
33396948 1 --封印されしエクゾディア
07902349 1 --封印されし者の左腕
70903634 1 --封印されし者の右腕
44519536 1 --封印されし者の左足
08124921 1 --封印されし者の右足
26674724 1 --ブリューナクの影霊衣
10802915 1 --魔界発現世行きデスガイド
33508719 1 --メタモルポット
90809975 1 --餅カエル
89463537 1 --ユニコールの影霊衣
92746535 1 --竜剣士ラスターP
14878871 1 --レスキューキャット
88264978 1 --レッドアイズ·ダークネスメタルドラゴン
48976825 1 --異次元からの埋葬
33782437 1 --一時休戦
66957584 1 --インフェルニティガン
57103969 1 --炎舞-「天璣」
81439173 1 --おろかな埋葬
23701465 1 --原初の種
96729612 1 --儀式の準備
67723438 1 --緊急テレポート
45305419 1 --継承の印
17639150 1 --機殻の生贄
83764718 1 --死者蘇生
87910978 1 --洗脳-ブレインコントロール
32807846 1 --増援
54447022 1 --ソウル・チャージ
48130397 1 --超融合
72892473 1 --手札抹殺
67169062 1 --貪欲な壺
97211663 1 --影霊衣の反魂術
18144506 1 --ハーピィの羽根帚
22842126 1 --汎神の帝王
53129443 1 --ブラック·ホール
53208660 1 --ペンデュラム・コール
93600443 1 --マスク・チェンジ・セカンド
15854426 1 --霞の谷の神風
77565204 1 --未来融合-フューチャー·フュージョン
58577036 1 --名推理
66399653 1 --ユニオン格納庫
31222701 1 --揺れる眼差し
23171610 1 --リミッター解除
14733538 1 --竜呼相打つ
62265044 1 --竜の渓谷
02295440 1 --ワン·フォー·ワン
05851097 1 --虚無空間
61740673 1 --王宮の勅命
84749824 1 --神の警告
41420027 1 --神の宣告
36468556 1 --停戦協定
83555666 1 --破壊輪
32723153 1 --マジカル·エクスプロージョン
#semi limit
85103922 2 --アーティファクト-モラルタ
45222299 2 --イビリチュア·ガストクラーケ
74311226 2 --海皇の竜騎隊
72989439 2 --カオス·ソルジャー -開闢の使者-
72714461 2 --慧眼の魔術師
31560081 2 --聖なる魔術師
15341821 2 --ダンディライオン
45206713 2 --DDスワラル・スライム
19580308 2 --DDラミア
10028593 2 --輪廻天狗
84171830 2 --真帝王領域
91623717 2 --連鎖爆撃
43040603 2 --モンスターゲート
!2016.10 !2016.10
#forbidden #forbidden
20663556 0 --イレカエル 20663556 0 --イレカエル
......
...@@ -9,7 +9,7 @@ lastdeck = new ...@@ -9,7 +9,7 @@ lastdeck = new
textfont = c:/windows/fonts/simsun.ttc 14 textfont = c:/windows/fonts/simsun.ttc 14
numfont = c:/windows/fonts/arialbd.ttf numfont = c:/windows/fonts/arialbd.ttf
serverport = 7911 serverport = 7911
lastip = 127.0.0.1 lasthost = 127.0.0.1
lastport = 7911 lastport = 7911
autopos = 1 autopos = 1
randompos = 0 randompos = 0
......
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