diff options
| author | Stijn Buys <ingar@osirion.org> | 2008-02-21 19:06:15 +0000 | 
|---|---|---|
| committer | Stijn Buys <ingar@osirion.org> | 2008-02-21 19:06:15 +0000 | 
| commit | 8aa04fc836116a58f8ffd1e0c3539b9ea8a94ddf (patch) | |
| tree | bb933edb3919ed67d05b098a6b97a73f01746762 /src/core/netconnection.cc | |
| parent | 41ad1e4c9e2a70d0a8811f4b035f0d3018045e61 (diff) | |
dedicated server, entity transfer
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);  	}  }  | 
