Commit 0e71945b authored by nanahira's avatar nanahira

load_beta

parent 2ad74955
......@@ -34,8 +34,8 @@ HostInfo game_info;
void Game::MainServerLoop() {
deckManager.LoadLFList();
LoadExpansionDB();
LoadBetaDB();
dataManager.LoadDB("cards.cdb");
aServerPort = NetServer::StartServer(aServerPort);
NetServer::InitDuel();
printf("%u\n", aServerPort);
......@@ -49,6 +49,38 @@ void Game::MainServerLoop() {
#endif
}
}
void Game::LoadBetaDB() {
#ifdef _WIN32
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./beta/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
char fname[780];
BufferIO::EncodeUTF8(fdataw.cFileName, fname);
sprintf(fpath, "./beta/%s", fname);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
if((dir = opendir("./beta/")) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char filepath[1000];
sprintf(filepath, "./beta/%s", dirp->d_name);
dataManager.LoadDB(filepath);
}
closedir(dir);
}
#endif
}
#else //YGOPRO_SERVER_MODE
bool Game::Initialize() {
srand(time(0));
......
......@@ -92,6 +92,7 @@ public:
#ifdef YGOPRO_SERVER_MODE
void MainServerLoop();
void LoadExpansionDB();
void LoadBetaDB();
void AddDebugMsg(char* msgbuf);
#else
void MainLoop();
......
......@@ -748,11 +748,15 @@ int32 interpreter::load_card_script(uint32 code) {
lua_pushvalue(current_state, -2);
lua_rawset(current_state, -3);
//load extra scripts
sprintf(script_name, "./expansions/script/c%d.lua", code);
sprintf(script_name, "./beta/script/c%d.lua", code);
if (!load_script(script_name)) {
sprintf(script_name, "./script/c%d.lua", code);
sprintf(script_name, "./expansions/script/c%d.lua", code);
if (!load_script(script_name)) {
return OPERATION_FAIL;
sprintf(script_name, "./script/c%d.lua", code);
if (!load_script(script_name)) {
return OPERATION_FAIL;
}
}
}
}
......
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