Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am8
-rw-r--r--src/core/entity.cc39
-rw-r--r--src/core/entity.h27
-rw-r--r--src/core/label.h42
-rw-r--r--src/core/zone.cc22
-rw-r--r--src/core/zone.h24
6 files changed, 32 insertions, 130 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 421dd59..6085085 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -3,8 +3,8 @@ INCLUDES = -I$(top_srcdir)/src
libcore_la_SOURCES = application.cc commandbuffer.cc core.cc cvar.cc \
descriptions.cc entity.cc extension.cc func.cc gameconnection.cc gameinterface.cc \
- gameserver.cc info.cc item.cc inventory.cc loader.cc module.cc netclient.cc netconnection.cc \
- netplayer.cc netserver.cc parser.cc player.cc stats.cc timer.cc zone.cc
+ gameserver.cc info.cc item.cc inventory.cc label.cc loader.cc module.cc netclient.cc \
+ netconnection.cc netplayer.cc netserver.cc parser.cc player.cc stats.cc timer.cc zone.cc
libcore_la_LDFLAGS = -avoid-version -no-undefined
libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
$(top_builddir)/src/filesystem/libfilesystem.la $(top_builddir)/src/math/libmath.la $(top_builddir)/src/sys/libsys.la \
@@ -12,6 +12,6 @@ libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
noinst_LTLIBRARIES = libcore.la
noinst_HEADERS = application.h commandbuffer.h core.h cvar.h entity.h func.h \
- gameconnection.h gameinterface.h gameserver.h message.h module.h net.h netclient.h \
+ gameconnection.h gameinterface.h gameserver.h label.h message.h module.h net.h netclient.h \
netconnection.h netserver.h player.h range.h stats.h timer.h parser.h descriptions.h \
- extension.h loader.h info.h item.h inventory.h label.h
+ extension.h loader.h info.h item.h inventory.h zone.h
diff --git a/src/core/entity.cc b/src/core/entity.cc
index d01d825..08fddbf 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -106,8 +106,6 @@ Entity::Entity(const unsigned int flags) :
entity_dirty = false;
entity_model = 0;
- entity_label.clear();
- entity_name.clear();
entity_zone = 0;
entity_oldzone = 0;
@@ -209,30 +207,6 @@ void Entity::set_zone(Zone *zone)
entity_zone->add(this);
}
-void Entity::set_label(const char *label)
-{
- entity_label.assign(label);
- aux::to_label(entity_label);
-}
-
-void Entity::set_label(const std::string &label)
-{
- entity_label.assign(label);
- aux::to_label(entity_label);
-}
-
-void Entity::set_name(const char *name)
-{
- entity_name.assign(name);
- aux::strip_quotes(entity_name);
-}
-
-void Entity::set_name(const std::string &name)
-{
- entity_name.assign(name);
- aux::strip_quotes(entity_name);
-}
-
void Entity::set_model(model::Model *model)
{
entity_model = model;
@@ -267,8 +241,8 @@ void Entity::serialize_server_create(std::ostream & os) const
<< radius() << " "
<< std::setprecision(8) << entity_axis.forward() << " "
<< std::setprecision(8) << entity_axis.left() << " "
- << "\"" << entity_label << "\" "
- << "\"" << entity_name << "\" "
+ << label() << " "
+ << "\"" << name() << "\" "
<< "\"" << (entity_model ? entity_model->name() : "") << "\" ";
}
@@ -311,18 +285,15 @@ void Entity::receive_server_create(std::istream &is)
entity_axis[2] = math::crossproduct(entity_axis.forward(), entity_axis.left());
char c;
- // read label
- while ((is.get(c)) && (c != '"'));
- while ((is.get(c)) && (c != '"'))
- n += c;
- entity_label = n;
+ is >> n;
+ set_label(n);
n.clear();
// read name
while ((is.get(c)) && (c != '"'));
while ((is.get(c)) && (c != '"'))
n += c;
- entity_name = n;
+ set_name(n);
n.clear();
// read model name
diff --git a/src/core/entity.h b/src/core/entity.h
index ed0b1f8..09839c8 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -27,6 +27,7 @@ class EntityControlable;
#include "core/extension.h"
#include "core/descriptions.h"
#include "core/inventory.h"
+#include "core/label.h"
#include "core/player.h"
#include "core/zone.h"
@@ -34,7 +35,7 @@ namespace core
{
/// The base world entity. All gameworld entities must derive from this class.
-class Entity
+class Entity : public Label
{
friend class Extension;
@@ -90,16 +91,6 @@ public:
return ((entity_flags & (unsigned int)flag) == (unsigned int)flag);
}
- /// entity label (can not contain double quotes ")
- inline const std::string& label() const {
- return entity_label;
- }
-
- /// entity name (can not contain double qoutes ")
- inline const std::string & name() const {
- return entity_name;
- }
-
/// pointer to the model, is used client-side
inline model::Model * model() {
return entity_model;
@@ -223,18 +214,6 @@ public:
*/
virtual void set_zone(Zone *zone);
- /// set the label
- void set_label(const char *label);
-
- /// set the label
- void set_label(const std::string &label);
-
- /// set the name
- void set_name(const char *name);
-
- /// set the name
- void set_name(const std::string &name);
-
/// set visibility
inline void set_visible(const bool visible = true) {
entity_visible = visible;
@@ -392,8 +371,6 @@ private:
math::Color entity_color;
math::Color entity_color_second;
- std::string entity_name;
- std::string entity_label;
std::string entity_modelname;
model::Model* entity_model;
diff --git a/src/core/label.h b/src/core/label.h
index e772277..12a417c 100644
--- a/src/core/label.h
+++ b/src/core/label.h
@@ -14,17 +14,12 @@
namespace core {
/**
- * @brief baseclass for objects with a name and a label
+ * @brief base class for objects with a name and a label
*/
class Label {
public:
- inline Label() {
- }
-
- inline ~Label() {
- labelstr.clear();
- namestr.clear();
- }
+ Label();
+ ~Label();
/* --- inspectors ------------------------------------------------- */
@@ -38,34 +33,13 @@ public:
/* --- mutators --------------------------------------------------- */
- inline void set_label(const std::string & label)
- {
- labelstr.assign(label);
- aux::to_label(labelstr);
- }
+ void set_label(const std::string & label);
- inline void set_label(const char *label)
- {
- if (label) {
- labelstr.assign(label);
- aux::to_label(labelstr);
- } else {
- labelstr.clear();
- }
- }
+ void set_label(const char *label);
- inline void set_name(const std::string & name)
- {
- namestr.assign(name);
- }
-
- inline void set_name(const char *name)
- {
- if (name)
- namestr.assign(name);
- else
- namestr.clear();
- }
+ void set_name(const std::string & name);
+
+ void set_name(const char *name);
private:
std::string labelstr;
diff --git a/src/core/zone.cc b/src/core/zone.cc
index ac3bc4d..49b20d5 100644
--- a/src/core/zone.cc
+++ b/src/core/zone.cc
@@ -108,14 +108,14 @@ void Zone ::clear()
}
/* ---- class Zone ------------------------------------------------- */
-Zone::Zone(std::string const & label) :
- zone_label(label)
+Zone::Zone(std::string const & label)
{
zone_id = 0;
- zone_name.clear();
zone_sky.clear();
zone_sky_texture = 0;
zone_defaultview = 0;
+
+ set_label(label);
}
Zone::Zone(std::istream & is)
@@ -230,8 +230,8 @@ Entity *Zone::search_entity(const std::string & searchname)
void Zone::serialize_server_update(std::ostream & os) const
{
- os << zone_label << " ";
- os << "\"" << zone_name << "\" ";
+ os << label() << " ";
+ os << "\"" << name() << "\" ";
os << "\"" << zone_sky << "\" ";
os << (zone_defaultview ? zone_defaultview->id() : 0);
@@ -239,16 +239,18 @@ void Zone::serialize_server_update(std::ostream & os) const
void Zone::receive_server_update(std::istream &is)
{
- is >> zone_label;
-
- std::string n;
unsigned int id = 0;
+ std::string n;
char c;
-
+
+ is >> n;
+ set_label(n);
+ n.clear();
+
while ((is.get(c)) && (c != '"'));
while ((is.get(c)) && (c != '"'))
n += c;
- zone_name.assign(n);
+ set_name(n);
n.clear();
while ((is.get(c)) && (c != '"'));
diff --git a/src/core/zone.h b/src/core/zone.h
index 6048a99..c96f7f9 100644
--- a/src/core/zone.h
+++ b/src/core/zone.h
@@ -24,7 +24,7 @@ namespace core
{
/// a Zone contains a compartment of the game universe
-class Zone
+class Zone : public Label
{
public:
/// type definition for the content of a zone
@@ -85,16 +85,6 @@ public:
return zone_id;
}
- /// zone label
- inline std::string const & label() const {
- return zone_label;
- }
-
- /// zone name
- inline std::string const & name() const {
- return zone_name;
- }
-
/// the name of the texture to be used as sky for this zone
inline std::string const & sky() const {
return zone_sky;
@@ -124,16 +114,6 @@ public:
/* ---- mutators ------------------------------------------- */
- /// set the Zone label
- inline void set_label(std::string const & label) {
- zone_label.assign(label);
- }
-
- /// set the Zone label
- inline void set_name(std::string const & name) {
- zone_name.assign(name);
- }
-
/// set the sky texture name to be used for this zone
inline void set_sky(std::string const & sky) {
zone_sky.assign(sky);
@@ -173,8 +153,6 @@ public:
private:
unsigned int zone_id;
- std::string zone_label;
- std::string zone_name;
std::string zone_sky;
size_t zone_sky_texture;