diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-29 19:36:51 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-29 19:36:51 +0000 |
commit | ceedc716cb0fe1e0360d2dd9e37a67ff726c4f0b (patch) | |
tree | c09228a09ea78a735c13d371659420fb3e51e754 /src/core | |
parent | 8b356bcd3cab06db7a47f464bffef7a1b62f2d30 (diff) |
first attempt at auto-leveling
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/entity.cc | 24 | ||||
-rw-r--r-- | src/core/entity.h | 8 | ||||
-rw-r--r-- | src/core/net.h | 2 |
3 files changed, 32 insertions, 2 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 20e34ee..d23959f 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -322,6 +322,7 @@ EntityControlable::EntityControlable(Player *owner, unsigned int flags) : EntityDynamic(flags) { entity_thrust = 0; + entity_autolevel = false; target_direction = 0.0f; target_thrust = 0.0f; @@ -338,6 +339,14 @@ EntityControlable::EntityControlable(std::istream & is) : { unsigned int o; + entity_thrust = 0; + entity_autolevel = false; + + target_direction = 0.0f; + target_thrust = 0.0f; + target_pitch = 0.0f; + target_roll = 0.0f; + is >> entity_thrust; is >> o; @@ -366,6 +375,7 @@ void EntityControlable::serialize_client_update(std::ostream & os) const os << " " << target_pitch; os << " " << target_thrust; os << " " << target_roll; + os << " " << (autolevel() ? 1 : 0); } @@ -376,6 +386,13 @@ void EntityControlable::receive_client_update(std::istream &is) is >> target_pitch; is >> target_thrust; is >> target_roll; + + unsigned int b = 0; + is >> b; + if (b) + entity_autolevel = true; + else + entity_autolevel = true; } void EntityControlable::serialize_server_update(std::ostream & os) const @@ -409,6 +426,13 @@ void EntityControlable::set_thrust(float thrust) } } +void EntityControlable::set_autolevel(bool autolevel) +{ + if (entity_autolevel != autolevel) { + entity_autolevel = autolevel; + entity_dirty = true; + } +} void EntityControlable::set_direction(float direction) { if ((flags() & Static) == Static) diff --git a/src/core/entity.h b/src/core/entity.h index ca2d029..2515796 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -286,6 +286,9 @@ public: /// serialize a server-to-client update on a stream virtual void serialize_server_update(std::ostream & os) const; + /// autolevel mode + bool autolevel() const { return entity_autolevel; } + /*----- mutators -------------------------------------------------- */ @@ -300,6 +303,9 @@ public: /// set the target direction void set_direction(float direction); + + /// set autolevel request + void set_autolevel(bool autolevel); /// set the target pitch void set_pitch(float pitch); @@ -336,7 +342,7 @@ public: private: // owner of the entity Player *entity_owner; - + bool entity_autolevel; }; /// a Globe entity diff --git a/src/core/net.h b/src/core/net.h index c80b979..04c77a5 100644 --- a/src/core/net.h +++ b/src/core/net.h @@ -11,7 +11,7 @@ namespace core { /// network protocol version -const unsigned int PROTOCOLVERSION = 3; +const unsigned int PROTOCOLVERSION = 4; /// maximum lenght of a (compressed) network message block const unsigned int FRAMESIZE = 1152; |