Split DoFlagshipCommands() into separate menu functions for IP, Orbital and Hyperspace; this allowed for some solarsys and manifest menu cleanups; temporary pBaseDesc setups removed; some invariant tests removed; some code moved around to more appropriate places

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3378 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-30 21:57:13 +00:00
parent 273a9933bb
commit d050f79cb6
19 changed files with 668 additions and 585 deletions
+4 -5
View File
@@ -73,15 +73,14 @@ DoSelectAction (MENU_STATE *pMS)
pMS->CurState = HAIL;
return (FALSE);
case ATTACK + 1:
pMS->Initialized = GameOptions ();
if (pMS->Initialized)
{
// Clearing FlashRect is not necessary
if (!GameOptions ())
return FALSE;
DrawMenuStateStrings (PM_CONVERSE, pMS->CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return ((BOOLEAN)pMS->Initialized);
break;
default:
printf ("Unknown option: %d\n", pMS->CurState);
}
+1 -11
View File
@@ -24,7 +24,6 @@
#ifdef NETPLAY
# include "netplay/netmelee.h"
#endif
#include "planets/planets.h"
#include "settings.h"
#include "sounds.h"
#include "tactrans.h"
@@ -377,16 +376,7 @@ DoInput (void *pInputState, BOOLEAN resetInput)
soundFlags = MenuKeysToSoundFlags (&PulsedInputState);
if (MenuSounds
&& (pSolarSysState == 0
/* see if in menu */
|| pSolarSysState->MenuState.CurState
|| pSolarSysState->MenuState.Initialized > 2)
&& (soundFlags & (sound_0 | sound_1))
#ifdef NEVER
&& !PLRPlaying ((MUSIC_REF)~0)
#endif /* NEVER */
)
if (MenuSounds && (soundFlags & (sound_0 | sound_1)))
{
SOUND S;
+34 -13
View File
@@ -238,8 +238,6 @@ DrawDescriptionString (MENU_STATE *pMS, UNICODE *Str, COUNT CursorPos,
if (!(state & DDSHS_EDIT))
{ // normal state
SetFlashRect (SFR_MENU_3DO);
if (pMS->CurState == CHANGE_CAPTAIN_SETTING)
DrawCaptainsName ();
else
@@ -327,6 +325,10 @@ DoNaming (MENU_STATE *pMS)
pMS->Initialized = TRUE;
pMS->InputFunc = DoNaming;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawDescriptionString (pMS, buf, 0, DDSHS_EDIT);
LockMutex (GraphicsLock);
@@ -357,6 +359,11 @@ DoNaming (MENU_STATE *pMS)
utf8StringCopy (Setting, tes.MaxSize, buf);
else
utf8StringCopy (buf, sizeof (buf), Setting);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
DrawDescriptionString (pMS, buf, 0, DDSHS_NORMAL);
if (namingCB)
@@ -837,11 +844,12 @@ DoPickGame (MENU_STATE *pMS)
return (FALSE);
}
first_time = (BOOLEAN)(pMS->Initialized == 0);
first_time = !pMS->Initialized;
SetMenuSounds (MENU_SOUND_ARROWS | MENU_SOUND_PAGEUP | MENU_SOUND_PAGEDOWN, MENU_SOUND_SELECT);
if (!pMS->Initialized)
{
// XXX: Save DoGameOptions() state
pMS->delta_item = (SIZE)pMS->CurState;
pMS->CurState = NewState = prev_save;
pMS->InputFunc = DoPickGame;
@@ -863,10 +871,8 @@ Restart:
}
else if (PulsedInputState.menu[KEY_MENU_CANCEL])
{
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
pMS->ModuleFrame = 0;
// XXX: Restore DoGameOptions() state
pMS->CurState = (BYTE)pMS->delta_item;
ResumeMusic ();
if (LastActivity == CHECK_LOAD)
@@ -894,7 +900,6 @@ Restart:
}
else
{
SetFlashRect (NULL);
DrawStamp (&MsgStamp);
DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
UnlockMutex (GraphicsLock);
@@ -916,10 +921,10 @@ Restart:
if (LoadGame ((COUNT)pMS->CurState, NULL))
GLOBAL (CurrentActivity) |= CHECK_LOAD;
}
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
pMS->ModuleFrame = 0;
// XXX: Restore DoGameOptions() state
pMS->CurState = (BYTE)pMS->delta_item;
return (FALSE);
}
@@ -1076,7 +1081,6 @@ ChangeGameSelection:
}
UnbatchGraphics ();
}
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
}
@@ -1125,7 +1129,7 @@ PickGame (MENU_STATE *pMS)
DoInput (pMS, TRUE);
LockMutex (GraphicsLock);
pMS->Initialized = -1;
pMS->Initialized = FALSE;
pMS->InputFunc = DoGameOptions;
retval = TRUE;
@@ -1169,13 +1173,13 @@ DoGameOptions (MENU_STATE *pMS)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
if (pMS->Initialized <= 0)
if (!pMS->Initialized)
{
if (LastActivity == CHECK_LOAD)
pMS->CurState = LOAD_GAME;
DrawMenuStateStrings (PM_SAVE_GAME, pMS->CurState);
pMS->Initialized = 1;
pMS->Initialized = TRUE;
pMS->InputFunc = DoGameOptions;
}
else if (PulsedInputState.menu[KEY_MENU_CANCEL]
@@ -1191,7 +1195,15 @@ DoGameOptions (MENU_STATE *pMS)
{
case SAVE_GAME:
case LOAD_GAME:
return PickGame (pMS);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (!PickGame (pMS))
return FALSE;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
case QUIT_GAME:
if (ConfirmExit ())
return FALSE;
@@ -1220,9 +1232,18 @@ GameOptions (void)
MenuState.InputFunc = DoGameOptions;
MenuState.CurState = SAVE_GAME;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, TRUE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
pLocMenuState = 0;
return ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)) ? FALSE : TRUE);
+74 -4
View File
@@ -22,10 +22,12 @@
#include "collide.h"
#include "colors.h"
#include "controls.h"
#include "gameopt.h"
#include "menustat.h"
// for DrawMenuStateStrings()
#include "encount.h"
#include "ship.h"
#include "shipcont.h"
#include "process.h"
#include "globdata.h"
#include "sis.h"
@@ -35,11 +37,11 @@
#include "resinst.h"
#include "setup.h"
#include "sounds.h"
#include "options.h"
#include "libs/graphics/gfx_common.h"
#include "libs/mathlib.h"
#define XOFFS ((RADAR_SCAN_WIDTH + (UNIT_SCREEN_WIDTH << 2)) >> 1)
#define YOFFS ((RADAR_SCAN_HEIGHT + (UNIT_SCREEN_HEIGHT << 2)) >> 1)
@@ -1598,6 +1600,74 @@ SeedUniverse (void)
}
}
static BOOLEAN
DoHyperspaceMenu (MENU_STATE *pMS)
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
BOOLEAN handled;
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return FALSE;
handled = DoMenuChooser (pMS, PM_STARMAP);
if (handled)
return TRUE;
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
case EQUIP_DEVICE:
select = DevicesMenu ();
if (GET_GAME_STATE (PORTAL_COUNTER))
{ // A player-induced portal to QuasiSpace is opening
return FALSE;
}
if (GLOBAL (CurrentActivity) & START_ENCOUNTER)
{ // Selected Talking Pet, going into conversation
return FALSE;
}
break;
case CARGO:
CargoMenu ();
break;
case ROSTER:
select = RosterMenu ();
break;
case GAME_MENU:
if (!GameOptions ())
return FALSE; // abort or load
break;
case STARMAP:
StarMap ();
SetDefaultMenuRepeatDelay ();
return FALSE;
case NAVIGATION:
return FALSE;
}
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
if (select)
{ // 3DO menu jumps to NAVIGATE after a successful submenu run
if (optWhichMenu != OPT_PC)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
void
HyperspaceMenu (void)
{
@@ -1613,9 +1683,9 @@ UnbatchGraphics ();
UnlockMutex (GraphicsLock);
memset (&MenuState, 0, sizeof (MenuState));
MenuState.InputFunc = DoFlagshipCommands;
MenuState.Initialized = 1;
MenuState.CurState = STARMAP + 1;
MenuState.InputFunc = DoHyperspaceMenu;
MenuState.Initialized = TRUE;
MenuState.CurState = STARMAP;
DrawMenuStateStrings (PM_STARMAP, STARMAP);
LockMutex (GraphicsLock);
-4
View File
@@ -144,8 +144,6 @@ ip_group_preprocess (ELEMENT *ElementPtr)
- pSolarSysState->PlanetDesc + 1);
task = GroupPtr->task;
if (pSolarSysState->MenuState.CurState)
goto ExitIPProcess;
if ((task & REFORM_GROUP) && --GroupPtr->group_counter == 0)
{ // Finished reforming the group
@@ -471,7 +469,6 @@ CheckGetAway:
+ (SIZE)((long)GroupPtr->loc.y
* (DISPLAY_FACTOR >> 1) / radius);
ExitIPProcess:
EPtr->next.location.x = DISPLAY_TO_WORLD (dest_pt.x)
+ (COORD)(LOG_SPACE_WIDTH >> 1)
- (LOG_SPACE_WIDTH >> (MAX_REDUCTION + 1));
@@ -672,7 +669,6 @@ flag_ship_preprocess (ELEMENT *ElementPtr)
ElementPtr->thrust_wait = FLIP_WAIT;
}
if (pSolarSysState->MenuState.CurState == 0)
{
BYTE flagship_loc, ec;
SIZE vdx, vdy, radius;
+2 -1
View File
@@ -800,7 +800,8 @@ ExitOutfit:
DoInstallModule (pMS);
break;
case OUTFIT_SAVELOAD:
if (GameOptions () == 0)
// Clearing FlashRect is not necessary
if (!GameOptions ())
goto ExitOutfit;
DrawMenuStateStrings (PM_FUEL, pMS->CurState);
LockMutex (GraphicsLock);
+12 -10
View File
@@ -303,10 +303,10 @@ DoDiscardCargo (MENU_STATE *pMS)
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE);
if (!(pMS->Initialized & 1))
if (!pMS->Initialized)
{
pMS->InputFunc = DoDiscardCargo;
++pMS->Initialized;
pMS->Initialized = TRUE;
NewState = pMS->CurState;
pMS->CurState = (BYTE)~0;
@@ -372,16 +372,18 @@ SelectCargo:
}
void
Cargo (MENU_STATE *pMS)
CargoMenu (void)
{
pMS->InputFunc = DoDiscardCargo;
--pMS->Initialized;
pMS->CurState = 1;
// XXX: Should get an own STATE struct
MENU_STATE MenuState;
MenuState.InputFunc = DoDiscardCargo;
MenuState.Initialized = FALSE;
// XXX: 1-based index because this had to work around the
// pSolarSysState->MenuState.CurState abuse. Should be changed.
MenuState.CurState = 1;
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (pMS, TRUE);
pMS->InputFunc = DoFlagshipCommands;
pMS->CurState = CARGO + 1;
DoInput (&MenuState, TRUE);
}
+18 -17
View File
@@ -460,12 +460,12 @@ DoManipulateDevices (MENU_STATE *pMS)
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return (FALSE);
if (!(pMS->Initialized & 1))
if (!pMS->Initialized)
{
DrawDevices (pMS, (BYTE)~0, (BYTE)~0);
pMS->InputFunc = DoManipulateDevices;
++pMS->Initialized;
pMS->Initialized = TRUE;
NewState = pMS->CurState;
goto SelectDevice;
}
@@ -640,27 +640,28 @@ InventoryDevices (BYTE *pDeviceMap, COUNT Size)
}
BOOLEAN
Devices (MENU_STATE *pMS)
DevicesMenu (void)
{
BYTE DeviceMap[NUM_DEVICES];
MENU_STATE MenuState;
pMS->first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES);
if (pMS->first_item.x)
memset (&MenuState, 0, sizeof MenuState);
MenuState.first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES);
if (MenuState.first_item.x)
{
pMS->InputFunc = DoManipulateDevices;
--pMS->Initialized;
pMS->CurState = 1;
pMS->first_item.y = 0;
MenuState.InputFunc = DoManipulateDevices;
MenuState.Initialized = FALSE;
// XXX: 1-based index because this had to work around the
// pSolarSysState->MenuState.CurState abuse. Should be changed.
MenuState.CurState = 1;
MenuState.first_item.y = 0;
pMS->CurFrame = (FRAME)DeviceMap;
FlushInput ();
DoManipulateDevices (pMS); /* to make sure it's initialized */
// XXX: CurFrame hack
MenuState.CurFrame = (FRAME)DeviceMap;
//DoManipulateDevices (pMS); /* to make sure it's initialized */
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (pMS, TRUE);
pMS->CurFrame = 0;
pMS->InputFunc = DoFlagshipCommands;
pMS->CurState = EQUIP_DEVICE + 1;
DoInput (&MenuState, TRUE);
if (GLOBAL_SIS (CrewEnlisted) != (COUNT)~0
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
+121
View File
@@ -23,10 +23,15 @@
#include "../colors.h"
#include "../element.h"
#include "../settings.h"
#include "../controls.h"
#include "../sounds.h"
#include "../gameopt.h"
#include "../shipcont.h"
#include "../setup.h"
#include "../uqmdebug.h"
#include "../resinst.h"
#include "../nameref.h"
#include "options.h"
#include "libs/graphics/gfx_common.h"
@@ -295,3 +300,119 @@ FreeLanderFont (PLANET_INFO *info)
DestroyDrawable (ReleaseDrawable (info->LanderFontEff));
info->LanderFontEff = NULL;
}
static BOOLEAN
DoPlanetOrbit (MENU_STATE *pMS)
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
BOOLEAN handled;
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return FALSE;
// XXX: pMS actually refers to pSolarSysState->MenuState
handled = DoMenuChooser (pMS, PM_SCAN);
if (handled)
return TRUE;
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
case SCAN:
ScanSystem ();
break;
case EQUIP_DEVICE:
select = DevicesMenu ();
if (GLOBAL (CurrentActivity) & START_ENCOUNTER)
{ // Invoked Talking Pet, a Caster or Sun Device over Chmmr,
// or a Caster for Ilwrath
// Going into conversation
return FALSE;
}
break;
case CARGO:
CargoMenu ();
break;
case ROSTER:
select = RosterMenu ();
break;
case GAME_MENU:
if (!GameOptions ())
return FALSE; // abort or load
break;
case STARMAP:
{
BOOLEAN AutoPilotSet;
LockMutex (GraphicsLock);
pSolarSysState->PauseRotate = 1;
RepairSISBorder ();
UnlockMutex (GraphicsLock);
TaskSwitch ();
AutoPilotSet = StarMap ();
SetDefaultMenuRepeatDelay ();
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return FALSE;
if (!AutoPilotSet)
{ // Redraw the orbital display
LoadPlanet (NULL);
LockMutex (GraphicsLock);
pSolarSysState->PauseRotate = 0;
UnlockMutex (GraphicsLock);
break;
}
// Fall through !!!
}
case NAVIGATION:
return FALSE;
}
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
if (select)
{ // 3DO menu jumps to NAVIGATE after a successful submenu run
if (optWhichMenu != OPT_PC)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_SCAN, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
void
PlanetOrbitMenu (void)
{
void *oldInputFunc = pSolarSysState->MenuState.InputFunc;
DrawMenuStateStrings (PM_SCAN, SCAN);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
pSolarSysState->MenuState.CurState = SCAN;
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
// XXX: temporary; will have an own MENU_STATE
pSolarSysState->MenuState.InputFunc = DoPlanetOrbit;
DoInput (&pSolarSysState->MenuState, TRUE);
pSolarSysState->MenuState.InputFunc = oldInputFunc;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
+2 -9
View File
@@ -237,20 +237,11 @@ extern void ExploreSolarSys (void);
extern void DrawStarBackGround (BOOLEAN ForPlanet);
extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay);
extern PLAN_GEN_FUNC GenerateIP (BYTE Index);
extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem);
extern void DrawOval (RECT *pRect, BYTE num_off_pixels);
extern void DrawFilledOval (RECT *pRect);
extern void FillOrbits (SOLARSYS_STATE *system, BYTE NumPlanets,
PLANET_DESC *pBaseDesc, BOOLEAN TypesDefined);
extern void ScanSystem (void);
extern void ChangeSolarSys (void);
extern BOOLEAN DoFlagshipCommands (MENU_STATE *pMS);
extern void ZoomSystem (void);
extern void LoadSolarSys (void);
extern void InitLander (BYTE LanderFlags);
extern BOOLEAN ValidateOrbits (void);
extern void IP_reset (void);
extern void IP_frame (void);
extern RECT* RotatePlanet (int x, int dx, int dy, COUNT scale_amt,
UBYTE zoom_from, RECT *r);
@@ -263,5 +254,7 @@ extern void DeltaTopography (COUNT num_iterations, SBYTE *DepthArray,
extern UNICODE* GetNamedPlanetaryBody (void);
extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize);
extern void PlanetOrbitMenu (void);
#endif /* _PLANETS_H */
+3 -188
View File
@@ -1586,8 +1586,8 @@ DoneSphereGrowth:
}
}
static BOOLEAN
DoStarMap (void)
BOOLEAN
StarMap (void)
{
MENU_STATE MenuState;
POINT universe;
@@ -1614,9 +1614,6 @@ DoStarMap (void)
if (cursorLoc.x == ~0 && cursorLoc.y == ~0)
cursorLoc = universe;
UnlockMutex (GraphicsLock);
TaskSwitch ();
MenuState.InputFunc = DoMoveCursor;
MenuState.Initialized = FALSE;
@@ -1643,10 +1640,10 @@ DoStarMap (void)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
LockMutex (GraphicsLock);
DrawHyperCoords (universe);
DrawSISMessage (NULL);
DrawStatusMessage (NULL);
UnlockMutex (GraphicsLock);
if (GLOBAL (autopilot.x) == universe.x
&& GLOBAL (autopilot.y) == universe.y)
@@ -1656,185 +1653,3 @@ DoStarMap (void)
&& GLOBAL (autopilot.y) != ~0);
}
BOOLEAN
DoFlagshipCommands (MENU_STATE *pMS)
{
/* TODO: Make this carried cleanly by MENU_STATE structure */
// static DWORD NextTime;
if (!(pMS->Initialized & 1))
{
/* This has some dependency on the IPtask_func */
ChangeSolarSys ();
// NextTime = GetTimeCounter ();
}
else
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
LockMutex (GraphicsLock);
if (*(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)
{
UnlockMutex (GraphicsLock);
IP_frame ();
return TRUE;
}
UnlockMutex (GraphicsLock);
if (pMS->CurState)
{
BOOLEAN DoMenu;
BYTE NewState;
/* If pMS->CurState == 0, then we're flying
* around in interplanetary. This needs to be
* corrected for the MenuChooser, which thinks
* that "0" is the first menu option */
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; // Selected LOAD from main menu
if (select)
{
if (NewState != SCAN + 1 && NewState != (GAME_MENU) + 1)
{
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
}
switch (NewState - 1)
{
case SCAN:
ScanSystem ();
break;
case EQUIP_DEVICE:
{
if (!Devices (pMS))
select = FALSE;
if (GET_GAME_STATE (PORTAL_COUNTER)) {
// A player-induced portal to QuasiSpace is
// opening.
return (FALSE);
}
break;
}
case CARGO:
{
Cargo (pMS);
break;
}
case ROSTER:
{
if (!Roster ())
select = FALSE;
break;
}
case GAME_MENU:
if (GameOptions () == 0)
return (FALSE);
break;
case STARMAP:
{
BOOLEAN AutoPilotSet;
LockMutex (GraphicsLock);
if (++pMS->Initialized > 3) {
pSolarSysState->PauseRotate = 1;
RepairSISBorder ();
}
AutoPilotSet = DoStarMap ();
SetDefaultMenuRepeatDelay ();
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE
|| (GLOBAL (CurrentActivity) & CHECK_ABORT))
{
UnlockMutex (GraphicsLock);
return (FALSE);
}
else if (pMS->Initialized <= 3)
{
ZoomSystem ();
--pMS->Initialized;
}
UnlockMutex (GraphicsLock);
if (!AutoPilotSet && pMS->Initialized >= 3)
{
LoadPlanet (NULL);
--pMS->Initialized;
pSolarSysState->PauseRotate = 0;
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
break;
}
}
case NAVIGATION:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
return (FALSE);
if (pMS->Initialized <= 1)
{
pMS->Initialized = 1;
}
else if (pMS->flash_task)
{ // In planet orbit
FreePlanet ();
LockMutex (GraphicsLock);
LoadSolarSys ();
ValidateOrbits ();
ZoomSystem ();
UnlockMutex (GraphicsLock);
}
LockMutex (GraphicsLock);
pMS->CurState = 0;
FlushInput ();
UnlockMutex (GraphicsLock);
break;
}
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
;
else if (pMS->CurState)
{
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
if (select)
{
if (optWhichMenu != OPT_PC)
pMS->CurState = (NAVIGATION) + 1;
DrawMenuStateStrings ((BYTE)(pMS->Initialized <= 1 ? PM_STARMAP : PM_SCAN),
pMS->CurState - 1);
}
}
else
{
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
}
}
}
}
return (!(GLOBAL (CurrentActivity)
& (START_ENCOUNTER | END_INTERPLANETARY
| CHECK_ABORT | CHECK_LOAD))
&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0);
}
+1 -1
View File
@@ -401,7 +401,7 @@ compShipPos (const void *ptr1, const void *ptr2)
}
BOOLEAN
Roster (void)
RosterMenu (void)
{
SIZE num_support_ships;
+10 -2
View File
@@ -667,8 +667,6 @@ PickPlanetSide (MENU_STATE *pMS)
// Set the current flash location
setPlanetCursorLoc (planetLoc);
savePlanetLocationImage ();
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
InitLander (0);
@@ -1001,6 +999,7 @@ DoScan (MENU_STATE *pMS)
UnlockMutex (GraphicsLock);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
SetContext (ScanContext);
BatchGraphics ();
DrawPlanet (0, 0, 0, BLACK_COLOR);
@@ -1010,6 +1009,8 @@ DoScan (MENU_STATE *pMS)
pMS->Initialized = FALSE;
pMS->CurFrame = 0;
// XXX: PickPlanetSide() will take over the InputFunc
// and later restore it when its done
return PickPlanetSide (pMS);
}
@@ -1241,6 +1242,9 @@ ScanSystem (void)
}
DrawMenuStateStrings (PM_MIN_SCAN, MenuState.CurState);
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
if (optWhichCoarseScan == OPT_PC)
PrintCoarseScanPC ();
@@ -1250,6 +1254,10 @@ ScanSystem (void)
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
DoInput (&MenuState, FALSE);
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
if (ScanContext)
{
LockMutex (GraphicsLock);
+2
View File
@@ -43,6 +43,8 @@ struct scan_block
SCAN_DESC *scan_base;
};
extern void ScanSystem (void);
extern void RepairBackRect (RECT *pRect);
extern void GeneratePlanetSide (void);
extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys,
+312 -250
View File
@@ -28,6 +28,8 @@
#include "../globdata.h"
#include "../sis.h"
#include "../init.h"
#include "../shipcont.h"
#include "../gameopt.h"
#include "../nameref.h"
#include "../resinst.h"
#include "../settings.h"
@@ -39,13 +41,18 @@
#include "../sounds.h"
#include "../state.h"
#include "../uqmdebug.h"
#include "options.h"
#include "libs/graphics/gfx_common.h"
#include "libs/mathlib.h"
#include "libs/log.h"
#include "libs/misc.h"
//#define DEBUG_SOLARSYS
static BOOLEAN DoIpFlight (MENU_STATE *pMS);
static void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem);
SOLARSYS_STATE *pSolarSysState;
FRAME SISIPFrame;
@@ -61,8 +68,11 @@ BYTE EncounterGroup;
// last encountered group info
#define DRAW_STARS (1 << 0)
// only ever cleared by DrawSimpleSystem() which is currently disabled
#define DRAW_PLANETS (1 << 1)
// only ever cleared by DrawSimpleSystem() which is currently disabled
#define DRAW_ORBITS (1 << 2)
// only ever cleared by DrawSimpleSystem() which is currently disabled
#define DRAW_HYPER_COORDS (1 << 3)
#define UNBATCH_SYS (1 << 4)
#define DRAW_REFRESH (1 << 5)
@@ -132,6 +142,16 @@ matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
return true;
}
// TODO: make code outside solarsys.c call a similar external version
static inline bool
inInnerSystem (void)
{
assert (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc
|| pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc);
return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc;
}
static void
GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
{
@@ -161,7 +181,7 @@ GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
BYTE data_index;
pMoonDesc->pPrevDesc = planet;
if (system->MenuState.Initialized > 1 || i >= planet->NumPlanets)
if (i >= planet->NumPlanets)
continue;
pMoonDesc->temp_color = planet->temp_color;
@@ -177,7 +197,6 @@ GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet)
}
}
system->pBaseDesc = system->MoonDesc;
TFB_SeedRandom (old_seed);
}
@@ -292,10 +311,11 @@ initSolarSysSISCharacteristics (void)
}
}
void
static BOOLEAN
LoadSolarSys (void)
{
COUNT i;
BOOLEAN orbital = FALSE;
PLANET_DESC *pCurDesc;
DWORD old_seed;
#define NUM_TEMP_RANGES 5
@@ -308,18 +328,6 @@ LoadSolarSys (void)
BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75),
};
pSolarSysState->MenuState.CurState = 0;
pSolarSysState->MenuState.Initialized = GLOBAL (in_orbit);
if (pSolarSysState->MenuState.Initialized)
{
GLOBAL (in_orbit) = 0;
++pSolarSysState->MenuState.Initialized;
}
else
{
// LoadIPData ();
}
old_seed = TFB_SeedRandom (MAKE_DWORD (CurStarDescPtr->star_pt.x,
CurStarDescPtr->star_pt.y));
@@ -347,9 +355,10 @@ LoadSolarSys (void)
{
pCurDesc->pPrevDesc = &pSolarSysState->SunDesc[0];
pCurDesc->image.origin = pCurDesc->location;
if (pSolarSysState->MenuState.Initialized != 0
|| i >= pSolarSysState->SunDesc[0].NumPlanets)
if (i >= pSolarSysState->SunDesc[0].NumPlanets)
{
pCurDesc->image.frame = 0;
}
else
{
COUNT index;
@@ -374,26 +383,26 @@ LoadSolarSys (void)
else
{
pSolarSysState->pOrbitalDesc = 0;
pSolarSysState->pBaseDesc = &pSolarSysState->PlanetDesc[i - 1];
pSolarSysState->SunDesc[0].location = GLOBAL (ip_location);
GenerateMoons (pSolarSysState, pSolarSysState->pBaseDesc);
GenerateMoons (pSolarSysState, &pSolarSysState->PlanetDesc[i - 1]);
pSolarSysState->pBaseDesc = pSolarSysState->MoonDesc;
SET_GAME_STATE (PLANETARY_LANDING, 0);
}
initSolarSysSISCharacteristics ();
i = pSolarSysState->MenuState.Initialized;
if (i)
{
i -= 2;
if (GLOBAL (in_orbit))
{ // Only when loading a game into orbital
orbital = TRUE;
i = GLOBAL (in_orbit) - 1;
if (i == 0)
pSolarSysState->pOrbitalDesc =
pSolarSysState->pBaseDesc->pPrevDesc;
else
pSolarSysState->pOrbitalDesc = &pSolarSysState->MoonDesc[i - 1];
pSolarSysState->MenuState.Initialized = 2;
GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location;
GLOBAL (in_orbit) = 0;
}
else
{
@@ -407,16 +416,14 @@ LoadSolarSys (void)
// Restore RNG state:
TFB_SeedRandom (old_seed);
return orbital;
}
static void
FreeSolarSys (void)
{
if (pSolarSysState->MenuState.flash_task)
{
if (pSolarSysState->MenuState.Initialized >= 3)
FreePlanet ();
else
{
if (pSolarSysState->MenuState.flash_task != (Task)(~0))
{
@@ -425,12 +432,12 @@ FreeSolarSys (void)
ConcludeTask (pSolarSysState->MenuState.flash_task);
}
pSolarSysState->MenuState.flash_task = 0;
LockMutex (GraphicsLock);
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
SaveFlagshipState ();
UnlockMutex (GraphicsLock);
}
}
LockMutex (GraphicsLock);
@@ -490,6 +497,8 @@ ShowPlanet:
if (!just_checking)
{
ZeroVelocityComponents (&GLOBAL (velocity));
// XXX: signal enter orbital
assert (pSolarSysState->MenuState.Initialized == 1);
++pSolarSysState->MenuState.Initialized;
pSolarSysState->pOrbitalDesc = pCurDesc;
}
@@ -510,7 +519,7 @@ ShowPlanet:
{
PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin;
PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin;
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
if (inInnerSystem ())
{
PlanetOffset = pCurDesc->pPrevDesc -
pSolarSysState->PlanetDesc;
@@ -543,7 +552,7 @@ ShowPlanet:
return;
else if (pSolarSysState->WaitIntersect == NewWaitPlanet)
continue;
else if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
else if (inInnerSystem ())
goto ShowPlanet;
else if (!just_checking) /* pBaseDesc == PlanetDesc */
{
@@ -566,11 +575,11 @@ ShowPlanet:
else if (GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
GLOBAL (ShipStamp.origin.y) =
(SIS_SCREEN_HEIGHT - 1) - 1;
pSolarSysState->pBaseDesc = pCurDesc;
XFormIPLoc (&pCurDesc->image.origin,
&pSolarSysState->SunDesc[0].location, FALSE);
ZeroVelocityComponents (&GLOBAL (velocity));
GenerateMoons (pSolarSysState, pCurDesc);
pSolarSysState->pBaseDesc = pSolarSysState->MoonDesc;
NewWaitPlanet = 0;
SetTransitionSource (NULL);
@@ -637,6 +646,7 @@ if (!(draw_sys_flags & (DRAW_ORBITS | DRAW_PLANETS)))
if (draw_sys_flags & DRAW_ORBITS)
{
// XXX: ValidateOrbits() sets pBaseDesc=0
if (pSolarSysState->pBaseDesc)
{
SetContextForeGroundColor (pPlanetDesc->temp_color);
@@ -724,7 +734,8 @@ FindRadius (void)
do
{
if ((pSolarSysState->SunDesc[0].radius >>= 1) > MIN_ZOOM_RADIUS)
pSolarSysState->SunDesc[0].radius >>= 1;
if (pSolarSysState->SunDesc[0].radius > MIN_ZOOM_RADIUS)
radius = pSolarSysState->SunDesc[0].radius >> 1;
else
radius = 0;
@@ -746,7 +757,7 @@ FindRadius (void)
&& delta_y < pSolarSysState->MenuState.flash_rect0.extent.height);
}
void
static void
ZoomSystem (void)
{
RECT r;
@@ -757,15 +768,10 @@ ZoomSystem (void)
SetTransitionSource (&r);
BatchGraphics ();
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
if (inInnerSystem ())
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
else
{
if (pSolarSysState->MenuState.CurState == 0)
FindRadius ();
DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE);
}
ScreenTransition (3, &r);
UnbatchGraphics ();
LoadIntoExtraScreen (&r);
@@ -904,7 +910,7 @@ UndrawShip (void)
|| GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
{
// The ship leaves the screen.
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
if (!inInnerSystem ())
{
if (radius == MAX_ZOOM_RADIUS)
{
@@ -934,7 +940,7 @@ UndrawShip (void)
pSolarSysState->MenuState.flash_rect0.corner.x;
delta_y = GLOBAL (ShipStamp.origin.y) -
pSolarSysState->MenuState.flash_rect0.corner.y;
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc
if (!inInnerSystem ()
&& (radius > MAX_ZOOM_RADIUS
|| (delta_x >= 0 && delta_y >= 0
&& delta_x < pSolarSysState->MenuState.flash_rect0.extent.width
@@ -985,6 +991,10 @@ static void
ScaleSystem (void)
{
#if 0
// XXX: This appears to have been an attempt to zoom the system view
// in a different way. This code would zoom gradually instead of
// doing crossfade from one zoom level to the other.
// Working state unknown.
#define NUM_STEPS 8
COUNT num_steps;
SIZE err, d, new_radius, step;
@@ -1064,83 +1074,47 @@ ScaleSystem (void)
#endif
}
/* Constants and routines for handling interplanetary play. TODO:
this is NOT THREAD-SAFE; only one IP task may be active at any
given time. --Michael */
static void
RestoreSystemView (void)
{
CONTEXT oldContext;
RECT r;
oldContext = SetContext (SpaceContext);
GetContextClipRect (&r);
DrawFromExtraScreen (&r);
SetContext (oldContext);
}
/* Constants and routines for handling interplanetary play. */
#define IP_FRAME_RATE (ONE_SECOND / 30)
static UWORD IP_input_state;
static DWORD IP_next_time;
void
IP_reset (void)
{
DrawAutoPilotMessage (TRUE);
if (LastActivity != CHECK_LOAD)
{
IP_input_state = 0;
}
else
{
IP_input_state = 2; /* CANCEL */
}
IP_next_time = GetTimeCounter ();
}
void
// Normally called by DoIpFlight() to process a frame
static void
IP_frame (void)
{
CONTEXT OldContext;
BOOLEAN InnerSystem;
BOOLEAN startedInInner;
RECT r;
BOOLEAN select, cancel;
InnerSystem = FALSE;
LockMutex (GraphicsLock);
if ((pSolarSysState->MenuState.Initialized > 1
|| (GLOBAL (CurrentActivity)
& (START_ENCOUNTER | END_INTERPLANETARY
| CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0))
{
UnlockMutex (GraphicsLock);
TaskSwitch ();
IP_input_state = 0;
IP_next_time = GetTimeCounter ();
return;
}
cancel = ((IP_input_state) >> 1) & 1;
select = (IP_input_state) & 1;
OldContext = SetContext (StatusContext);
if (pSolarSysState->MenuState.CurState
|| pSolarSysState->MenuState.Initialized == 0)
{
select = FALSE;
cancel = FALSE;
if (draw_sys_flags & DRAW_REFRESH)
goto TheMess;
}
else
{
TheMess:
// this is a mess:
// we have to treat things slightly differently depending on the
// situation (note that DRAW_REFRESH means we had gone to the
// menu)
InnerSystem = (BOOLEAN) (pSolarSysState->pBaseDesc !=
pSolarSysState->PlanetDesc);
if (InnerSystem)
// situation (note that DRAW_REFRESH means entered a new system
// not from a load)
startedInInner = inInnerSystem ();
if (startedInInner)
{
SetTransitionSource (NULL);
BatchGraphics ();
// XXX: this test is now invariant false
if (draw_sys_flags & DRAW_REFRESH)
{
InnerSystem = FALSE;
startedInInner = FALSE;
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
}
}
@@ -1157,11 +1131,6 @@ IP_frame (void)
ProcessShipControls ();
}
UndrawShip ();
if (pSolarSysState->MenuState.Initialized != 1)
{
select = FALSE;
cancel = FALSE;
}
}
if (old_radius)
@@ -1171,27 +1140,18 @@ IP_frame (void)
if (!(draw_sys_flags & DRAW_REFRESH))
// don't repair from Extra or draw ship if forcing repair
{
CONTEXT OldContext;
OldContext = SetContext (SpaceContext);
GetContextClipRect (&r);
DrawFromExtraScreen (&r);
SetContext (OldContext);
RestoreSystemView ();
// Don't redraw if entering/exiting inner system
// this screws up ScreenTransition by leaving an image of the
// ship in the ExtraScreen (which we use for repair)
if (pSolarSysState->MenuState.CurState == 0
&& (InnerSystem ^ (BOOLEAN)(
pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc)))
;
else
if (startedInInner == inInnerSystem ())
RedrawQueue (FALSE);
}
if (InnerSystem)
if (startedInInner)
{
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
if (!inInnerSystem ())
{
// transition screen if we left inner system (if going
// from outer to inner, ScreenTransition happens elsewhere)
@@ -1205,7 +1165,7 @@ IP_frame (void)
}
else if (draw_sys_flags & DRAW_REFRESH)
{
// must set rect for LoadInto... below
// must set rect for LoadIntoExtraScreen below
r.corner.x = SIS_ORG_X;
r.corner.y = SIS_ORG_Y;
r.extent.width = SIS_SCREEN_WIDTH;
@@ -1220,14 +1180,14 @@ IP_frame (void)
if (draw_sys_flags & UNBATCH_SYS)
{
// means we're forcing a redraw/transition from Init- & ChangeSolarSys
// InitSolarSys() prepared a transition for us
draw_sys_flags &= ~UNBATCH_SYS;
UnbatchGraphics ();
}
// LoadInto Extra if we left inner system, or we forced a redraw
if ((InnerSystem && pSolarSysState->pBaseDesc ==
pSolarSysState->PlanetDesc) || (draw_sys_flags & DRAW_REFRESH))
// Save the system image if we left inner system, or we forced a redraw
if ((startedInInner && !inInnerSystem ())
|| (draw_sys_flags & DRAW_REFRESH))
{
LoadIntoExtraScreen (&r);
draw_sys_flags &= ~DRAW_REFRESH;
@@ -1235,48 +1195,6 @@ IP_frame (void)
SetContext (OldContext);
UnlockMutex (GraphicsLock);
if (!cancel)
{
SleepThreadUntil (IP_next_time + IP_FRAME_RATE);
IP_next_time = GetTimeCounter ();
if (pSolarSysState->MenuState.CurState
|| pSolarSysState->MenuState.Initialized != 1)
{
cancel = FALSE;
select = FALSE;
}
else
{
/* Updating the input state is handled by
* DoFlagshipCommands, which is running in
* parallel with us */
// UpdateInputState ();
cancel = PulsedInputState.menu[KEY_MENU_CANCEL];
select = PulsedInputState.menu[KEY_MENU_SELECT];
IP_input_state = (cancel << 1) | select;
}
}
else
{
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
if (LastActivity == CHECK_LOAD)
{ // Selected LOAD from main menu
pSolarSysState->MenuState.CurState = (ROSTER + 1) + 1;
}
else
{
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, STARMAP);
LockMutex (GraphicsLock);
pSolarSysState->MenuState.CurState = STARMAP + 1;
IP_input_state = 0;
}
SetFlashRect (SFR_MENU_3DO);
FlushInput ();
UnlockMutex (GraphicsLock);
}
}
static void
@@ -1288,7 +1206,7 @@ DrawInnerSystem (void)
UnlockMutex (GraphicsLock);
}
BOOLEAN
static BOOLEAN
ValidateOrbits (void)
{
BYTE i;
@@ -1296,8 +1214,7 @@ ValidateOrbits (void)
POINT old_pts[2] = { { 0, 0 }, { 0, 0 } };
PLANET_DESC *pCurDesc;
InnerSystem = (BOOLEAN)(
pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc);
InnerSystem = inInnerSystem ();
if (InnerSystem)
{
old_pts[0] = GLOBAL (ShipStamp.origin);
@@ -1308,6 +1225,7 @@ ValidateOrbits (void)
pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1;
FindRadius ();
// XXX: DrawOrbit() checks pBaseDesc for 0
pSolarSysState->pBaseDesc = 0;
for (i = pSolarSysState->SunDesc[0].NumPlanets,
pCurDesc = &pSolarSysState->PlanetDesc[0]; i; --i, ++pCurDesc)
@@ -1329,15 +1247,14 @@ ValidateOrbits (void)
return (InnerSystem);
}
void
ChangeSolarSys (void)
static void
ResetSolarSys (void)
{
if (pSolarSysState->MenuState.Initialized == 0)
{
StartGroups:
++pSolarSysState->MenuState.Initialized;
if (pSolarSysState->MenuState.flash_task == 0)
{
// Originally there was a flash_task test here, however, I found no cases
// where flash_task could be set at the time of call. The test was
// probably needed on 3DO when IP_frame() was a task.
assert (!pSolarSysState->MenuState.flash_task);
DrawMenuStateStrings (PM_STARMAP, -(PM_NAVIGATE - PM_SCAN));
LockMutex (GraphicsLock);
@@ -1347,64 +1264,65 @@ StartGroups:
DoMissions ();
// if entering new system (NOT from load),
// force redraw and transition in IPtask_func
// force redraw and transition in IP_frame()
if ((draw_sys_flags & UNBATCH_SYS)
&& LastActivity != (CHECK_LOAD | CHECK_RESTART))
draw_sys_flags |= DRAW_REFRESH;
CheckIntersect (TRUE);
IP_reset ();
pSolarSysState->MenuState.flash_task = (Task)(~0);
/*
pSolarSysState->MenuState.flash_task =
AssignTask (IPtask_func, 6144,
"interplanetary task");
*/
UnlockMutex (GraphicsLock);
if (!PLRPlaying ((MUSIC_REF)~0) && LastActivity != CHECK_LOAD)
{
PlayMusic (SpaceMusic, TRUE, 1);
// XXX: This is begging to be moved somewhere more appropriate
// This fades in the solar system view when a New game starts
if (LastActivity == (CHECK_LOAD | CHECK_RESTART))
{
{ // Starting a new game, NOT from load!
BYTE clut_buf[] = {FadeAllToColor};
LastActivity = 0;
// XXX: this test is invariant true
if (draw_sys_flags & UNBATCH_SYS)
{
draw_sys_flags &= ~UNBATCH_SYS;
UnbatchGraphics ();
}
LockMutex (GraphicsLock);
while ((pSolarSysState->SunDesc[0].radius ==
(MAX_ZOOM_RADIUS << 1)) &&
!(GLOBAL(CurrentActivity) & CHECK_ABORT))
{
UnlockMutex (GraphicsLock);
IP_frame ();
LockMutex (GraphicsLock);
}
UnlockMutex (GraphicsLock);
XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 2);
}
}
}
SetGameClockRate (INTERPLANETARY_CLOCK_RATE);
}
}
else
{
static void
ReinitInnerSystem (void)
{
LockMutex (GraphicsLock);
SetTransitionSource (NULL);
LoadSolarSys ();
ValidateOrbits ();
DrawInnerSystem ();
ScreenTransition (3, NULL);
UnlockMutex (GraphicsLock);
}
static void
EnterPlanetOrbit (void)
{
if (pSolarSysState->MenuState.flash_task)
{
{ // This means we hit a planet in IP flight; not a Load into orbit
FreeSolarSys ();
if (pSolarSysState->pOrbitalDesc->pPrevDesc !=
&pSolarSysState->SunDesc[0])
{ // Moon -- use its origin
GLOBAL (ShipStamp.origin) =
pSolarSysState->pOrbitalDesc->image.origin;
}
else
{
{ // Planet -- its origin is for the outer view, so use mid-screen
GLOBAL (ShipStamp.origin.x) = SIS_SCREEN_WIDTH >> 1;
GLOBAL (ShipStamp.origin.y) = SIS_SCREEN_HEIGHT >> 1;
}
@@ -1419,27 +1337,23 @@ StartGroups:
|| GET_GAME_STATE (CHMMR_BOMB_STATE) == 2)
return;
if (pSolarSysState->MenuState.flash_task == 0)
{
/* Note! This implies that our generateOrbital function started
a conversation; that is, that this is a homeworld */
SetTransitionSource (NULL);
LoadSolarSys ();
ValidateOrbits ();
DrawInnerSystem ();
ScreenTransition (3, NULL);
if (pSolarSysState->MenuState.flash_task)
{ // We've entered orbit; LoadPlanet() set flash_task to rotate planet
PlanetOrbitMenu ();
FreePlanet ();
}
// Otherwise, generateOrbital function started a homeworld conversation,
// and we did not get to the planet no matter what.
goto StartGroups;
}
else
// START_ENCOUNTER could be set by Devices menu a number of ways:
// Talking Pet, Sun Device or a Caster over Chmmr, or
// a Caster for Ilwrath
// Could also have blown self up with Utwig Bomb
if (!(GLOBAL (CurrentActivity) & (START_ENCOUNTER |
CHECK_ABORT | CHECK_LOAD))
&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0)
{
DrawMenuStateStrings (PM_SCAN, SCAN);
LockMutex (GraphicsLock);
pSolarSysState->MenuState.CurState = SCAN + 1;
SetFlashRect (SFR_MENU_3DO);
FlushInput ();
UnlockMutex (GraphicsLock);
}
ReinitInnerSystem ();
}
}
@@ -1448,6 +1362,7 @@ InitSolarSys (void)
{
BOOLEAN InnerSystem;
BOOLEAN Reentry;
BOOLEAN orbital;
LockMutex (GraphicsLock);
@@ -1455,7 +1370,7 @@ InitSolarSys (void)
LoadLanderData ();
UnlockMutex (GraphicsLock);
pSolarSysState->MenuState.InputFunc = DoFlagshipCommands;
pSolarSysState->MenuState.InputFunc = DoIpFlight;
Reentry = (GLOBAL (ShipFacing) != 0);
if (!Reentry)
@@ -1471,7 +1386,7 @@ InitSolarSys (void)
XFormIPLoc (&GLOBAL (ShipStamp.origin), &GLOBAL (ip_location), FALSE);
}
LoadSolarSys ();
orbital = LoadSolarSys ();
InnerSystem = ValidateOrbits ();
if (Reentry)
@@ -1488,14 +1403,24 @@ InitSolarSys (void)
(*pSolarSysState->genFuncs->initNpcs) (pSolarSysState);
}
if (pSolarSysState->MenuState.Initialized == 0)
if (orbital)
{
// XXX: signal enter orbital
pSolarSysState->MenuState.Initialized = 2;
}
else
{
LockMutex (GraphicsLock);
// We draw the IP display here but do not flush it to the screen yet
// Whatever we have drawn will fade in in ResetSolarSys() or will
// get transitioned onto the screen in IP_frame()
SetTransitionSource (NULL);
BatchGraphics ();
draw_sys_flags |= UNBATCH_SYS;
// XXX: This whole "maybe loaded a game or maybe starting a new game"
// mess is begging to be cleaned up.
if (LastActivity & (CHECK_LOAD | CHECK_RESTART))
{
if ((LastActivity & (CHECK_LOAD | CHECK_RESTART)) ==
@@ -1513,8 +1438,6 @@ InitSolarSys (void)
}
}
// Enabled graphics synchronization again, as in 3DO code originally.
// This should fix the 'entering star' lockup/messed graphics problems.
DrawSISMessage (NULL);
SetContext (SpaceContext);
SetContextFGFrame (Screen);
@@ -1523,16 +1446,11 @@ InitSolarSys (void)
if (InnerSystem)
{
SetGraphicGrabOther (1); // since Unbatch won't have flipped yet
DrawInnerSystem ();
SetGraphicGrabOther (0);
if (draw_sys_flags & UNBATCH_SYS)
{
draw_sys_flags &= ~UNBATCH_SYS;
ScreenTransition (3, 0);
ScreenTransition (3, NULL);
UnbatchGraphics ();
LoadIntoExtraScreen (0);
}
LoadIntoExtraScreen (NULL);
}
else
{
@@ -1540,7 +1458,7 @@ InitSolarSys (void)
DrawHyperCoords (CurStarDescPtr->star_pt); /* Adjust position */
UnlockMutex (GraphicsLock);
/* force a redraw */
// force a redraw in UndrawShip()
pSolarSysState->SunDesc[0].radius = MAX_ZOOM_RADIUS << 1;
}
}
@@ -1562,7 +1480,8 @@ endInterPlanetary (void)
// Find the closest planet to a point, in interplanetary.
static PLANET_DESC *
closestPlanetInterPlanetary (const POINT *point) {
closestPlanetInterPlanetary (const POINT *point)
{
BYTE i;
BYTE numPlanets;
DWORD bestDistSquared;
@@ -1612,16 +1531,16 @@ UninitSolarSys (void)
if (GLOBAL (ip_planet) == 0)
{
pSolarSysState->pBaseDesc =
PLANET_DESC *planet =
closestPlanetInterPlanetary (&GLOBAL (ShipStamp.origin));
(*pSolarSysState->genFuncs->generateName) (
pSolarSysState, pSolarSysState->pBaseDesc);
pSolarSysState, planet);
}
}
}
void
static void
DrawSystem (SIZE radius, BOOLEAN IsInnerSystem)
{
BYTE i;
@@ -1704,7 +1623,7 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem)
}
}
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
if (!inInnerSystem ())
XFormIPLoc (&GLOBAL (ip_location),
&GLOBAL (ShipStamp.origin),
TRUE);
@@ -1841,20 +1760,16 @@ XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay)
{
pOut->x = (SIS_SCREEN_WIDTH >> 1)
+ (SIZE)((long)pIn->x * (DISPLAY_FACTOR >> 1)
// / (long)pSolarSysState->SunDesc[0].radius);
/ pSolarSysState->SunDesc[0].radius);
pOut->y = (SIS_SCREEN_HEIGHT >> 1)
+ (SIZE)((long)pIn->y * (DISPLAY_FACTOR >> 1)
// / (long)pSolarSysState->SunDesc[0].radius);
/ pSolarSysState->SunDesc[0].radius);
}
else
{
pOut->x = (SIZE)((long)(pIn->x - (SIS_SCREEN_WIDTH >> 1))
// * (long)pSolarSysState->SunDesc[0].radius
* pSolarSysState->SunDesc[0].radius / (DISPLAY_FACTOR >> 1));
pOut->y = (SIZE)((long)(pIn->y - (SIS_SCREEN_HEIGHT >> 1))
// * (long)pSolarSysState->SunDesc[0].radius
* pSolarSysState->SunDesc[0].radius / (DISPLAY_FACTOR >> 1));
}
}
@@ -1871,12 +1786,11 @@ ExploreSolarSys (void)
universe.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x));
universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
CurStarDescPtr = FindStar (0, &universe, 1, 1);
/*
// The following code used to be there, but the test is
// pointless. Maybe we should panic here?
if ((CurStarDescPtr = FindStar (0, &universe, 1, 1)) == 0)
;
*/
if (!CurStarDescPtr)
{
log_add (log_Fatal, "ExploreSolarSys(): do not know where you are!");
explode ();
}
}
GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (CurStarDescPtr->star_pt.x);
GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (CurStarDescPtr->star_pt.y);
@@ -1888,7 +1802,7 @@ ExploreSolarSys (void)
SolarSysState.genFuncs = getGenerateFunctions (CurStarDescPtr->Index);
InitSolarSys ();
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
DoInput (&SolarSysState.MenuState, FALSE);
UninitSolarSys ();
pSolarSysState = 0;
@@ -2004,3 +1918,151 @@ GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize)
}
}
static BOOLEAN
DoSolarSysMenu (MENU_STATE *pMS)
{
BOOLEAN select = PulsedInputState.menu[KEY_MENU_SELECT];
BOOLEAN handled;
if ((GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD))
|| GLOBAL_SIS (CrewEnlisted) == (COUNT)~0)
return FALSE;
// XXX: pMS actually refers to pSolarSysState->MenuState
handled = DoMenuChooser (pMS, PM_STARMAP);
if (handled)
return TRUE;
if (LastActivity == CHECK_LOAD)
select = TRUE; // Selected LOAD from main menu
if (!select)
return TRUE;
LockMutex (GraphicsLock);
SetFlashRect (NULL);
UnlockMutex (GraphicsLock);
switch (pMS->CurState)
{
case EQUIP_DEVICE:
select = DevicesMenu ();
if (GLOBAL (CurrentActivity) & START_ENCOUNTER)
{ // Invoked Talking Pet or a Caster for Ilwrath
// Going into conversation
return FALSE;
}
break;
case CARGO:
CargoMenu ();
break;
case ROSTER:
select = RosterMenu ();
break;
case GAME_MENU:
if (!GameOptions ())
return FALSE; // abort or load
break;
case STARMAP:
StarMap ();
SetDefaultMenuRepeatDelay ();
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
return FALSE;
LockMutex (GraphicsLock);
ZoomSystem ();
UnlockMutex (GraphicsLock);
// Fall through !!!
case NAVIGATION:
// TODO: what's this?
//DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
return FALSE;
}
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
{
if (select)
{ // 3DO menu jumps to NAVIGATE after a successful submenu run
if (optWhichMenu != OPT_PC)
pMS->CurState = NAVIGATION;
DrawMenuStateStrings (PM_STARMAP, pMS->CurState);
}
LockMutex (GraphicsLock);
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
}
return TRUE;
}
static void
SolarSysMenu (void)
{
void *oldInputFunc = pSolarSysState->MenuState.InputFunc;
LockMutex (GraphicsLock);
DrawStatusMessage (NULL);
if (LastActivity == CHECK_LOAD)
{ // Selected LOAD from main menu
pSolarSysState->MenuState.CurState = GAME_MENU;
}
else
{
UnlockMutex (GraphicsLock);
DrawMenuStateStrings (PM_STARMAP, STARMAP);
LockMutex (GraphicsLock);
pSolarSysState->MenuState.CurState = STARMAP;
}
SetFlashRect (SFR_MENU_3DO);
UnlockMutex (GraphicsLock);
SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
// XXX: temporary; will have an own MENU_STATE
pSolarSysState->MenuState.InputFunc = DoSolarSysMenu;
DoInput (&pSolarSysState->MenuState, TRUE);
pSolarSysState->MenuState.InputFunc = oldInputFunc;
}
static BOOLEAN
DoIpFlight (MENU_STATE *pMS)
{
static TimeCount NextTime;
BOOLEAN cancel = PulsedInputState.menu[KEY_MENU_CANCEL];
if (!pMS->Initialized)
{
// This has some dependency on the IP_frame()
ResetSolarSys ();
// XXX: pMS refers to pSolarSysState->MenuState
pMS->Initialized = 1;
// XXX: InitSolarSys() leaves gfx batched so that IP_frame
// does a screen transition. It's currently easier to just
// call IP_frame() for loading a game from main menu.
IP_frame ();
}
else if (pMS->Initialized == 2)
{ // CheckIntersect() or InitSolarSys() sent us to orbital
EnterPlanetOrbit ();
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
// Force a reset after orbital
// XXX: pMS refers to pSolarSysState->MenuState
pMS->Initialized = FALSE;
}
else if (cancel || LastActivity == CHECK_LOAD)
{
SolarSysMenu ();
SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE);
}
else
{
IP_frame ();
SleepThreadUntil (NextTime);
NextTime = GetTimeCounter () + IP_FRAME_RATE;
}
return (!(GLOBAL (CurrentActivity)
& (START_ENCOUNTER | END_INTERPLANETARY
| CHECK_ABORT | CHECK_LOAD))
&& GLOBAL_SIS (CrewEnlisted) != (COUNT)~0);
}
+4 -3
View File
@@ -23,9 +23,10 @@
#define FIELD_WIDTH (STATUS_WIDTH - 5)
extern void Cargo (MENU_STATE *pMS);
extern BOOLEAN Roster (void);
extern BOOLEAN Devices (MENU_STATE *pMS);
extern void CargoMenu (void);
extern BOOLEAN RosterMenu (void);
extern BOOLEAN DevicesMenu (void);
extern BOOLEAN StarMap (void);
extern void DrawCargoStrings (BYTE OldElement, BYTE NewElement);
extern void ShowRemainingCapacity (void);
+2 -1
View File
@@ -1258,7 +1258,8 @@ ExitShipyard:
}
else
{
if (GameOptions () == 0)
// Clearing FlashRect is not necessary
if (!GameOptions ())
goto ExitShipyard;
DrawMenuStateStrings (PM_CREW, pMS->CurState);
LockMutex (GraphicsLock);
+3
View File
@@ -253,6 +253,9 @@ while (--ac > 0)
else if (GLOBAL (CurrentActivity) & START_INTERPLANETARY)
{
GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0);
DrawAutoPilotMessage (TRUE);
SetGameClockRate (INTERPLANETARY_CLOCK_RATE);
ExploreSolarSys ();
}
else
-3
View File
@@ -584,7 +584,6 @@ forAllMoons (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
COUNT i;
assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
for (i = 0; i < planet->NumPlanets; i++)
callback (star, system, planet, &system->MoonDesc[i], arg);
@@ -675,7 +674,6 @@ planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
assert(CurStarDescPtr == star);
assert(pSolarSysState == system);
system->pBaseDesc = planet;
planet->pPrevDesc = &system->SunDesc[0];
if (universeRecurseArg->planetFuncPre != NULL)
@@ -723,7 +721,6 @@ moonRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
assert(CurStarDescPtr == star);
assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
moon->pPrevDesc = planet;