Revision | 9c10091ded711f53b225362a6bbeebf926f3468d (tree) |
---|---|
Zeit | 2012-09-14 00:50:13 |
Autor | h2so5 <h2so5@git....> |
Commiter | h2so5 |
コマンド受信時に落ちる問題が直っていなかったのを修正
チャットコマンドにダイス機能を追加
@@ -250,12 +250,13 @@ void Client::Close() | ||
250 | 250 | std::shared_ptr<Command> Client::PopCommand() |
251 | 251 | { |
252 | 252 | boost::mutex::scoped_lock lock(mutex_); |
253 | - std::shared_ptr<Command> command; | |
253 | + std::shared_ptr<Command> command_ptr; | |
254 | 254 | if (!command_queue_.empty()) { |
255 | - command = std::make_shared<Command>(command_queue_.front()); | |
255 | + Command command = command_queue_.front(); | |
256 | + command_ptr = std::make_shared<Command>(command); | |
256 | 257 | command_queue_.pop(); |
257 | 258 | } |
258 | - return command; | |
259 | + return command_ptr; | |
259 | 260 | } |
260 | 261 | |
261 | 262 | bool Client::command_empty() |
@@ -94,6 +94,21 @@ Player.onLogout = function(player) { | ||
94 | 94 | // チャットメッセージ送信 |
95 | 95 | InputBox.onEnter = function (text) { |
96 | 96 | |
97 | + //サイコロ用 | |
98 | + var dice_parsed_text = text.match(/^\/(\d+)[Dd](\d+)/) | |
99 | + if (dice_parsed_text) { | |
100 | + var time = dice_parsed_text[1] | |
101 | + var size = dice_parsed_text[2] | |
102 | + var msg = "【ダイス /" + time + "D" + size + "】\n " | |
103 | + for (var i = 0; i < time; i++) { | |
104 | + msg += Number.random(1, size) + ", " | |
105 | + } | |
106 | + | |
107 | + var msgObject = { body: msg }; | |
108 | + Network.sendAll(msgObject); | |
109 | + return; | |
110 | + } | |
111 | + | |
97 | 112 | // コマンドを解析 |
98 | 113 | var parsed_text = text.match(/^\/(\w{1,8})\s?(\S*)/) |
99 | 114 | if (parsed_text) { |
@@ -117,13 +132,19 @@ InputBox.onEnter = function (text) { | ||
117 | 132 | case "escape": |
118 | 133 | Player.escape(); |
119 | 134 | break; |
135 | + | |
136 | + // リロード | |
120 | 137 | case "reload": |
121 | 138 | Model.rebuild(); |
122 | 139 | break; |
140 | + | |
141 | + // システム | |
123 | 142 | case "system": |
124 | 143 | var msgObject = { system: args.trim() }; |
125 | 144 | Network.sendAll(msgObject); |
126 | 145 | break; |
146 | + | |
147 | + // プライベート | |
127 | 148 | case "private": |
128 | 149 | args.trim(); |
129 | 150 | var tok = args.split(" "); |