OSDN Git Service

UDPコマンドの受信を制限
authorh2so5 <h2so5@git.sourceforge.jp>
Mon, 17 Sep 2012 09:27:50 +0000 (18:27 +0900)
committerh2so5 <h2so5@git.sourceforge.jp>
Mon, 17 Sep 2012 09:27:50 +0000 (18:27 +0900)
UIListのマウス認識範囲を修正

13 files changed:
client/Client.cpp
client/Client.hpp
client/CommandManager.cpp
client/CommandManager.hpp
client/scene/Connect.cpp
client/ui/UIList.cpp
client/version.hpp
common/Logger.hpp
common/network/Command.cpp
common/network/Command.hpp
server/Server.cpp
server/main.cpp
server/version.hpp

index 3ce2a20..6b641dd 100644 (file)
@@ -8,6 +8,7 @@
 #include "../common/network/Utils.hpp"
 #include "../common/network/Command.hpp"
 #include "../common/Logger.hpp"
+#include "version.hpp"
 
 namespace network {
 
@@ -104,7 +105,7 @@ Client::Client(const std::string& host,
 
                             session->Send(network::ServerReceiveClientInfo(
                                             network::Encrypter::GetHash(public_key),
-                                            PROTOCOL_VERSION,
+                                            (uint16_t)MMO_PROTOCOL_VERSION,
                                             session->udp_port()
                                     ));
                         }
index dab3fca..9d47baa 100644 (file)
@@ -10,7 +10,6 @@
 #include "../common/network/Signature.hpp"
 
 #define UDP_MAX_RECEIVE_LENGTH (512)
-#define PROTOCOL_VERSION (1)
 #define DEFAULT_WRITE_AVERAGE_LIMIT (200)
 
 namespace network {
index ddcc5ad..b1f2eff 100644 (file)
@@ -54,6 +54,12 @@ void CommandManager::Update()
                        }
                        break;
 
+                       case ClientReceiveUnsupportVersionError:
+                       {
+                               status_ = STATUS_ERROR_VERSION;
+                       }
+                       break;
+
                        // サーバーデータ受信
                        case ClientReceiveServerInfo:
                        {
index 6703737..c3ae73f 100644 (file)
@@ -22,7 +22,8 @@ class CommandManager {
                        STATUS_READY,
                        STATUS_ERROR,
                        STATUS_ERROR_CROWDED,
-                       STATUS_ERROR_NOSTAGE
+                       STATUS_ERROR_NOSTAGE,
+                       STATUS_ERROR_VERSION
                };
 
     public:
index 11e080a..d383bbd 100644 (file)
@@ -32,7 +32,7 @@ void Connect::Begin()
     int width, height;
     GetScreenState(&width, &height, nullptr);
 
-    message_.set_width(400);
+    message_.set_width(450);
     message_.set_text(_T("\90Ú\91±\92\86..."));
     message_.set_bgcolor(UIBase::Color(0,0,0,0));
     message_.set_textcolor(UIBase::Color(0,0,0,255));
@@ -83,6 +83,10 @@ void Connect::Update()
                message_.set_text(_T("\83G\83\89\81[\81F\90l\90\94\82ª\91½\82·\82¬\82Ü\82·"));
                command_manager_->set_client(ClientUniqPtr());
                break;
+       case CommandManager::STATUS_ERROR_VERSION:
+               message_.set_text(_T("\83G\83\89\81[\81F\83T\81[\83o\81[\82Æ\83N\83\89\83C\83A\83\93\83g\82Ì\83o\81[\83W\83\87\83\93\82ª\91Î\89\9e\82µ\82Ä\82¢\82Ü\82¹\82ñ"));
+               command_manager_->set_client(ClientUniqPtr());
+               break;
        case CommandManager::STATUS_ERROR_NOSTAGE:
                message_.set_text((tformat(_T("\83G\83\89\81[\81F\90Ú\91±\82·\82é\82É\82Í\83X\83e\81[\83W\83f\81[\83^\81u%s\81v\82ª\95K\97v\82Å\82·")) % 
                        unicode::ToTString(command_manager_->stage())).str());
index 8efeb37..aeaa891 100644 (file)
@@ -136,8 +136,8 @@ void UIList::ProcessInput(InputManager* input)
     for (auto it = items_.begin(); it != items_.end(); ++it) {
         auto item = *it;
         UIBasePtr item_ptr = *static_cast<UIBasePtr*>(item->GetPointerFromInternalField(0));
-               if (item_ptr->absolute_y() > absolute_y() && 
-                       item_ptr->absolute_y() + item_ptr->absolute_height() < absolute_y() + absolute_height()) {
+               if (input->GetMousePos().first > absolute_y() && 
+                       input->GetMousePos().second < absolute_y() + absolute_height()) {
                        item_ptr->ProcessInput(input);
                }
     }
index f353cb8..9307a6e 100644 (file)
@@ -11,6 +11,8 @@
 #define MMO_VERSION_MINOR 3
 #define MMO_VERSION_REVISION 5
 
+#define MMO_PROTOCOL_VERSION 2
+
 #ifdef MMO_VERSION_BUILD
 #define MMO_VERSION_BUILD_TEXT " Build " MMO_VERSION_TOSTRING(MMO_VERSION_BUILD)
 #else
index 243819f..7072575 100644 (file)
@@ -142,7 +142,7 @@ class Logger {
         void Log(const tstring& prefix, const tstring& format) {
             auto out = GetTimeString() + _T(">  ") + prefix + format + _T("\n");
             OutputDebugString(out.c_str());
-                       std::cout << unicode::ToString(out);
+                       std::cout << unicode::ToString(out) << std::flush;
                        ofs_ << unicode::ToString(out) << std::flush;
         }
 
@@ -150,7 +150,7 @@ class Logger {
         void Log(const tstring& prefix, const tstring& format, const T1& t1) {
             auto out = GetTimeString() + _T(">  ") + prefix + (tformat(format) % t1).str() + _T("\n");
             OutputDebugString(out.c_str());
-                       std::cout << unicode::ToString(out);
+                       std::cout << unicode::ToString(out) << std::flush;
                        ofs_ << unicode::ToString(out) << std::flush;
         }
 
@@ -158,7 +158,7 @@ class Logger {
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2) {
             auto out = GetTimeString() + _T(">  ") + prefix + (tformat(format) % t1 % t2).str() + _T("\n");
             OutputDebugString(out.c_str());
-                       std::cout << unicode::ToString(out);
+                       std::cout << unicode::ToString(out) << std::flush;
             ofs_ << unicode::ToString(out) << std::flush;
         }
 
@@ -166,7 +166,7 @@ class Logger {
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2, const T3& t3) {
             auto out = GetTimeString() + _T(">  ") + prefix + (tformat(format) % t1 % t2 % t3).str() + _T("\n");
             OutputDebugString(out.c_str());
-                       std::cout << unicode::ToString(out);
+                       std::cout << unicode::ToString(out) << std::flush;
                        ofs_ << unicode::ToString(out) << std::flush;
         }
 
@@ -174,7 +174,7 @@ class Logger {
         void Log(const tstring& prefix, const tstring& format, const T1& t1, const T2& t2, const T3& t3, const T4& t4) {
             auto out = GetTimeString() + _T(">  ") + prefix + (tformat(format) % t1 % t2 % t3 % t4).str() + _T("\n");
             OutputDebugString(out.c_str());
-                       std::cout << unicode::ToString(out);
+                       std::cout << unicode::ToString(out) << std::flush;
                        ofs_ << unicode::ToString(out) << std::flush;
         }
 
index f04e2c8..b992b8a 100644 (file)
@@ -77,7 +77,7 @@ ServerUpdatePlayerPosition::ServerUpdatePlayerPosition(short x, short y, short z
 {
 }
 
-ServerReceiveClientInfo::ServerReceiveClientInfo(const std::string& key, uint32_t version, uint16_t udp_port) :
+ServerReceiveClientInfo::ServerReceiveClientInfo(const std::string& key, uint16_t version, uint16_t udp_port) :
                 Command(header::ServerReceiveClientInfo, Utils::Serialize(key, version, udp_port))
 {
 
index bc65858..087c007 100644 (file)
@@ -91,7 +91,7 @@ typedef boost::weak_ptr<Session> SessionWeakPtr;
     // クライアントの情報を受信した (公開鍵のフィンガープリント, UDPポート)
     class ServerReceiveClientInfo : public Command {
     public:
-        ServerReceiveClientInfo(const std::string& key, uint32_t version, uint16_t udp_port);
+        ServerReceiveClientInfo(const std::string& key, uint16_t version, uint16_t udp_port);
     };
 
     // 公開鍵を要求された
index c5192cd..5b21c44 100644 (file)
@@ -77,7 +77,7 @@ namespace network {
     void Server::Stop()
     {
         io_service_.stop();
-       Logger::Info("stop server");
+               Logger::Info("stop server");
     }
     void Server::Stop(int innterrupt_type)
     {
@@ -261,6 +261,11 @@ namespace network {
                        readed = network::Utils::Deserialize(buffer, &user_id, &count);
                }
 
+               // 現在コマンドがひとつしか無いのでそれ以外は無視
+               if (header != network::header::ServerRequstedStatus) {
+                       return;
+               }
+
         if (readed < buffer.size()) {
             body = buffer.substr(readed);
         }
index 8d18187..d827161 100644 (file)
@@ -16,6 +16,7 @@
 #include "../common/Logger.hpp"
 #include "Config.hpp"
 #include "Account.hpp"
+#include "version.hpp"
 #ifdef __linux__
 #include "ServerSigHandler.hpp"
 #include <csignal>
@@ -114,13 +115,13 @@ int main(int argc, char* argv[])
             if (auto session = c.session().lock()) {
 
                 std::string finger_print;
-                uint32_t version;
+                uint16_t version;
                 uint16_t udp_port;
 
                 network::Utils::Deserialize(c.body(), &finger_print, &version, &udp_port);
 
                 // クライアントのプロトコルバージョンをチェック
-                if (version != 1) {
+                if (version != MMO_PROTOCOL_VERSION) {
                     Logger::Info("Unsupported Client Version : v%d", version);
                     session->Send(network::ClientReceiveUnsupportVersionError(1));
                     return;
index 63555de..895d0f7 100644 (file)
@@ -11,6 +11,8 @@
 #define MMO_VERSION_MINOR 1
 #define MMO_VERSION_REVISION 5
 
+#define MMO_PROTOCOL_VERSION 2
+
 #ifdef MMO_VERSION_BUILD
 #define MMO_VERSION_BUILD_TEXT " Build " MMO_VERSION_TOSTRING(MMO_VERSION_BUILD)
 #else