41 static const char*
TYPENAME() {
return "HangarSlot"; }
65 :
ship(0), group(0), design(0), deck(0), slot(0),
66 state(0), time(0), package(0), alert_hold(false)
68 for (
int i = 0; i < 16; i++)
109 for (
int i = 0; i <
nslots[n]; i++) {
112 switch (slot->state) {
124 if (slot->time > 0) {
125 slot->time -= seconds;
135 if (slot->time > 0) {
136 slot->time -= seconds;
145 if (slot->time > 0) {
146 slot->time -= seconds;
148 else if (slot->deck) {
152 if (!slot->alert_hold)
153 slot->deck->
Launch(slot->slot);
155 switch (slot->deck->
State(slot->slot)) {
160 default: slot->state =
STORAGE;
break;
168 switch (slot->deck->
State(slot->slot)) {
173 default: slot->state =
STORAGE;
break;
207 Text ship_name = slot->squadron;
221 slot->package->
AddShip(slot->ship);
229 sprintf_s(name,
"%s %d",
230 (
const char*) slot->package->
Name(),
236 if (slot->deck->
Spot(slot->ship, slot->slot)) {
241 Print(
"WARNING: Could not spot alert ship - carrier: '%s' ship '%s'\n",
255 for (
int n = 0; !found && n <
nsquadrons; n++) {
257 for (
int i = 0; !found && i <
nslots[n]; i++) {
260 if (slot->ship == obj) {
263 if (slot->state !=
MAINT) {
283 static char name[64];
285 sprintf_s(name,
"Hangar(%s)",
ship->
Name());
287 sprintf_s(name,
"Hangar");
296 int* def_load,
int maint_count,
int dead_count)
298 if (nsquadrons < MAX_SQUADRONS && count > 0) {
301 for (
int i = 0; i < count; i++) {
302 s[i].squadron = squadron;
304 s[i].design = design;
308 CopyMemory(s[i].loadout, def_load,
sizeof(s[i].loadout));
316 while (dead_count-- > 0)
319 while (maint_count-- > 0) {
321 s[i--].time = 600 + rand() / 15;
341 slot->package = elem;
342 slot->alert_hold =
false;
345 CopyMemory(slot->loadout, loadout,
sizeof(slot->loadout));
349 Text ship_name = slot->squadron;
371 sprintf_s(name,
"%s %d",
372 (
const char*) elem->
Name(),
394 s->time = expedite ? 3 : s->design->
prep_time;
396 s->alert_hold = !pkg;
399 CopyMemory(s->loadout, loadout,
sizeof(s->loadout));
417 if (s->state ==
ALERT && s->deck)
418 return s->deck->
Launch(s->slot);
431 bool clear_slot =
false;
433 if (s->state ==
ALERT && s->deck) {
434 if (s->deck->
Clear(s->slot)) {
439 package = s->package;
440 package->DelShip(s->ship);
450 else if (s->state ==
PREP) {
452 package = s->package;
464 for (
int i = 0; i <
nslots[squadron]; i++) {
465 if (
squadrons[squadron][i].package == package)
489 if (
FindSlot(incoming, squadron, slot))
503 if (
FindSlot(incoming, squadron, slot)) {
506 s->design = incoming->
Design();
514 if (damage < 10) s->time *= 1.2;
515 else if (damage < 25) s->time *= 2;
516 else if (damage < 50) s->time *= 4;
543 slot = inbound->
Index();
548 int avail_squadron = -1;
552 if (squadron < 0 || squadron == i) {
553 for (
int j = 0; j <
nslots[i]; j++) {
555 if (s->ship == test) {
561 else if (avail_slot < 0 && s->
ship == 0) {
572 if (avail_squadron >= 0 && avail_slot >= 0) {
573 squadron = avail_squadron;
580 s->design = test->
Design();
581 s->state = desired_state;
602 if (squadron < 0 || squadron == i) {
603 for (
int j = 0; j <
nslots[i]; j++) {
605 if (s->ship == test) {
625 for (
int j = 0; j <
nslots[i]; j++) {
644 if (squadron < 0 || squadron >=
nsquadrons || slot < 0 || slot >=
nslots[squadron] || !d)
653 if (d->
Spot(s->ship, s->slot)) {
655 s->alert_hold =
false;
704 if (j >= 0 && j <
nslots[i])
715 if (s)
return s->ship;
722 if (s)
return s->design;
729 if (s)
return s->deck;
736 if (s)
return s->slot;
743 if (s)
return s->state;
750 if (s)
return s->time;
757 if (s)
return s->package;
764 if (s)
return s->loadout;
781 sprintf_s(seq,
" %d", s->deck->
Sequence(s->slot));
801 for (
int i = 0; i <
nslots[n]; i++) {
821 for (
int i = 0; i <
nslots[n]; i++) {
838 for (
int i = 0; i <
nslots[n]; i++) {
841 if (slot->state ==
MAINT)
855 for (
int i = 0; i <
nslots[n]; i++) {
873 for (
int i = 0; i <
nslots[n]; i++) {
892 for (
int i = 0; i <
nslots[n]; i++) {
895 if (slot->package != 0 && !active_list.
contains(slot->package))
896 active_list.
append(slot->package);
901 return active_list.
size();
925 for (
int i = 0; i <
nslots[n]; i++) {