@@ -648,6 +648,8 @@ static struct bridge_data {
648
648
uint32_t last_missile_fail_time; /* universe timestamp of last missile failure */
649
649
int enforce_solarsystem;
650
650
char resident_solarsystem[SSGL_LOCATIONSIZE];
651
+ int warp_core_ejection_armed;
652
+ int warp_core_ejection_confirm_countdown;
651
653
} bridgelist[MAXCLIENTS];
652
654
static int nbridges = 0; /* Number of elements present in bridgelist[] */
653
655
static int announce_players = 0; /* Announce new players via TTS? */
@@ -10102,6 +10104,24 @@ static void maybe_reboot_terminals(struct snis_entity *player_ship)
10102
10104
reboot_random_terminals(player_ship);
10103
10105
}
10104
10106
10107
+ static void update_warp_ejection_countdown(struct snis_entity *o)
10108
+ {
10109
+ int bn = lookup_bridge_by_shipid(o->id);
10110
+ if (bn < 0)
10111
+ return;
10112
+ /* If armed, decrement count down, if countdown hits zero before confirmation, disarm. */
10113
+ if (bridgelist[bn].warp_core_ejection_armed == -1)
10114
+ return;
10115
+
10116
+ if (bridgelist[bn].warp_core_ejection_confirm_countdown > 0)
10117
+ bridgelist[bn].warp_core_ejection_confirm_countdown--;
10118
+ if (bridgelist[bn].warp_core_ejection_confirm_countdown == 0) {
10119
+ bridgelist[bn].warp_core_ejection_armed = -1;
10120
+ snis_queue_add_text_to_speech("Warp core ejection sequence aborted.",
10121
+ ROLE_TEXT_TO_SPEECH, o->id);
10122
+ }
10123
+ }
10124
+
10105
10125
static void aim_high_gain_antenna(struct snis_entity *o)
10106
10126
{
10107
10127
union vec3 straight_ahead = { { 1.0, 0.0, 0.0 } };
@@ -10365,6 +10385,7 @@ static void player_move(struct snis_entity *o)
10365
10385
}
10366
10386
check_science_selection(o);
10367
10387
maybe_reboot_terminals(o);
10388
+ update_warp_ejection_countdown(o);
10368
10389
10369
10390
update_flare_cooldown_timer(o);
10370
10391
@@ -11566,6 +11587,8 @@ static void init_player(struct snis_entity *o)
11566
11587
memset(bridgelist[b].guessed_key, '_', sizeof(bridgelist[b].guessed_key));
11567
11588
memset(bridgelist[b].enciphered_message, 0, sizeof(bridgelist[b].enciphered_message));
11568
11589
bridgelist[b].flare_cooldown = 0;
11590
+ bridgelist[b].warp_core_ejection_confirm_countdown = 0; /* not counting */
11591
+ bridgelist[b].warp_core_ejection_armed = -1; /* not armed */
11569
11592
}
11570
11593
quat_init_axis(&o->tsd.ship.computer_desired_orientation, 0, 1, 0, 0);
11571
11594
o->tsd.ship.computer_steering_time_left = 0;
@@ -23614,12 +23637,33 @@ static int process_eject_warp_core(struct game_client *c)
23614
23637
struct snis_entity *ship = &go[c->ship_index];
23615
23638
union vec3 relvel = { { 1.0, 0.0, 0.0, }, };
23616
23639
int b = c->bridge;
23640
+ unsigned char which;
23641
+ unsigned char buffer[10];
23642
+ int rc;
23643
+
23644
+ rc = read_and_unpack_buffer(c, buffer, "b", &which);
23645
+ if (rc != 0)
23646
+ return -1;
23617
23647
23618
23648
if (ship->tsd.ship.warp_core_status == WARP_CORE_STATUS_EJECTED) {
23619
23649
snis_queue_add_text_to_speech("The warp core has already been ejected.",
23620
23650
ROLE_TEXT_TO_SPEECH, ship->id);
23621
23651
return 0; /* Warp core is already ejected */
23622
23652
}
23653
+
23654
+ if (bridgelist[b].warp_core_ejection_armed == -1) { /* not armed */
23655
+ bridgelist[b].warp_core_ejection_armed = which; /* which person pressed eject 1st time. */
23656
+ bridgelist[b].warp_core_ejection_confirm_countdown = 10 * 10; /* 10 seconds */
23657
+ snis_queue_add_text_to_speech("Warp core ejection sequence armed.",
23658
+ ROLE_TEXT_TO_SPEECH, ship->id);
23659
+ return 0;
23660
+ } else if (bridgelist[b].warp_core_ejection_armed == which) { /* the same person pressed eject again */
23661
+ /* Do nothing. */
23662
+ return 0;
23663
+ }
23664
+ bridgelist[b].warp_core_ejection_armed = -1; /* reset for next time */
23665
+ bridgelist[b].warp_core_ejection_confirm_countdown = 0;
23666
+
23623
23667
snis_queue_add_text_to_speech("Ejecting the warp core.", ROLE_TEXT_TO_SPEECH, ship->id);
23624
23668
quat_rot_vec_self(&relvel, &ship->orientation);
23625
23669
add_warp_core(ship->x, ship->y, ship->z,
@@ -26003,6 +26047,8 @@ static int add_new_player(struct game_client *c, int enforce_solarsystem)
26003
26047
bridgelist[nbridges].active_custom_buttons = 0;
26004
26048
bridgelist[nbridges].last_missile_fail_time = 0;
26005
26049
bridgelist[nbridges].enforce_solarsystem = enforce_solarsystem;
26050
+ bridgelist[nbridges].warp_core_ejection_armed = -1;
26051
+ bridgelist[nbridges].warp_core_ejection_confirm_countdown = 0;
26006
26052
memset(bridgelist[nbridges].custom_button_text, 0, sizeof(bridgelist[nbridges].custom_button_text));
26007
26053
memset(bridgelist[nbridges].cipher_key, '_', sizeof(bridgelist[nbridges].cipher_key));
26008
26054
memset(bridgelist[nbridges].guessed_key, '_', sizeof(bridgelist[nbridges].guessed_key));
0 commit comments