diff options
-rw-r--r-- | osirion.kdevelop | 2 | ||||
-rw-r--r-- | src/core/entity.cc | 8 | ||||
-rw-r--r-- | src/core/entity.h | 5 | ||||
-rw-r--r-- | src/game/racetrack.cc | 22 |
4 files changed, 21 insertions, 16 deletions
diff --git a/osirion.kdevelop b/osirion.kdevelop index 82878a1..d40c050 100644 --- a/osirion.kdevelop +++ b/osirion.kdevelop @@ -21,7 +21,7 @@ </general> <kdevautoproject> <general> - <activetarget>src/game/libgame.la</activetarget> + <activetarget>src/core/libcore.la</activetarget> <useconfiguration>debug</useconfiguration> </general> <run> diff --git a/src/core/entity.cc b/src/core/entity.cc index 7472908..04ede71 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -279,6 +279,14 @@ EntityDynamic::~EntityDynamic() { } +void EntityDynamic::set_eventstate(Event eventstate) +{ + if (entity_eventstate != eventstate) { + entity_eventstate = eventstate; + entity_dirty = true; + } +} + void EntityDynamic::frame(float seconds) { if ((flags() & Static) == Static) diff --git a/src/core/entity.h b/src/core/entity.h index 30e3356..8a996fd 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -266,6 +266,9 @@ public: /// receive a server-to-client update from a stream virtual void receive_server_update(std::istream &is); + /// set event state + virtual void set_eventstate(Event eventstate); + /// runs one game frame for the entity /** * The default implementation will update the position() of the entity, @@ -276,10 +279,10 @@ public: /// speed of the entity float entity_speed; - unsigned int entity_eventstate; protected: float entity_timer; + int entity_eventstate; }; diff --git a/src/game/racetrack.cc b/src/game/racetrack.cc index 31e5b40..897a839 100644 --- a/src/game/racetrack.cc +++ b/src/game/racetrack.cc @@ -61,8 +61,7 @@ void RaceTrack::reset() track_checkpointtime = 0; for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) { - (*cpit)->entity_eventstate |= core::Entity::NoPower; - (*cpit)->entity_dirty = true; + (*cpit)->set_eventstate(core::Entity::NoPower); } entity_eventstate |= core::Entity::NoPower; @@ -83,12 +82,10 @@ void RaceTrack::frame(float seconds) track_player = (*it); track_racestart = core::server()->time(); - entity_eventstate &= (~core::Entity::NoPower); - entity_dirty = true; + set_eventstate(core::Entity::Normal); for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) { - (*cpit)->entity_eventstate &= (~core::Entity::NoPower); - (*cpit)->entity_dirty = true; + set_eventstate(core::Entity::Normal); } entity_timer = 5.0f; @@ -143,8 +140,7 @@ void RaceTrack::frame(float seconds) track_racestart = core::server()->time(); } else { for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) { - (*cpit)->entity_eventstate |= core::Entity::NoPower; - (*cpit)->entity_dirty = true; + (*cpit)->set_eventstate(core::Entity::NoPower); } std::string message("^BGo!"); core::server()->broadcast(message); @@ -152,8 +148,7 @@ void RaceTrack::frame(float seconds) track_racestart = core::server()->time(); track_checkpointtime = core::server()->time() + 15.0f; track_checkpoint = track_checkpoints.begin(); - (*track_checkpoint)->entity_eventstate &= ~core::Entity::NoPower; - (*track_checkpoint)->entity_dirty = true; + (*track_checkpoint)->set_eventstate(core::Entity::Normal); } } @@ -177,13 +172,12 @@ void RaceTrack::frame(float seconds) std::string message("^BCheckpoint!"); core::server()->broadcast(message); track_checkpointtime = core::server()->time() + 15.0f; - (*track_checkpoint)->entity_eventstate |= core::Entity::NoPower; - (*track_checkpoint)->entity_dirty = true; + (*track_checkpoint)->set_eventstate(core::Entity::NoPower); track_checkpoint++; - (*track_checkpoint)->entity_eventstate &= ~core::Entity::NoPower; - (*track_checkpoint)->entity_dirty = true; + (*track_checkpoint)->set_eventstate(core::Entity::Normal); } else { + std::stringstream msgstr; msgstr << "^BRace completed in " << core::server()->time() - track_racestart << " seconds!"; core::server()->broadcast(msgstr.str()); |