Commit 627ba3ef authored by nanahira's avatar nanahira Committed by GitHub

Merge branch 'master' into patch-2

parents df269693 84200fa1
...@@ -38,8 +38,10 @@ bool Game::Initialize() { ...@@ -38,8 +38,10 @@ bool Game::Initialize() {
params.DriverType = irr::video::EDT_OPENGL; params.DriverType = irr::video::EDT_OPENGL;
params.WindowSize = irr::core::dimension2d<u32>(1024, 640); params.WindowSize = irr::core::dimension2d<u32>(1024, 640);
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device) {
ErrorLog("Failed to create Irrlicht Engine device!");
return false; return false;
}
linePatternD3D = 0; linePatternD3D = 0;
linePatternGL = 0x0f0f; linePatternGL = 0x0f0f;
waitFrame = 0; waitFrame = 0;
...@@ -61,22 +63,30 @@ bool Game::Initialize() { ...@@ -61,22 +63,30 @@ 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("cards.cdb")) if(!dataManager.LoadDB("cards.cdb")) {
ErrorLog("Failed to load card database (cards.cdb)!");
return false; return false;
}
LoadExpansionStrings(); LoadExpansionStrings();
if(!dataManager.LoadStrings("strings.conf")) if(!dataManager.LoadStrings("strings.conf")) {
ErrorLog("Failed to load strings!");
return false; return false;
}
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12); adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12);
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 = guiFont; textFont = guiFont;
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"YGOPro"); device->setWindowCaption(L"YGOPro");
device->setResizable(false); device->setResizable(false);
...@@ -1442,17 +1452,22 @@ void Game::AddDebugMsg(char* msg) ...@@ -1442,17 +1452,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;
......
...@@ -138,6 +138,7 @@ public: ...@@ -138,6 +138,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