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>2008-09-27 17:16:15 +0000
committerStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
commitca0c1d3e6f8b5fa4eb2e0a86fcf47b12fb600786 (patch)
tree5d72e330f11350065806e83cc8712693241b9aad /src/core/netconnection.cc
parent29984680d6e0e52efec489497b1796e056164442 (diff)
mission targets, texture unloading, private messages
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r--src/core/netconnection.cc91
1 files changed, 63 insertions, 28 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index ed1a91b..9268447 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -328,6 +328,7 @@ void NetConnection::send_raw(std::string const &msg)
* cup <id> <entity data>
* cmd <text>
* say <text>
+ * priv <text>
*/
// send a "connect" message to the server
@@ -380,6 +381,15 @@ void NetConnection::send_say(std::string const &text)
this->send_raw(msg);
}
+// send a "priv" private message to the server
+void NetConnection::send_private_message(std::string const &text)
+{
+ std::string msg("priv ");
+ msg.append(text);
+ msg += '\n';
+ this->send_raw(msg);
+}
+
// parse incoming client messages
/**
* The following incoming messages are parsed;
@@ -388,13 +398,14 @@ void NetConnection::send_say(std::string const &text)
* disconnect
* msg info <text>
* msg public <name> <text>
+ * msg private <name> <text>
* msg rcon <text>
* msg snd <soundname>
- * die
- * ent
+ * die <id>
+ * ent <id>
* frame
- * sup
- * pif
+ * sup <id>
+ * pif <id>
* zone
*/
void NetConnection::parse_incoming_message(const std::string & message)
@@ -409,19 +420,22 @@ void NetConnection::parse_incoming_message(const std::string & message)
if (msgstream >> level) {
if (level =="info") {
if (message.size() > 9) {
- application()->notify_message(message.substr(9));
+ application()->notify_message(Message::Info, message.substr(9));
}
} else if (level =="rcon") {
if (message.size() > 9) {
- con_print << message.substr(9) << std::endl;
+ application()->notify_message(Message::RCon, message.substr(9));
}
} else if (level == "public") {
// FIXME - separate sender nickname
if (message.size() > 11) {
- application()->notify_message(message.substr(11));
- application()->notify_sound("com/chat");
+ application()->notify_message(Message::Public, message.substr(11));
}
-
+ } else if (level == "private") {
+ // FIXME - separate sender nickname
+ if (message.size() > 12) {
+ application()->notify_message(Message::Private, message.substr(12));
+ }
} else if (level == "snd") {
if (message.size() > 8) {
application()->notify_sound(message.substr(8).c_str());
@@ -527,29 +541,50 @@ void NetConnection::parse_incoming_message(const std::string & message)
} else if (command == "pif") {
//con_debug << "Received update player info" << std::endl;
-
- Zone *oldzone = connection()->localplayer()->zone();
- connection()->localplayer()->receive_server_update(msgstream);
-
- //con_debug << "zone " << ( connection()->localplayer()->zone() ? connection()->localplayer()->zone()->id() : 0) << std::endl;
- if (connection()->localplayer()->zonechange() && oldzone && (oldzone != connection()->localplayer()->zone())) {
-
- // notify the applciation to clear none-core zone assets (textures etc)
- application()->notify_zoneclear(oldzone);
-
- // delete all entities in the old zone
- for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) {
- Entity *entity = (*it).second;
+ int player_id;
+ if (!(msgstream >> player_id)) {
+ con_warn << "Received illegal update player info for player!" << std::endl;
+ return;
+ }
- if ((entity->zone() == oldzone)) {
- delete entity;
- Entity::registry().erase(it++);
- } else {
- ++it;
+ if (!player_id) {
+ Zone *oldzone = connection()->localplayer()->zone();
+ connection()->localplayer()->receive_server_update(msgstream);
+
+ //con_debug << "zone " << ( connection()->localplayer()->zone() ? connection()->localplayer()->zone()->id() : 0) << std::endl;
+
+ if (connection()->localplayer()->zonechange() && oldzone && (oldzone != connection()->localplayer()->zone())) {
+
+ // notify the applciation to clear none-core zone assets (textures etc)
+ application()->notify_zoneclear(oldzone);
+
+ // delete all entities in the old zone
+ for (Entity::Registry::iterator it=Entity::registry().begin(); it != Entity::registry().end(); ) {
+ Entity *entity = (*it).second;
+
+ if ((entity->zone() == oldzone)) {
+ delete entity;
+ Entity::registry().erase(it++);
+ } else {
+ ++it;
+ }
+ }
+ oldzone->content().clear();
+ }
+ } else {
+ // FIXME find player
+ Player *player = 0;
+ for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) {
+ if( (*it)->id() == player_id) {
+ player = (*it);
}
}
- oldzone->content().clear();
+ if (!player) {
+ player = new Player();
+ game()->players().push_back(player);
+ }
+ player->receive_server_update(msgstream);
}
} else if (command == "sup") {