Revisión | 51a447f63de926e283a91174baf9751226018999 (tree) |
---|---|
Tiempo | 2012-09-16 22:35:37 |
Autor | h2so5 <h2so5@git....> |
Commiter | h2so5 |
ステージ名をサーバー経由で受信するように変更
@@ -377,11 +377,13 @@ void FieldPlayer::InputFromUser() | ||
377 | 377 | : prev_stat_.motion == motion.run_ ? 180.0f |
378 | 378 | : 90.0f) * PHI_F / 180; |
379 | 379 | |
380 | + /* | |
380 | 381 | auto warp_chk = stage_->CheckWarpPoint(current_stat_.pos); |
381 | 382 | if (warp_chk.first && input.GetKeyCount(InputManager::KEYBIND_ENTER) > 0 ) |
382 | 383 | { |
383 | 384 | stage_->SetHostChangeFlag(warp_chk); |
384 | 385 | } |
386 | + */ | |
385 | 387 | |
386 | 388 | int move_dir = 0; |
387 | 389 | if (input.GetKeyCount(InputManager::KEYBIND_FORWARD) > 0) |
@@ -24,7 +24,7 @@ void CommandManager::Update() | ||
24 | 24 | if (client_) |
25 | 25 | { |
26 | 26 | auto command = client_->PopCommand(); |
27 | - | |
27 | + | |
28 | 28 | if (command) { |
29 | 29 | unsigned int header = command->header(); |
30 | 30 |
@@ -47,6 +47,14 @@ void CommandManager::Update() | ||
47 | 47 | } |
48 | 48 | break; |
49 | 49 | |
50 | + // サーバーデータ受信 | |
51 | + case ClientReceiveServerInfo: | |
52 | + { | |
53 | + network::Utils::Deserialize(command->body(), & stage_); | |
54 | + status_ = STATUS_READY; | |
55 | + } | |
56 | + break; | |
57 | + | |
50 | 58 | case ClientReceiveJSON: |
51 | 59 | // case ClientReceiveChatLog: |
52 | 60 | { |
@@ -104,7 +112,7 @@ void CommandManager::Update() | ||
104 | 112 | void CommandManager::set_client(ClientUniqPtr client) |
105 | 113 | { |
106 | 114 | client_= std::move(client); |
107 | - status_ = STATUS_CONNECTING; | |
115 | + // status_ = STATUS_CONNECTING; | |
108 | 116 | } |
109 | 117 | |
110 | 118 |
@@ -141,7 +149,12 @@ void CommandManager::SendJSON(const std::string& msg) { | ||
141 | 149 | } |
142 | 150 | } |
143 | 151 | |
144 | -Status CommandManager::status() const | |
152 | +CommandManager::Status CommandManager::status() const | |
145 | 153 | { |
146 | 154 | return status_; |
147 | 155 | } |
156 | + | |
157 | +std::string CommandManager::stage() const | |
158 | +{ | |
159 | + return stage_; | |
160 | +} | |
\ No newline at end of file |
@@ -33,6 +33,7 @@ class CommandManager { | ||
33 | 33 | |
34 | 34 | void set_client(ClientUniqPtr client); |
35 | 35 | unsigned int user_id(); |
36 | + std::string stage() const; | |
36 | 37 | |
37 | 38 | Status status() const; |
38 | 39 |
@@ -40,6 +41,7 @@ class CommandManager { | ||
40 | 41 | ManagerAccessorPtr manager_accessor_; |
41 | 42 | ClientUniqPtr client_; |
42 | 43 | Status status_; |
44 | + std::string stage_; | |
43 | 45 | }; |
44 | 46 | |
45 | 47 | typedef std::shared_ptr<CommandManager> CommandManagerPtr; |
@@ -15,7 +15,7 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : | ||
15 | 15 | manager_accessor_(manager_accessor), |
16 | 16 | player_manager_(std::make_shared<PlayerManager>(manager_accessor_)), |
17 | 17 | card_manager_(manager_accessor->card_manager().lock()), |
18 | - command_manager_(std::make_shared<CommandManager>(manager_accessor_)), | |
18 | + command_manager_(manager_accessor->command_manager().lock()), | |
19 | 19 | world_manager_(std::make_shared<WorldManager>(manager_accessor_)), |
20 | 20 | account_manager_(manager_accessor->account_manager().lock()), |
21 | 21 | config_manager_(manager_accessor->config_manager().lock()), |
@@ -24,25 +24,10 @@ MainLoop::MainLoop(const ManagerAccessorPtr& manager_accessor) : | ||
24 | 24 | snapshot_number_(0) |
25 | 25 | { |
26 | 26 | manager_accessor_->set_player_manager(player_manager_); |
27 | - manager_accessor_->set_command_manager(command_manager_); | |
28 | 27 | manager_accessor_->set_world_manager(world_manager_); |
29 | 28 | |
30 | 29 | inputbox_.ReloadTabs(); |
31 | 30 | |
32 | - command_manager_->set_client( | |
33 | - ClientUniqPtr( | |
34 | - new network::Client( | |
35 | - account_manager_->host(), | |
36 | - config_manager_->port(), | |
37 | - (uint16_t)config_manager_->udp_port(), | |
38 | - account_manager_->public_key(), | |
39 | - account_manager_->private_key(), | |
40 | - "server_key.pub", | |
41 | - config_manager_->upnp() | |
42 | - ) | |
43 | - ) | |
44 | - ); | |
45 | - | |
46 | 31 | minimap_.UIPlacement(config_manager_->screen_width() - MINIMAP_MINSIZE - 12, 12); |
47 | 32 | player_manager_->Init(); |
48 | 33 | world_manager_->Init(); |
@@ -151,4 +151,10 @@ ClientReceiveJSON::ClientReceiveJSON(const std::string& info_json, const std::st | ||
151 | 151 | { |
152 | 152 | } |
153 | 153 | |
154 | +ClientReceiveServerInfo::ClientReceiveServerInfo(const std::string& stage) : | |
155 | + Command(header::ClientReceiveServerInfo, Utils::Serialize(stage)) | |
156 | +{ | |
157 | + | |
158 | +} | |
159 | + | |
154 | 160 | } |
@@ -158,4 +158,9 @@ typedef boost::weak_ptr<Session> SessionWeakPtr; | ||
158 | 158 | ClientReceiveJSON(const std::string& info_json, const std::string& message_json); |
159 | 159 | }; |
160 | 160 | |
161 | + class ClientReceiveServerInfo : public Command { | |
162 | + public: | |
163 | + ClientReceiveServerInfo(const std::string& stage); | |
164 | + }; | |
165 | + | |
161 | 166 | } |
@@ -45,7 +45,7 @@ int main(int argc, char* argv[]) | ||
45 | 45 | network::Server server(config); |
46 | 46 | |
47 | 47 | auto callback = std::make_shared<std::function<void(network::Command)>>( |
48 | - [&server, &account, &sign](network::Command c){ | |
48 | + [&server, &account, &sign, &config](network::Command c){ | |
49 | 49 | |
50 | 50 | // ログを出力 |
51 | 51 | auto msg = (boost::format("Receive: 0x%08x %dbyte") % c.header() % c.body().size()).str(); |
@@ -186,6 +186,9 @@ int main(int argc, char* argv[]) | ||
186 | 186 | case network::header::ServerStartEncryptedSession: |
187 | 187 | { |
188 | 188 | if (auto session = c.session().lock()) { |
189 | + | |
190 | + session->Send(network::ClientReceiveServerInfo(config.stage())); | |
191 | + | |
189 | 192 | session->Send(network::ClientStartEncryptedSession()); |
190 | 193 | session->EnableEncryption(); |
191 | 194 |