diff options
author | Stijn Buys <ingar@osirion.org> | 2011-07-11 12:54:44 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-07-11 12:54:44 +0000 |
commit | 99bd770a6030805ecd2cb22671e8f29d32fd59db (patch) | |
tree | 6743c40b773570d22cacffa1e9e1cbddda0edc7b /src/game | |
parent | 02169591261cc09047117ddff961595717c8903a (diff) |
Made jumpgates respect the cooldown time
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/jumppoint.cc | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc index 3d9fd01..12516c0 100644 --- a/src/game/base/jumppoint.cc +++ b/src/game/base/jumppoint.cc @@ -155,21 +155,34 @@ void JumpGate::validate() void JumpGate::func_dock(Ship *ship) { if (target()) { + // check if this jumpgate is in use if (activated()) { - if (ship->owner()) + if (ship->owner()) { ship->owner()->send("Jumpgate in use"); + } return; } - ship->initiate_jump(this); - activate(); if (target()->moduletype() == jumpgate_enttype) { + // check if the target jumpgate is in use + if (static_cast<JumpGate *>(target())->activated()) { + if (ship->owner()) { + ship->owner()->send("Jumpgate in use"); + } + return; + } + // activate target jumpgate static_cast<JumpGate *>(target())->activate(); } - + + // activate jumpgate + activate(); + ship->initiate_jump(this); + if (ship->owner() && ship->owner()->control() == ship) { ship->owner()->set_view(this); } + } else { if (ship->owner()) ship->owner()->send("Jumpgate inactive"); @@ -179,17 +192,20 @@ void JumpGate::func_dock(Ship *ship) void JumpGate::activate() { - jumpgate_timer = jump_timer_delay * 1000; + jumpgate_timer = (jump_timer_delay + jump_cooldown_delay) * 1000; set_state(core::Entity::Normal); } void JumpGate::frame(const unsigned long elapsed) { - if (jumpgate_timer > elapsed) { - jumpgate_timer -= elapsed; - } else if (state() != core::Entity::NoPower) { - set_state(core::Entity::NoPower); - jumpgate_timer = 0; + if (jumpgate_timer > 0) { + + if (jumpgate_timer > elapsed) { + jumpgate_timer -= elapsed; + } else if (state() != core::Entity::NoPower) { + set_state(core::Entity::NoPower); + jumpgate_timer = 0; + } } } |