Commit e92211fc authored by DailyShana's avatar DailyShana Committed by nanahira

update loading expansion script (#2125)

* update loading expansion script

* update

* Revert "update"

This reverts commit 30415ba8.
parent 366ff6e4
......@@ -64,11 +64,11 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
if(mainGame->dInfo.isSingleMode) {
set_script_reader((script_reader)SingleMode::ScriptReader);
set_script_reader((script_reader)SingleMode::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler);
} else {
set_script_reader(default_script_reader);
set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler);
}
......@@ -935,6 +935,15 @@ void ReplayMode::ReplayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
}
byte* ReplayMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int ReplayMode::MessageHandler(long fduel, int type) {
if(!enable_log)
return 0;
......
......@@ -47,6 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type);
};
......
......@@ -406,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader);
set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)SingleDuel::MessageHandler);
rnd.reset(seed);
......@@ -1545,6 +1545,15 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer::ReSendToPlayer(*pit);
}
}
byte* SingleDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int SingleDuel::MessageHandler(long fduel, int type) {
if(!enable_log)
return 0;
......
......@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg);
......
......@@ -38,7 +38,7 @@ int SingleMode::SinglePlayThread(void* param) {
mtrandom rnd;
time_t seed = time(0);
rnd.reset(seed);
set_script_reader((script_reader)ScriptReader);
set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler);
pduel = create_duel(rnd.rand());
......@@ -849,6 +849,14 @@ void SingleMode::SinglePlayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
}
byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
if(ScriptReader(sname, slen))
return buffer;
else
return ScriptReader(script_name, slen);
}
byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
FILE *fp;
#ifdef _WIN32
......
......@@ -26,6 +26,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload();
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);
......
......@@ -381,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
}
time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader);
set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)TagDuel::MessageHandler);
rnd.reset(seed);
......@@ -1662,6 +1662,15 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
}
}
}
byte* TagDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int TagDuel::MessageHandler(long fduel, int type) {
if(!enable_log)
return 0;
......
......@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type);
static void TagTimer(evutil_socket_t fd, short events, void* arg);
......
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