Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-12-07 23:27:31 +0000
committerStijn Buys <ingar@osirion.org>2014-12-07 23:27:31 +0000
commit493e4317e19725e2de2d51753e5c1906bf9c64ba (patch)
treec46831d6d661a79b5da6580d4472d39a615fedea /src/core/netserver.cc
parent941c64546ca22b87a9153d36e9e3fe59c18abafe (diff)
Implemented messageboxes and the ability for the game module to send them to remote clients,
send a messagebox if the player's ship is destroyed, this fixes having to press the respawn button twice. added messageboxes on network connection failures.
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 {