Cleanup: removal of pLanderInputState global

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3341 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-11-22 17:47:12 +00:00
parent 68579000ce
commit c99241ca22
9 changed files with 41 additions and 59 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
if (!GET_GAME_STATE (ROSY_SPHERE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (ROSY_SPHERE, 1);
SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1);
+1 -1
View File
@@ -152,7 +152,7 @@ GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
if (!GET_GAME_STATE (CLEAR_SPINDLE))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (CLEAR_SPINDLE, 1);
SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1);
+1 -1
View File
@@ -527,7 +527,7 @@ GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1);
solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]
&= ~(1L << 0);
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
}
else if (*whichNode == (COUNT)~0)
*whichNode = 1;
+1 -1
View File
@@ -155,7 +155,7 @@ GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
if (!GET_GAME_STATE (ULTRON_CONDITION))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (ULTRON_CONDITION, 1);
}
+1 -1
View File
@@ -104,7 +104,7 @@ GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
&= ~(1L << 0);
if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (SHIP_VAULT_UNLOCKED, 1);
SET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP, 0);
+1 -1
View File
@@ -348,7 +348,7 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
UnbatchGraphics ();
DoDiscoveryReport (MenuSounds);
BatchGraphics ();
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (VUX_BEAST, 1);
SET_GAME_STATE (VUX_BEAST_ON_SHIP, 1);
+1 -1
View File
@@ -98,7 +98,7 @@ GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
if (!GET_GAME_STATE (PORTAL_KEY))
{
pLanderInputState->planetSideDesc->InTransit = TRUE;
SetLanderTakeoff ();
SET_GAME_STATE (PORTAL_KEY, 1);
SET_GAME_STATE (PORTAL_KEY_ON_SHIP, 1);
+30 -24
View File
@@ -50,12 +50,18 @@
// ONE_SECOND.
#define PLANET_SIDE_RATE (ONE_SECOND / 35)
LanderInputState *pLanderInputState;
// Temporary, to replace the references to pMenuState.
// TODO: Many functions depend on pLanderInputState. In particular,
// the ELEMENT property functions. Fields in LanderInputState
// should either be made static vars, or ELEMENT should carry
// something like an 'intptr_t private' field
// This is a derived type from INPUT_STATE_DESC.
typedef struct LanderInputState LanderInputState;
struct LanderInputState {
// Fields required by DoInput()
BOOLEAN (*InputFunc) (LanderInputState *pMS);
COUNT MenuRepeatDelay;
BOOLEAN Initialized;
TimeCount NextTime;
// Frame rate control
};
FRAME LanderFrame[8];
static SOUND LanderSounds;
@@ -164,6 +170,9 @@ static int turn_wait;
static int weapon_wait;
// semantics similar to STARSHIP.weapon_counter
// TODO: We may want to make the PLANETSIDE_DESC fields into static vars
static PLANETSIDE_DESC *planetSideDesc;
#define ON_THE_GROUND 0
@@ -646,7 +655,7 @@ CheckObjectCollision (COUNT index)
DRAWABLE LanderHandle;
PRIMITIVE *pPrim;
PRIMITIVE *pLanderPrim;
PLANETSIDE_DESC *pPSD;
PLANETSIDE_DESC *pPSD = planetSideDesc;
if (index != END_OF_LIST)
{
@@ -663,7 +672,6 @@ CheckObjectCollision (COUNT index)
index = GetSuccLink (DisplayLinks);
}
pPSD = pLanderInputState->planetSideDesc;
LanderControl.EndPoint = LanderControl.IntersectStamp.origin;
LanderHandle = GetFrameParentDrawable (LanderControl.IntersectStamp.frame);
@@ -920,9 +928,8 @@ lightning_process (ELEMENT *ElementPtr)
if (ElementPtr->mass_points == LIGHTNING_DISASTER)
{
/* This one always strikes the lander and can hurt */
PLANETSIDE_DESC *pPSD = pLanderInputState->planetSideDesc;
if (crew_left && TFB_Random () % 100 < 10
&& !pPSD->InTransit)
&& !planetSideDesc->InTransit)
lander_flags |= KILL_CREW;
ElementPtr->next.location = curLanderLoc;
@@ -1055,13 +1062,12 @@ BuildObjectList (void)
DWORD rand_val;
POINT org;
HELEMENT hElement, hNextElement;
PLANETSIDE_DESC *pPSD;
PLANETSIDE_DESC *pPSD = planetSideDesc;
DisplayLinks = MakeLinks (END_OF_LIST, END_OF_LIST);
lander_flags &= ~KILL_CREW;
pPSD = pLanderInputState->planetSideDesc;
rand_val = TFB_Random ();
if (LOBYTE (HIWORD (rand_val)) < pPSD->FireChance)
{
@@ -1267,9 +1273,7 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingOffset)
CheckObjectCollision (END_OF_LIST);
{
PLANETSIDE_DESC *pPSD;
pPSD = pLanderInputState->planetSideDesc;
PLANETSIDE_DESC *pPSD = planetSideDesc;
if (pPSD->NumFrames)
{
--pPSD->NumFrames;
@@ -1624,7 +1628,7 @@ landerSpeedNumer = WORLD_TO_VELOCITY (48);
else if (crew_left /* alive and taking off */
&& ((CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE] ||
CurrentInputState.key[PlayerControls[0]][KEY_SPECIAL])
|| pLanderInputState->planetSideDesc->InTransit))
|| planetSideDesc->InTransit))
{
return FALSE;
}
@@ -1870,6 +1874,14 @@ LandingTakeoffSequence (LanderInputState *inputState, BOOLEAN landing)
IdlePlanetSide (inputState, ONE_SECOND / 2);
}
void
SetLanderTakeoff (void)
{
assert (planetSideDesc != NULL);
if (planetSideDesc)
planetSideDesc->InTransit = TRUE;
}
void
PlanetSide (POINT planetLoc)
{
@@ -1936,14 +1948,8 @@ PlanetSide (POINT planetLoc)
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x0A, 0x00), 0x7D);
PSD.ColorCycle[(NUM_TEXT_FRAMES >> 1) - 1] =
BUILD_COLOR (MAKE_RGB15 (0x1F, 0x03, 0x00), 0x7F);
landerInputState.planetSideDesc = &PSD;
planetSideDesc = &PSD;
// TODO: Many functions depend on pLanderInputState. In particular,
// the ELEMENT property functions. Fields in LanderInputState
// should either be made static vars, or ELEMENT should carry
// something like an 'intptr_t private' field
pLanderInputState = &landerInputState;
index = NORMALIZE_FACING (TFB_Random ());
LanderFrame[0] = SetAbsFrameIndex (LanderFrame[0], index);
crew_left = 0;
@@ -2020,7 +2026,7 @@ PlanetSide (POINT planetLoc)
}
}
landerInputState.planetSideDesc = NULL;
planetSideDesc = NULL;
{
HELEMENT hElement, hNextElement;
+4 -28
View File
@@ -32,6 +32,8 @@
#define NUM_TEXT_FRAMES 32
// XXX: This is a private type now. Move it to lander.c?
// We may also want to merge it with LanderInputState.
typedef struct
{
BOOLEAN InTransit;
@@ -54,34 +56,6 @@ typedef struct
BYTE FireChance;
} PLANETSIDE_DESC;
// This is a derived type from INPUT_STATE_DESC.
// Originally, the general MENU_STATE structure was used. Now, only the
// fields which are relevant are put in here. In the MENU_STATE structure,
// these fields were reused for all sorts of purposes, which had nothing
// to do with what the name suggests. Not all fields have been renamed yet
// in LanderInputState.
typedef struct LanderInputState LanderInputState;
struct LanderInputState {
BOOLEAN (*InputFunc) (LanderInputState *pMS);
COUNT MenuRepeatDelay;
PLANETSIDE_DESC *planetSideDesc;
SIZE Initialized;
TimeCount NextTime;
// Frame rate control
};
extern LanderInputState *pLanderInputState;
// Temporary, to replace the references to pMenuState.
// TODO: Many functions depend on pLanderInputState. In particular,
// the ELEMENT property functions. Fields in LanderInputState
// should either be made static vars, or ELEMENT should carry
// something like an 'intptr_t private' field
// TODO: Generation functions use pLanderInputState to locate
// the PLANETSIDE_DESC.InTransit. Make those instances into
// a function call instead.
extern MUSIC_REF LanderMusic;
extern void PlanetSide (POINT planetLoc);
@@ -92,6 +66,8 @@ extern void FreeLanderData (void);
extern void object_animation (ELEMENT *ElementPtr);
extern void SetLanderTakeoff (void);
// ELEMENT.playerNr constants
enum
{