Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-11-14 18:05:52 +0000
committerStijn Buys <ingar@osirion.org>2009-11-14 18:05:52 +0000
commite61d9ba10a40c9e51d14b30b86b2b3fe853f5db8 (patch)
tree469ec5d63897744132d87397c6898fa847431a4e
parent4293e8854a30443e4d5818fc55df404976dbfd9b (diff)
made core::Entity and core::Zone child classes from core::Label
-rw-r--r--doc/ROADMAP2
-rw-r--r--doc/TODO19
-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
-rw-r--r--src/game/base/game.cc2
9 files changed, 42 insertions, 143 deletions
diff --git a/doc/ROADMAP b/doc/ROADMAP
index 7250999..88b25e4 100644
--- a/doc/ROADMAP
+++ b/doc/ROADMAP
@@ -1,7 +1,7 @@
------------------------------------------------------------------
- The Osirion Project - ROADMAP
+ The Osirion Project - ROADMAP (outdated)
------------------------------------------------------------------
diff --git a/doc/TODO b/doc/TODO
index 1ea2a02..6925cb7 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -16,17 +16,18 @@ version 0.1.0:
fix ui widget hierarchy
version 0.2.0:
+ cargo
+ inventories
server-client event system, hit-once lightweight entities
explosion events
- weapons fire events
-
- model trigger_dock
+ sound events
+ world sounds
+ eject/beam cargo
version 0.3.0:
- comodities
- economy
+ weapons
+ ship improvements (radars, shield, armor)
-
filesystem:
write a filesystem based on streams
write handlers for zip
@@ -73,9 +74,7 @@ render:
sphere texture distortion at the poles
ui:
- fix chat while docked (ok)
-
- text color configuration
+ add generic trade/inventory widget
sound:
entity/event positional sounds
@@ -87,8 +86,6 @@ game:
entity health/shield/armor
data:
- move ships into subdiretories (colonial/, lindblade/, tsu-khan/, ) (ok)
-
update starsystem roadmap
rename skies (lindblade1, lindblade2, ...)
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;
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 6c15c75..96c0835 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -839,7 +839,7 @@ bool Game::load_commodities()
} else if (cargoini.got_key_string("model", str)) {
commodity->set_modelname(str);
- continue;
+ continue;
} else {
cargoini.unkown_key();