diff options
author | Stijn Buys <ingar@osirion.org> | 2011-02-10 18:07:24 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-02-10 18:07:24 +0000 |
commit | 9ff5cf6184b9c5183c1f55cfa6c0d08586eb02c9 (patch) | |
tree | d50dd2d8ed48acfbb7063d4c073f77cb195106f7 /src/game/base | |
parent | a255dbc032d15a4f5024bc60baa19c45ebceecc6 (diff) |
Added a local chat channel. The say command defaults to zone chat, global messages can be send with the shout command.
Removed NonSolid flag fro race objects, have race use the local chat channel.
Updated to network protocol version 22.
Updated developer documentation.
Diffstat (limited to 'src/game/base')
-rw-r--r-- | src/game/base/racetrack.cc | 39 | ||||
-rw-r--r-- | src/game/base/racetrack.h | 1 |
2 files changed, 29 insertions, 11 deletions
diff --git a/src/game/base/racetrack.cc b/src/game/base/racetrack.cc index 67b8327..fd5d339 100644 --- a/src/game/base/racetrack.cc +++ b/src/game/base/racetrack.cc @@ -29,7 +29,7 @@ CheckPoint::CheckPoint(RaceTrack *parent) die(); } - set_flag(core::Entity::NonSolid); + //set_flag(core::Entity::NonSolid); } CheckPoint::~CheckPoint() @@ -44,11 +44,13 @@ RaceTrack::RaceTrack() : EntityDynamic() track_player = 0; track_racestart = 0; track_checkpointtime = 0; + track_record = 0; + entity_moduletypeid = race_enttype; set_state(core::Entity::NoPower); set_flag(core::Entity::Dockable); - set_flag(core::Entity::NonSolid); + //set_flag(core::Entity::NonSolid); } RaceTrack::~RaceTrack() @@ -104,7 +106,7 @@ void RaceTrack::func_dock(core::Entity *entity) entity_timer = 5.0f; std::string message("^B" + track_player->name() + " ^Bactivated the race! Race starts in 5..."); - core::server()->broadcast(message); + core::server()->broadcast(zone(), message); track_player->set_mission_target(this); return; } @@ -140,7 +142,7 @@ void RaceTrack::frame(float seconds) if (math::distance(location(), player->control()->location()) > radius()) { std::string message("^BNo cheating!"); - core::server()->broadcast(message); + core::server()->broadcast(zone(), message); reset_race(); return; } @@ -152,14 +154,14 @@ void RaceTrack::frame(float seconds) if (entity_timer > 0) { std::stringstream msgstr; msgstr << "^B" << entity_timer << "..."; - core::server()->broadcast(msgstr.str()); + core::server()->broadcast(zone(), msgstr.str()); track_racestart = core::server()->time(); } else { for (CheckPoints::iterator cpit = track_checkpoints.begin(); cpit != track_checkpoints.end(); ++cpit) { (*cpit)->set_state(core::Entity::NoPower); } std::string message("^BGo!"); - core::server()->broadcast(message); + core::server()->broadcast(zone(), message); track_racestart = core::server()->time(); track_checkpointtime = core::server()->time() + 15.0f; @@ -174,7 +176,7 @@ void RaceTrack::frame(float seconds) if (core::server()->time() > track_checkpointtime) { std::string message("^BToo slow, race lost!"); - core::server()->broadcast(message); + core::server()->broadcast(zone(), message); reset_race(); return; @@ -187,7 +189,7 @@ void RaceTrack::frame(float seconds) if (next_checkpoint != track_checkpoints.end()) { std::string message("^BCheckpoint!"); - core::server()->broadcast(message); + core::server()->broadcast(zone(), message); track_checkpointtime = core::server()->time() + 15.0f; (*track_checkpoint)->set_state(core::Entity::NoPower); track_checkpoint++; @@ -196,12 +198,25 @@ void RaceTrack::frame(float seconds) } else { + float player_time = core::server()->time() - track_racestart; + const bool new_record = ((track_record > 0.0f) && (player_time > 0.0f) && (player_time < track_record)); + std::stringstream msgstr; - msgstr << "^BRace completed in " << core::server()->time() - track_racestart << " seconds!"; - core::server()->broadcast(msgstr.str()); - + msgstr << "^B" << player->name() << "completed the race in " << player_time << " seconds"; + + if (new_record) { + msgstr << ", a new record!"; + } else { + msgstr << "."; + } + core::server()->broadcast(zone(), msgstr.str()); + // prize money unsigned long the_prize = (unsigned long) floorf(10000.0f / (core::server()->time() - track_racestart)); + if (track_record && new_record) { + the_prize += 1000.0f * (track_record - player_time); + } + player->add_credits(the_prize); msgstr.clear(); msgstr.str(""); @@ -209,6 +224,8 @@ void RaceTrack::frame(float seconds) player->send(msgstr.str()); player->sound("game/buy"); + if (new_record) + track_record = player_time; reset_race(); } } diff --git a/src/game/base/racetrack.h b/src/game/base/racetrack.h index da810a3..705039a 100644 --- a/src/game/base/racetrack.h +++ b/src/game/base/racetrack.h @@ -57,6 +57,7 @@ private: float track_racestart; float track_checkpointtime; CheckPoints::iterator track_checkpoint; + float track_record; }; |