From 977a9a68d2465818a331643399a9ecc998d0cbb3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Nov 2013 15:22:44 +0000 Subject: Bumped network protocol to version 27, send player reputation and stats from server to client, send entity faction to clients, improved list_entity. --- src/core/entity.cc | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'src/core/entity.cc') diff --git a/src/core/entity.cc b/src/core/entity.cc index 4c4c35b..ff780a5 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -265,8 +265,33 @@ void Entity::print() const // print header print_header(); + // type + con_print << " ^Ntype ^B"; + switch (type()) { + case Default: + con_print << "entity"; + break; + + case Dynamic: + con_print << "dynamic"; + break; + + case Controlable: + con_print << "controlable"; + break; + + case Globe: + con_print << "globe"; + break; + + case Projectile: + con_print << "projectile"; + } + con_print << std::endl; + con_print << " ^Nmodule type ^B" << moduletype() << std::endl; + // print entity flags - con_print << " flags ^B"; + con_print << " ^Nflags ^B"; if (has_flag(NonSolid)) { con_print << " nonsolid"; } @@ -277,17 +302,27 @@ void Entity::print() const con_print << " dockable"; } if (has_flag(ShowOnMap)) { - con_print << " shwonmap"; + con_print << " shownmap"; } if (has_flag(KeepAlive)) { con_print << " keepalive"; } - con_print << std::endl; + con_print << std::endl; + if (inventory()) { + con_print << " ^Ninventory ^Byes" << std::endl; + } + if (faction()) { + con_print << " ^Nfaction ^B" << faction()->label(); + } } void Entity::print_header() const { - con_print << " entity id ^B" << id() << " ^Nlabel ^B" << label() << " ^Nname ^B" << name() << std::endl; + con_print << " entity id ^B" << id() << " ^Nlabel ^B" << label() << " ^Nname ^B" << name(); + if (!zone()) { + con_print << " ^Nzone ^B" << zone()->label(); + } + con_print << std::endl; } void Entity::print_inventory() const @@ -427,6 +462,7 @@ void Entity::serialize_server_create(std::ostream & os) const << "\"" <name() : "") << "\" " + << (faction() ? faction()->id() : 0) << " " << (info() ? info()->id() : 0) << " " << (inventory() ? 1 : 0) << " "; @@ -492,6 +528,15 @@ void Entity::receive_server_create(std::istream &is) n += c; set_modelname(n); + // read faction id + if(is >> o) { + entity_faction = Info::find(o); + if (o && !entity_faction) + entity_faction = new Info(o); + } else { + entity_faction = 0; + } + // read info id if(is >> o) { entity_info = Info::find(o); @@ -749,6 +794,43 @@ EntityDynamic::~EntityDynamic() delete entity_motionstate; } +void EntityDynamic::print() const +{ + Entity::print(); + + con_print << " ^Nstate ^B"; + switch (state()) { + case Normal: + con_print << "normal"; + break; + + case ImpulseInitiate: + con_print << "impulseinitiate"; + break; + + case Impulse: + con_print << "impulse"; + break; + + case JumpInitiate: + con_print << "jumpinitiate"; + break; + + case Jump: + con_print << "jump"; + break; + + case Destroyed: + con_print << "destroyed"; + break; + + case NoPower: + con_print << "nopower"; + break; + } + con_print << std::endl; + +} void EntityDynamic::set_state(int state) { if (this->state() != state) { -- cgit v1.2.3