Commit 30415ba8 authored by DailyShana's avatar DailyShana

update

parent ad5cfe65
...@@ -12,8 +12,6 @@ bool SingleMode::is_closing = false; ...@@ -12,8 +12,6 @@ bool SingleMode::is_closing = false;
bool SingleMode::is_continuing = false; bool SingleMode::is_continuing = false;
Replay SingleMode::last_replay; Replay SingleMode::last_replay;
static byte buffer[0x20000];
bool SingleMode::StartPlay() { bool SingleMode::StartPlay() {
Thread::NewThread(SinglePlayThread, 0); Thread::NewThread(SinglePlayThread, 0);
return true; return true;
...@@ -60,7 +58,11 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -60,7 +58,11 @@ int SingleMode::SinglePlayThread(void* param) {
if(!preload_script(pduel, filename, slen)) { if(!preload_script(pduel, filename, slen)) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./single/%ls", open_file_name); myswprintf(fname, L"./single/%ls", open_file_name);
#ifdef _WIN32
slen = WideCharToMultiByte(CP_ACP, 0, fname, -1, filename, 256, 0, 0);
#else
slen = BufferIO::EncodeUTF8(fname, filename); slen = BufferIO::EncodeUTF8(fname, filename);
#endif // _WIN32
if(!preload_script(pduel, filename, slen)) if(!preload_script(pduel, filename, slen))
slen = 0; slen = 0;
} }
...@@ -68,7 +70,11 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -68,7 +70,11 @@ int SingleMode::SinglePlayThread(void* param) {
const wchar_t* name = mainGame->lstSinglePlayList->getListItem(mainGame->lstSinglePlayList->getSelected()); const wchar_t* name = mainGame->lstSinglePlayList->getListItem(mainGame->lstSinglePlayList->getSelected());
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name); myswprintf(fname, L"./single/%ls", name);
#ifdef _WIN32
slen = WideCharToMultiByte(CP_ACP, 0, fname, -1, filename, 256, 0, 0);
#else
slen = BufferIO::EncodeUTF8(fname, filename); slen = BufferIO::EncodeUTF8(fname, filename);
#endif // _WIN32
if(!preload_script(pduel, filename, slen)) if(!preload_script(pduel, filename, slen))
slen = 0; slen = 0;
} }
...@@ -898,30 +904,13 @@ void SingleMode::SinglePlayReload() { ...@@ -898,30 +904,13 @@ void SingleMode::SinglePlayReload() {
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer); mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) { byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256]="./expansions"; char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
if(ScriptReader(sname, slen)) byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer; return buffer;
else else
return ScriptReader(script_name, slen); return default_script_reader(script_name, slen);
}
byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
FILE *fp;
#ifdef _WIN32
wchar_t fname[256];
BufferIO::DecodeUTF8(script_name, fname);
fp = _wfopen(fname, L"rb");
#else
fp = fopen(script_name, "rb");
#endif
if(!fp)
return 0;
int len = fread(buffer, 1, sizeof(buffer), fp);
fclose(fp);
if(len >= sizeof(buffer))
return 0;
*slen = len;
return buffer;
} }
int SingleMode::MessageHandler(long fduel, int type) { int SingleMode::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
......
...@@ -27,7 +27,6 @@ public: ...@@ -27,7 +27,6 @@ public:
static void SinglePlayReload(); static void SinglePlayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen); static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
protected: protected:
......
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