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/entity.h2
-rw-r--r--src/core/gameserver.cc3
-rw-r--r--src/core/zone.cc14
-rw-r--r--src/core/zone.h92
4 files changed, 97 insertions, 14 deletions
diff --git a/src/core/entity.h b/src/core/entity.h
index 77bc2d8..07a3bec 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -201,7 +201,7 @@ public:
return entity_slots;
}
- /// entity info
+ /// entity information record
inline const Info *info() const {
return entity_info;
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 96dd51e..f9cc061 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -158,6 +158,9 @@ GameServer::GameServer() : GameInterface()
server_mode = SinglePlayer;
}
+ // create the default infotype for zones
+ Zone::set_infotype(new InfoType("zone"));
+
// create the default infotype for entities
Entity::set_infotype(new InfoType("entity"));
diff --git a/src/core/zone.cc b/src/core/zone.cc
index 8050716..2059e03 100644
--- a/src/core/zone.cc
+++ b/src/core/zone.cc
@@ -15,8 +15,12 @@ namespace core
/* ---- Static functions for the Zone registry ------------------- */
+// zone registry
Zone::Registry Zone::zone_registry;
+// info type for zone information
+const InfoType *Zone::zone_infotype = 0;
+
void Zone::add(Zone *zone)
{
unsigned int id = 1;
@@ -122,6 +126,7 @@ Zone::Zone(std::string const & label) :
{
zone_id = 0;
zone_defaultview = 0;
+ zone_info = 0 ;
btVector3 worldAabbMin(-10000, -10000, -10000);
btVector3 worldAabbMax(10000, 10000, 10000);
@@ -133,7 +138,6 @@ Zone::Zone(std::string const & label) :
// disable gravity
zone_bullet_world->setGravity(btVector3(0.0f, 0.0f, 0.0f));
-
}
Zone::Zone(std::istream & is) :
@@ -142,6 +146,8 @@ Zone::Zone(std::istream & is) :
{
zone_id = 0;
zone_defaultview = 0;
+ zone_info = 0 ;
+
// client side does not setup a bullet physics environment
zone_bullet_cache = 0;
zone_bullet_world = 0;
@@ -169,6 +175,12 @@ Zone::~Zone()
delete zone_bullet_cache;
}
+void Zone::set_info(const Info *info)
+{
+ zone_info = info;
+}
+
+
void Zone::print()
{
con_print << " zone id ^B" << id() << " ^Nlabel ^B" << label() << " ^Nname ^B" << name() << std::endl;
diff --git a/src/core/zone.h b/src/core/zone.h
index 79e4a6c..644620d 100644
--- a/src/core/zone.h
+++ b/src/core/zone.h
@@ -64,16 +64,34 @@ public:
static inline Registry & registry() {
return zone_registry;
}
+
+ /// default infotype for zones
+ static inline const InfoType *infotype() {
+ return zone_infotype;
+ }
+
+ /// set the default infotype for zones
+ static inline void set_infotype(const InfoType *infotype) {
+ zone_infotype = infotype;
+ }
/* ---- Zone class ----------------------------------------- */
- /// create a new zone
+ /**
+ * @brief create a new zone
+ * This is a server-side constructor
+ * */
Zone(std::string const & label);
- /// create a zone from stream data
+ /**
+ * @brief create a zone from stream data
+ * This is a client-side constructor
+ * */
Zone(std::istream & is);
- /// delete a zone
+ /**
+ * @brief default destructor
+ * */
virtual ~Zone();
/* ---- inspectors ----------------------------------------- */
@@ -96,10 +114,22 @@ public:
return zone_sky;
}
- /// default zone view
+ /// default zone view, returns 0 if not set
inline Entity *default_view() {
return zone_defaultview;
}
+
+ /// zone information record, returns 0 if not set
+ inline const Info *info() const {
+ return zone_info;
+ }
+
+ /**
+ * @brief returns the galactic location of this zone
+ * */
+ const math::Vector3f & location() const {
+ return zone_location;
+ }
/// find an entity inside a zone
Entity *find_entity(const Entity *entity);
@@ -115,32 +145,66 @@ public:
/* ---- mutators ------------------------------------------- */
- /// set the skybox name
+ /**
+ * @brief set the skybox name
+ * */
inline void set_sky(std::string const & sky) {
zone_sky.assign(sky);
}
- /// set the ambient light color
+ /**
+ * @brief set the ambient light color
+ * */
inline void set_ambient_color(const math::Color & ambient_color) {
zone_ambient_color.assign(ambient_color);
}
- /// set the ambient light color
+ /**
+ * @brief set the ambient light color
+ * @param r red value [0-1]
+ * @param g green value [0-1]
+ * @param b blue value [0-1]
+ * */
inline void set_ambient_color(float r, float g, float b) {
zone_ambient_color.assign(r, g, b);
}
- /// set the default view
+ /**
+ * @brief set the default view for this zone
+ * */
inline void set_default_view(Entity *entity) {
zone_defaultview = entity;
}
+
+ /**
+ * @brief set the galactic location for this zone
+ * */
+ inline void set_location(float x, float y, float z) {
+ zone_location.assign(x, y, z);
+ }
+
+ /**
+ * @brief set the galactic location for this zone
+ * */
+ inline void set_location(const math::Vector3f & location) {
+ zone_location.assign(location);
+ }
+
+ /**
+ * @brief set the information record for this zone
+ * */
+ void set_info(const Info *info);
/* ---- serializers ---------------------------------------- */
- /// serialize a server-to-client update on a stream
+ /**
+ * @brief serialize the zone's state to a server-to-client update message on a stream
+ * */
void serialize_server_update(std::ostream & os) const;
- /// receive a server-to-client update from a stream
+ /**
+ * @brief deserialize the zone's state from a server-to-client update message on a stream
+ * */
void receive_server_update(std::istream &is);
/* ---- zone content --------------------------------------- */
@@ -183,10 +247,9 @@ private:
std::string zone_sky;
math::Color zone_ambient_color;
+ math::Vector3f zone_location;
Content zone_content;
- static Registry zone_registry;
-
Entity *zone_defaultview;
btAxisSweep3 *zone_bullet_cache;
@@ -195,6 +258,11 @@ private:
math::BoundingBox3f zone_keepalive_box;
bool zone_keepalive_run;
+
+ const Info* zone_info;
+
+ static const InfoType *zone_infotype;
+ static Registry zone_registry;
};
}