OSDN Git Service

.gitignoreを更新
authorh2so5 <h2so5@git.sourceforge.jp>
Wed, 5 Sep 2012 06:42:52 +0000 (15:42 +0900)
committerh2so5 <h2so5@git.sourceforge.jp>
Wed, 5 Sep 2012 06:42:52 +0000 (15:42 +0900)
バーション管理用のファイルを追加
ログファイルを出力するように変更

.gitignore
client/Core.cpp
client/Core.hpp
client/version.hpp [new file with mode: 0644]
common/Logger.hpp
server/main.cpp
server/version.hpp [new file with mode: 0644]

index 29c8b4c..c1654b6 100644 (file)
@@ -24,3 +24,7 @@
 /Client/Debug
 /client/resourse.aps
 /client/bin/resources/textures
+/client/buildversion.hpp
+/client/get_auto_ver_client.vbs
+/server/get_auto_ver_server.vbs
+/server/buildversion.hpp
index e154617..68c668f 100644 (file)
@@ -7,17 +7,29 @@
 #include "ServerLauncher.hpp"
 #include "ConfigManager.hpp"
 #include "../common/Logger.hpp"
+#include "version.hpp"
 
 const TCHAR* Core::CONFIG_PATH = _T("config.json");
-const TCHAR* Core::WINDOW_TITILE = _T("Miku Miku Online");
 const TCHAR* Core::FONT_FILE_PATH = _T("resources/fonts/umeplus-p-gothic.ttf");
 
+#ifdef _DEBUG
+#define EXCEPTION_LOG(e) (e)
+#else
+#define EXCEPTION_LOG(e) try { \
+                       (e); \
+               } catch (std::exception& e) { \
+                       Logger::Error(_T("%s"), unicode::ToTString(e.what())); \
+               }
+#endif
+
 Core::Core()
 {
 }
 
 int Core::Run()
 {
+       Logger::Info(_T("%s"), unicode::ToTString(MMO_VERSION_TEXT));
+
     if (SetUpDxLib() == -1) {
         return -1;
     }
@@ -26,7 +38,8 @@ int Core::Run()
 
     LoadFont();
     SceneInit();
-    MainLoop();
+
+       EXCEPTION_LOG(MainLoop());
 
     if (current_scene_) {
         current_scene_ = scene::BasePtr();
@@ -62,8 +75,7 @@ void Core::MainLoop()
 int Core::SetUpDxLib()
 {
     //TCHAR title[] = WINDOW_TITILE;
-    const TCHAR* title = WINDOW_TITILE;
-    SetMainWindowText(title);
+    SetMainWindowText(unicode::ToTString(MMO_VERSION_TEXT).c_str());
 
     SetWindowIconID(100);
 
index 28aff6f..19202b1 100644 (file)
@@ -32,7 +32,6 @@ class Core {
 
     private:
         const static TCHAR* CONFIG_PATH;
-        const static TCHAR* WINDOW_TITILE;
         const static TCHAR* FONT_FILE_PATH;
 
 };
diff --git a/client/version.hpp b/client/version.hpp
new file mode 100644 (file)
index 0000000..4371991
--- /dev/null
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "buildversion.hpp"
+
+#define MMO_VERSION_TOSTRING_(val) #val
+#define MMO_VERSION_TOSTRING(val) MMO_VERSION_TOSTRING_(val)
+
+#define MMO_VERSION_MAJOR 0
+#define MMO_VERSION_MINOR 1
+#define MMO_VERSION_REVISION 1
+
+#ifdef MMO_VERSION_BUILD
+#define MMO_VERSION_BUILD_TEXT " Build " MMO_VERSION_TOSTRING(MMO_VERSION_BUILD)
+#else
+#define MMO_VERSION_BUILD_TEXT
+#endif
+
+#define MMO_VERSION_TITLE "Miku Miku Online"
+
+#define MMO_VERSION_TEXT (MMO_VERSION_TITLE " " MMO_VERSION_TOSTRING(MMO_VERSION_MAJOR) "." \
+                                                       MMO_VERSION_TOSTRING(MMO_VERSION_MINOR) "." MMO_VERSION_TOSTRING(MMO_VERSION_REVISION)\
+                                                       MMO_VERSION_BUILD_TEXT)
index c830045..54d2d89 100644 (file)
@@ -13,7 +13,7 @@
 class Logger {
         // Singleton
     private:
-        Logger() {}
+        Logger() : ofs_("mmo_log.txt") {}
         Logger(const Logger& logger) {}
         virtual ~Logger() {}
 
@@ -102,37 +102,38 @@ class Logger {
         }
 
         void Log(const tstring& prefix, const tstring& format) {
-            auto out = prefix + format + _T("\r\n");
-            OutputDebugString(prefix.c_str());
-            OutputDebugString(format.c_str());
-            OutputDebugString(_T("\r\n"));
+            auto out = prefix + format + _T("\n");
+            OutputDebugString(out.c_str());
+                       ofs_ << unicode::ToString(out);
         }
 
         template<class T1>
         void Log(const tstring& prefix, const tstring& format, const T1& t1) {
-            OutputDebugString(prefix.c_str());
-            OutputDebugString((tformat(format) % t1).str().c_str());
-            OutputDebugString(_T("\r\n"));
+            auto out = prefix + (tformat(format) % t1).str() + _T("\n");
+            OutputDebugString(out.c_str());
+                       ofs_ << unicode::ToString(out);
         }
 
         template<class T1, class T2>
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2) {
-            OutputDebugString(prefix.c_str());
-            OutputDebugString((tformat(format) % t1 % t2).str().c_str());
-            OutputDebugString(_T("\r\n"));
+            auto out = prefix + (tformat(format) % t1 % t2).str() + _T("\n");
+            OutputDebugString(out.c_str());
+                       ofs_ << unicode::ToString(out);
         }
 
         template<class T1, class T2, class T3>
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2, const T3& t3) {
-            OutputDebugString(prefix.c_str());
-            OutputDebugString((tformat(format) % t1 % t2 % t3).str().c_str());
-            OutputDebugString(_T("\r\n"));
+            auto out = prefix + (tformat(format) % t1 % t2 % t3).str() + _T("\n");
+            OutputDebugString(out.c_str());
+                       ofs_ << unicode::ToString(out);
         }
 
         template<class T1, class T2, class T3, class T4>
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2, const T3& t3, const T4& t4) {
-            OutputDebugString(prefix.c_str());
-            OutputDebugString((tformat(format) % t1 % t2 % t3 % t4).str().c_str());
-            OutputDebugString(_T("\r\n"));
+            auto out = prefix + (tformat(format) % t1 % t2 % t3 % t4).str() + _T("\n");
+            OutputDebugString(out.c_str());
+                       ofs_ << unicode::ToString(out);
         }
