Commit 47cb1ed1 authored by edo9300's avatar edo9300

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

parents bf20b910 c052813b
...@@ -83,12 +83,7 @@ bool DataManager::LoadStrings(const char* file) { ...@@ -83,12 +83,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;
...@@ -225,12 +220,7 @@ bool DeckManager::LoadDeck(const wchar_t* file) { ...@@ -225,12 +220,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;
......
...@@ -1272,9 +1272,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1272,9 +1272,16 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->is_highlighting = true; pcard->is_highlighting = true;
mainGame->dField.highlighting_card = pcard; mainGame->dField.highlighting_card = pcard;
} }
wchar_t ynbuf[256]; int desc = BufferIO::ReadInt32(pbuf);
myswprintf(ynbuf, dataManager.GetSysString(200), dataManager.FormatLocation(l, s), dataManager.GetName(code)); if(desc == 0) {
myswprintf(textBuffer, L"%ls\n%ls", event_string, ynbuf); wchar_t ynbuf[256];
myswprintf(ynbuf, dataManager.GetSysString(200), dataManager.FormatLocation(l, s), dataManager.GetName(code));
myswprintf(textBuffer, L"%ls\n%ls", event_string, ynbuf);
} else if(desc < 2048) {
myswprintf(textBuffer, dataManager.GetSysString(desc), dataManager.GetName(code));
} else {
myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code));
}
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
......
...@@ -1017,11 +1017,7 @@ void Game::LoadConfig() { ...@@ -1017,11 +1017,7 @@ void Game::LoadConfig() {
gameConf.enablemusic = true; gameConf.enablemusic = true;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
gameConf.draw_field_spell = 1; gameConf.draw_field_spell = 1;
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);
......
...@@ -159,18 +159,15 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -159,18 +159,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;
} }
......
...@@ -387,7 +387,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -387,7 +387,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
pbuf += 8; pbuf += 12;
return ReadReplayResponse(); return ReadReplayResponse();
} }
case MSG_SELECT_YESNO: { case MSG_SELECT_YESNO: {
......
...@@ -712,7 +712,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -712,7 +712,7 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
pbuf += 8; pbuf += 12;
WaitforResponse(player); WaitforResponse(player);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1; return 1;
......
...@@ -187,7 +187,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -187,7 +187,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
pbuf += 8; pbuf += 12;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) { if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) {
mainGame->singleSignal.Reset(); mainGame->singleSignal.Reset();
...@@ -856,15 +856,10 @@ byte* SingleMode::ScriptReader(const char* script_name, int* slen) { ...@@ -856,15 +856,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);
return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
fclose(fp); fclose(fp);
if(len >= sizeof(buffer))
return 0;
*slen = len; *slen = len;
return buffer; return buffer;
} }
......
...@@ -650,7 +650,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -650,7 +650,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
pbuf += 8; pbuf += 12;
WaitforResponse(player); WaitforResponse(player);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1; return 1;
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
!system 92 Use Opponent Monster !system 92 Use Opponent Monster
!system 93 Do you want to continue to choose the material? !system 93 Do you want to continue to choose the material?
!system 94 Activate effect now? !system 94 Activate effect now?
!system 95 Do you wish to use [%ls]'s effect?
!system 96 Do you wish to use [%ls]'s effect instead of destroying?
!system 97 Do you wish to put [%ls] in the Spell & Trap Zone?
!system 100 First to go !system 100 First to go
!system 101 Second to go !system 101 Second to go
!system 200 Do you wish to use from [%ls] [%ls]'s effect? !system 200 Do you wish to use from [%ls] [%ls]'s effect?
......
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