Commit fa5234f0 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into server-link

parents df40d0c9 538a0eba
...@@ -76,6 +76,13 @@ void ClientField::Clear() { ...@@ -76,6 +76,13 @@ void ClientField::Clear() {
reposable_cards.clear(); reposable_cards.clear();
attackable_cards.clear(); attackable_cards.clear();
disabled_field = 0; disabled_field = 0;
panel = 0;
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
deck_act = false; deck_act = false;
grave_act = false; grave_act = false;
remove_act = false; remove_act = false;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <locale.h>
#define SD_BOTH 2 #define SD_BOTH 2
#define SOCKET int #define SOCKET int
......
...@@ -80,12 +80,7 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -80,12 +80,7 @@ bool DataManager::LoadStrings(const char* file) {
char linebuf[256]; char linebuf[256];
char strbuf[256]; char strbuf[256];
int value; int value;
fseek(fp, 0, SEEK_END); while(fgets(linebuf, 256, fp)) {
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
if(linebuf[0] != '!') if(linebuf[0] != '!')
continue; continue;
sscanf(linebuf, "!%s", strbuf); sscanf(linebuf, "!%s", strbuf);
......
...@@ -13,12 +13,7 @@ void DeckManager::LoadLFList() { ...@@ -13,12 +13,7 @@ void DeckManager::LoadLFList() {
char linebuf[256]; char linebuf[256];
wchar_t strBuffer[256]; wchar_t strBuffer[256];
if(fp) { if(fp) {
fseek(fp, 0, SEEK_END); while(fgets(linebuf, 256, fp)) {
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
if(linebuf[0] == '#') if(linebuf[0] == '#')
continue; continue;
int p = 0, sa = 0, code, count; int p = 0, sa = 0, code, count;
...@@ -191,12 +186,7 @@ bool DeckManager::LoadDeck(const wchar_t* file) { ...@@ -191,12 +186,7 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
int cardlist[128]; int cardlist[128];
bool is_side = false; bool is_side = false;
char linebuf[256]; char linebuf[256];
fseek(fp, 0, SEEK_END); while(fgets(linebuf, 256, fp) && ct < 128) {
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize && ct < 128) {
fgets(linebuf, 256, fp);
if(linebuf[0] == '!') { if(linebuf[0] == '!') {
is_side = true; is_side = true;
continue; continue;
......
...@@ -294,6 +294,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -294,6 +294,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->deckBuilder.result_string[0] = L'0'; mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0; mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear(); mainGame->deckBuilder.results.clear();
mainGame->deckBuilder.hovered_code = 0;
mainGame->deckBuilder.is_draging = false; mainGame->deckBuilder.is_draging = false;
mainGame->deckBuilder.is_starting_dragging = false; mainGame->deckBuilder.is_starting_dragging = false;
mainGame->deckBuilder.pre_mainc = deckManager.current_deck.main.size(); mainGame->deckBuilder.pre_mainc = deckManager.current_deck.main.size();
...@@ -489,7 +490,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -489,7 +490,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnEP->setVisible(false); mainGame->btnEP->setVisible(false);
mainGame->btnShuffle->setVisible(false); mainGame->btnShuffle->setVisible(false);
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
mainGame->imgCard->setImage(imageManager.tCover[0]);
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) { if(!mainGame->dInfo.isTag) {
if(selftype > 1) { if(selftype > 1) {
...@@ -554,6 +554,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -554,6 +554,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
...@@ -777,6 +778,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -777,6 +778,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
......
...@@ -115,6 +115,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -115,6 +115,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
DuelClient::StopClient(); DuelClient::StopClient();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false);
mainGame->wCardImg->setVisible(false); mainGame->wCardImg->setVisible(false);
mainGame->wInfos->setVisible(false); mainGame->wInfos->setVisible(false);
mainGame->wPhase->setVisible(false); mainGame->wPhase->setVisible(false);
......
...@@ -990,11 +990,7 @@ void Game::LoadConfig() { ...@@ -990,11 +990,7 @@ void Game::LoadConfig() {
gameConf.separate_clear_button = 1; gameConf.separate_clear_button = 1;
gameConf.auto_search_limit = -1; gameConf.auto_search_limit = -1;
gameConf.chkIgnoreDeckChanges = 0; gameConf.chkIgnoreDeckChanges = 0;
fseek(fp, 0, SEEK_END); while(fgets(linebuf, 256, fp)) {
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
sscanf(linebuf, "%s = %s", strbuf, valbuf); sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) { if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf); gameConf.antialias = atoi(valbuf);
......
...@@ -36,6 +36,9 @@ void ClickButton(irr::gui::IGUIElement* btn) { ...@@ -36,6 +36,9 @@ void ClickButton(irr::gui::IGUIElement* btn) {
} }
*/ */
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
#ifndef _WIN32
setlocale(LC_CTYPE, "UTF-8");
#endif
#ifdef _WIN32 #ifdef _WIN32
#ifndef _DEBUG #ifndef _DEBUG
wchar_t exepath[MAX_PATH]; wchar_t exepath[MAX_PATH];
......
...@@ -213,9 +213,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -213,9 +213,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnReplayStep->setVisible(false); mainGame->btnReplayStep->setVisible(false);
mainGame->btnReplayUndo->setVisible(false); mainGame->btnReplayUndo->setVisible(false);
mainGame->wPhase->setVisible(true); mainGame->wPhase->setVisible(true);
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->HideElement(mainGame->wReplay); mainGame->HideElement(mainGame->wReplay);
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
......
...@@ -215,18 +215,15 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -215,18 +215,15 @@ bool Replay::OpenReplay(const wchar_t* name) {
} }
if(!fp) if(!fp)
return false; return false;
fseek(fp, 0, SEEK_END);
comp_size = ftell(fp) - sizeof(pheader);
fseek(fp, 0, SEEK_SET);
fread(&pheader, sizeof(pheader), 1, fp); fread(&pheader, sizeof(pheader), 1, fp);
if(pheader.flag & REPLAY_COMPRESSED) { if(pheader.flag & REPLAY_COMPRESSED) {
fread(comp_data, 0x1000, 1, fp); comp_size = fread(comp_data, 1, 0x1000, fp);
fclose(fp); fclose(fp);
replay_size = pheader.datasize; replay_size = pheader.datasize;
if(LzmaUncompress(replay_data, &replay_size, comp_data, &comp_size, pheader.props, 5) != SZ_OK) if(LzmaUncompress(replay_data, &replay_size, comp_data, &comp_size, pheader.props, 5) != SZ_OK)
return false; return false;
} else { } else {
fread(replay_data, 0x20000, 1, fp); comp_size = fread(replay_data, 1, 0x20000, fp);
fclose(fp); fclose(fp);
replay_size = comp_size; replay_size = comp_size;
} }
......
...@@ -185,6 +185,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -185,6 +185,7 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->ShowElement(mainGame->wReplay); mainGame->ShowElement(mainGame->wReplay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
if(exit_on_return) if(exit_on_return)
...@@ -195,9 +196,6 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -195,9 +196,6 @@ int ReplayMode::ReplayThread(void* param) {
void ReplayMode::Restart(bool refresh) { void ReplayMode::Restart(bool refresh) {
end_duel(pduel); end_duel(pduel);
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear(); mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField); //mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay.Rewind(); cur_replay.Rewind();
......
...@@ -78,9 +78,6 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -78,9 +78,6 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->stText->setText(L""); mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false); mainGame->scrCardText->setVisible(false);
mainGame->wPhase->setVisible(true); mainGame->wPhase->setVisible(true);
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isFirst = true; mainGame->dInfo.isFirst = true;
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
...@@ -112,6 +109,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -112,6 +109,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
if(exit_on_return) if(exit_on_return)
...@@ -830,15 +828,10 @@ byte* SingleMode::ScriptReader(const char* script_name, int* slen) { ...@@ -830,15 +828,10 @@ byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
#endif #endif
if(!fp) if(!fp)
return 0; return 0;
fseek(fp, 0, SEEK_END); int len = fread(buffer, 1, sizeof(buffer), fp);
unsigned int len = ftell(fp);
if(len > sizeof(buffer)) {
fclose(fp); fclose(fp);
if(len >= sizeof(buffer))
return 0; return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
fclose(fp);
*slen = len; *slen = len;
return buffer; return buffer;
} }
......
...@@ -501,6 +501,7 @@ ...@@ -501,6 +501,7 @@
!counter 0x40 指示物(No.51 怪腕之必杀摔角手) !counter 0x40 指示物(No.51 怪腕之必杀摔角手)
!counter 0x1041 捕食指示物 !counter 0x1041 捕食指示物
!counter 0x42 指示物(爆竹鬼) !counter 0x42 指示物(爆竹鬼)
!counter 0x43 缺陷指示物
#setnames, using tab for comment #setnames, using tab for comment
!setname 0x1 正义盟军 AOJ !setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス !setname 0x2 次世代 ジェネクス
...@@ -842,3 +843,5 @@ ...@@ -842,3 +843,5 @@
!setname 0x103 幻变骚灵 オルターガイスト !setname 0x103 幻变骚灵 オルターガイスト
!setname 0x104 机怪虫 クローラー !setname 0x104 机怪虫 クローラー
!setname 0x105 玄化 メタファイズ !setname 0x105 玄化 メタファイズ
!setname 0x106 复仇死灵 Vendread
!setname 0x107 F.A.
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