Some functions for activities.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3773 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2012-02-24 21:00:39 +00:00
parent 947767d944
commit f5bb4c0c57
17 changed files with 134 additions and 42 deletions
+5 -6
View File
@@ -236,12 +236,12 @@ BattleSong (BOOLEAN DoPlay)
{
if (BattleRef == 0)
{
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
BattleRef = LoadMusic (BATTLE_MUSIC);
else if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
if (inHyperSpace ())
BattleRef = LoadMusic (HYPERSPACE_MUSIC);
else
else if (inQuasiSpace ())
BattleRef = LoadMusic (QUASISPACE_MUSIC);
else
BattleRef = LoadMusic (BATTLE_MUSIC);
}
if (DoPlay)
@@ -463,8 +463,7 @@ Battle (BattleFrameCallback *callback)
#endif /* NETPLAY */
bs.InputFunc = DoBattle;
bs.frame_cb = callback;
bs.first_time = (BOOLEAN)(LOBYTE (GLOBAL (CurrentActivity)) ==
IN_HYPERSPACE);
bs.first_time = inHQSpace ();
DoInput (&bs, FALSE);
+2 -2
View File
@@ -1327,7 +1327,7 @@ InitCommunication (CONVERSATION which_comm)
RepairSISBorder ();
}
DrawSISMessage (NULL);
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
DrawHyperCoords (GLOBAL (ShipStamp.origin));
else if (GLOBAL (ip_planet) == 0)
DrawHyperCoords (CurStarDescPtr->star_pt);
@@ -1492,7 +1492,7 @@ RaceCommunication (void)
SET_GAME_STATE (ESCAPE_COUNTER, ec);
return;
}
else if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
else if (inHQSpace ())
{
ReinitQueue (&GLOBAL (npc_built_ship_q));
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) >= 2)
+2 -2
View File
@@ -296,7 +296,7 @@ InitEncounter (void)
SetContextFont (MicroFont);
SetContextForeGroundColor (
BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x14), 0x01));
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
t.pStr = GAME_STRING (ENCOUNTER_STRING_BASE + 0);
// "ENCOUNTER IN"
@@ -566,7 +566,7 @@ UninitEncounter (void)
{
DrawSISFrame ();
DrawSISMessage (NULL);
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
DrawHyperCoords (GLOBAL (ShipStamp.origin));
else if (GLOBAL (ip_planet) == 0)
DrawHyperCoords (CurStarDescPtr->star_pt);
+4 -4
View File
@@ -268,7 +268,7 @@ InitGalaxy (void)
else
{
SetPrimType (&DisplayArray[p], POINT_PRIM);
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
SetPrimColor (&DisplayArray[p],
BUILD_COLOR (MAKE_RGB15 (0x15, 0x15, 0x15), 0x07));
else if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
@@ -327,7 +327,7 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
if (view_state == VIEW_CHANGE)
{
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
for (iss = 0, pprim = DisplayArray; iss < 2; ++iss)
{
@@ -385,7 +385,7 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
}
}
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
for (i = BIG_STAR_COUNT + MED_STAR_COUNT, pprim = DisplayArray;
i > 0; --i, ++pprim)
@@ -406,7 +406,7 @@ MoveGalaxy (VIEW_STATE view_state, SIZE dx, SIZE dy)
WrapStarBlock (1, dx, dy);
WrapStarBlock (0, dx, dy);
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
{
dx = SpaceOrg.x;
dy = SpaceOrg.y;
+1 -2
View File
@@ -60,8 +60,7 @@ EventHandler (BYTE selector)
break;
case HYPERSPACE_ENCOUNTER_EVENT:
check_race_growth ();
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE
&& GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
if (inHyperSpace ())
check_hyperspace_encounter ();
AddEvent (RELATIVE_EVENT, 0, 1, 0, HYPERSPACE_ENCOUNTER_EVENT);
+85
View File
@@ -32,6 +32,7 @@
#include "grpinfo.h"
#include "gamestr.h"
#include <assert.h>
#include <stdlib.h>
#ifdef STATE_DEBUG
# include "libs/log.h"
@@ -424,4 +425,88 @@ InitGlobData (void)
}
BOOLEAN
inFullGame (void)
{
ACTIVITY act = LOBYTE (GLOBAL (CurrentActivity));
return (act == IN_LAST_BATTLE || act == IN_ENCOUNTER ||
act == IN_HYPERSPACE || act == IN_INTERPLANETARY ||
act == WON_LAST_BATTLE);
}
BOOLEAN
inSuperMelee (void)
{
return (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE);
// TODO: && !inMainMenu ()
}
#if 0
BOOLEAN
inBattle (void)
{
// TODO: IN_BATTLE is also set while in HyperSpace/QuasiSpace.
return ((GLOBAL (CurrentActivity) & IN_BATTLE) != 0);
}
#endif
#if 0
// Disabled for now as there are similar functions in uqm/planets/planets.h
// Pre: inFullGame()
BOOLEAN
inInterPlanetary (void)
{
assert (inFullGame ());
return (pSolarSysState != NULL);
}
// Pre: inFullGame()
BOOLEAN
inSolarSystem (void)
{
assert (inFullGame ());
return (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY);
}
// Pre: inFullGame()
BOOLEAN
inOrbit (void)
{
assert (inFullGame ());
return (pSolarSysState != NULL) &&
(pSolarSysState->pOrbitalDesc != NULL);
}
#endif
// In HyperSpace or QuasiSpace
// Pre: inFullGame()
BOOLEAN
inHQSpace (void)
{
assert (inFullGame ());
return (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE);
// IN_HYPERSPACE is also set for QuasiSpace
}
// In HyperSpace
// Pre: inFullGame()
BOOLEAN
inHyperSpace (void)
{
//assert (inFullGame ());
return (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) &&
(GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1);
// IN_HYPERSPACE is also set for QuasiSpace
}
// In QuasiSpace
// Pre: inFullGame()
BOOLEAN
inQuasiSpace (void)
{
//assert (inFullGame ());
return (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE) &&
(GET_GAME_STATE (ARILOU_SPACE_SIDE) > 1);
// IN_HYPERSPACE is also set for QuasiSpace
}
+12 -1
View File
@@ -892,7 +892,7 @@ enum
SUPER_MELEE = 0, /* Is also used while in the main menu */
IN_LAST_BATTLE,
IN_ENCOUNTER,
IN_HYPERSPACE /* in Hyperspace or Quasispace */,
IN_HYPERSPACE /* in HyperSpace or QuasiSpace */,
IN_INTERPLANETARY,
WON_LAST_BATTLE,
@@ -904,6 +904,7 @@ enum
CHECK_PAUSE = MAKE_WORD (0, (1 << 0)),
IN_BATTLE = MAKE_WORD (0, (1 << 1)),
/* Is also set while in HyperSpace/QuasiSpace */
START_ENCOUNTER = MAKE_WORD (0, (1 << 2)),
START_INTERPLANETARY = MAKE_WORD (0, (1 << 3)),
CHECK_LOAD = MAKE_WORD (0, (1 << 4)),
@@ -1011,6 +1012,16 @@ extern BOOLEAN LoadSC2Data (void);
extern void InitGlobData (void);
BOOLEAN inFullGame (void);
BOOLEAN inSuperMelee (void);
//BOOLEAN inBattle (void);
//BOOLEAN inInterPlanetary (void);
//BOOLEAN inSolarSystem (void);
//BOOLEAN inOrbit (void);
BOOLEAN inHQSpace (void);
BOOLEAN inHyperSpace (void);
BOOLEAN inQuasiSpace (void);
extern BOOLEAN InitGameStructures (void);
extern void UninitGameStructures (void);
+2 -2
View File
@@ -187,7 +187,7 @@ InitShips (void)
InitDisplayList ();
InitGalaxy ();
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
ReinitQueue (&race_q[0]);
ReinitQueue (&race_q[1]);
@@ -346,7 +346,7 @@ UninitShips (void)
for (i = 0; i < NUM_PLAYERS; i++)
ReinitQueue (&race_q[i]);
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
FreeHyperspace ();
}
}
+1 -1
View File
@@ -304,7 +304,7 @@ SetContext (OldContext);
HSTARSHIP
GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player)
{
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
assert (which_player == RPG_PLAYER_NUM);
// SIS for the Hyperspace flight
+3 -4
View File
@@ -217,7 +217,7 @@ DrawDevices (DEVICES_STATE *devState, COUNT OldDevice, COUNT NewDevice)
static BOOLEAN
UseCaster (void)
{
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
{
@@ -372,7 +372,7 @@ InvokeDevice (BYTE which_device)
NextActivity |= CHECK_LOAD; /* fake a load game */
GLOBAL (CurrentActivity) |= START_ENCOUNTER;
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 0);
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
if (GetHeadEncounter ())
{
@@ -443,8 +443,7 @@ InvokeDevice (BYTE which_device)
break;
case PORTAL_SPAWNER_DEVICE:
#define PORTAL_FUEL_COST (10 * FUEL_TANK_SCALE)
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE
&& GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1
if (inHyperSpace ()
&& GLOBAL_SIS (FuelOnBoard) >= PORTAL_FUEL_COST)
{
/* No DeltaSISGauges because the flagship picture
+6 -6
View File
@@ -161,7 +161,7 @@ DrawAutoPilot (POINT *pDstPt)
cycle, delta;
POINT pt;
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
pt = CurStarDescPtr->star_pt;
else
{
@@ -346,7 +346,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
{
Color OldColor;
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
r.corner = CurStarDescPtr->star_pt;
else
{
@@ -773,7 +773,7 @@ UpdateFuelRequirement (void)
DWORD f;
POINT pt;
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
pt = CurStarDescPtr->star_pt;
else
{
@@ -1223,7 +1223,7 @@ DoMoveCursor (MENU_STATE *pMS)
pMS->Initialized = TRUE;
pMS->InputFunc = DoMoveCursor;
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
universe = CurStarDescPtr->star_pt;
else
{
@@ -1250,7 +1250,7 @@ DoMoveCursor (MENU_STATE *pMS)
{
PlayMenuSound (MENU_SOUND_INVOKED);
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
// Move to the new location immediately.
doInstantMove ();
@@ -1579,7 +1579,7 @@ StarMap (void)
mapOrigin.y = MAX_Y_UNIVERSE >> 1;
StarMapFrame = SetAbsFrameIndex (MiscDataFrame, 48);
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
universe = CurStarDescPtr->star_pt;
else
{
+2 -3
View File
@@ -308,12 +308,11 @@ CalcView (POINT *pNewScrollPt, SIZE next_reduction,
dy = -ORG_JUMP_Y;
}
if ((dx || dy) && LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if ((dx || dy) && inHQSpace ())
MoveSIS (&dx, &dy);
if (zoom_out == next_reduction)
view_state = dx == 0 && dy == 0
&& LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE
view_state = dx == 0 && dy == 0 && !inHQSpace ()
? VIEW_STABLE : VIEW_SCROLL;
else
{
+2 -2
View File
@@ -486,7 +486,7 @@ PrepareSummary (SUMMARY_DESC *SummPtr)
switch (SummPtr->Activity)
{
case IN_HYPERSPACE:
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) > 1)
if (inQuasiSpace ())
SummPtr->Activity = IN_QUASISPACE;
break;
case IN_INTERPLANETARY:
@@ -621,7 +621,7 @@ SaveProblem (void)
static void
SaveFlagshipState (void)
{
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
// Player is in HyperSpace or QuasiSpace.
SaveSisHyperState ();
+1 -1
View File
@@ -454,7 +454,7 @@ spawn_ship (STARSHIP *StarShipPtr)
else
{
StarShipPtr->ShipFacing = NORMALIZE_FACING (TFB_Random ());
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{ // Only one ship is ever spawned in HyperSpace -- flagship
COUNT facing = GLOBAL (ShipFacing);
// XXX: Solar system reentry test depends on ShipFacing != 0
+2 -2
View File
@@ -891,7 +891,7 @@ init_sis (void)
new_sis_desc.uninit_func = uninit_sis;
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
if (inHQSpace ())
{
for (i = 0; i < NUM_VIEWS; ++i)
{
@@ -950,7 +950,7 @@ init_sis (void)
static void
uninit_sis (RACE_DESC *pRaceDesc)
{
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
if (!inHQSpace ())
{
GLOBAL_SIS (CrewEnlisted) = pRaceDesc->ship_info.crew_level;
if (pRaceDesc->ship_info.ship_flags & PLAYER_CAPTAIN)
+1 -1
View File
@@ -214,7 +214,7 @@ DrawSISMessageEx (const UNICODE *pStr, SIZE CurPos, SIZE ExPos, COUNT flags)
pStr = buf;
break;
case IN_HYPERSPACE:
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
if (inHyperSpace ())
{
pStr = GAME_STRING (NAVIGATION_STRING_BASE);
// "HyperSpace"
+3 -3
View File
@@ -369,7 +369,7 @@ equipShip (void)
}
// Make sure everything is redrawn:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE ||
if (inHQSpace () ||
LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY)
{
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
@@ -1508,7 +1508,7 @@ resetCrewBattle (void)
CONTEXT OldContext;
if (!(GLOBAL (CurrentActivity) & IN_BATTLE) ||
(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE))
(inHQSpace ()))
return;
StarShipPtr = findPlayerShip (RPG_PLAYER_NUM);
@@ -1531,7 +1531,7 @@ resetEnergyBattle (void)
CONTEXT OldContext;
if (!(GLOBAL (CurrentActivity) & IN_BATTLE) ||
(LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE))
(inHQSpace ()))
return;
StarShipPtr = findPlayerShip (RPG_PLAYER_NUM);