Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r--src/core/netserver.cc42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index cbb2dc7..1b49aee 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -487,20 +487,23 @@ void NetServer::frame(unsigned long timestamp)
* The following messages can be send to a client
*
* frame <timestamp> <previous timestamp>
- * ent <id> <entity create data>
+ * ent <id> <entity data>
* die <id> <entity data>
* inf <id>
* inv <id>
* ping <timestamp>
- * sup <entity update data>
+ * rep <reputation data>
+ * sup <entity data>
*
* msg <channel> <text>
* supported message channels are "info" "public" "rcon" and "snd"
* "snd" is a special channel to transmit sound events
+ * box <text> <label1> <command1> <label2> <command2>
+ * send a messagebox
* zone <id> <zone create/update data>
*/
-// send a message on a specified channel to a single client
+// send a text message on a specified channel to a single client
void NetServer::send_message(NetClient *client, const Message::Channel channel, const std::string & message)
{
if (!message.size())
@@ -538,15 +541,44 @@ void NetServer::send_message(NetClient *client, const Message::Channel channel,
break;
}
+ std::string str_message(message);
+ aux::strip_quotes(str_message);
+
std::string msg("msg ");
msg.append(msg_channel);
msg += ' ';
- msg.append(message);
+ msg.append(str_message);
msg += '\n';
client->send_raw(msg);
}
+// send a messagebox to a single client
+void NetServer::send_messagebox(NetClient *client, const std::string & text, const std::string &label1, const std::string command1, const std::string &label2, const std::string command2)
+{
+ std::string str_text(text);
+ aux::strip_quotes(str_text);
+
+ std::string str_label1(label1);
+ aux::strip_quotes(str_label1);
+ std::string str_command1(command1);
+ aux::strip_quotes(str_command1);
+
+ std::string str_label2(label2);
+ aux::strip_quotes(str_label2);
+ std::string str_command2(command2);
+ aux::strip_quotes(str_command2);
+
+ std::ostringstream msg("");
+ msg << "box ";
+ msg << "\"" << str_text << '\"' << ' ';
+ msg << "\"" << str_label1 << '\"' << ' ';
+ msg << "\"" << str_command1 << '\"' << ' ';
+ msg << "\"" << str_label2 << '\"' << ' ';
+ msg << "\"" << str_command2 << '\"' << '\n';
+
+ client->send_raw(msg.str());
+}
// disconnect a client
void NetServer::send_disconnect(NetClient *client)
@@ -745,7 +777,6 @@ void NetServer::send_inventory_update(NetClient *client, Entity *entity, const u
* info <id>
* req <id>
* inv <id>
- *
*/
void NetServer::parse_incoming_message(NetClient *client, const std::string & message)
{
@@ -779,6 +810,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
con_print << client->host() << ":" << client->port() << " " << netmsgstream.str() << std::endl;
send_message(client, Message::Info, netmsgstream.str());
+ send_messagebox(client, netmsgstream.str(), "", "", "", "");
send_disconnect(client);
} else {