Cleanup of some of the pSolarSysState references
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3379 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+26
-1
@@ -448,7 +448,7 @@ unhyper_transition (ELEMENT *ElementPtr)
|
|||||||
switch ((TRANSITION_TYPE) ElementPtr->turn_wait)
|
switch ((TRANSITION_TYPE) ElementPtr->turn_wait)
|
||||||
{
|
{
|
||||||
case RANDOM_ENCOUNTER_TRANSITION:
|
case RANDOM_ENCOUNTER_TRANSITION:
|
||||||
SaveFlagshipState ();
|
SaveSisHyperState ();
|
||||||
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
|
||||||
break;
|
break;
|
||||||
case INTERPLANETARY_TRANSITION:
|
case INTERPLANETARY_TRANSITION:
|
||||||
@@ -880,6 +880,15 @@ getSisElement (void)
|
|||||||
hShip = StarShipPtr->hShip;
|
hShip = StarShipPtr->hShip;
|
||||||
UnlockStarShip (&race_q[RPG_PLAYER_NUM], hSis);
|
UnlockStarShip (&race_q[RPG_PLAYER_NUM], hSis);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
ELEMENT *ElementPtr;
|
||||||
|
LockElement (hShip, &ElementPtr);
|
||||||
|
assert (ElementPtr->state_flags & PLAYER_SHIP);
|
||||||
|
UnlockElement (hShip);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return hShip;
|
return hShip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1716,3 +1725,19 @@ UnbatchGraphics ();
|
|||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaveSisHyperState (void)
|
||||||
|
{
|
||||||
|
HELEMENT hSisElement;
|
||||||
|
ELEMENT *ElementPtr;
|
||||||
|
STARSHIP *StarShipPtr;
|
||||||
|
|
||||||
|
// Update 'GLOBAL (ShipFacing)' to the direction the flagship is facing
|
||||||
|
hSisElement = getSisElement ();
|
||||||
|
//if (ElementPtr->state_flags & PLAYER_SHIP)
|
||||||
|
LockElement (hSisElement, &ElementPtr);
|
||||||
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
|
// XXX: Solar system reentry test depends on ShipFacing != 0
|
||||||
|
GLOBAL (ShipFacing) = StarShipPtr->ShipFacing + 1;
|
||||||
|
UnlockElement (hSisElement);
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ extern void check_hyperspace_encounter (void);
|
|||||||
extern BOOLEAN hyper_transition (ELEMENT *ElementPtr);
|
extern BOOLEAN hyper_transition (ELEMENT *ElementPtr);
|
||||||
|
|
||||||
extern void HyperspaceMenu (void);
|
extern void HyperspaceMenu (void);
|
||||||
|
extern void SaveSisHyperState (void);
|
||||||
|
|
||||||
#endif /* _HYPER_H */
|
#endif /* _HYPER_H */
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ ip_group_preprocess (ELEMENT *ElementPtr)
|
|||||||
|
|
||||||
InitIntersectStartPoint (EPtr);
|
InitIntersectStartPoint (EPtr);
|
||||||
|
|
||||||
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
|
if (!playerInInnerSystem ())
|
||||||
flagship_loc = 0;
|
flagship_loc = 0;
|
||||||
else
|
else
|
||||||
flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc
|
flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc
|
||||||
@@ -676,7 +676,7 @@ flag_ship_preprocess (ELEMENT *ElementPtr)
|
|||||||
|
|
||||||
GetCurrentVelocityComponents (&GLOBAL (velocity), &vdx, &vdy);
|
GetCurrentVelocityComponents (&GLOBAL (velocity), &vdx, &vdy);
|
||||||
|
|
||||||
if (pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc)
|
if (playerInInnerSystem ())
|
||||||
{
|
{
|
||||||
flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc
|
flagship_loc = (BYTE)(pSolarSysState->pBaseDesc->pPrevDesc
|
||||||
- pSolarSysState->PlanetDesc + 2);
|
- pSolarSysState->PlanetDesc + 2);
|
||||||
@@ -767,7 +767,7 @@ spawn_flag_ship (void)
|
|||||||
|
|
||||||
LockElement (hFlagShipElement, &FlagShipElementPtr);
|
LockElement (hFlagShipElement, &FlagShipElementPtr);
|
||||||
FlagShipElementPtr->hit_points = 1;
|
FlagShipElementPtr->hit_points = 1;
|
||||||
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
|
if (!playerInInnerSystem ())
|
||||||
FlagShipElementPtr->sys_loc = 1;
|
FlagShipElementPtr->sys_loc = 1;
|
||||||
else
|
else
|
||||||
FlagShipElementPtr->sys_loc =
|
FlagShipElementPtr->sys_loc =
|
||||||
|
|||||||
@@ -26,10 +26,14 @@
|
|||||||
#include "../setup.h"
|
#include "../setup.h"
|
||||||
#include "../state.h"
|
#include "../state.h"
|
||||||
#include "../sis.h"
|
#include "../sis.h"
|
||||||
// for ClearSISRect(), SaveFlagshipState()
|
// for ClearSISRect()
|
||||||
#include "../grpinfo.h"
|
#include "../grpinfo.h"
|
||||||
#include "../sounds.h"
|
#include "../sounds.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
#include "../hyper.h"
|
||||||
|
// for SaveSisHyperState()
|
||||||
|
#include "planets.h"
|
||||||
|
// for SaveSolarSysLocation() and tests
|
||||||
#include "libs/strlib.h"
|
#include "libs/strlib.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -206,11 +210,11 @@ UseCaster (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_INTERPLANETARY
|
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_INTERPLANETARY
|
||||||
|| pSolarSysState == NULL)
|
|| !playerInSolarSystem ())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1]
|
if (pSolarSysState->pOrbitalDesc == &pSolarSysState->PlanetDesc[1]
|
||||||
&& pSolarSysState->MenuState.Initialized == 3
|
&& playerInPlanetOrbit ()
|
||||||
&& CurStarDescPtr->Index == CHMMR_DEFINED
|
&& CurStarDescPtr->Index == CHMMR_DEFINED
|
||||||
&& !GET_GAME_STATE (CHMMR_UNLEASHED))
|
&& !GET_GAME_STATE (CHMMR_UNLEASHED))
|
||||||
{
|
{
|
||||||
@@ -224,7 +228,7 @@ UseCaster (void)
|
|||||||
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
|
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
|
||||||
|
|
||||||
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
|
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7);
|
||||||
SaveFlagshipState ();
|
SaveSolarSysLocation ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,8 +271,8 @@ UseCaster (void)
|
|||||||
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 5);
|
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSolarSysState->MenuState.Initialized >= 3)
|
if (playerInPlanetOrbit ())
|
||||||
SaveFlagshipState ();
|
SaveSolarSysLocation ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,9 +304,7 @@ DeviceFailed (BYTE which_device)
|
|||||||
break;
|
break;
|
||||||
case SUN_EFFICIENCY_DEVICE:
|
case SUN_EFFICIENCY_DEVICE:
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
|
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
|
||||||
&& pSolarSysState
|
&& playerInPlanetOrbit ())
|
||||||
&& pSolarSysState->pOrbitalDesc
|
|
||||||
&& pSolarSysState->MenuState.Initialized == 3)
|
|
||||||
{
|
{
|
||||||
BYTE fade_buf[1];
|
BYTE fade_buf[1];
|
||||||
|
|
||||||
@@ -361,6 +363,8 @@ DeviceFailed (BYTE which_device)
|
|||||||
SET_GAME_STATE (SHIP_TO_COMPEL, 1);
|
SET_GAME_STATE (SHIP_TO_COMPEL, 1);
|
||||||
}
|
}
|
||||||
GLOBAL (CurrentActivity) &= ~IN_BATTLE;
|
GLOBAL (CurrentActivity) &= ~IN_BATTLE;
|
||||||
|
|
||||||
|
SaveSisHyperState ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -378,10 +382,9 @@ DeviceFailed (BYTE which_device)
|
|||||||
{
|
{
|
||||||
SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1);
|
SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1);
|
||||||
}
|
}
|
||||||
if (pSolarSysState->MenuState.Initialized < 3)
|
if (playerInPlanetOrbit ())
|
||||||
return (FALSE);
|
SaveSolarSysLocation ();
|
||||||
}
|
}
|
||||||
SaveFlagshipState ();
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
case AQUA_HELIX_DEVICE:
|
case AQUA_HELIX_DEVICE:
|
||||||
val = GET_GAME_STATE (ULTRON_CONDITION);
|
val = GET_GAME_STATE (ULTRON_CONDITION);
|
||||||
|
|||||||
@@ -219,6 +219,9 @@ struct solarsys_state
|
|||||||
extern SOLARSYS_STATE *pSolarSysState;
|
extern SOLARSYS_STATE *pSolarSysState;
|
||||||
extern MUSIC_REF SpaceMusic;
|
extern MUSIC_REF SpaceMusic;
|
||||||
|
|
||||||
|
bool playerInSolarSystem (void);
|
||||||
|
bool playerInPlanetOrbit (void);
|
||||||
|
bool playerInInnerSystem (void);
|
||||||
bool worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
bool worldIsPlanet (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
||||||
bool worldIsMoon (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
bool worldIsMoon (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
||||||
COUNT planetIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
COUNT planetIndex (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world);
|
||||||
@@ -255,6 +258,7 @@ extern UNICODE* GetNamedPlanetaryBody (void);
|
|||||||
extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize);
|
extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize);
|
||||||
|
|
||||||
extern void PlanetOrbitMenu (void);
|
extern void PlanetOrbitMenu (void);
|
||||||
|
extern void SaveSolarSysLocation (void);
|
||||||
|
|
||||||
#endif /* _PLANETS_H */
|
#endif /* _PLANETS_H */
|
||||||
|
|
||||||
|
|||||||
@@ -736,7 +736,7 @@ PickPlanetSide (MENU_STATE *pMS)
|
|||||||
UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip);
|
UnlockShipFrag (&GLOBAL (npc_built_ship_q), hStarShip);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveFlagshipState ();
|
SaveSolarSysLocation ();
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,10 +142,24 @@ matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make code outside solarsys.c call a similar external version
|
bool
|
||||||
static inline bool
|
playerInSolarSystem (void)
|
||||||
inInnerSystem (void)
|
|
||||||
{
|
{
|
||||||
|
return pSolarSysState != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
playerInPlanetOrbit (void)
|
||||||
|
{
|
||||||
|
return playerInSolarSystem () &&
|
||||||
|
pSolarSysState->MenuState.Initialized >= 3;
|
||||||
|
// XXX: This test will change eventually
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
playerInInnerSystem (void)
|
||||||
|
{
|
||||||
|
assert (playerInSolarSystem ());
|
||||||
assert (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc
|
assert (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc
|
||||||
|| pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc);
|
|| pSolarSysState->pBaseDesc == pSolarSysState->MoonDesc);
|
||||||
return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc;
|
return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc;
|
||||||
@@ -433,10 +447,8 @@ FreeSolarSys (void)
|
|||||||
}
|
}
|
||||||
pSolarSysState->MenuState.flash_task = 0;
|
pSolarSysState->MenuState.flash_task = 0;
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
|
||||||
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
|
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
|
||||||
SaveFlagshipState ();
|
SaveSolarSysLocation ();
|
||||||
UnlockMutex (GraphicsLock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
@@ -519,7 +531,7 @@ ShowPlanet:
|
|||||||
{
|
{
|
||||||
PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin;
|
PlanetIntersect.IntersectStamp.origin = pCurDesc->image.origin;
|
||||||
PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin;
|
PlanetIntersect.EndPoint = PlanetIntersect.IntersectStamp.origin;
|
||||||
if (inInnerSystem ())
|
if (playerInInnerSystem ())
|
||||||
{
|
{
|
||||||
PlanetOffset = pCurDesc->pPrevDesc -
|
PlanetOffset = pCurDesc->pPrevDesc -
|
||||||
pSolarSysState->PlanetDesc;
|
pSolarSysState->PlanetDesc;
|
||||||
@@ -552,7 +564,7 @@ ShowPlanet:
|
|||||||
return;
|
return;
|
||||||
else if (pSolarSysState->WaitIntersect == NewWaitPlanet)
|
else if (pSolarSysState->WaitIntersect == NewWaitPlanet)
|
||||||
continue;
|
continue;
|
||||||
else if (inInnerSystem ())
|
else if (playerInInnerSystem ())
|
||||||
goto ShowPlanet;
|
goto ShowPlanet;
|
||||||
else if (!just_checking) /* pBaseDesc == PlanetDesc */
|
else if (!just_checking) /* pBaseDesc == PlanetDesc */
|
||||||
{
|
{
|
||||||
@@ -768,7 +780,7 @@ ZoomSystem (void)
|
|||||||
|
|
||||||
SetTransitionSource (&r);
|
SetTransitionSource (&r);
|
||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
if (inInnerSystem ())
|
if (playerInInnerSystem ())
|
||||||
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
|
DrawSystem (pSolarSysState->pBaseDesc->pPrevDesc->radius, TRUE);
|
||||||
else
|
else
|
||||||
DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE);
|
DrawSystem (pSolarSysState->SunDesc[0].radius, FALSE);
|
||||||
@@ -910,7 +922,7 @@ UndrawShip (void)
|
|||||||
|| GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
|
|| GLOBAL (ShipStamp.origin.y) >= SIS_SCREEN_HEIGHT)
|
||||||
{
|
{
|
||||||
// The ship leaves the screen.
|
// The ship leaves the screen.
|
||||||
if (!inInnerSystem ())
|
if (!playerInInnerSystem ())
|
||||||
{
|
{
|
||||||
if (radius == MAX_ZOOM_RADIUS)
|
if (radius == MAX_ZOOM_RADIUS)
|
||||||
{
|
{
|
||||||
@@ -940,7 +952,7 @@ UndrawShip (void)
|
|||||||
pSolarSysState->MenuState.flash_rect0.corner.x;
|
pSolarSysState->MenuState.flash_rect0.corner.x;
|
||||||
delta_y = GLOBAL (ShipStamp.origin.y) -
|
delta_y = GLOBAL (ShipStamp.origin.y) -
|
||||||
pSolarSysState->MenuState.flash_rect0.corner.y;
|
pSolarSysState->MenuState.flash_rect0.corner.y;
|
||||||
if (!inInnerSystem ()
|
if (!playerInInnerSystem ()
|
||||||
&& (radius > MAX_ZOOM_RADIUS
|
&& (radius > MAX_ZOOM_RADIUS
|
||||||
|| (delta_x >= 0 && delta_y >= 0
|
|| (delta_x >= 0 && delta_y >= 0
|
||||||
&& delta_x < pSolarSysState->MenuState.flash_rect0.extent.width
|
&& delta_x < pSolarSysState->MenuState.flash_rect0.extent.width
|
||||||
@@ -1106,7 +1118,7 @@ IP_frame (void)
|
|||||||
// we have to treat things slightly differently depending on the
|
// we have to treat things slightly differently depending on the
|
||||||
// situation (note that DRAW_REFRESH means entered a new system
|
// situation (note that DRAW_REFRESH means entered a new system
|
||||||
// not from a load)
|
// not from a load)
|
||||||
startedInInner = inInnerSystem ();
|
startedInInner = playerInInnerSystem ();
|
||||||
if (startedInInner)
|
if (startedInInner)
|
||||||
{
|
{
|
||||||
SetTransitionSource (NULL);
|
SetTransitionSource (NULL);
|
||||||
@@ -1145,13 +1157,13 @@ IP_frame (void)
|
|||||||
// Don't redraw if entering/exiting inner system
|
// Don't redraw if entering/exiting inner system
|
||||||
// this screws up ScreenTransition by leaving an image of the
|
// this screws up ScreenTransition by leaving an image of the
|
||||||
// ship in the ExtraScreen (which we use for repair)
|
// ship in the ExtraScreen (which we use for repair)
|
||||||
if (startedInInner == inInnerSystem ())
|
if (startedInInner == playerInInnerSystem ())
|
||||||
RedrawQueue (FALSE);
|
RedrawQueue (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startedInInner)
|
if (startedInInner)
|
||||||
{
|
{
|
||||||
if (!inInnerSystem ())
|
if (!playerInInnerSystem ())
|
||||||
{
|
{
|
||||||
// transition screen if we left inner system (if going
|
// transition screen if we left inner system (if going
|
||||||
// from outer to inner, ScreenTransition happens elsewhere)
|
// from outer to inner, ScreenTransition happens elsewhere)
|
||||||
@@ -1186,7 +1198,7 @@ IP_frame (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the system image if we left inner system, or we forced a redraw
|
// Save the system image if we left inner system, or we forced a redraw
|
||||||
if ((startedInInner && !inInnerSystem ())
|
if ((startedInInner && !playerInInnerSystem ())
|
||||||
|| (draw_sys_flags & DRAW_REFRESH))
|
|| (draw_sys_flags & DRAW_REFRESH))
|
||||||
{
|
{
|
||||||
LoadIntoExtraScreen (&r);
|
LoadIntoExtraScreen (&r);
|
||||||
@@ -1214,7 +1226,7 @@ ValidateOrbits (void)
|
|||||||
POINT old_pts[2] = { { 0, 0 }, { 0, 0 } };
|
POINT old_pts[2] = { { 0, 0 }, { 0, 0 } };
|
||||||
PLANET_DESC *pCurDesc;
|
PLANET_DESC *pCurDesc;
|
||||||
|
|
||||||
InnerSystem = inInnerSystem ();
|
InnerSystem = playerInInnerSystem ();
|
||||||
if (InnerSystem)
|
if (InnerSystem)
|
||||||
{
|
{
|
||||||
old_pts[0] = GLOBAL (ShipStamp.origin);
|
old_pts[0] = GLOBAL (ShipStamp.origin);
|
||||||
@@ -1623,7 +1635,7 @@ DrawSystem (SIZE radius, BOOLEAN IsInnerSystem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inInnerSystem ())
|
if (!playerInInnerSystem ())
|
||||||
XFormIPLoc (&GLOBAL (ip_location),
|
XFormIPLoc (&GLOBAL (ip_location),
|
||||||
&GLOBAL (ShipStamp.origin),
|
&GLOBAL (ShipStamp.origin),
|
||||||
TRUE);
|
TRUE);
|
||||||
@@ -1918,6 +1930,51 @@ GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaveSolarSysLocation (void)
|
||||||
|
{
|
||||||
|
assert (playerInSolarSystem ());
|
||||||
|
|
||||||
|
if (!playerInPlanetOrbit ())
|
||||||
|
{
|
||||||
|
// XXX: Solar system reentry test depends on ShipFacing != 0
|
||||||
|
GLOBAL (ShipFacing) = GetFrameIndex (GLOBAL (ShipStamp.frame)) + 1;
|
||||||
|
GLOBAL (in_orbit) = 0;
|
||||||
|
if (!playerInInnerSystem ())
|
||||||
|
{
|
||||||
|
GLOBAL (ip_planet) = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// XXX: Is that even correct? pBaseDesc should point to PlanetDesc
|
||||||
|
GLOBAL (ip_planet) = pSolarSysState->pBaseDesc->pPrevDesc
|
||||||
|
- pSolarSysState->PlanetDesc + 1;
|
||||||
|
GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // In orbit around a planet.
|
||||||
|
BYTE moon;
|
||||||
|
|
||||||
|
// Update the starinfo.dat file if necessary.
|
||||||
|
if (GET_GAME_STATE (PLANETARY_CHANGE))
|
||||||
|
{
|
||||||
|
PutPlanetInfo ();
|
||||||
|
SET_GAME_STATE (PLANETARY_CHANGE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GLOBAL (ip_planet) is already set
|
||||||
|
moon = 1; /* the planet itself */
|
||||||
|
// XXX: This test is convoluted, and we should come up with a
|
||||||
|
// better linking system
|
||||||
|
if (pSolarSysState->pOrbitalDesc !=
|
||||||
|
pSolarSysState->pBaseDesc->pPrevDesc)
|
||||||
|
moon += pSolarSysState->pOrbitalDesc
|
||||||
|
- pSolarSysState->pBaseDesc + 1;
|
||||||
|
GLOBAL (in_orbit) = moon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
DoSolarSysMenu (MENU_STATE *pMS)
|
DoSolarSysMenu (MENU_STATE *pMS)
|
||||||
{
|
{
|
||||||
|
|||||||
+20
-2
@@ -21,7 +21,6 @@
|
|||||||
#include "save.h"
|
#include "save.h"
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "libs/declib.h"
|
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
#include "encount.h"
|
#include "encount.h"
|
||||||
#include "libs/file.h"
|
#include "libs/file.h"
|
||||||
@@ -34,9 +33,14 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "grpinfo.h"
|
#include "grpinfo.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "hyper.h"
|
||||||
|
// for SaveSisHyperState()
|
||||||
|
#include "planets/planets.h"
|
||||||
|
// for SaveSolarSysLocation() and tests
|
||||||
#include "libs/inplib.h"
|
#include "libs/inplib.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
#include "libs/memlib.h"
|
#include "libs/memlib.h"
|
||||||
|
#include "libs/declib.h"
|
||||||
|
|
||||||
|
|
||||||
// XXX: these should handle endian conversions later
|
// XXX: these should handle endian conversions later
|
||||||
@@ -481,7 +485,7 @@ PrepareSummary (SUMMARY_DESC *SummPtr)
|
|||||||
sizeof (SummPtr->SS.PlanetName));
|
sizeof (SummPtr->SS.PlanetName));
|
||||||
if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0)
|
if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0)
|
||||||
SummPtr->Activity = IN_STARBASE;
|
SummPtr->Activity = IN_STARBASE;
|
||||||
else if (pSolarSysState && pSolarSysState->MenuState.Initialized >= 3)
|
else if (playerInPlanetOrbit ())
|
||||||
SummPtr->Activity = IN_PLANET_ORBIT;
|
SummPtr->Activity = IN_PLANET_ORBIT;
|
||||||
break;
|
break;
|
||||||
case IN_LAST_BATTLE:
|
case IN_LAST_BATTLE:
|
||||||
@@ -617,6 +621,20 @@ SaveProblem (void)
|
|||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
SaveFlagshipState (void)
|
||||||
|
{
|
||||||
|
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
|
||||||
|
{
|
||||||
|
// Player is in HyperSpace or QuasiSpace.
|
||||||
|
SaveSisHyperState ();
|
||||||
|
}
|
||||||
|
else if (playerInSolarSystem ())
|
||||||
|
{
|
||||||
|
SaveSolarSysLocation ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This function first writes to a memory file, and then writes the whole
|
// This function first writes to a memory file, and then writes the whole
|
||||||
// lot to the actual save file at once.
|
// lot to the actual save file at once.
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
|||||||
@@ -1809,76 +1809,3 @@ SetFlashRect (RECT *pRect)
|
|||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SaveFlagshipState (void)
|
|
||||||
{
|
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
|
|
||||||
{
|
|
||||||
// Player is in HyperSpace or QuasiSpace.
|
|
||||||
// Update 'GLOBAL (ShipFacing)' to the direction the flagship
|
|
||||||
// is facing.
|
|
||||||
|
|
||||||
HELEMENT hElement, hNextElement;
|
|
||||||
|
|
||||||
// Find the flagship element.
|
|
||||||
for (hElement = GetHeadElement ();
|
|
||||||
hElement != 0; hElement = hNextElement)
|
|
||||||
{
|
|
||||||
ELEMENT *ElementPtr;
|
|
||||||
|
|
||||||
LockElement (hElement, &ElementPtr);
|
|
||||||
hNextElement = GetSuccElement (ElementPtr);
|
|
||||||
if (ElementPtr->state_flags & PLAYER_SHIP)
|
|
||||||
{
|
|
||||||
STARSHIP *StarShipPtr;
|
|
||||||
|
|
||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
|
||||||
// XXX: Solar system reentry test depends on ShipFacing != 0
|
|
||||||
GLOBAL (ShipFacing) = StarShipPtr->ShipFacing + 1;
|
|
||||||
hNextElement = 0;
|
|
||||||
}
|
|
||||||
UnlockElement (hElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pSolarSysState)
|
|
||||||
{
|
|
||||||
// Player is in a solar system.
|
|
||||||
if (pSolarSysState->MenuState.Initialized < 3)
|
|
||||||
{
|
|
||||||
// XXX: Solar system reentry test depends on ShipFacing != 0
|
|
||||||
GLOBAL (ShipFacing) = GetFrameIndex (GLOBAL (ShipStamp.frame)) + 1;
|
|
||||||
GLOBAL (in_orbit) = 0;
|
|
||||||
if (pSolarSysState->pBaseDesc == pSolarSysState->PlanetDesc)
|
|
||||||
{
|
|
||||||
GLOBAL (ip_planet) = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GLOBAL (ip_planet) = pSolarSysState->pBaseDesc->pPrevDesc
|
|
||||||
- pSolarSysState->PlanetDesc + 1;
|
|
||||||
GLOBAL (ip_location) = pSolarSysState->SunDesc[0].location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// In orbit around a planet.
|
|
||||||
BYTE moon;
|
|
||||||
|
|
||||||
// Update the starinfo.dat file if necessary.
|
|
||||||
if (GET_GAME_STATE (PLANETARY_CHANGE))
|
|
||||||
{
|
|
||||||
PutPlanetInfo ();
|
|
||||||
SET_GAME_STATE (PLANETARY_CHANGE, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GLOBAL (ip_planet) is already set
|
|
||||||
moon = 1; /* the planet itself */
|
|
||||||
if (pSolarSysState->pOrbitalDesc !=
|
|
||||||
pSolarSysState->pBaseDesc->pPrevDesc)
|
|
||||||
moon += pSolarSysState->pOrbitalDesc
|
|
||||||
- pSolarSysState->pBaseDesc + 1;
|
|
||||||
GLOBAL (in_orbit) = moon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ extern void DrawLanders (void);
|
|||||||
extern void DrawStorageBays (BOOLEAN Refresh);
|
extern void DrawStorageBays (BOOLEAN Refresh);
|
||||||
extern void GetGaugeRect (RECT *pRect, BOOLEAN IsCrewRect);
|
extern void GetGaugeRect (RECT *pRect, BOOLEAN IsCrewRect);
|
||||||
extern void DrawFlagshipStats (void);
|
extern void DrawFlagshipStats (void);
|
||||||
extern void SaveFlagshipState (void);
|
|
||||||
void DrawAutoPilotMessage (BOOLEAN Reset);
|
void DrawAutoPilotMessage (BOOLEAN Reset);
|
||||||
|
|
||||||
extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int
|
extern void DeltaSISGauges (SIZE crew_delta, SIZE fuel_delta, int
|
||||||
|
|||||||
Reference in New Issue
Block a user