Commit 122e33fa authored by nanahira's avatar nanahira

merge

parents 4e1e6b61 84200fa1
...@@ -39,8 +39,10 @@ bool Game::Initialize() { ...@@ -39,8 +39,10 @@ bool Game::Initialize() {
params.DriverType = irr::video::EDT_OPENGL; params.DriverType = irr::video::EDT_OPENGL;
params.WindowSize = irr::core::dimension2d<u32>(gameConf.window_width, gameConf.window_height); params.WindowSize = irr::core::dimension2d<u32>(gameConf.window_width, gameConf.window_height);
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device) {
ErrorLog("Failed to create Irrlicht Engine device!");
return false; return false;
}
// Apply skin // Apply skin
if(gameConf.skin_index && gameConf.use_d3d) { if(gameConf.skin_index && gameConf.use_d3d) {
wchar_t skin_dir[16]; wchar_t skin_dir[16];
...@@ -81,15 +83,21 @@ bool Game::Initialize() { ...@@ -81,15 +83,21 @@ bool Game::Initialize() {
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
driver->setTextureCreationFlag(irr::video::ETCF_OPTIMIZED_FOR_QUALITY, true); driver->setTextureCreationFlag(irr::video::ETCF_OPTIMIZED_FOR_QUALITY, true);
imageManager.SetDevice(device); imageManager.SetDevice(device);
if(!imageManager.Initial()) if(!imageManager.Initial()) {
ErrorLog("Failed to load textures!");
return false; return false;
}
LoadExpansionDB(); LoadExpansionDB();
if(dataManager.LoadDB(GetLocaleDir("cards.cdb"))) {} else if(dataManager.LoadDB(GetLocaleDir("cards.cdb"))) {} else
if(!dataManager.LoadDB("cards.cdb")) if(!dataManager.LoadDB("cards.cdb")) {
ErrorLog("Failed to load card database (cards.cdb)!");
return false; return false;
}
if(dataManager.LoadStrings(GetLocaleDir("strings.conf"))) {} else if(dataManager.LoadStrings(GetLocaleDir("strings.conf"))) {} else
if(!dataManager.LoadStrings("strings.conf")) if(!dataManager.LoadStrings("strings.conf")) {
ErrorLog("Failed to load strings!");
return false; return false;
}
dataManager.LoadStrings("./expansions/strings.conf"); dataManager.LoadStrings("./expansions/strings.conf");
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
...@@ -97,8 +105,10 @@ bool Game::Initialize() { ...@@ -97,8 +105,10 @@ bool Game::Initialize() {
lpcFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 48); lpcFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 48);
guiFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize); guiFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize);
textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize); textFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.textfont, gameConf.textfontsize);
if(!numFont || !textFont) if(!numFont || !textFont) {
ErrorLog("Failed to load font(s)!");
return false; return false;
}
smgr = device->getSceneManager(); smgr = device->getSceneManager();
device->setWindowCaption(L"KoishiPro"); device->setWindowCaption(L"KoishiPro");
device->setResizable(true); device->setResizable(true);
...@@ -1722,17 +1732,22 @@ void Game::AddDebugMsg(char* msg) ...@@ -1722,17 +1732,22 @@ void Game::AddDebugMsg(char* msg)
AddChatMsg(wbuf, 9); AddChatMsg(wbuf, 9);
} }
if (enable_log & 0x2) { if (enable_log & 0x2) {
FILE* fp = fopen("error.log", "at"); char msgbuf[1040];
if (!fp) sprintf(msgbuf, "[Script Error]: %s", msg);
return; ErrorLog(msgbuf);
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
strftime(timebuf, 40, "%Y-%m-%d %H:%M:%S", localedtime);
fprintf(fp, "[%s][Script Error]: %s\n", timebuf, msg);
fclose(fp);
} }
} }
void Game::ErrorLog(char* msg) {
FILE* fp = fopen("error.log", "at");
if(!fp)
return;
time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
strftime(timebuf, 40, "%Y-%m-%d %H:%M:%S", localedtime);
fprintf(fp, "[%s]%s\n", timebuf, msg);
fclose(fp);
}
bool Game::MakeDirectory(const std::string folder) { bool Game::MakeDirectory(const std::string folder) {
std::string folder_builder; std::string folder_builder;
std::string sub; std::string sub;
......
...@@ -157,6 +157,7 @@ public: ...@@ -157,6 +157,7 @@ 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);
void ErrorLog(char* msgbuf);
bool MakeDirectory(const std::string folder); bool MakeDirectory(const std::string folder);
void initUtils(); void initUtils();
void ClearTextures(); void ClearTextures();
......
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