static void UninitKernel (BOOLEAN ships) { UninitSpace (); DestroySound (ReleaseSound (MenuSounds)); DestroyFont (MicroFont); DestroyStringTable (ReleaseStringTable (GameStrings)); DestroyDrawable (ReleaseDrawable (StatusFrame)); DestroyDrawable (ReleaseDrawable (ActivityFrame)); DestroyFont (TinyFont); DestroyFont (StarConFont); UninitQueue (&race_q[0]); UninitQueue (&race_q[1]); if (ships) FreeMasterShipList (); ActivityFrame = 0; }
void UninitShips (void) { COUNT crew_retrieved; int i; HELEMENT hElement, hNextElement; STARSHIP *SPtr[NUM_PLAYERS]; StopSound (); UninitSpace (); for (i = 0; i < NUM_PLAYERS; ++i) SPtr[i] = 0; // Count the crew floating in space. crew_retrieved = CountCrewElements(); for (hElement = GetHeadElement (); hElement != 0; hElement = hNextElement) { ELEMENT *ElementPtr; LockElement (hElement, &ElementPtr); hNextElement = GetSuccElement (ElementPtr); if ((ElementPtr->state_flags & PLAYER_SHIP) || ElementPtr->death_func == new_ship) { STARSHIP *StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); // There should only be one ship left in battle. // He gets the crew still floating in space. if (StarShipPtr->RaceDescPtr->ship_info.crew_level) { if (crew_retrieved >= StarShipPtr->RaceDescPtr->ship_info.max_crew - StarShipPtr->RaceDescPtr->ship_info.crew_level) StarShipPtr->RaceDescPtr->ship_info.crew_level = StarShipPtr->RaceDescPtr->ship_info.max_crew; else StarShipPtr->RaceDescPtr->ship_info.crew_level += crew_retrieved; } /* Record crew left after battle */ StarShipPtr->crew_level = StarShipPtr->RaceDescPtr->ship_info.crew_level; SPtr[StarShipPtr->playerNr] = StarShipPtr; free_ship (StarShipPtr->RaceDescPtr, TRUE, TRUE); StarShipPtr->RaceDescPtr = 0; } UnlockElement (hElement); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; if (LOBYTE (GLOBAL (CurrentActivity)) == IN_ENCOUNTER && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { // Encounter battle in full game. // Record the crew left in the last ship standing. The crew left // is first recorded into STARSHIP.crew_level just a few lines // above here. for (i = NUM_PLAYERS - 1; i >= 0; --i) { if (SPtr[i] && !FleetIsInfinite (i)) UpdateShipFragCrew (SPtr[i]); } } if (LOBYTE (GLOBAL (CurrentActivity)) != IN_ENCOUNTER) { // Remove any ships left from the race queue. for (i = 0; i < NUM_PLAYERS; i++) ReinitQueue (&race_q[i]); if (inHQSpace ()) FreeHyperspace (); } }
void UninitShips (void) { COUNT crew_retrieved; SIZE i; HELEMENT hElement, hNextElement; STARSHIP *SPtr[NUM_PLAYERS]; StopSound (); UninitSpace (); for (i = 0; i < NUM_PLAYERS; ++i) SPtr[i] = 0; // Count the crew floating in space. crew_retrieved = CountCrewElements(); for (hElement = GetHeadElement (); hElement != 0; hElement = hNextElement) { ELEMENT *ElementPtr; extern void new_ship (ELEMENT *ElementPtr); LockElement (hElement, &ElementPtr); hNextElement = GetSuccElement (ElementPtr); if ((ElementPtr->state_flags & PLAYER_SHIP) || ElementPtr->death_func == new_ship) { STARSHIP *StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); // There should only be one ship left in battle. // He gets the crew still floating in space. if (StarShipPtr->RaceDescPtr->ship_info.crew_level) { if (crew_retrieved >= StarShipPtr->RaceDescPtr->ship_info.max_crew - StarShipPtr->RaceDescPtr->ship_info.crew_level) StarShipPtr->RaceDescPtr->ship_info.crew_level = StarShipPtr->RaceDescPtr->ship_info.max_crew; else StarShipPtr->RaceDescPtr->ship_info.crew_level += crew_retrieved; } if (StarShipPtr->RaceDescPtr->uninit_func != NULL) (*StarShipPtr->RaceDescPtr->uninit_func) ( StarShipPtr->RaceDescPtr); /* Record crew left after battle */ StarShipPtr->crew_level = StarShipPtr->RaceDescPtr->ship_info.crew_level; SPtr[WHICH_SIDE (ElementPtr->state_flags)] = StarShipPtr; free_ship (StarShipPtr->RaceDescPtr, TRUE, TRUE); StarShipPtr->RaceDescPtr = 0; } UnlockElement (hElement); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; if (LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) { } else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { // XXX: This has no purpose for SuperMelee // In full-game, the sole purpose of this is to record the crew // left in the last ship standing. The crew left is first recorded // into STARSHIP.crew_level just a few lines above here. for (i = NUM_PLAYERS - 1; i >= 0; --i) { if (SPtr[i]) GetEncounterStarShip (SPtr[i], i); } } if (LOBYTE (GLOBAL (CurrentActivity)) != IN_ENCOUNTER) { // Remove any ships left from the race queue. for (i = 0; i < NUM_PLAYERS; i++) ReinitQueue (&race_q[i]); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) FreeHyperspace (); } }
void UninitShips (void) { BYTE crew_retrieved; SIZE i; HELEMENT hElement, hNextElement; STARSHIPPTR SPtr[NUM_PLAYERS]; StopSound (); UninitSpace (); for (i = 0; i < NUM_PLAYERS; ++i) SPtr[i] = 0; // Count the crew floating in space. crew_retrieved = 0; for (hElement = GetHeadElement (); hElement != 0; hElement = hNextElement) { ELEMENTPTR ElementPtr; LockElement (hElement, &ElementPtr); hNextElement = GetSuccElement (ElementPtr); if (ElementPtr->state_flags & CREW_OBJECT) ++crew_retrieved; UnlockElement (hElement); } for (hElement = GetHeadElement (); hElement != 0; hElement = hNextElement) { ELEMENTPTR ElementPtr; extern void new_ship (PELEMENT ElementPtr); LockElement (hElement, &ElementPtr); hNextElement = GetSuccElement (ElementPtr); if ((ElementPtr->state_flags & PLAYER_SHIP) || ElementPtr->death_func == new_ship) { STARSHIPPTR StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); // There should only be one ship left in battle. // He gets the crew still floating in space. if (StarShipPtr->RaceDescPtr->ship_info.crew_level) { if (crew_retrieved >= StarShipPtr->RaceDescPtr->ship_info.max_crew - StarShipPtr->RaceDescPtr->ship_info.crew_level) StarShipPtr->RaceDescPtr->ship_info.crew_level = StarShipPtr->RaceDescPtr->ship_info.max_crew; else StarShipPtr->RaceDescPtr->ship_info.crew_level += crew_retrieved; } if (StarShipPtr->RaceDescPtr->uninit_func != NULL) (*StarShipPtr->RaceDescPtr->uninit_func) ( StarShipPtr->RaceDescPtr); StarShipPtr->ShipFacing = StarShipPtr->RaceDescPtr->ship_info.var2; StarShipPtr->special_counter = StarShipPtr->RaceDescPtr->ship_info.crew_level; SPtr[WHICH_SIDE (ElementPtr->state_flags)] = StarShipPtr; free_ship (StarShipPtr, TRUE); } UnlockElement (hElement); } GLOBAL (CurrentActivity) &= ~IN_BATTLE; if (LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE) { } else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER && !(GLOBAL (CurrentActivity) & CHECK_ABORT)) { for (i = NUM_PLAYERS - 1; i >= 0; --i) { if (SPtr[i]) GetEncounterStarShip (SPtr[i], i); } } if (LOBYTE (GLOBAL (CurrentActivity)) != IN_ENCOUNTER) { ReinitQueue (&race_q[0]); ReinitQueue (&race_q[1]); if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) FreeHyperspace (); } }