Commit 8bd789e3 authored by nanahira's avatar nanahira

merge mkdir

parents 8df9e3f0 621551e9
...@@ -18,7 +18,12 @@ ...@@ -18,7 +18,12 @@
#ifndef _WIN32 #ifndef _WIN32
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <unistd.h>
#else
#include <direct.h>
#include <io.h>
#endif #endif
const unsigned short PRO_VERSION = 0x1343; const unsigned short PRO_VERSION = 0x1343;
...@@ -33,6 +38,7 @@ unsigned short replay_mode; ...@@ -33,6 +38,7 @@ unsigned short replay_mode;
HostInfo game_info; HostInfo game_info;
void Game::MainServerLoop() { void Game::MainServerLoop() {
initUtils();
deckManager.LoadLFList(); deckManager.LoadLFList();
LoadExpansionDB(); LoadExpansionDB();
dataManager.LoadDB("cards.cdb"); dataManager.LoadDB("cards.cdb");
...@@ -53,6 +59,7 @@ void Game::MainServerLoop() { ...@@ -53,6 +59,7 @@ void Game::MainServerLoop() {
#else //YGOPRO_SERVER_MODE #else //YGOPRO_SERVER_MODE
bool Game::Initialize() { bool Game::Initialize() {
srand(time(0)); srand(time(0));
initUtils();
LoadConfig(); LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters(); irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
params.AntiAlias = gameConf.antialias; params.AntiAlias = gameConf.antialias;
...@@ -1381,6 +1388,57 @@ void Game::AddDebugMsg(char* msg) ...@@ -1381,6 +1388,57 @@ void Game::AddDebugMsg(char* msg)
} }
#endif //YGOPRO_SERVER_MODE #endif //YGOPRO_SERVER_MODE
} }
bool Game::MakeDirectory(const std::string folder) {
std::string folder_builder;
std::string sub;
sub.reserve(folder.size());
for(auto it = folder.begin(); it != folder.end(); ++it) {
const char c = *it;
sub.push_back(c);
if(c == '/' || it == folder.end() - 1) {
folder_builder.append(sub);
if(access(folder_builder.c_str(), 0) != 0)
#ifdef _WIN32
if(mkdir(folder_builder.c_str()) != 0)
#else
if(mkdir(folder_builder.c_str(), 0777) != 0)
#endif
return false;
sub.clear();
}
}
return true;
}
void Game::initUtils() {
//user files
MakeDirectory("replay");
#ifdef YGOPRO_SERVER_MODE
//special scripts
MakeDirectory("specials");
#else
//cards from extra pack
MakeDirectory("expansions");
//files in ygopro-starter-pack
MakeDirectory("deck");
MakeDirectory("single");
//original files
MakeDirectory("script");
MakeDirectory("textures");
//sound
MakeDirectory("sound");
MakeDirectory("sound/BGM");
MakeDirectory("sound/BGM/advantage");
MakeDirectory("sound/BGM/deck");
MakeDirectory("sound/BGM/disadvantage");
MakeDirectory("sound/BGM/duel");
MakeDirectory("sound/BGM/lose");
MakeDirectory("sound/BGM/menu");
MakeDirectory("sound/BGM/win");
//pics
MakeDirectory("pics");
MakeDirectory("pics/field");
#endif //YGOPRO_SERVER_MODE
}
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
void Game::ClearTextures() { void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0); matManager.mCard.setTexture(0, 0);
......
...@@ -110,6 +110,8 @@ public: ...@@ -110,6 +110,8 @@ public:
void MainServerLoop(); void MainServerLoop();
void LoadExpansionDB(); void LoadExpansionDB();
void AddDebugMsg(char* msgbuf); void AddDebugMsg(char* msgbuf);
void AddDebugMsg(char* msgbuf);
bool MakeDirectory(const std::string folder);
#else #else
void MainLoop(); void MainLoop();
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
...@@ -144,6 +146,8 @@ public: ...@@ -144,6 +146,8 @@ public:
void AddChatMsg(wchar_t* msg, int player); void AddChatMsg(wchar_t* msg, int player);
void ClearChatMsg(); void ClearChatMsg();
void AddDebugMsg(char* msgbuf); void AddDebugMsg(char* msgbuf);
bool MakeDirectory(const std::string folder);
void initUtils();
void ClearTextures(); void ClearTextures();
void CloseDuelWindow(); void CloseDuelWindow();
......
...@@ -240,6 +240,9 @@ ...@@ -240,6 +240,9 @@
!system 1161 效果处理 !system 1161 效果处理
!system 1162 效果重置 !system 1162 效果重置
!system 1163 灵摆召唤 !system 1163 灵摆召唤
!system 1164 同调召唤
!system 1165 超量召唤
!system 1166 连接召唤
#menu #menu
!system 1200 联机模式 !system 1200 联机模式
!system 1201 单人模式 !system 1201 单人模式
......
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