add: ValidateOrbits ();
context: DoFlagshipCommands (PMENU_STATE pMS){	if (!(pMS->Initialized & 1))	{		ChangeSolarSys ();	}	else	{		BOOLEAN select = CurrentMenuState.select;		SetSemaphore (GraphicsSem);		while (*(volatile BYTE *)&pMS->CurState == 0				&& (*(volatile SIZE *)&pMS->Initialized & 1)				&& !(GLOBAL (CurrentActivity)				& (START_ENCOUNTER | END_INTERPLANETARY				| CHECK_ABORT | CHECK_LOAD))				&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0)		{			ClearSemaphore (GraphicsSem);			TaskSwitch ();			SetSemaphore (GraphicsSem);		}		ClearSemaphore (GraphicsSem);		if (pMS->CurState)		{			BOOLEAN DoMenu;			BYTE NewState;			// For some reason, DoFlagshipCommands uses CurState a bit differently			pMS->CurState --;			DoMenu = DoMenuChooser (pMS, 				(BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN));			pMS->CurState ++;			if (!DoMenu) {				NewState = pMS->CurState;				if (LastActivity == CHECK_LOAD)					select = TRUE;				if (select)				{					if (NewState != SCAN + 1 && NewState != (GAME_MENU) + 1)					{						SetSemaphore (GraphicsSem);						SetFlashRect (NULL_PTR, (FRAME)0);						ClearSemaphore (GraphicsSem);					}					switch (NewState - 1)					{						case SCAN:							ScanSystem ();							break;						case EQUIP_DEVICE:						{							extern BOOLEAN Devices (PMENU_STATE pMS);							pMenuState = pMS;							if (!Devices (pMS))								select = FALSE;							pMenuState = 0;							if (GET_GAME_STATE (PORTAL_COUNTER)) {								// A player-induced portal to QuasiSpace is								// opening.								return (FALSE);							}							break;						}						case CARGO:						{							extern void Cargo (PMENU_STATE pMS);							Cargo (pMS);							break;						}						case ROSTER:						{							extern BOOLEAN Roster (void);							if (!Roster ())								select = FALSE;							break;						}						case GAME_MENU:							if (GameOptions () == 0)								return (FALSE);													break;						case STARMAP:						{							BOOLEAN AutoPilotSet;							SetSemaphore (GraphicsSem);							if (++pMS->Initialized > 3) {								pSolarSysState->PauseRotate = 1;								RepairSISBorder ();							}							AutoPilotSet = DoStarMap ();							if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE									|| (GLOBAL (CurrentActivity) & CHECK_ABORT))							{								ClearSemaphore (GraphicsSem);								return (FALSE);							}							else if (pMS->Initialized <= 3)							{								ZoomSystem ();								--pMS->Initialized;							}							ClearSemaphore (GraphicsSem);							if (!AutoPilotSet && pMS->Initialized >= 3)							{								LoadPlanet (FALSE);								--pMS->Initialized;								pSolarSysState->PauseRotate = 0;								SetSemaphore (GraphicsSem);								SetFlashRect ((PRECT)~0L, (FRAME)0);								ClearSemaphore (GraphicsSem);								break;							}						}						case NAVIGATION:							if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)								return (FALSE);							if (pMS->Initialized <= 1)							{								pMS->Initialized = 1;								ResumeGameClock ();							}							else if (pMS->flash_task)							{								FreePlanet ();								SetSemaphore (GraphicsSem);								LoadSolarSys ();								ZoomSystem ();								ClearSemaphore (GraphicsSem);							}							SetSemaphore (GraphicsSem);							pMS->CurState = 0;							ClearSemaphore (GraphicsSem);							break;					}									if (GLOBAL (CurrentActivity) & CHECK_ABORT)						;					else if (pMS->CurState)					{						SetSemaphore (GraphicsSem);						SetFlashRect ((PRECT)~0L, (FRAME)0);						ClearSemaphore (GraphicsSem);						if (select)						{							if (optWhichMenu != OPT_PC)								pMS->CurState = (NAVIGATION) + 1;							DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN),									pMS->CurState - 1);						}					}					else					{						SetSemaphore (GraphicsSem);						SetFlashRect (NULL_PTR, (FRAME)0);						ClearSemaphore (GraphicsSem);						DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);					}				}			}		}	}	return (!(GLOBAL (CurrentActivity)			& (START_ENCOUNTER | END_INTERPLANETARY			| CHECK_ABORT | CHECK_LOAD))			&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0);}