From c7ce266051705c68f3440bcc5a83833536b2b7ca Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 25 Nov 2012 21:26:52 +0000 Subject: Receive network entity create messages for projectiles. --- src/core/netconnection.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index ce8fc8c..959f52e 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -13,6 +13,7 @@ #include "core/application.h" #include "core/entity.h" #include "core/entityglobe.h" +#include "core/entityprojectile.h" #include "core/gameconnection.h" #include "core/netconnection.h" #include "core/player.h" @@ -510,7 +511,7 @@ void NetConnection::parse_incoming_message(const std::string & message) } } - if (!entity) { + if (!entity) { switch (type) { case Entity::Default: entity = new Entity(msgstream); @@ -524,6 +525,10 @@ void NetConnection::parse_incoming_message(const std::string & message) case Entity::Globe: entity = new EntityGlobe(msgstream); break; + case Entity::Projectile: + entity = new EntityProjectile(msgstream); + static_cast(entity)->set_timestamp(application()->timestamp()); + break; default: con_warn << "Received update for unknown entity type " << type << "!" << std::endl; return; @@ -579,6 +584,10 @@ void NetConnection::parse_incoming_message(const std::string & message) case Entity::Globe: entity = new EntityGlobe(msgstream); break; + case Entity::Projectile: + entity = new EntityProjectile(msgstream); + static_cast(entity)->set_timestamp(application()->timestamp()); + break; default: con_warn << "Received create for unknown entity type " << type << "!" << std::endl; return; @@ -596,10 +605,12 @@ void NetConnection::parse_incoming_message(const std::string & message) if (msgstream >> id) { //con_debug << "Received die entity id " << id << std::endl; Entity *e = Entity::find(id); - if (localcontrol() == e) - localplayer()->set_control(0); - if (e) + if (e) { + if (localcontrol() == e) { + localplayer()->set_control(0); + } Entity::erase(id); + } } } else if (command.compare("msg") == 0) { -- cgit v1.2.3