+
+               std::ofstream ofs_;
 };
index 20a19e8..8200472 100644 (file)
@@ -9,6 +9,7 @@
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/interprocess/managed_shared_memory.hpp>
 #include <boost/foreach.hpp>
+#include "version.hpp"
 #include "Server.hpp"
 #include "../common/network/Encrypter.hpp"
 #include "../common/network/Signature.hpp"
@@ -21,6 +22,7 @@ using namespace boost::posix_time;
 
 int main(int argc, char* argv[])
 {
+       Logger::Info(_T("%s"), unicode::ToTString(MMO_VERSION_TEXT));
 
  try {
 
diff --git a/server/version.hpp b/server/version.hpp
new file mode 100644 (file)
index 0000000..2e7b5b2
--- /dev/null
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "buildversion.hpp"
+
+#define MMO_VERSION_TOSTRING_(val) #val
+#define MMO_VERSION_TOSTRING(val) MMO_VERSION_TOSTRING_(val)
+
+#define MMO_VERSION_MAJOR 0
+#define MMO_VERSION_MINOR 1
+#define MMO_VERSION_REVISION 1
+
+#ifdef MMO_VERSION_BUILD
+#define MMO_VERSION_BUILD_TEXT " Build " MMO_VERSION_TOSTRING(MMO_VERSION_BUILD)
+#else
+#define MMO_VERSION_BUILD_TEXT
+#endif
+
+#define MMO_VERSION_TITLE "Miku Miku Online Server"
+
+#define MMO_VERSION_TEXT (MMO_VERSION_TITLE " " MMO_VERSION_TOSTRING(MMO_VERSION_MAJOR) "." \
+                                                       MMO_VERSION_TOSTRING(MMO_VERSION_MINOR) "." MMO_VERSION_TOSTRING(MMO_VERSION_REVISION)\
+                                                       MMO_VERSION_BUILD_TEXT)