Commit 83cf6344 authored by mercury233's avatar mercury233

Merge branch 'fh' into sound

parents 8c7b5999 fbf10697
......@@ -76,6 +76,13 @@ void ClientField::Clear() {
reposable_cards.clear();
attackable_cards.clear();
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;
grave_act = false;
remove_act = false;
......
......@@ -78,12 +78,7 @@ bool DataManager::LoadStrings(const char* file) {
char linebuf[256];
char strbuf[256];
int value;
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
while(fgets(linebuf, 256, fp)) {
if(linebuf[0] != '!')
continue;
sscanf(linebuf, "!%s", strbuf);
......
......@@ -13,12 +13,7 @@ void DeckManager::LoadLFList() {
char linebuf[256];
wchar_t strBuffer[256];
if(fp) {
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#')
continue;
int p = 0, sa = 0, code, count;
......@@ -191,12 +186,7 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
int cardlist[128];
bool is_side = false;
char linebuf[256];
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
fgets(linebuf, 256, fp);
while(ftell(fp) < fsize && ct < 128) {
fgets(linebuf, 256, fp);
while(fgets(linebuf, 256, fp) && ct < 128) {
if(linebuf[0] == '!') {
is_side = true;
continue;
......
......@@ -558,6 +558,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock();
......@@ -786,6 +787,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock();
......
......@@ -126,6 +126,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false);
mainGame->wCardImg->setVisible(false);
mainGame->wInfos->setVisible(false);
mainGame->wPhase->setVisible(false);
......
......@@ -1015,11 +1015,7 @@ void Game::LoadConfig() {
gameConf.enable_music = true;
gameConf.music_volume = 0.5;
gameConf.music_mode = 1;
fseek(fp, 0, SEEK_END);
int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
while(ftell(fp) < fsize) {
fgets(linebuf, 256, fp);
while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf);
......
......@@ -217,9 +217,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnReplayStep->setVisible(false);
mainGame->btnReplayUndo->setVisible(false);
mainGame->wPhase->setVisible(true);
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear();
mainGame->HideElement(mainGame->wReplay);
mainGame->device->setEventReceiver(&mainGame->dField);
......
......@@ -159,18 +159,15 @@ bool Replay::OpenReplay(const wchar_t* name) {
}
if(!fp)
return false;
fseek(fp, 0, SEEK_END);
comp_size = ftell(fp) - sizeof(pheader);
fseek(fp, 0, SEEK_SET);
fread(&pheader, sizeof(pheader), 1, fp);
if(pheader.flag & REPLAY_COMPRESSED) {
fread(comp_data, 0x1000, 1, fp);
comp_size = fread(comp_data, 1, 0x1000, fp);
fclose(fp);
replay_size = pheader.datasize;
if(LzmaUncompress(replay_data, &replay_size, comp_data, &comp_size, pheader.props, 5) != SZ_OK)
return false;
} else {
fread(replay_data, 0x20000, 1, fp);
comp_size = fread(replay_data, 1, 0x20000, fp);
fclose(fp);
replay_size = comp_size;
}
......
......@@ -188,6 +188,7 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock();
mainGame->ShowElement(mainGame->wReplay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock();
if(exit_on_return)
......@@ -199,9 +200,6 @@ void ReplayMode::Restart(bool refresh) {
end_duel(pduel);
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear();
//mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay.Rewind();
......
......@@ -78,9 +78,6 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false);
mainGame->wPhase->setVisible(true);
mainGame->dField.panel = 0;
mainGame->dField.hovered_card = 0;
mainGame->dField.clicked_card = 0;
mainGame->dField.Clear();
mainGame->dInfo.isFirst = true;
mainGame->dInfo.isStarted = true;
......@@ -114,6 +111,7 @@ int SingleMode::SinglePlayThread(void* param) {
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock();
mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock();
if(exit_on_return)
......@@ -834,15 +832,10 @@ byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
#endif
if(!fp)
return 0;
fseek(fp, 0, SEEK_END);
unsigned int len = ftell(fp);
if(len > sizeof(buffer)) {
fclose(fp);
return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
int len = fread(buffer, 1, sizeof(buffer), fp);
fclose(fp);
if(len >= sizeof(buffer))
return 0;
*slen = len;
return buffer;
}
......
......@@ -504,6 +504,7 @@
!counter 0x40 指示物(No.51 怪腕之必杀摔角手)
!counter 0x1041 捕食指示物
!counter 0x42 指示物(爆竹鬼)
!counter 0x43 缺陷指示物
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......
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