Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
committerStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
commitca0c1d3e6f8b5fa4eb2e0a86fcf47b12fb600786 (patch)
tree5d72e330f11350065806e83cc8712693241b9aad /src/game/ship.cc
parent29984680d6e0e52efec489497b1796e056164442 (diff)
mission targets, texture unloading, private messages
Diffstat (limited to 'src/game/ship.cc')
-rw-r--r--src/game/ship.cc59
1 files changed, 41 insertions, 18 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index 0dde90e..1828172 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -118,7 +118,7 @@ void Ship::jump(std::string const &args)
return;
}
- core::server()->send(owner(), "Jumping to '" + jumptargetzone->name() + '\'');
+ core::server()->send(owner(), "Jumping to the " + jumptargetzone->name());
set_zone(jumptargetzone);
if (owner()->control() == (EntityControlable*) this)
owner()->set_zone(jumptargetzone);
@@ -145,6 +145,10 @@ void Ship::jump(std::string const &args)
return;
}
+ if (!find_closest_jumppoint()) {
+ return;
+ }
+
entity_eventstate = core::Entity::JumpInitiate;
if (Game::instance()->g_devel->value()) {
entity_timer = 0;
@@ -157,6 +161,39 @@ void Ship::jump(std::string const &args)
}
}
+JumpPoint * Ship::find_closest_jumppoint()
+{
+ // find closest jumppoint
+ float d = -1;
+ JumpPoint *jumppoint = 0;
+ for (core::Zone::Content::iterator it = zone()->content().begin(); it != zone()->content().end(); it++) {
+ core::Entity *entity = (*it);
+ if (entity->moduletype() == jumppoint_enttype) {
+ JumpPoint *te = static_cast<JumpPoint *>(entity);
+ float d1 = math::distance(location(), te->location());
+ if ((d < 0) || (d1 < d)) {
+ d = d1;
+ jumppoint = te;
+ }
+ }
+ }
+
+ if (jumppoint && jumppoint->target()) {
+ if (Game::instance()->g_jumppointrange->value() < d) {
+ core::server()->send(owner(), "Jumppoint out of range!");
+ return 0;
+ } else {
+ core::server()->send(owner(), "Jumping to the " + jumppoint->target()->zone()->name());
+ return jumppoint;
+ }
+ } else {
+ core::server()->send(owner(), "No jumppoints found!");
+ return 0;
+ }
+
+ return 0;
+}
+
void Ship::frame(float seconds)
{
const float direction_change_speed = 2;
@@ -184,29 +221,15 @@ void Ship::frame(float seconds)
entity_timer -= 1.0f;
if (entity_timer <= 0) {
- // find closest jumppoint
- float d = -1;
- JumpPoint *jumppoint = 0;
- for (core::Zone::Content::iterator it = zone()->content().begin(); it != zone()->content().end(); it++) {
- core::Entity *entity = (*it);
- if (entity->moduletype() == jumppoint_enttype) {
- JumpPoint *te = static_cast<JumpPoint *>(entity);
- float d1 = math::distance(location(), te->location());
- if ((d < 0) || (d1 < d1)) {
- d = d1;
- jumppoint = te;
- }
- }
- }
- if (jumppoint && jumppoint->target()) {
- core::server()->send(owner(), "Jumping to '" + jumppoint->target()->zone()->name() + '\'');
+ JumpPoint *jumppoint = find_closest_jumppoint();
+
+ if (jumppoint) {
set_zone(jumppoint->target()->zone());
if (owner()->control() == (EntityControlable*) this)
owner()->set_zone(jumppoint->target()->zone());
entity_eventstate = core::Entity::Jump;
entity_location.assign(jumppoint->target()->location() + location() - jumppoint->location());
} else {
- core::server()->send(owner(), "Jump failed!");
entity_eventstate = core::Entity::Normal;
}
ship_jumpdrive_timer = 0;