Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/input.cc17
-rw-r--r--src/core/entity.cc40
-rw-r--r--src/core/entity.h87
-rw-r--r--src/game/base/ship.cc10
-rw-r--r--src/game/intro/convoy.cc4
5 files changed, 90 insertions, 68 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index 480ba61..2c03c64 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -909,14 +909,14 @@ void frame()
else if (local_thrust > 0.99f)
local_thrust = 1.0f;
- core::localcontrol()->set_thrust(local_thrust);
- core::localcontrol()->set_direction(local_direction);
- core::localcontrol()->set_pitch(local_pitch / render::State::aspect());
- core::localcontrol()->set_roll(local_roll);
- core::localcontrol()->set_strafe(local_strafe);
- core::localcontrol()->set_vstrafe(local_vstrafe);
- core::localcontrol()->set_afterburner(local_afterburner);
- core::localcontrol()->set_control_flags(local_controlflags);
+ core::localcontrol()->set_target_thrust(local_thrust);
+ core::localcontrol()->set_target_direction(local_direction);
+ core::localcontrol()->set_target_pitch(local_pitch / render::State::aspect());
+ core::localcontrol()->set_target_roll(local_roll);
+ core::localcontrol()->set_target_strafe(local_strafe);
+ core::localcontrol()->set_target_vstrafe(local_vstrafe);
+ core::localcontrol()->set_target_afterburner(local_afterburner);
+ core::localcontrol()->set_target_controlflags(local_controlflags);
} else {
@@ -926,6 +926,7 @@ void frame()
local_vstrafe = 0.0f;
local_strafe = 0.0f;
local_afterburner = 0.0f;
+ local_controlflags = 0;
render::Camera::set_direction(0.0f);
render::Camera::set_pitch(0.0f);
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 78878f9..feff172 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -1000,7 +1000,7 @@ void EntityControlable::ActionInterface::debugDraw(btIDebugDraw* debugDrawer)
EntityControlable::EntityControlable() : EntityDynamic()
{
entity_thrust = 0;
- entity_control_flags = 0;
+ entity_controlflags = 0;
target_direction = 0.0f;
target_thrust = 0.0f;
@@ -1008,6 +1008,7 @@ EntityControlable::EntityControlable() : EntityDynamic()
target_roll = 0.0f;
target_strafe = 0.0f;
target_afterburner = 0.0f;
+ target_controlflags = 0;
entity_owner = 0;
@@ -1018,7 +1019,7 @@ EntityControlable::EntityControlable(std::istream & is) :
EntityDynamic(is)
{
entity_thrust = 0;
- entity_control_flags = 0;
+ entity_controlflags = 0;
target_direction = 0.0f;
target_thrust = 0.0f;
@@ -1026,6 +1027,7 @@ EntityControlable::EntityControlable(std::istream & is) :
target_roll = 0.0f;
target_strafe = 0.0f;
target_afterburner = 0.0f;
+ target_controlflags = 0;
entity_owner = 0;
@@ -1056,6 +1058,14 @@ void EntityControlable::set_owner(Player *owner)
}
+void EntityControlable::set_thrust(float thrust)
+{
+ if (entity_thrust != thrust) {
+ entity_thrust = thrust;
+ set_dirty();
+ }
+}
+
void EntityControlable::serialize_server_create(std::ostream & os) const
{
EntityDynamic::serialize_server_create(os);
@@ -1098,7 +1108,7 @@ void EntityControlable::serialize_client_update(std::ostream & os) const
os << target_strafe << " ";
os << target_vstrafe << " ";
os << target_afterburner << " ";
- os << entity_control_flags << " ";
+ os << target_controlflags << " ";
}
void EntityControlable::receive_client_update(std::istream &is)
@@ -1111,7 +1121,7 @@ void EntityControlable::receive_client_update(std::istream &is)
is >> target_strafe;
is >> target_vstrafe;
is >> target_afterburner;
- is >> entity_control_flags;
+ is >> target_controlflags;
}
void EntityControlable::serialize_server_update(std::ostream & os) const
@@ -1127,7 +1137,7 @@ void EntityControlable::receive_server_update(std::istream &is)
entity_thrust /= 100.0f;
}
-void EntityControlable::set_thrust(float thrust)
+void EntityControlable::set_target_thrust(float thrust)
{
if (thrust != target_thrust) {
target_thrust = thrust;
@@ -1135,7 +1145,7 @@ void EntityControlable::set_thrust(float thrust)
}
}
-void EntityControlable::set_direction(float direction)
+void EntityControlable::set_target_direction(float direction)
{
if (target_direction != direction) {
target_direction = direction;
@@ -1143,7 +1153,7 @@ void EntityControlable::set_direction(float direction)
}
}
-void EntityControlable::set_pitch(float pitch)
+void EntityControlable::set_target_pitch(float pitch)
{
if (target_pitch != pitch) {
target_pitch = pitch;
@@ -1151,7 +1161,7 @@ void EntityControlable::set_pitch(float pitch)
}
}
-void EntityControlable::set_roll(float roll)
+void EntityControlable::set_target_roll(float roll)
{
if (target_roll != roll) {
target_roll = roll;
@@ -1159,7 +1169,7 @@ void EntityControlable::set_roll(float roll)
}
}
-void EntityControlable::set_strafe(float strafe)
+void EntityControlable::set_target_strafe(float strafe)
{
if (target_strafe != strafe) {
target_strafe = strafe;
@@ -1167,7 +1177,7 @@ void EntityControlable::set_strafe(float strafe)
}
}
-void EntityControlable::set_vstrafe(float vstrafe)
+void EntityControlable::set_target_vstrafe(float vstrafe)
{
if (target_vstrafe != vstrafe) {
target_vstrafe = vstrafe;
@@ -1183,7 +1193,7 @@ void EntityControlable::set_target_aim(const math::Vector3f &aim)
}
}
-void EntityControlable::set_afterburner(float afterburner)
+void EntityControlable::set_target_afterburner(float afterburner)
{
if (target_afterburner != afterburner) {
target_afterburner = afterburner;
@@ -1191,6 +1201,14 @@ void EntityControlable::set_afterburner(float afterburner)
}
}
+void EntityControlable::set_target_controlflags(int controlflags)
+{
+ if (target_controlflags != controlflags) {
+ target_controlflags = controlflags;
+ set_dirty();
+ }
+}
+
void EntityControlable::set_zone(Zone *zone)
{
if (entity_zone == zone)
diff --git a/src/core/entity.h b/src/core/entity.h
index 092f4a7..72553fa 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -698,13 +698,13 @@ public:
}
/// control flags
- inline int control_flags() const {
- return entity_control_flags;
+ inline int controlflags() const {
+ return entity_controlflags;
}
/// returns true if the specified control flag is set
- inline bool control_has_flag(ControlFlags flag) const {
- return ((flag && entity_control_flags) == flag);
+ inline bool has_controlflag(ControlFlags flag) const {
+ return ((flag && entity_controlflags) == flag);
}
/// physics action
@@ -724,27 +724,39 @@ public:
virtual void serialize_server_update(std::ostream & os) const;
/*----- mutators -------------------------------------------------- */
+
+ /// set the target thrust
+ void set_target_thrust(float thrust);
+
+ /// set the target direction
+ void set_target_direction(float direction);
+
+ /// set the target pitch
+ void set_target_pitch(float pitch);
+
+ /// set target roll
+ void set_target_roll(float roll);
+
+ /// set target strafe
+ void set_target_strafe(float strafe);
- /// set all control flags
- inline void set_control_flags(int control_flags) {
- entity_control_flags = control_flags;
- }
-
- /// set a single control flag
- inline void set_control_flag(ControlFlags control_flag) {
- entity_control_flags |= control_flag;
- }
+ /// set target vertical strafe
+ void set_target_vstrafe(float vstrafe);
- /// unset a single control flag
- inline void unset_control_flag(ControlFlags control_flag) {
- entity_control_flags &= ~control_flag;
- }
+ /// set target afterburner/reverse
+ void set_target_afterburner(float afterburner);
+
+ /// set target aim
+ void set_target_aim(const math::Vector3f &aim);
+
+ /// set target controlflags
+ void set_target_controlflags(int controlflags);
/**
* @brief set the zone the entity is currently in
* this fuction removes the entity from its previous zone
* and removes it to the new one, if it is not 0
- */
+ * */
virtual void set_zone(Zone *zone);
/**
@@ -763,30 +775,9 @@ public:
/// set the player who owns this entity
void set_owner(Player *owner);
-
- /// set the target thrust
- void set_thrust(float thrust);
-
- /// set the target direction
- void set_direction(float direction);
-
- /// set the target pitch
- void set_pitch(float pitch);
-
- /// set target roll
- void set_roll(float roll);
-
- /// set target strafe
- void set_strafe(float strafe);
-
- /// set target vertical strafe
- void set_vstrafe(float vstrafe);
-
- /// set afterburner/reverse
- void set_afterburner(float afterburner);
- /// set aim
- void set_target_aim(const math::Vector3f &aim);
+ /// set thrust
+ void set_thrust(float thrust);
/**
* @brief runs one game frame for the entity
@@ -796,14 +787,17 @@ public:
*/
virtual void frame(const unsigned long elapsed);
- /// current thrust
- float entity_thrust;
-
protected:
/// physics action interface callback
virtual void action (btScalar seconds);
+ /// current control flags
+ int entity_controlflags;
+
+ /// current thrust
+ float entity_thrust;
+
/* target_ variables can be set by the client */
/**
@@ -837,13 +831,14 @@ protected:
math::Vector3f target_aim;
- int entity_control_flags;
+ int target_controlflags;
ActionInterface *entity_actioninterface;
private:
- // owner of the entity
+ /// owner of the entity
Player *entity_owner;
+
};
/// a Globe entity
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 22fb269..22725e0 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -485,7 +485,8 @@ void Ship::frame(const unsigned long elapsed)
entity_thrust = 0;
entity_speed = 0.0f;
-
+ entity_controlflags = 0;
+
} else if (entity_state == core::Entity::JumpInitiate) {
if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
@@ -533,6 +534,8 @@ void Ship::frame(const unsigned long elapsed)
target_afterburner = 0.0f;
target_thrust = 0.1f;
+
+ entity_controlflags = 0;
} else if (entity_state == core::Entity::Jump) {
@@ -545,6 +548,8 @@ void Ship::frame(const unsigned long elapsed)
target_afterburner = 0.0f;
target_thrust = 0.0f;
+
+ entity_controlflags = 0;
// apply jump drive cooldown
if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
@@ -623,6 +628,8 @@ void Ship::frame(const unsigned long elapsed)
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
math::clamp(target_afterburner, -1.0f, 1.0f);
+
+ entity_controlflags = target_controlflags;
} else if (entity_state == core::Entity::Destroyed) {
@@ -637,6 +644,7 @@ void Ship::frame(const unsigned long elapsed)
target_thrust = 0;
entity_thrust = 0;
+ entity_controlflags = 0;
}
/* -- SNAPPY ------------------------------------------ */
diff --git a/src/game/intro/convoy.cc b/src/game/intro/convoy.cc
index 8a436bb..47f997c 100644
--- a/src/game/intro/convoy.cc
+++ b/src/game/intro/convoy.cc
@@ -23,7 +23,7 @@ Member::Member(std::string const &modelname) : core::EntityControlable()
set_radius(model()->radius());
}
- entity_thrust = 1.0f;
+ set_thrust(1.0f);
}
Member::~Member()
@@ -69,7 +69,7 @@ void Convoy::add(const std::string &modelname)
member->get_color().assign(color());
member->get_color_second().assign(color_second());
- member->entity_thrust = 1.0f;
+ member->set_thrust(1.0f);
member->set_speed(speed());
member->get_location().assign(location());