|
From: <Mee...@us...> - 2012-02-24 21:00:46
|
Revision: 3773
http://sc2.svn.sourceforge.net/sc2/?rev=3773&view=rev
Author: Meep-Eep
Date: 2012-02-24 21:00:39 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
Some functions for activities.
Modified Paths:
--------------
trunk/sc2/src/uqm/battle.c
trunk/sc2/src/uqm/comm.c
trunk/sc2/src/uqm/encount.c
trunk/sc2/src/uqm/galaxy.c
trunk/sc2/src/uqm/gameev.c
trunk/sc2/src/uqm/globdata.c
trunk/sc2/src/uqm/globdata.h
trunk/sc2/src/uqm/init.c
trunk/sc2/src/uqm/pickship.c
trunk/sc2/src/uqm/planets/devices.c
trunk/sc2/src/uqm/planets/pstarmap.c
trunk/sc2/src/uqm/process.c
trunk/sc2/src/uqm/save.c
trunk/sc2/src/uqm/ship.c
trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c
trunk/sc2/src/uqm/sis.c
trunk/sc2/src/uqm/uqmdebug.c
Modified: trunk/sc2/src/uqm/battle.c
===================================================================
--- trunk/sc2/src/uqm/battle.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/battle.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -236,12 +236,12 @@
{
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 @@
#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);
Modified: trunk/sc2/src/uqm/comm.c
===================================================================
--- trunk/sc2/src/uqm/comm.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/comm.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -1327,7 +1327,7 @@
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 @@
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)
Modified: trunk/sc2/src/uqm/encount.c
===================================================================
--- trunk/sc2/src/uqm/encount.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/encount.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -296,7 +296,7 @@
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 @@
{
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);
Modified: trunk/sc2/src/uqm/galaxy.c
===================================================================
--- trunk/sc2/src/uqm/galaxy.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/galaxy.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -268,7 +268,7 @@
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 @@
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 @@
}
}
- 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 @@
WrapStarBlock (1, dx, dy);
WrapStarBlock (0, dx, dy);
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
{
dx = SpaceOrg.x;
dy = SpaceOrg.y;
Modified: trunk/sc2/src/uqm/gameev.c
===================================================================
--- trunk/sc2/src/uqm/gameev.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/gameev.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -60,8 +60,7 @@
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);
Modified: trunk/sc2/src/uqm/globdata.c
===================================================================
--- trunk/sc2/src/uqm/globdata.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/globdata.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -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 @@
}
+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
+}
+
Modified: trunk/sc2/src/uqm/globdata.h
===================================================================
--- trunk/sc2/src/uqm/globdata.h 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/globdata.h 2012-02-24 21:00:39 UTC (rev 3773)
@@ -892,7 +892,7 @@
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 @@
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 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);
Modified: trunk/sc2/src/uqm/init.c
===================================================================
--- trunk/sc2/src/uqm/init.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/init.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -187,7 +187,7 @@
InitDisplayList ();
InitGalaxy ();
- if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
+ if (inHQSpace ())
{
ReinitQueue (&race_q[0]);
ReinitQueue (&race_q[1]);
@@ -346,7 +346,7 @@
for (i = 0; i < NUM_PLAYERS; i++)
ReinitQueue (&race_q[i]);
- if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
+ if (inHQSpace ())
FreeHyperspace ();
}
}
Modified: trunk/sc2/src/uqm/pickship.c
===================================================================
--- trunk/sc2/src/uqm/pickship.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/pickship.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -304,7 +304,7 @@
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
Modified: trunk/sc2/src/uqm/planets/devices.c
===================================================================
--- trunk/sc2/src/uqm/planets/devices.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/planets/devices.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -217,7 +217,7 @@
static BOOLEAN
UseCaster (void)
{
- if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
+ if (inHQSpace ())
{
if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
{
@@ -372,7 +372,7 @@
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 @@
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
Modified: trunk/sc2/src/uqm/planets/pstarmap.c
===================================================================
--- trunk/sc2/src/uqm/planets/pstarmap.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/planets/pstarmap.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -161,7 +161,7 @@
cycle, delta;
POINT pt;
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
pt = CurStarDescPtr->star_pt;
else
{
@@ -346,7 +346,7 @@
{
Color OldColor;
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
r.corner = CurStarDescPtr->star_pt;
else
{
@@ -773,7 +773,7 @@
DWORD f;
POINT pt;
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
pt = CurStarDescPtr->star_pt;
else
{
@@ -1223,7 +1223,7 @@
pMS->Initialized = TRUE;
pMS->InputFunc = DoMoveCursor;
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
universe = CurStarDescPtr->star_pt;
else
{
@@ -1250,7 +1250,7 @@
{
PlayMenuSound (MENU_SOUND_INVOKED);
- if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
+ if (inHQSpace ())
{
// Move to the new location immediately.
doInstantMove ();
@@ -1579,7 +1579,7 @@
mapOrigin.y = MAX_Y_UNIVERSE >> 1;
StarMapFrame = SetAbsFrameIndex (MiscDataFrame, 48);
- if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
+ if (!inHQSpace ())
universe = CurStarDescPtr->star_pt;
else
{
Modified: trunk/sc2/src/uqm/process.c
===================================================================
--- trunk/sc2/src/uqm/process.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/process.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -308,12 +308,11 @@
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
{
Modified: trunk/sc2/src/uqm/save.c
===================================================================
--- trunk/sc2/src/uqm/save.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/save.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -486,7 +486,7 @@
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 @@
static void
SaveFlagshipState (void)
{
- if (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE)
+ if (inHQSpace ())
{
// Player is in HyperSpace or QuasiSpace.
SaveSisHyperState ();
Modified: trunk/sc2/src/uqm/ship.c
===================================================================
--- trunk/sc2/src/uqm/ship.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/ship.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -454,7 +454,7 @@
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
Modified: trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c
===================================================================
--- trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/ships/sis_ship/sis_ship.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -891,7 +891,7 @@
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 @@
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)
Modified: trunk/sc2/src/uqm/sis.c
===================================================================
--- trunk/sc2/src/uqm/sis.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/sis.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -214,7 +214,7 @@
pStr = buf;
break;
case IN_HYPERSPACE:
- if (GET_GAME_STATE (ARILOU_SPACE_SIDE) <= 1)
+ if (inHyperSpace ())
{
pStr = GAME_STRING (NAVIGATION_STRING_BASE);
// "HyperSpace"
Modified: trunk/sc2/src/uqm/uqmdebug.c
===================================================================
--- trunk/sc2/src/uqm/uqmdebug.c 2012-02-24 19:52:10 UTC (rev 3772)
+++ trunk/sc2/src/uqm/uqmdebug.c 2012-02-24 21:00:39 UTC (rev 3773)
@@ -369,7 +369,7 @@
}
// 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 @@
CONTEXT OldContext;
if (!(GLOBAL (CurrentActivity) & IN_BATTLE) ||
- (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE))
+ (inHQSpace ()))
return;
StarShipPtr = findPlayerShip (RPG_PLAYER_NUM);
@@ -1531,7 +1531,7 @@
CONTEXT OldContext;
if (!(GLOBAL (CurrentActivity) & IN_BATTLE) ||
- (LOBYTE (GLOBAL (CurrentActivity)) == IN_HYPERSPACE))
+ (inHQSpace ()))
return;
StarShipPtr = findPlayerShip (RPG_PLAYER_NUM);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|