From 92dfee736b9985db6509a6fdb567d78de402a0f9 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 6 Jan 2012 18:27:13 +0000 Subject: Add support for Zone::ambient_color, bump network protocol version --- src/core/net.h | 2 +- src/core/zone.cc | 20 ++++++++++++++++++-- src/core/zone.h | 20 ++++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/net.h b/src/core/net.h index 2dbebfd..8f3175d 100644 --- a/src/core/net.h +++ b/src/core/net.h @@ -11,7 +11,7 @@ namespace core { /// network protocol version -const unsigned int PROTOCOLVERSION = 22; +const unsigned int PROTOCOLVERSION = 23; /// maximum lenght of a (compressed) network message block const unsigned int FRAMESIZE = 1152; diff --git a/src/core/zone.cc b/src/core/zone.cc index 8c74457..f33fc60 100644 --- a/src/core/zone.cc +++ b/src/core/zone.cc @@ -116,7 +116,9 @@ void Zone ::clear() } /* ---- class Zone ------------------------------------------------- */ -Zone::Zone(std::string const & label) : Label(label) +Zone::Zone(std::string const & label) : + Label(label), + zone_ambient_color(1.0f, 1.0f, 1.0f) { zone_id = 0; zone_defaultview = 0; @@ -134,7 +136,9 @@ Zone::Zone(std::string const & label) : Label(label) } -Zone::Zone(std::istream & is) : Label() +Zone::Zone(std::istream & is) : + Label(), + zone_ambient_color(1.0f, 1.0f, 1.0f) { zone_id = 0; zone_defaultview = 0; @@ -262,6 +266,9 @@ void Zone::serialize_server_update(std::ostream & os) const os << label() << " "; os << "\"" << name() << "\" "; os << "\"" << zone_sky << "\" "; + os << zone_ambient_color.r << " "; + os << zone_ambient_color.g << " "; + os << zone_ambient_color.b << " "; os << (zone_defaultview ? zone_defaultview->id() : 0); } @@ -269,25 +276,34 @@ void Zone::serialize_server_update(std::ostream & os) const void Zone::receive_server_update(std::istream &is) { unsigned int id = 0; + float r = 1.0f, g = 1.0f, b = 1.0f; std::string n; char c; + // zone label is >> n; set_label(n); n.clear(); + // zone name while ((is.get(c)) && (c != '"')); while ((is.get(c)) && (c != '"')) n += c; set_name(n); n.clear(); + // sky name while ((is.get(c)) && (c != '"')); while ((is.get(c)) && (c != '"')) n += c; zone_sky.assign(n); n.clear(); + // ambient light color + is >> r >> g >> b; + zone_ambient_color.assign(r, g, b); + + // default view is >> id; zone_defaultview = Entity::find(id); } diff --git a/src/core/zone.h b/src/core/zone.h index f80999d..79e4a6c 100644 --- a/src/core/zone.h +++ b/src/core/zone.h @@ -86,6 +86,11 @@ public: return zone_id; } + /// ambient light color + inline math::Color const & ambient_color() { + return zone_ambient_color; + } + /// name of the skybox inline std::string const & sky() const { return zone_sky; @@ -115,7 +120,17 @@ public: zone_sky.assign(sky); } - ///set the default view + /// 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 + inline void set_ambient_color(float r, float g, float b) { + zone_ambient_color.assign(r, g, b); + } + + /// set the default view inline void set_default_view(Entity *entity) { zone_defaultview = entity; } @@ -167,7 +182,8 @@ private: unsigned int zone_id; std::string zone_sky; - + math::Color zone_ambient_color; + Content zone_content; static Registry zone_registry; -- cgit v1.2.3