Commit 9c232040 authored by nanahira's avatar nanahira

update

parent 2243e2d1
......@@ -80,12 +80,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;
......
......@@ -20,7 +20,7 @@
#include <unistd.h>
#endif
const unsigned short PRO_VERSION = 0x133E;
const unsigned short PRO_VERSION = 0x133F;
namespace ygo {
......@@ -990,11 +990,7 @@ void Game::LoadConfig() {
gameConf.separate_clear_button = 1;
gameConf.auto_search_limit = -1;
gameConf.chkIgnoreDeckChanges = 0;
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);
......
......@@ -215,18 +215,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;
}
......
......@@ -682,8 +682,8 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(*oit);
break;
}
case 10:
//modded
case 10:
case 11:
case 12: {
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
......
......@@ -830,15 +830,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)) {
int len = fread(buffer, 1, sizeof(buffer), fp);
fclose(fp);
if(len >= sizeof(buffer))
return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
fclose(fp);
*slen = len;
return buffer;
}
......
......@@ -602,8 +602,8 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
case 2:
case 3:
case 5:
case 10:
//modded
case 10:
case 11:
case 12: {
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, offset, pbuf - offset);
......
......@@ -44,15 +44,10 @@ byte* default_script_reader(const char* script_name, int* slen) {
fp = fopen(script_name, "rb");
if (!fp)
return 0;
fseek(fp, 0, SEEK_END);
uint32 len = ftell(fp);
if (len > sizeof(buffer)) {
int len = fread(buffer, 1, sizeof(buffer), fp);
fclose(fp);
if(len >= sizeof(buffer))
return 0;
}
fseek(fp, 0, SEEK_SET);
fread(buffer, len, 1, fp);
fclose(fp);
*slen = len;
return buffer;
}
......
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