diff options
-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; + } } } |