diff options
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r-- | src/core/netconnection.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 63c906a..4770528 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -9,6 +9,7 @@ #include "sys/sys.h" #include "net/net.h" #include "core/application.h" +#include "core/gameconnection.h" #include "core/netconnection.h" #include "core/player.h" @@ -119,6 +120,10 @@ void NetConnection::frame(float seconds) * * msg info <text> * msg public <name> <text> + * die + * ent + * sup + * pif */ void NetConnection::parse_incoming_message(const std::string & message) { @@ -142,6 +147,51 @@ void NetConnection::parse_incoming_message(const std::string & message) } } + } else if (command == "die") { + unsigned int id; + msgstream >> id; + + Entity *e = Entity::find(id); + con_debug << "Received die entity id " << id << "\n"; + + if (game()->localplayer()->control == e) + game()->localplayer()-> control = 0; + if (e) + Entity::remove(id); + + } else if (command == "ent") { + unsigned int type; + msgstream >> type; + + con_debug << "Received create entity type " << type << "\n"; + switch (type) + { + case Entity::Default: + new Entity(msgstream); + break; + case Entity::Dynamic: + new EntityDynamic(msgstream); + break; + case Entity::Controlable: + new EntityControlable(msgstream); + break; + default: + break; + } + + } else if (command == "sup") { + unsigned int id; + if (msgstream >> id) { + Entity *entity = Entity::find(id); + if (!entity) { + con_warn << "Update for unknown entity " << id << "\n"; + } else + entity->recieve_server_update(msgstream); + } + return; + + } else if (command == "pif") { + connection()->localplayer()->recieve_server_update(msgstream); } } |