Cleanup: separation of ActivateStarShip actions, removed Orz and Fwiffo hacks; other cleanups and comments
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2766 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+226
-209
@@ -89,233 +89,211 @@ GetStarShipFromIndex (QUEUE *pShipQ, COUNT Index)
|
||||
* CHECK_ALLIANCE:
|
||||
* Test the alliance status of the race of 'which_ship'.
|
||||
* Either GOOD_GUY (allied) or BAD_GUY (not allied) is returned.
|
||||
* 0:
|
||||
* SET_ALLIED (0):
|
||||
* Ally with the race of 'which_ship'. This makes their ship available
|
||||
* for building in the shipyard.
|
||||
* -1:
|
||||
* SET_NOT_ALLIED:
|
||||
* End an alliance with the race of 'which_ship'. This ends the possibility
|
||||
* of building their ships in the shipyard. For the Orz also the ships the
|
||||
* player has with him will disappear.
|
||||
* of building their ships in the shipyard.
|
||||
* REMOVE_BUILT:
|
||||
* Make the already built escorts of the race of 'which_ship' disappear.
|
||||
* (as for the Orz when the alliance with them ends)
|
||||
* any other positive number:
|
||||
* Give the player this much ships of type 'which_ship'. If it's
|
||||
* Give the player this many ships of type 'which_ship'.
|
||||
*/
|
||||
COUNT
|
||||
ActivateStarShip (COUNT which_ship, SIZE state)
|
||||
{
|
||||
HSTARSHIP hStarShip, hNextShip;
|
||||
|
||||
hStarShip = GetStarShipFromIndex (
|
||||
&GLOBAL (avail_race_q), which_ship
|
||||
);
|
||||
if (hStarShip)
|
||||
hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_ship);
|
||||
if (!hStarShip)
|
||||
return 0;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
switch (state)
|
||||
case SPHERE_TRACKING:
|
||||
case SPHERE_KNOWN:
|
||||
{
|
||||
case SPHERE_TRACKING:
|
||||
case SPHERE_KNOWN:
|
||||
EXTENDED_SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
StarShipPtr = (EXTENDED_SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
if (state == SPHERE_KNOWN)
|
||||
which_ship = StarShipPtr->ShipInfo.known_strength;
|
||||
else if (StarShipPtr->ShipInfo.actual_strength == 0)
|
||||
{
|
||||
EXTENDED_SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
StarShipPtr = (EXTENDED_SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
if (state == SPHERE_KNOWN)
|
||||
which_ship = StarShipPtr->ShipInfo.known_strength;
|
||||
else if (StarShipPtr->ShipInfo.actual_strength == 0)
|
||||
{
|
||||
if (!(StarShipPtr->ShipInfo.ship_flags
|
||||
& (GOOD_GUY | BAD_GUY)))
|
||||
which_ship = 0;
|
||||
}
|
||||
else if (StarShipPtr->ShipInfo.known_strength == 0
|
||||
&& StarShipPtr->ShipInfo.actual_strength != (COUNT)~0)
|
||||
{
|
||||
StarShipPtr->ShipInfo.known_strength = 1;
|
||||
StarShipPtr->ShipInfo.known_loc =
|
||||
StarShipPtr->ShipInfo.loc;
|
||||
}
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
return (which_ship);
|
||||
if (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)))
|
||||
which_ship = 0;
|
||||
}
|
||||
case ESCORT_WORTH:
|
||||
else if (StarShipPtr->ShipInfo.known_strength == 0
|
||||
&& StarShipPtr->ShipInfo.actual_strength != (COUNT)~0)
|
||||
{
|
||||
COUNT ShipCost[] =
|
||||
{
|
||||
RACE_SHIP_COST
|
||||
};
|
||||
COUNT total = 0;
|
||||
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
total += ShipCost[GET_RACE_ID (StarShipPtr)];
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
}
|
||||
return total;
|
||||
StarShipPtr->ShipInfo.known_strength = 1;
|
||||
StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.loc;
|
||||
}
|
||||
case ESCORTING_FLAGSHIP:
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
return (which_ship);
|
||||
}
|
||||
case ESCORT_WORTH:
|
||||
{
|
||||
COUNT ShipCost[] =
|
||||
{
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
BYTE ship_type;
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
RACE_SHIP_COST
|
||||
};
|
||||
COUNT total = 0;
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
ship_type = GET_RACE_ID (StarShipPtr);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
if ((COUNT) ship_type == which_ship)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case FEASIBILITY_STUDY:
|
||||
return (MAX_BUILT_SHIPS
|
||||
- CountLinks (&GLOBAL (built_ship_q)));
|
||||
default:
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
if (state <= 0)
|
||||
{
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
if (state == CHECK_ALLIANCE)
|
||||
{
|
||||
state = StarShipPtr->ShipInfo.ship_flags
|
||||
& (GOOD_GUY | BAD_GUY);
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
return ((COUNT)state);
|
||||
}
|
||||
else if (StarShipPtr->ShipInfo.ship_flags
|
||||
& (GOOD_GUY | BAD_GUY))
|
||||
{
|
||||
StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY);
|
||||
if (state == 0)
|
||||
StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY;
|
||||
else
|
||||
{
|
||||
StarShipPtr->ShipInfo.ship_flags |= BAD_GUY;
|
||||
if (which_ship == ORZ_SHIP)
|
||||
{
|
||||
BOOLEAN ShipRemoved;
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
total += ShipCost[GET_RACE_ID (StarShipPtr)];
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
case ESCORTING_FLAGSHIP:
|
||||
{
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
BYTE ship_type;
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
ShipRemoved = FALSE;
|
||||
for (hStarShip = GetHeadLink (
|
||||
&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
BOOLEAN RemoveShip;
|
||||
SHIP_FRAGMENT *StarShipPtr2;
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
ship_type = GET_RACE_ID (StarShipPtr);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
StarShipPtr2 =
|
||||
(SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr2);
|
||||
RemoveShip = (BOOLEAN) (
|
||||
GET_RACE_ID (StarShipPtr2) ==
|
||||
ORZ_SHIP);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q),
|
||||
hStarShip);
|
||||
if (ship_type == which_ship)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case FEASIBILITY_STUDY:
|
||||
{
|
||||
return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q)));
|
||||
}
|
||||
case CHECK_ALLIANCE:
|
||||
{
|
||||
COUNT flags;
|
||||
SHIP_FRAGMENT *StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
flags = StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY);
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
return flags;
|
||||
}
|
||||
case SET_ALLIED:
|
||||
case SET_NOT_ALLIED:
|
||||
{
|
||||
SHIP_FRAGMENT *StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
|
||||
if (RemoveShip)
|
||||
{
|
||||
ShipRemoved = TRUE;
|
||||
|
||||
RemoveQueue (&GLOBAL (built_ship_q),
|
||||
hStarShip);
|
||||
FreeStarShip (&GLOBAL (built_ship_q),
|
||||
hStarShip);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShipRemoved)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
DeltaSISGauges (UNDEFINED_DELTA,
|
||||
UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 'state > 0', add ships to the escorts */
|
||||
BYTE which_window;
|
||||
COUNT i;
|
||||
|
||||
which_window = 0;
|
||||
for (i = 0; i < (COUNT)state; i++)
|
||||
{
|
||||
HSTARSHIP hOldShip;
|
||||
BYTE crewLevel;
|
||||
|
||||
if (which_ship == SPATHI_SHIP &&
|
||||
GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1)
|
||||
crewLevel = 1; // Only Fwiffo is on board.
|
||||
else
|
||||
crewLevel = 0; // Crewed to the max
|
||||
|
||||
hStarShip = CloneShipFragment((COUNT) which_ship,
|
||||
&GLOBAL (built_ship_q), crewLevel);
|
||||
if (!hStarShip)
|
||||
break;
|
||||
|
||||
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
while ((hOldShip = GetStarShipFromIndex (
|
||||
&GLOBAL (built_ship_q), which_window++)))
|
||||
{
|
||||
BYTE win_loc;
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hOldShip);
|
||||
win_loc = GET_GROUP_LOC (StarShipPtr);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q),
|
||||
hOldShip);
|
||||
if (which_window <= win_loc)
|
||||
break;
|
||||
}
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
SET_GROUP_LOC (StarShipPtr, which_window - 1);
|
||||
if (which_ship == SPATHI_SHIP
|
||||
&& GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1)
|
||||
{
|
||||
OwnStarShip (StarShipPtr, GOOD_GUY,
|
||||
NAME_OFFSET + NUM_CAPTAINS_NAMES);
|
||||
}
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
InsertQueue (&GLOBAL (built_ship_q), hStarShip,
|
||||
hOldShip);
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
DeltaSISGauges (UNDEFINED_DELTA,
|
||||
UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||
UnlockMutex (GraphicsLock);
|
||||
return (i);
|
||||
}
|
||||
if (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)))
|
||||
{ /* Strange request, silently ignore it */
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY);
|
||||
if (state == SET_ALLIED)
|
||||
StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY;
|
||||
else
|
||||
StarShipPtr->ShipInfo.ship_flags |= BAD_GUY;
|
||||
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||
break;
|
||||
}
|
||||
case REMOVE_BUILT:
|
||||
{
|
||||
BOOLEAN ShipRemoved = FALSE;
|
||||
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
|
||||
hStarShip; hStarShip = hNextShip)
|
||||
{
|
||||
BOOLEAN RemoveShip;
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
RemoveShip = (GET_RACE_ID (StarShipPtr) == which_ship);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
if (RemoveShip)
|
||||
{
|
||||
ShipRemoved = TRUE;
|
||||
|
||||
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
||||
FreeStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShipRemoved)
|
||||
{
|
||||
LockMutex (GraphicsLock);
|
||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
|
||||
UNDEFINED_DELTA);
|
||||
UnlockMutex (GraphicsLock);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BYTE which_window;
|
||||
COUNT i;
|
||||
|
||||
assert (state > 0);
|
||||
/* Add ships to the escorts */
|
||||
which_window = 0;
|
||||
for (i = 0; i < (COUNT)state; i++)
|
||||
{
|
||||
HSTARSHIP hOldShip;
|
||||
SHIP_FRAGMENT *StarShipPtr;
|
||||
|
||||
hStarShip = CloneShipFragment ((COUNT) which_ship,
|
||||
&GLOBAL (built_ship_q), 0);
|
||||
if (!hStarShip)
|
||||
break;
|
||||
|
||||
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
/* Find first available escort window */
|
||||
while ((hOldShip = GetStarShipFromIndex (
|
||||
&GLOBAL (built_ship_q), which_window++)))
|
||||
{
|
||||
BYTE win_loc;
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hOldShip);
|
||||
win_loc = GET_GROUP_LOC (StarShipPtr);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hOldShip);
|
||||
if (which_window <= win_loc)
|
||||
break;
|
||||
}
|
||||
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
SET_GROUP_LOC (StarShipPtr, which_window - 1);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip);
|
||||
}
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
DeltaSISGauges (UNDEFINED_DELTA,
|
||||
UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||
UnlockMutex (GraphicsLock);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
COUNT
|
||||
@@ -362,13 +340,9 @@ NameCaptain (QUEUE *pQueue, STARSHIP *StarShipPtr)
|
||||
BOOLEAN SameName;
|
||||
|
||||
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
|
||||
SameName = (BOOLEAN)(
|
||||
name_index == TestShipPtr->captains_name_index
|
||||
);
|
||||
SameName = (name_index == TestShipPtr->captains_name_index);
|
||||
else
|
||||
SameName = (BOOLEAN)(
|
||||
name_index == StarShipCaptain (TestShipPtr)
|
||||
);
|
||||
SameName = (name_index == StarShipCaptain (TestShipPtr));
|
||||
|
||||
if (SameName)
|
||||
{
|
||||
@@ -397,9 +371,7 @@ CloneShipFragment (COUNT shipIndex, QUEUE *pDstQueue, COUNT crew_level)
|
||||
|
||||
TemplatePtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hStarShip);
|
||||
hBuiltShip =
|
||||
Build (pDstQueue,
|
||||
TemplatePtr->RaceResIndex,
|
||||
hBuiltShip = Build (pDstQueue, TemplatePtr->RaceResIndex,
|
||||
TemplatePtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY),
|
||||
(BYTE)(shipIndex == SAMATRA_SHIP ?
|
||||
0 : NameCaptain (pDstQueue, (STARSHIP*)TemplatePtr)));
|
||||
@@ -413,8 +385,10 @@ CloneShipFragment (COUNT shipIndex, QUEUE *pDstQueue, COUNT crew_level)
|
||||
ShipFragPtr->ShipInfo.crew_level = crew_level;
|
||||
ShipFragPtr->ShipInfo.energy_level = 0;
|
||||
ShipFragPtr->ShipInfo.ship_flags = 0;
|
||||
ShipFragPtr->ShipInfo.var1 = ShipFragPtr->ShipInfo.var2 = 0;
|
||||
ShipFragPtr->ShipInfo.loc.x = ShipFragPtr->ShipInfo.loc.y = 0;
|
||||
ShipFragPtr->ShipInfo.var1 = 0;
|
||||
ShipFragPtr->ShipInfo.var2 = 0;
|
||||
ShipFragPtr->ShipInfo.loc.x = 0;
|
||||
ShipFragPtr->ShipInfo.loc.y = 0;
|
||||
SET_RACE_ID (ShipFragPtr, (BYTE)shipIndex);
|
||||
UnlockStarShip (pDstQueue, hBuiltShip);
|
||||
}
|
||||
@@ -423,3 +397,46 @@ CloneShipFragment (COUNT shipIndex, QUEUE *pDstQueue, COUNT crew_level)
|
||||
return hBuiltShip;
|
||||
}
|
||||
|
||||
/* Set the crew and captain's name on the first fully-crewed escort
|
||||
* ship of race 'which_ship' */
|
||||
int
|
||||
SetEscortCrewComplement (COUNT which_ship, COUNT crew_level, BYTE captain)
|
||||
{
|
||||
HSTARSHIP hTemplateShip;
|
||||
SHIP_FRAGMENT *TemplatePtr;
|
||||
HSTARSHIP hStarShip;
|
||||
HSTARSHIP hNextShip;
|
||||
SHIP_FRAGMENT *StarShipPtr = 0;
|
||||
int Index;
|
||||
|
||||
hTemplateShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_ship);
|
||||
if (!hTemplateShip)
|
||||
return -1;
|
||||
TemplatePtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (avail_race_q), hTemplateShip);
|
||||
|
||||
/* Find first ship of which_ship race */
|
||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)), Index = 0;
|
||||
hStarShip; hStarShip = hNextShip, ++Index)
|
||||
{
|
||||
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
|
||||
&GLOBAL (built_ship_q), hStarShip);
|
||||
hNextShip = _GetSuccLink (StarShipPtr);
|
||||
if (which_ship == GET_RACE_ID (StarShipPtr) &&
|
||||
StarShipPtr->ShipInfo.crew_level ==
|
||||
TemplatePtr->ShipInfo.crew_level)
|
||||
break; /* found one */
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
}
|
||||
if (hStarShip)
|
||||
{
|
||||
StarShipPtr->ShipInfo.crew_level = crew_level;
|
||||
OwnStarShip (StarShipPtr, StarShipPlayer (StarShipPtr), captain);
|
||||
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
}
|
||||
else
|
||||
Index = -1;
|
||||
|
||||
UnlockStarShip (&GLOBAL (avail_race_q), hTemplateShip);
|
||||
return Index;
|
||||
}
|
||||
|
||||
+11
-6
@@ -55,16 +55,21 @@ extern BYTE NameCaptain (QUEUE *pQueue, STARSHIP *StarShipPtr);
|
||||
* COUNT ActivateStarShip (COUNT which_ship, SIZE state)
|
||||
* See that function for more information.
|
||||
*/
|
||||
#define CHECK_ALLIANCE -2
|
||||
#define ESCORT_WORTH 9995
|
||||
#define SPHERE_KNOWN 9996
|
||||
#define SPHERE_TRACKING 9997
|
||||
#define ESCORTING_FLAGSHIP 9998
|
||||
#define FEASIBILITY_STUDY 9999
|
||||
#define SET_ALLIED 0
|
||||
#define SET_NOT_ALLIED -1
|
||||
#define CHECK_ALLIANCE -2
|
||||
#define REMOVE_BUILT -3
|
||||
#define ESCORT_WORTH -4
|
||||
#define SPHERE_KNOWN -5
|
||||
#define SPHERE_TRACKING -6
|
||||
#define ESCORTING_FLAGSHIP -7
|
||||
#define FEASIBILITY_STUDY -8
|
||||
/* Check for how many escort ships there's still space */
|
||||
|
||||
extern COUNT ActivateStarShip (COUNT which_ship, SIZE state);
|
||||
extern COUNT GetIndexFromStarShip (QUEUE *pShipQ, HSTARSHIP hStarShip);
|
||||
extern int SetEscortCrewComplement (COUNT which_ship, COUNT crew_level,
|
||||
BYTE captain);
|
||||
|
||||
extern MEM_HANDLE load_ship (STARSHIP *StarShipPtr, BOOLEAN
|
||||
LoadBattleData);
|
||||
|
||||
@@ -39,6 +39,7 @@ typedef struct
|
||||
DWORD TimeCounter;
|
||||
|
||||
QUEUE event_q;
|
||||
/* Queue element is EVENT */
|
||||
} CLOCK_STATE;
|
||||
|
||||
typedef QUEUE_HANDLE HEVENT;
|
||||
|
||||
@@ -128,7 +128,7 @@ ExitConversation (RESPONSE_REF R)
|
||||
|
||||
NPCPhrase (TAKE_2_WEEKS);
|
||||
|
||||
ActivateStarShip (CHMMR_SHIP, 0);
|
||||
ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
|
||||
|
||||
SET_GAME_STATE (CHMMR_HOME_VISITS, 0);
|
||||
SET_GAME_STATE (CHMMR_STACK, 0);
|
||||
@@ -239,7 +239,7 @@ NotReady (RESPONSE_REF R)
|
||||
{
|
||||
NPCPhrase (USE_OUR_SHIPS_BEFORE);
|
||||
|
||||
ActivateStarShip (CHMMR_SHIP, 0);
|
||||
ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
|
||||
}
|
||||
else if (PLAYER_SAID (R, where_weapon))
|
||||
{
|
||||
@@ -292,7 +292,7 @@ ImproveBomb (RESPONSE_REF R)
|
||||
{
|
||||
NPCPhrase (USE_OUR_SHIPS_AFTER);
|
||||
|
||||
ActivateStarShip (CHMMR_SHIP, 0);
|
||||
ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
|
||||
}
|
||||
|
||||
if (PHRASE_ENABLED (what_now))
|
||||
|
||||
@@ -208,7 +208,7 @@ ExitConversation (RESPONSE_REF R)
|
||||
SET_GAME_STATE (ORZ_GENERAL_INFO, 0);
|
||||
SET_GAME_STATE (ORZ_PERSONAL_INFO, 0);
|
||||
SET_GAME_STATE (ORZ_MANNER, 3);
|
||||
ActivateStarShip (ORZ_SHIP, 0);
|
||||
ActivateStarShip (ORZ_SHIP, SET_ALLIED);
|
||||
}
|
||||
else if (PLAYER_SAID (R, demand_to_land))
|
||||
{
|
||||
@@ -228,7 +228,10 @@ ExitConversation (RESPONSE_REF R)
|
||||
SET_GAME_STATE (ORZ_MANNER, 2);
|
||||
SET_GAME_STATE (BATTLE_SEGUE, 1);
|
||||
if (PLAYER_SAID (R, about_andro_3))
|
||||
ActivateStarShip (ORZ_SHIP, -1);
|
||||
{
|
||||
ActivateStarShip (ORZ_SHIP, SET_NOT_ALLIED);
|
||||
ActivateStarShip (ORZ_SHIP, REMOVE_BUILT);
|
||||
}
|
||||
|
||||
XFormColorMap (GetColorMapAddress (
|
||||
SetAbsColorMapIndex (CommData.AlienColorMap, 1)
|
||||
@@ -314,9 +317,8 @@ TaaloWorld (RESPONSE_REF R)
|
||||
|
||||
if (PHRASE_ENABLED (may_we_land))
|
||||
{
|
||||
if (Manner == 3 && (ActivateStarShip (
|
||||
ORZ_SHIP, CHECK_ALLIANCE
|
||||
) & GOOD_GUY))
|
||||
if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE)
|
||||
& GOOD_GUY))
|
||||
Response (may_we_land, ExitConversation);
|
||||
else
|
||||
Response (may_we_land, TaaloWorld);
|
||||
@@ -330,7 +332,7 @@ TaaloWorld (RESPONSE_REF R)
|
||||
if (Manner == 1)
|
||||
Response (demand_to_land, ExitConversation);
|
||||
else
|
||||
Response (demand_to_land, TaaloWorld);
|
||||
Response (demand_to_land, TaaloWorld);
|
||||
}
|
||||
if (PHRASE_ENABLED (why_you_here))
|
||||
Response (why_you_here, TaaloWorld);
|
||||
@@ -698,9 +700,8 @@ Intro (void)
|
||||
|
||||
TaaloWorld ((RESPONSE_REF)0);
|
||||
}
|
||||
else if (Manner == 3 && (ActivateStarShip (
|
||||
ORZ_SHIP, CHECK_ALLIANCE
|
||||
) & GOOD_GUY))
|
||||
else if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE)
|
||||
& GOOD_GUY))
|
||||
{
|
||||
if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7))
|
||||
{
|
||||
|
||||
@@ -247,7 +247,7 @@ ExitConversation (RESPONSE_REF R)
|
||||
{
|
||||
NPCPhrase (DEPART_FOR_EARTH);
|
||||
|
||||
ActivateStarShip (SPATHI_SHIP, 0);
|
||||
ActivateStarShip (SPATHI_SHIP, SET_ALLIED);
|
||||
AddEvent (RELATIVE_EVENT, 6, 0, 0, SPATHI_SHIELD_EVENT);
|
||||
SET_GAME_STATE (SPATHI_HOME_VISITS, 0);
|
||||
SET_GAME_STATE (SPATHI_VISITS, 0);
|
||||
|
||||
@@ -192,6 +192,9 @@ ExitConversation (RESPONSE_REF Response)
|
||||
|
||||
AlienTalkSegue ((COUNT)~0);
|
||||
ActivateStarShip (SPATHI_SHIP, 1);
|
||||
/* Make the Eluder escort captained by Fwiffo alone */
|
||||
SetEscortCrewComplement (SPATHI_SHIP, 1,
|
||||
NAME_OFFSET + NUM_CAPTAINS_NAMES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ Intro (void)
|
||||
{
|
||||
case 0:
|
||||
NPCPhrase (HELLO_AFTER_AMBUSH_1);
|
||||
ActivateStarShip (SYREEN_SHIP, 0);
|
||||
ActivateStarShip (SYREEN_SHIP, SET_ALLIED);
|
||||
break;
|
||||
case 1:
|
||||
NPCPhrase (HELLO_AFTER_AMBUSH_2);
|
||||
|
||||
@@ -499,7 +499,7 @@ ThraddWorship (RESPONSE_REF R)
|
||||
SET_GAME_STATE (THRADD_VISITS, 0);
|
||||
SET_GAME_STATE (THRADD_MANNER, 1);
|
||||
SET_GAME_STATE (THRADD_STACK_1, 0);
|
||||
ActivateStarShip (THRADDASH_SHIP, 0);
|
||||
ActivateStarShip (THRADDASH_SHIP, SET_ALLIED);
|
||||
|
||||
Response (be_polite, ThraddCulture);
|
||||
Response (speak_pig_latin, ThraddCulture);
|
||||
|
||||
@@ -284,8 +284,8 @@ ExitConversation (RESPONSE_REF R)
|
||||
SET_GAME_STATE (SUPOX_HOSTILE, 0);
|
||||
SET_GAME_STATE (UTWIG_HOSTILE, 0);
|
||||
|
||||
ActivateStarShip (UTWIG_SHIP, 0);
|
||||
ActivateStarShip (SUPOX_SHIP, 0);
|
||||
ActivateStarShip (UTWIG_SHIP, SET_ALLIED);
|
||||
ActivateStarShip (SUPOX_SHIP, SET_ALLIED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ ExitConversation (RESPONSE_REF R)
|
||||
NPCPhrase_cb (WE_ALLY4, &SelectAlienZOQ);
|
||||
NPCPhrase_cb (WE_ALLY5, &SelectAlienPIK);
|
||||
ZFPTalkSegue ((COUNT)~0);
|
||||
ActivateStarShip (ZOQFOTPIK_SHIP, 0);
|
||||
ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED);
|
||||
AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT);
|
||||
SET_GAME_STATE (ZOQFOT_HOME_VISITS, 0);
|
||||
}
|
||||
@@ -717,7 +717,7 @@ ZoqFotHome (RESPONSE_REF R)
|
||||
NPCPhrase_cb (GOOD9, &SelectAlienPIK);
|
||||
ZFPTalkSegue ((COUNT)~0);
|
||||
|
||||
ActivateStarShip (ZOQFOTPIK_SHIP, 0);
|
||||
ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED);
|
||||
AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT);
|
||||
}
|
||||
else if (PLAYER_SAID (R, enough_info))
|
||||
|
||||
@@ -120,7 +120,7 @@ EventHandler (BYTE selector)
|
||||
}
|
||||
break;
|
||||
case SHOFIXTI_RETURN_EVENT:
|
||||
ActivateStarShip (SHOFIXTI_SHIP, 0);
|
||||
ActivateStarShip (SHOFIXTI_SHIP, SET_ALLIED);
|
||||
GLOBAL (CrewCost) -= 2;
|
||||
/* crew is not an issue anymore */
|
||||
SET_GAME_STATE (CREW_PURCHASED0, 0);
|
||||
@@ -146,7 +146,7 @@ EventHandler (BYTE selector)
|
||||
|
||||
if (SpathiPtr->ShipInfo.actual_strength)
|
||||
{
|
||||
ActivateStarShip (SPATHI_SHIP, -1);
|
||||
ActivateStarShip (SPATHI_SHIP, SET_NOT_ALLIED);
|
||||
SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1);
|
||||
SpathiPtr->ShipInfo.actual_strength = 0;
|
||||
}
|
||||
@@ -599,7 +599,7 @@ ilwrath_mission (void)
|
||||
|
||||
SET_GAME_STATE (THRADD_VISITS, 0);
|
||||
if (ThraddPtr->ShipInfo.ship_flags & GOOD_GUY)
|
||||
ActivateStarShip (THRADDASH_SHIP, -1);
|
||||
ActivateStarShip (THRADDASH_SHIP, SET_NOT_ALLIED);
|
||||
}
|
||||
|
||||
ThraddState = GET_GAME_STATE (THRADD_MISSION);
|
||||
|
||||
@@ -305,7 +305,7 @@ InitSIS (void)
|
||||
MAX_BUILT_SHIPS, sizeof (SHIP_FRAGMENT));
|
||||
InitQueue (&GLOBAL (npc_built_ship_q),
|
||||
(MAX_BATTLE_GROUPS >> 1), sizeof (SHIP_FRAGMENT));
|
||||
InitQueue (&GLOBAL (encounter_q), 16, sizeof (ENCOUNTER));
|
||||
InitQueue (&GLOBAL (encounter_q), MAX_ENCOUNTERS, sizeof (ENCOUNTER));
|
||||
|
||||
GLOBAL (CurrentActivity) = IN_INTERPLANETARY | START_INTERPLANETARY;
|
||||
|
||||
@@ -329,7 +329,7 @@ InitSIS (void)
|
||||
sizeof (GLOBAL_SIS (CommanderName)),
|
||||
GAME_STRING (NAMING_STRING_BASE + 3));
|
||||
|
||||
ActivateStarShip (HUMAN_SHIP, 0);
|
||||
ActivateStarShip (HUMAN_SHIP, SET_ALLIED);
|
||||
CloneShipFragment (HUMAN_SHIP, &GLOBAL (built_ship_q), 0);
|
||||
|
||||
GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (SOL_X);
|
||||
|
||||
@@ -942,12 +942,20 @@ typedef struct
|
||||
|
||||
DWORD BattleGroupRef;
|
||||
QUEUE avail_race_q;
|
||||
/* List of all the races in the game with information
|
||||
* about their ships, and what player knows about their
|
||||
* fleet, center of SoI, status, etc.
|
||||
* queue element is EXTENDED_SHIP_FRAGMENT */
|
||||
QUEUE npc_built_ship_q;
|
||||
// Non-player-character list of ships (during encounter)
|
||||
// or list of groups present in solarsys (during IP)
|
||||
/* Non-player-character list of ships (during encounter)
|
||||
* or list of groups present in solarsys (during IP);
|
||||
* queue element is SHIP_FRAGMENT */
|
||||
QUEUE encounter_q;
|
||||
/* List of HyperSpace encounters (black globes);
|
||||
* queue element is ENCOUNTER */
|
||||
QUEUE built_ship_q;
|
||||
/* Queue of SIS escort ships */
|
||||
/* List of SIS escort ships;
|
||||
* queue element is SHIP_FRAGMENT */
|
||||
|
||||
BYTE GameState[(NUM_GAME_STATE_BITS + 7) >> 3];
|
||||
} GAME_STATE;
|
||||
@@ -962,6 +970,7 @@ extern GLOBDATA GlobData;
|
||||
#define GLOBAL(f) GlobData.Game_state.f
|
||||
#define GLOBAL_SIS(f) GlobData.SIS_state.f
|
||||
|
||||
#define MAX_ENCOUNTERS 16
|
||||
|
||||
//#define STATE_DEBUG
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
QUEUE master_q;
|
||||
|
||||
void
|
||||
LoadMasterShipList (void)
|
||||
LoadMasterShipList (void (* YieldProcessing)(void))
|
||||
{
|
||||
COUNT num_entries;
|
||||
RES_TYPE rt;
|
||||
@@ -37,7 +37,8 @@ LoadMasterShipList (void)
|
||||
rt = GET_TYPE (ARILOU_SHIP_INDEX);
|
||||
ri = GET_INSTANCE (ARILOU_SHIP_INDEX);
|
||||
rp = GET_PACKAGE (ARILOU_SHIP_INDEX);
|
||||
InitQueue (&master_q, num_entries = NUM_MELEE_SHIPS, sizeof (SHIP_FRAGMENT));
|
||||
num_entries = NUM_MELEE_SHIPS;
|
||||
InitQueue (&master_q, num_entries, sizeof (SHIP_FRAGMENT));
|
||||
while (num_entries--)
|
||||
{
|
||||
HSTARSHIP hBuiltShip;
|
||||
@@ -50,8 +51,10 @@ LoadMasterShipList (void)
|
||||
STARSHIP *BuiltShipPtr;
|
||||
SHIP_INFO *ShipInfoPtr;
|
||||
|
||||
TaskSwitch ();
|
||||
// XXX: what is this doing here?
|
||||
// Allow other things to run
|
||||
// supposedly, loading ship packages and data takes some time
|
||||
if (YieldProcessing)
|
||||
YieldProcessing ();
|
||||
|
||||
BuiltShipPtr = LockStarShip (&master_q, hBuiltShip);
|
||||
load_ship (BuiltShipPtr, FALSE);
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
#include "races.h"
|
||||
#include "libs/compiler.h"
|
||||
|
||||
extern QUEUE master_q;
|
||||
/* List of all ships present in the game;
|
||||
* queue element is SHIP_FRAGMENT */
|
||||
|
||||
extern void LoadMasterShipList (void);
|
||||
extern void LoadMasterShipList (void (* YieldProcessing)(void));
|
||||
extern void FreeMasterShipList (void);
|
||||
extern HSTARSHIP FindMasterShip (DWORD ship_ref);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#endif
|
||||
#include "options.h"
|
||||
#include "races.h"
|
||||
#include "master.h"
|
||||
#include "resinst.h"
|
||||
#include "save.h"
|
||||
#include "settings.h"
|
||||
@@ -191,7 +192,6 @@ static FRAME MeleeFrame;
|
||||
// Loaded from melee/melebkgd.ani
|
||||
static FRAME BuildPickFrame;
|
||||
// Constructed.
|
||||
extern QUEUE master_q;
|
||||
DWORD InTime;
|
||||
MELEE_STATE *pMeleeState;
|
||||
|
||||
|
||||
@@ -113,14 +113,19 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
UWORD ship_flags;
|
||||
/* Also: group_counter */
|
||||
BYTE var1;
|
||||
/* Also: ship_cost, race_id */
|
||||
BYTE var2;
|
||||
/* Also: group loc and mission, ship's queue index */
|
||||
COUNT crew_level;
|
||||
/* For ships in npc_built_ship_q, the value INFINITE_FLEET for
|
||||
* crew_level indicates an infinite number of ships. */
|
||||
COUNT max_crew;
|
||||
BYTE energy_level;
|
||||
/* Also: group destination and orbit loc, */
|
||||
BYTE max_energy;
|
||||
/* Also: group_id */
|
||||
POINT loc;
|
||||
|
||||
/* The fields above this line are included in queues in savegames,
|
||||
@@ -169,6 +174,7 @@ enum
|
||||
#define STATION_RADIUS 1600
|
||||
#define ORBIT_RADIUS 2400
|
||||
|
||||
/* XXX: overloads SHIP_INFO */
|
||||
typedef struct
|
||||
{
|
||||
UWORD ship_flags;
|
||||
@@ -233,6 +239,8 @@ typedef void (UNINIT_FUNC) (RACE_DESC *pRaceDesc);
|
||||
|
||||
struct race_desc
|
||||
{
|
||||
/* XXX: SHIP_INFO *must* currently be the first field in the struct.
|
||||
* See why in comments of EXTENDED_SHIP_FRAGMENT. */
|
||||
SHIP_INFO ship_info _ALIGNED_ANY;
|
||||
CHARACTERISTIC_STUFF characteristics _ALIGNED_ANY;
|
||||
DATA_STUFF ship_data _ALIGNED_ANY;
|
||||
@@ -253,6 +261,12 @@ struct race_desc
|
||||
|
||||
typedef QUEUE_HANDLE HSTARSHIP;
|
||||
|
||||
/* XXX: STARSHIP, SHIP_FRAGMENT and EXTENDED_SHIP_FRAGMENT are inter-cast
|
||||
* to each other in many places. Some of those are unsafe and potentially
|
||||
* destructive if the code is changed later.
|
||||
* Currently, the first 4 members of each struct MUST remain the same,
|
||||
* the first 2 being the queue links.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
HSTARSHIP pred;
|
||||
@@ -316,13 +330,20 @@ typedef struct
|
||||
SHIP_INFO ShipInfo;
|
||||
} SHIP_FRAGMENT;
|
||||
|
||||
/* XXX: overloads SHIP_FRAGMENT */
|
||||
typedef struct
|
||||
{
|
||||
HSTARSHIP pred;
|
||||
HSTARSHIP succ;
|
||||
|
||||
DWORD RaceResIndex;
|
||||
|
||||
/* This field is set to actually point to struct's own EXTENDED_SHIP_INFO
|
||||
* instead of a RACE_DESC when GLOBAL(avail_race_q) is initialized
|
||||
* [see InitSIS]. For this reason, RACE_DESC must maintain a SHIP_INFO
|
||||
* as the first member. */
|
||||
RACE_DESC *RaceDescPtr;
|
||||
|
||||
EXTENDED_SHIP_INFO ShipInfo;
|
||||
} EXTENDED_SHIP_FRAGMENT;
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ extern Mutex GraphicsLock;
|
||||
extern CondVar RenderingCond;
|
||||
|
||||
extern QUEUE race_q[];
|
||||
/* Array of lists of ships involved in a battle, one queue per side;
|
||||
* queue element is STARSHIP */
|
||||
|
||||
extern ACTIVITY LastActivity;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "gameopt.h"
|
||||
#include "gamestr.h"
|
||||
#include "melee.h"
|
||||
#include "master.h"
|
||||
#include "options.h"
|
||||
#include "races.h"
|
||||
#include "nameref.h"
|
||||
@@ -128,7 +129,6 @@ SpinStarShip (HSTARSHIP hStarShip)
|
||||
COUNT Index;
|
||||
HSTARSHIP hNextShip, hShip;
|
||||
STARSHIP *StarShipPtr;
|
||||
extern QUEUE master_q;
|
||||
|
||||
StarShipPtr = LockStarShip (&GLOBAL (built_ship_q), hStarShip);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ arilou_gate_task(void *data)
|
||||
static void
|
||||
BackgroundInitKernel (DWORD TimeOut)
|
||||
{
|
||||
LoadMasterShipList ();
|
||||
LoadMasterShipList (TaskSwitch);
|
||||
TaskSwitch ();
|
||||
InitGameKernel ();
|
||||
|
||||
|
||||
@@ -68,7 +68,9 @@ debugKeyPressed (void)
|
||||
instantMove = !instantMove;
|
||||
showSpheres ();
|
||||
activateAllShips ();
|
||||
// forwardToNextEvent (TRUE);
|
||||
// forwardToNextEvent (TRUE);
|
||||
// SET_GAME_STATE (MELNORME_CREDIT1, 100);
|
||||
// GLOBAL_SIS (ResUnits) = 100000;
|
||||
|
||||
// Tests
|
||||
// Scale_PerfTest ();
|
||||
|
||||
Reference in New Issue
Block a user