OSDN Git Service

サーバーのチャンネル設定用default.config.jsonを追加
authorh2so5 <h2so5@git.sourceforge.jp>
Sun, 21 Oct 2012 05:10:12 +0000 (14:10 +0900)
committerh2so5 <h2so5@git.sourceforge.jp>
Sun, 21 Oct 2012 05:10:12 +0000 (14:10 +0900)
チャンネル0のサーバーステータスを返すように変更

client/bin/server/channels/default.config.json [new file with mode: 0644]
client/bin/server/config.json
server/Channel.cpp
server/Channel.hpp
server/Server.cpp

diff --git a/client/bin/server/channels/default.config.json b/client/bin/server/channels/default.config.json
new file mode 100644 (file)
index 0000000..811f88c
--- /dev/null
@@ -0,0 +1,6 @@
+{
+       "name": "メインチャンネル",
+       "stage": "stage:ケロリン町",
+       "capacity": 20,
+       "warp_points": []
+}
\ No newline at end of file
index b250eb5..38ddff6 100644 (file)
@@ -9,8 +9,7 @@
                [
                        "m2op.net"
                ],
-       
-       "stage": "stage:ケロリン町",
+               
        "capacity": 20,
        
        "receive_limit_1": 50,
index c87b4e0..9dce51a 100644 (file)
@@ -15,8 +15,20 @@ Channel::Channel()
 void Channel::Load()
 {
        pt_.clear();
-       path p("./channels");
 
+       path default_json_path("./channels/default.config.json");
+       if (exists(default_json_path) && !is_directory(default_json_path)) {
+               try {
+                       boost::property_tree::ptree config_pt;
+                       read_json(default_json_path.string(), config_pt);
+                       pt_.put_child("ch000", config_pt);
+
+               } catch (const std::exception& e) {
+                       Logger::Error("%d", e.what());
+               }
+       }
+
+       path p("./channels");
        if (exists(p) && is_directory(p)) {
                for (auto it_dir = directory_iterator(p); it_dir != directory_iterator(); ++it_dir) {
                        if (is_directory(*it_dir)) {
@@ -40,4 +52,14 @@ void Channel::Load()
 const boost::property_tree::ptree& Channel::pt() const
 {
        return pt_;
+}
+
+std::string Channel::GetDefaultStage() const
+{
+       return pt_.get<std::string>("ch000.stage");
+}
+
+int Channel::GetDefaultCapacity() const
+{
+       return pt_.get<int>("ch000.capacity");
 }
\ No newline at end of file
index 0adee6e..18e2188 100644 (file)
@@ -10,6 +10,8 @@ class Channel {
                Channel();
 
                const boost::property_tree::ptree& pt() const;
+               std::string GetDefaultStage() const;
+               int GetDefaultCapacity() const;
 
        private:
                void Load();
index 59e6912..4d73f66 100644 (file)
@@ -104,7 +104,7 @@ namespace network {
                                                % MMO_VERSION_MAJOR % MMO_VERSION_MINOR % MMO_VERSION_REVISION\r
                                                % GetUserCount()\r
                                                % config_.capacity()\r
-                                               % config_.stage()\r
+                                               % channel_.GetDefaultStage()\r
                                        ).str();\r
 \r
                return msg;\r