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:
avolkov
2007-05-31 08:59:15 +00:00
parent 6db566e8a8
commit c9095d9793
22 changed files with 318 additions and 251 deletions
+114 -97
View File
@@ -89,26 +89,27 @@ GetStarShipFromIndex (QUEUE *pShipQ, COUNT Index)
* CHECK_ALLIANCE: * CHECK_ALLIANCE:
* Test the alliance status of the race of 'which_ship'. * Test the alliance status of the race of 'which_ship'.
* Either GOOD_GUY (allied) or BAD_GUY (not allied) is returned. * 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 * Ally with the race of 'which_ship'. This makes their ship available
* for building in the shipyard. * for building in the shipyard.
* -1: * SET_NOT_ALLIED:
* End an alliance with the race of 'which_ship'. This ends the possibility * 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 * of building their ships in the shipyard.
* player has with him will disappear. * 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: * 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 COUNT
ActivateStarShip (COUNT which_ship, SIZE state) ActivateStarShip (COUNT which_ship, SIZE state)
{ {
HSTARSHIP hStarShip, hNextShip; HSTARSHIP hStarShip, hNextShip;
hStarShip = GetStarShipFromIndex ( hStarShip = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_ship);
&GLOBAL (avail_race_q), which_ship if (!hStarShip)
); return 0;
if (hStarShip)
{
switch (state) switch (state)
{ {
case SPHERE_TRACKING: case SPHERE_TRACKING:
@@ -122,16 +123,14 @@ ActivateStarShip (COUNT which_ship, SIZE state)
which_ship = StarShipPtr->ShipInfo.known_strength; which_ship = StarShipPtr->ShipInfo.known_strength;
else if (StarShipPtr->ShipInfo.actual_strength == 0) else if (StarShipPtr->ShipInfo.actual_strength == 0)
{ {
if (!(StarShipPtr->ShipInfo.ship_flags if (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)))
& (GOOD_GUY | BAD_GUY)))
which_ship = 0; which_ship = 0;
} }
else if (StarShipPtr->ShipInfo.known_strength == 0 else if (StarShipPtr->ShipInfo.known_strength == 0
&& StarShipPtr->ShipInfo.actual_strength != (COUNT)~0) && StarShipPtr->ShipInfo.actual_strength != (COUNT)~0)
{ {
StarShipPtr->ShipInfo.known_strength = 1; StarShipPtr->ShipInfo.known_strength = 1;
StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.loc;
StarShipPtr->ShipInfo.loc;
} }
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip); UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
return (which_ship); return (which_ship);
@@ -171,108 +170,100 @@ ActivateStarShip (COUNT which_ship, SIZE state)
ship_type = GET_RACE_ID (StarShipPtr); ship_type = GET_RACE_ID (StarShipPtr);
UnlockStarShip (&GLOBAL (built_ship_q), hStarShip); UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
if ((COUNT) ship_type == which_ship) if (ship_type == which_ship)
return 1; return 1;
} }
return 0; return 0;
} }
case FEASIBILITY_STUDY: case FEASIBILITY_STUDY:
return (MAX_BUILT_SHIPS
- CountLinks (&GLOBAL (built_ship_q)));
default:
{ {
SHIP_FRAGMENT *StarShipPtr; return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q)));
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 case CHECK_ALLIANCE:
& (GOOD_GUY | BAD_GUY))
{ {
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 (!(StarShipPtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY)))
{ /* Strange request, silently ignore it */
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
break;
}
StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY); StarShipPtr->ShipInfo.ship_flags &= ~(GOOD_GUY | BAD_GUY);
if (state == 0) if (state == SET_ALLIED)
StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY; StarShipPtr->ShipInfo.ship_flags |= GOOD_GUY;
else else
{
StarShipPtr->ShipInfo.ship_flags |= BAD_GUY; StarShipPtr->ShipInfo.ship_flags |= BAD_GUY;
if (which_ship == ORZ_SHIP)
{
BOOLEAN ShipRemoved;
ShipRemoved = FALSE; UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
for (hStarShip = GetHeadLink ( break;
&GLOBAL (built_ship_q)); }
case REMOVE_BUILT:
{
BOOLEAN ShipRemoved = FALSE;
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q));
hStarShip; hStarShip = hNextShip) hStarShip; hStarShip = hNextShip)
{ {
BOOLEAN RemoveShip; BOOLEAN RemoveShip;
SHIP_FRAGMENT *StarShipPtr2; SHIP_FRAGMENT *StarShipPtr;
StarShipPtr2 = StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
(SHIP_FRAGMENT*) LockStarShip (
&GLOBAL (built_ship_q), hStarShip); &GLOBAL (built_ship_q), hStarShip);
hNextShip = _GetSuccLink (StarShipPtr2); hNextShip = _GetSuccLink (StarShipPtr);
RemoveShip = (BOOLEAN) ( RemoveShip = (GET_RACE_ID (StarShipPtr) == which_ship);
GET_RACE_ID (StarShipPtr2) == UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
ORZ_SHIP);
UnlockStarShip (&GLOBAL (built_ship_q),
hStarShip);
if (RemoveShip) if (RemoveShip)
{ {
ShipRemoved = TRUE; ShipRemoved = TRUE;
RemoveQueue (&GLOBAL (built_ship_q), RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
hStarShip); FreeStarShip (&GLOBAL (built_ship_q), hStarShip);
FreeStarShip (&GLOBAL (built_ship_q),
hStarShip);
} }
} }
if (ShipRemoved) if (ShipRemoved)
{ {
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA,
UNDEFINED_DELTA, UNDEFINED_DELTA); UNDEFINED_DELTA);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
} }
break;
} }
} default:
}
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
}
else
{ {
/* 'state > 0', add ships to the escorts */
BYTE which_window; BYTE which_window;
COUNT i; COUNT i;
assert (state > 0);
/* Add ships to the escorts */
which_window = 0; which_window = 0;
for (i = 0; i < (COUNT)state; i++) for (i = 0; i < (COUNT)state; i++)
{ {
HSTARSHIP hOldShip; HSTARSHIP hOldShip;
BYTE crewLevel; SHIP_FRAGMENT *StarShipPtr;
if (which_ship == SPATHI_SHIP && hStarShip = CloneShipFragment ((COUNT) which_ship,
GET_GAME_STATE (FOUND_PLUTO_SPATHI) == 1) &GLOBAL (built_ship_q), 0);
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) if (!hStarShip)
break; break;
RemoveQueue (&GLOBAL (built_ship_q), hStarShip); RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
/* Find first available escort window */
while ((hOldShip = GetStarShipFromIndex ( while ((hOldShip = GetStarShipFromIndex (
&GLOBAL (built_ship_q), which_window++))) &GLOBAL (built_ship_q), which_window++)))
{ {
@@ -281,8 +272,7 @@ ActivateStarShip (COUNT which_ship, SIZE state)
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip ( StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
&GLOBAL (built_ship_q), hOldShip); &GLOBAL (built_ship_q), hOldShip);
win_loc = GET_GROUP_LOC (StarShipPtr); win_loc = GET_GROUP_LOC (StarShipPtr);
UnlockStarShip (&GLOBAL (built_ship_q), UnlockStarShip (&GLOBAL (built_ship_q), hOldShip);
hOldShip);
if (which_window <= win_loc) if (which_window <= win_loc)
break; break;
} }
@@ -290,32 +280,20 @@ ActivateStarShip (COUNT which_ship, SIZE state)
StarShipPtr = (SHIP_FRAGMENT*) LockStarShip ( StarShipPtr = (SHIP_FRAGMENT*) LockStarShip (
&GLOBAL (built_ship_q), hStarShip); &GLOBAL (built_ship_q), hStarShip);
SET_GROUP_LOC (StarShipPtr, which_window - 1); 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); UnlockStarShip (&GLOBAL (built_ship_q), hStarShip);
InsertQueue (&GLOBAL (built_ship_q), hStarShip, InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip);
hOldShip);
} }
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
DeltaSISGauges (UNDEFINED_DELTA, DeltaSISGauges (UNDEFINED_DELTA,
UNDEFINED_DELTA, UNDEFINED_DELTA); UNDEFINED_DELTA, UNDEFINED_DELTA);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
return (i); return i;
}
break;
} }
} }
return 1; return 1;
}
return 0;
} }
COUNT COUNT
@@ -362,13 +340,9 @@ NameCaptain (QUEUE *pQueue, STARSHIP *StarShipPtr)
BOOLEAN SameName; BOOLEAN SameName;
if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE) if (LOBYTE (GLOBAL (CurrentActivity)) == SUPER_MELEE)
SameName = (BOOLEAN)( SameName = (name_index == TestShipPtr->captains_name_index);
name_index == TestShipPtr->captains_name_index
);
else else
SameName = (BOOLEAN)( SameName = (name_index == StarShipCaptain (TestShipPtr));
name_index == StarShipCaptain (TestShipPtr)
);
if (SameName) if (SameName)
{ {
@@ -397,9 +371,7 @@ CloneShipFragment (COUNT shipIndex, QUEUE *pDstQueue, COUNT crew_level)
TemplatePtr = (SHIP_FRAGMENT*) LockStarShip ( TemplatePtr = (SHIP_FRAGMENT*) LockStarShip (
&GLOBAL (avail_race_q), hStarShip); &GLOBAL (avail_race_q), hStarShip);
hBuiltShip = hBuiltShip = Build (pDstQueue, TemplatePtr->RaceResIndex,
Build (pDstQueue,
TemplatePtr->RaceResIndex,
TemplatePtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY), TemplatePtr->ShipInfo.ship_flags & (GOOD_GUY | BAD_GUY),
(BYTE)(shipIndex == SAMATRA_SHIP ? (BYTE)(shipIndex == SAMATRA_SHIP ?
0 : NameCaptain (pDstQueue, (STARSHIP*)TemplatePtr))); 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.crew_level = crew_level;
ShipFragPtr->ShipInfo.energy_level = 0; ShipFragPtr->ShipInfo.energy_level = 0;
ShipFragPtr->ShipInfo.ship_flags = 0; ShipFragPtr->ShipInfo.ship_flags = 0;
ShipFragPtr->ShipInfo.var1 = ShipFragPtr->ShipInfo.var2 = 0; ShipFragPtr->ShipInfo.var1 = 0;
ShipFragPtr->ShipInfo.loc.x = ShipFragPtr->ShipInfo.loc.y = 0; ShipFragPtr->ShipInfo.var2 = 0;
ShipFragPtr->ShipInfo.loc.x = 0;
ShipFragPtr->ShipInfo.loc.y = 0;
SET_RACE_ID (ShipFragPtr, (BYTE)shipIndex); SET_RACE_ID (ShipFragPtr, (BYTE)shipIndex);
UnlockStarShip (pDstQueue, hBuiltShip); UnlockStarShip (pDstQueue, hBuiltShip);
} }
@@ -423,3 +397,46 @@ CloneShipFragment (COUNT shipIndex, QUEUE *pDstQueue, COUNT crew_level)
return hBuiltShip; 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;
}
+10 -5
View File
@@ -55,16 +55,21 @@ extern BYTE NameCaptain (QUEUE *pQueue, STARSHIP *StarShipPtr);
* COUNT ActivateStarShip (COUNT which_ship, SIZE state) * COUNT ActivateStarShip (COUNT which_ship, SIZE state)
* See that function for more information. * See that function for more information.
*/ */
#define SET_ALLIED 0
#define SET_NOT_ALLIED -1
#define CHECK_ALLIANCE -2 #define CHECK_ALLIANCE -2
#define ESCORT_WORTH 9995 #define REMOVE_BUILT -3
#define SPHERE_KNOWN 9996 #define ESCORT_WORTH -4
#define SPHERE_TRACKING 9997 #define SPHERE_KNOWN -5
#define ESCORTING_FLAGSHIP 9998 #define SPHERE_TRACKING -6
#define FEASIBILITY_STUDY 9999 #define ESCORTING_FLAGSHIP -7
#define FEASIBILITY_STUDY -8
/* Check for how many escort ships there's still space */ /* Check for how many escort ships there's still space */
extern COUNT ActivateStarShip (COUNT which_ship, SIZE state); extern COUNT ActivateStarShip (COUNT which_ship, SIZE state);
extern COUNT GetIndexFromStarShip (QUEUE *pShipQ, HSTARSHIP hStarShip); 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 extern MEM_HANDLE load_ship (STARSHIP *StarShipPtr, BOOLEAN
LoadBattleData); LoadBattleData);
+1
View File
@@ -39,6 +39,7 @@ typedef struct
DWORD TimeCounter; DWORD TimeCounter;
QUEUE event_q; QUEUE event_q;
/* Queue element is EVENT */
} CLOCK_STATE; } CLOCK_STATE;
typedef QUEUE_HANDLE HEVENT; typedef QUEUE_HANDLE HEVENT;
+3 -3
View File
@@ -128,7 +128,7 @@ ExitConversation (RESPONSE_REF R)
NPCPhrase (TAKE_2_WEEKS); NPCPhrase (TAKE_2_WEEKS);
ActivateStarShip (CHMMR_SHIP, 0); ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
SET_GAME_STATE (CHMMR_HOME_VISITS, 0); SET_GAME_STATE (CHMMR_HOME_VISITS, 0);
SET_GAME_STATE (CHMMR_STACK, 0); SET_GAME_STATE (CHMMR_STACK, 0);
@@ -239,7 +239,7 @@ NotReady (RESPONSE_REF R)
{ {
NPCPhrase (USE_OUR_SHIPS_BEFORE); NPCPhrase (USE_OUR_SHIPS_BEFORE);
ActivateStarShip (CHMMR_SHIP, 0); ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
} }
else if (PLAYER_SAID (R, where_weapon)) else if (PLAYER_SAID (R, where_weapon))
{ {
@@ -292,7 +292,7 @@ ImproveBomb (RESPONSE_REF R)
{ {
NPCPhrase (USE_OUR_SHIPS_AFTER); NPCPhrase (USE_OUR_SHIPS_AFTER);
ActivateStarShip (CHMMR_SHIP, 0); ActivateStarShip (CHMMR_SHIP, SET_ALLIED);
} }
if (PHRASE_ENABLED (what_now)) if (PHRASE_ENABLED (what_now))
+9 -8
View File
@@ -208,7 +208,7 @@ ExitConversation (RESPONSE_REF R)
SET_GAME_STATE (ORZ_GENERAL_INFO, 0); SET_GAME_STATE (ORZ_GENERAL_INFO, 0);
SET_GAME_STATE (ORZ_PERSONAL_INFO, 0); SET_GAME_STATE (ORZ_PERSONAL_INFO, 0);
SET_GAME_STATE (ORZ_MANNER, 3); SET_GAME_STATE (ORZ_MANNER, 3);
ActivateStarShip (ORZ_SHIP, 0); ActivateStarShip (ORZ_SHIP, SET_ALLIED);
} }
else if (PLAYER_SAID (R, demand_to_land)) 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 (ORZ_MANNER, 2);
SET_GAME_STATE (BATTLE_SEGUE, 1); SET_GAME_STATE (BATTLE_SEGUE, 1);
if (PLAYER_SAID (R, about_andro_3)) if (PLAYER_SAID (R, about_andro_3))
ActivateStarShip (ORZ_SHIP, -1); {
ActivateStarShip (ORZ_SHIP, SET_NOT_ALLIED);
ActivateStarShip (ORZ_SHIP, REMOVE_BUILT);
}
XFormColorMap (GetColorMapAddress ( XFormColorMap (GetColorMapAddress (
SetAbsColorMapIndex (CommData.AlienColorMap, 1) SetAbsColorMapIndex (CommData.AlienColorMap, 1)
@@ -314,9 +317,8 @@ TaaloWorld (RESPONSE_REF R)
if (PHRASE_ENABLED (may_we_land)) if (PHRASE_ENABLED (may_we_land))
{ {
if (Manner == 3 && (ActivateStarShip ( if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE)
ORZ_SHIP, CHECK_ALLIANCE & GOOD_GUY))
) & GOOD_GUY))
Response (may_we_land, ExitConversation); Response (may_we_land, ExitConversation);
else else
Response (may_we_land, TaaloWorld); Response (may_we_land, TaaloWorld);
@@ -698,9 +700,8 @@ Intro (void)
TaaloWorld ((RESPONSE_REF)0); TaaloWorld ((RESPONSE_REF)0);
} }
else if (Manner == 3 && (ActivateStarShip ( else if (Manner == 3 && (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE)
ORZ_SHIP, CHECK_ALLIANCE & GOOD_GUY))
) & GOOD_GUY))
{ {
if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7))
{ {
+1 -1
View File
@@ -247,7 +247,7 @@ ExitConversation (RESPONSE_REF R)
{ {
NPCPhrase (DEPART_FOR_EARTH); NPCPhrase (DEPART_FOR_EARTH);
ActivateStarShip (SPATHI_SHIP, 0); ActivateStarShip (SPATHI_SHIP, SET_ALLIED);
AddEvent (RELATIVE_EVENT, 6, 0, 0, SPATHI_SHIELD_EVENT); AddEvent (RELATIVE_EVENT, 6, 0, 0, SPATHI_SHIELD_EVENT);
SET_GAME_STATE (SPATHI_HOME_VISITS, 0); SET_GAME_STATE (SPATHI_HOME_VISITS, 0);
SET_GAME_STATE (SPATHI_VISITS, 0); SET_GAME_STATE (SPATHI_VISITS, 0);
+3
View File
@@ -192,6 +192,9 @@ ExitConversation (RESPONSE_REF Response)
AlienTalkSegue ((COUNT)~0); AlienTalkSegue ((COUNT)~0);
ActivateStarShip (SPATHI_SHIP, 1); ActivateStarShip (SPATHI_SHIP, 1);
/* Make the Eluder escort captained by Fwiffo alone */
SetEscortCrewComplement (SPATHI_SHIP, 1,
NAME_OFFSET + NUM_CAPTAINS_NAMES);
} }
} }
} }
+1 -1
View File
@@ -734,7 +734,7 @@ Intro (void)
{ {
case 0: case 0:
NPCPhrase (HELLO_AFTER_AMBUSH_1); NPCPhrase (HELLO_AFTER_AMBUSH_1);
ActivateStarShip (SYREEN_SHIP, 0); ActivateStarShip (SYREEN_SHIP, SET_ALLIED);
break; break;
case 1: case 1:
NPCPhrase (HELLO_AFTER_AMBUSH_2); NPCPhrase (HELLO_AFTER_AMBUSH_2);
+1 -1
View File
@@ -499,7 +499,7 @@ ThraddWorship (RESPONSE_REF R)
SET_GAME_STATE (THRADD_VISITS, 0); SET_GAME_STATE (THRADD_VISITS, 0);
SET_GAME_STATE (THRADD_MANNER, 1); SET_GAME_STATE (THRADD_MANNER, 1);
SET_GAME_STATE (THRADD_STACK_1, 0); SET_GAME_STATE (THRADD_STACK_1, 0);
ActivateStarShip (THRADDASH_SHIP, 0); ActivateStarShip (THRADDASH_SHIP, SET_ALLIED);
Response (be_polite, ThraddCulture); Response (be_polite, ThraddCulture);
Response (speak_pig_latin, ThraddCulture); Response (speak_pig_latin, ThraddCulture);
+2 -2
View File
@@ -284,8 +284,8 @@ ExitConversation (RESPONSE_REF R)
SET_GAME_STATE (SUPOX_HOSTILE, 0); SET_GAME_STATE (SUPOX_HOSTILE, 0);
SET_GAME_STATE (UTWIG_HOSTILE, 0); SET_GAME_STATE (UTWIG_HOSTILE, 0);
ActivateStarShip (UTWIG_SHIP, 0); ActivateStarShip (UTWIG_SHIP, SET_ALLIED);
ActivateStarShip (SUPOX_SHIP, 0); ActivateStarShip (SUPOX_SHIP, SET_ALLIED);
} }
} }
} }
+2 -2
View File
@@ -206,7 +206,7 @@ ExitConversation (RESPONSE_REF R)
NPCPhrase_cb (WE_ALLY4, &SelectAlienZOQ); NPCPhrase_cb (WE_ALLY4, &SelectAlienZOQ);
NPCPhrase_cb (WE_ALLY5, &SelectAlienPIK); NPCPhrase_cb (WE_ALLY5, &SelectAlienPIK);
ZFPTalkSegue ((COUNT)~0); ZFPTalkSegue ((COUNT)~0);
ActivateStarShip (ZOQFOTPIK_SHIP, 0); ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED);
AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT); AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT);
SET_GAME_STATE (ZOQFOT_HOME_VISITS, 0); SET_GAME_STATE (ZOQFOT_HOME_VISITS, 0);
} }
@@ -717,7 +717,7 @@ ZoqFotHome (RESPONSE_REF R)
NPCPhrase_cb (GOOD9, &SelectAlienPIK); NPCPhrase_cb (GOOD9, &SelectAlienPIK);
ZFPTalkSegue ((COUNT)~0); ZFPTalkSegue ((COUNT)~0);
ActivateStarShip (ZOQFOTPIK_SHIP, 0); ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED);
AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT); AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT);
} }
else if (PLAYER_SAID (R, enough_info)) else if (PLAYER_SAID (R, enough_info))
+3 -3
View File
@@ -120,7 +120,7 @@ EventHandler (BYTE selector)
} }
break; break;
case SHOFIXTI_RETURN_EVENT: case SHOFIXTI_RETURN_EVENT:
ActivateStarShip (SHOFIXTI_SHIP, 0); ActivateStarShip (SHOFIXTI_SHIP, SET_ALLIED);
GLOBAL (CrewCost) -= 2; GLOBAL (CrewCost) -= 2;
/* crew is not an issue anymore */ /* crew is not an issue anymore */
SET_GAME_STATE (CREW_PURCHASED0, 0); SET_GAME_STATE (CREW_PURCHASED0, 0);
@@ -146,7 +146,7 @@ EventHandler (BYTE selector)
if (SpathiPtr->ShipInfo.actual_strength) if (SpathiPtr->ShipInfo.actual_strength)
{ {
ActivateStarShip (SPATHI_SHIP, -1); ActivateStarShip (SPATHI_SHIP, SET_NOT_ALLIED);
SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1); SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1);
SpathiPtr->ShipInfo.actual_strength = 0; SpathiPtr->ShipInfo.actual_strength = 0;
} }
@@ -599,7 +599,7 @@ ilwrath_mission (void)
SET_GAME_STATE (THRADD_VISITS, 0); SET_GAME_STATE (THRADD_VISITS, 0);
if (ThraddPtr->ShipInfo.ship_flags & GOOD_GUY) if (ThraddPtr->ShipInfo.ship_flags & GOOD_GUY)
ActivateStarShip (THRADDASH_SHIP, -1); ActivateStarShip (THRADDASH_SHIP, SET_NOT_ALLIED);
} }
ThraddState = GET_GAME_STATE (THRADD_MISSION); ThraddState = GET_GAME_STATE (THRADD_MISSION);
+2 -2
View File
@@ -305,7 +305,7 @@ InitSIS (void)
MAX_BUILT_SHIPS, sizeof (SHIP_FRAGMENT)); MAX_BUILT_SHIPS, sizeof (SHIP_FRAGMENT));
InitQueue (&GLOBAL (npc_built_ship_q), InitQueue (&GLOBAL (npc_built_ship_q),
(MAX_BATTLE_GROUPS >> 1), sizeof (SHIP_FRAGMENT)); (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; GLOBAL (CurrentActivity) = IN_INTERPLANETARY | START_INTERPLANETARY;
@@ -329,7 +329,7 @@ InitSIS (void)
sizeof (GLOBAL_SIS (CommanderName)), sizeof (GLOBAL_SIS (CommanderName)),
GAME_STRING (NAMING_STRING_BASE + 3)); GAME_STRING (NAMING_STRING_BASE + 3));
ActivateStarShip (HUMAN_SHIP, 0); ActivateStarShip (HUMAN_SHIP, SET_ALLIED);
CloneShipFragment (HUMAN_SHIP, &GLOBAL (built_ship_q), 0); CloneShipFragment (HUMAN_SHIP, &GLOBAL (built_ship_q), 0);
GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (SOL_X); GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (SOL_X);
+12 -3
View File
@@ -942,12 +942,20 @@ typedef struct
DWORD BattleGroupRef; DWORD BattleGroupRef;
QUEUE avail_race_q; 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; QUEUE npc_built_ship_q;
// Non-player-character list of ships (during encounter) /* Non-player-character list of ships (during encounter)
// or list of groups present in solarsys (during IP) * or list of groups present in solarsys (during IP);
* queue element is SHIP_FRAGMENT */
QUEUE encounter_q; QUEUE encounter_q;
/* List of HyperSpace encounters (black globes);
* queue element is ENCOUNTER */
QUEUE built_ship_q; 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]; BYTE GameState[(NUM_GAME_STATE_BITS + 7) >> 3];
} GAME_STATE; } GAME_STATE;
@@ -962,6 +970,7 @@ extern GLOBDATA GlobData;
#define GLOBAL(f) GlobData.Game_state.f #define GLOBAL(f) GlobData.Game_state.f
#define GLOBAL_SIS(f) GlobData.SIS_state.f #define GLOBAL_SIS(f) GlobData.SIS_state.f
#define MAX_ENCOUNTERS 16
//#define STATE_DEBUG //#define STATE_DEBUG
+7 -4
View File
@@ -27,7 +27,7 @@
QUEUE master_q; QUEUE master_q;
void void
LoadMasterShipList (void) LoadMasterShipList (void (* YieldProcessing)(void))
{ {
COUNT num_entries; COUNT num_entries;
RES_TYPE rt; RES_TYPE rt;
@@ -37,7 +37,8 @@ LoadMasterShipList (void)
rt = GET_TYPE (ARILOU_SHIP_INDEX); rt = GET_TYPE (ARILOU_SHIP_INDEX);
ri = GET_INSTANCE (ARILOU_SHIP_INDEX); ri = GET_INSTANCE (ARILOU_SHIP_INDEX);
rp = GET_PACKAGE (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--) while (num_entries--)
{ {
HSTARSHIP hBuiltShip; HSTARSHIP hBuiltShip;
@@ -50,8 +51,10 @@ LoadMasterShipList (void)
STARSHIP *BuiltShipPtr; STARSHIP *BuiltShipPtr;
SHIP_INFO *ShipInfoPtr; SHIP_INFO *ShipInfoPtr;
TaskSwitch (); // Allow other things to run
// XXX: what is this doing here? // supposedly, loading ship packages and data takes some time
if (YieldProcessing)
YieldProcessing ();
BuiltShipPtr = LockStarShip (&master_q, hBuiltShip); BuiltShipPtr = LockStarShip (&master_q, hBuiltShip);
load_ship (BuiltShipPtr, FALSE); load_ship (BuiltShipPtr, FALSE);
+4 -1
View File
@@ -20,8 +20,11 @@
#include "races.h" #include "races.h"
#include "libs/compiler.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 void FreeMasterShipList (void);
extern HSTARSHIP FindMasterShip (DWORD ship_ref); extern HSTARSHIP FindMasterShip (DWORD ship_ref);
+1 -1
View File
@@ -38,6 +38,7 @@
#endif #endif
#include "options.h" #include "options.h"
#include "races.h" #include "races.h"
#include "master.h"
#include "resinst.h" #include "resinst.h"
#include "save.h" #include "save.h"
#include "settings.h" #include "settings.h"
@@ -191,7 +192,6 @@ static FRAME MeleeFrame;
// Loaded from melee/melebkgd.ani // Loaded from melee/melebkgd.ani
static FRAME BuildPickFrame; static FRAME BuildPickFrame;
// Constructed. // Constructed.
extern QUEUE master_q;
DWORD InTime; DWORD InTime;
MELEE_STATE *pMeleeState; MELEE_STATE *pMeleeState;
+21
View File
@@ -113,14 +113,19 @@ typedef struct
typedef struct typedef struct
{ {
UWORD ship_flags; UWORD ship_flags;
/* Also: group_counter */
BYTE var1; BYTE var1;
/* Also: ship_cost, race_id */
BYTE var2; BYTE var2;
/* Also: group loc and mission, ship's queue index */
COUNT crew_level; COUNT crew_level;
/* For ships in npc_built_ship_q, the value INFINITE_FLEET for /* For ships in npc_built_ship_q, the value INFINITE_FLEET for
* crew_level indicates an infinite number of ships. */ * crew_level indicates an infinite number of ships. */
COUNT max_crew; COUNT max_crew;
BYTE energy_level; BYTE energy_level;
/* Also: group destination and orbit loc, */
BYTE max_energy; BYTE max_energy;
/* Also: group_id */
POINT loc; POINT loc;
/* The fields above this line are included in queues in savegames, /* The fields above this line are included in queues in savegames,
@@ -169,6 +174,7 @@ enum
#define STATION_RADIUS 1600 #define STATION_RADIUS 1600
#define ORBIT_RADIUS 2400 #define ORBIT_RADIUS 2400
/* XXX: overloads SHIP_INFO */
typedef struct typedef struct
{ {
UWORD ship_flags; UWORD ship_flags;
@@ -233,6 +239,8 @@ typedef void (UNINIT_FUNC) (RACE_DESC *pRaceDesc);
struct race_desc 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; SHIP_INFO ship_info _ALIGNED_ANY;
CHARACTERISTIC_STUFF characteristics _ALIGNED_ANY; CHARACTERISTIC_STUFF characteristics _ALIGNED_ANY;
DATA_STUFF ship_data _ALIGNED_ANY; DATA_STUFF ship_data _ALIGNED_ANY;
@@ -253,6 +261,12 @@ struct race_desc
typedef QUEUE_HANDLE HSTARSHIP; 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 typedef struct
{ {
HSTARSHIP pred; HSTARSHIP pred;
@@ -316,13 +330,20 @@ typedef struct
SHIP_INFO ShipInfo; SHIP_INFO ShipInfo;
} SHIP_FRAGMENT; } SHIP_FRAGMENT;
/* XXX: overloads SHIP_FRAGMENT */
typedef struct typedef struct
{ {
HSTARSHIP pred; HSTARSHIP pred;
HSTARSHIP succ; HSTARSHIP succ;
DWORD RaceResIndex; 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; RACE_DESC *RaceDescPtr;
EXTENDED_SHIP_INFO ShipInfo; EXTENDED_SHIP_INFO ShipInfo;
} EXTENDED_SHIP_FRAGMENT; } EXTENDED_SHIP_FRAGMENT;
+2
View File
@@ -49,6 +49,8 @@ extern Mutex GraphicsLock;
extern CondVar RenderingCond; extern CondVar RenderingCond;
extern QUEUE race_q[]; extern QUEUE race_q[];
/* Array of lists of ships involved in a battle, one queue per side;
* queue element is STARSHIP */
extern ACTIVITY LastActivity; extern ACTIVITY LastActivity;
+1 -1
View File
@@ -23,6 +23,7 @@
#include "gameopt.h" #include "gameopt.h"
#include "gamestr.h" #include "gamestr.h"
#include "melee.h" #include "melee.h"
#include "master.h"
#include "options.h" #include "options.h"
#include "races.h" #include "races.h"
#include "nameref.h" #include "nameref.h"
@@ -128,7 +129,6 @@ SpinStarShip (HSTARSHIP hStarShip)
COUNT Index; COUNT Index;
HSTARSHIP hNextShip, hShip; HSTARSHIP hNextShip, hShip;
STARSHIP *StarShipPtr; STARSHIP *StarShipPtr;
extern QUEUE master_q;
StarShipPtr = LockStarShip (&GLOBAL (built_ship_q), hStarShip); StarShipPtr = LockStarShip (&GLOBAL (built_ship_q), hStarShip);
+1 -1
View File
@@ -84,7 +84,7 @@ arilou_gate_task(void *data)
static void static void
BackgroundInitKernel (DWORD TimeOut) BackgroundInitKernel (DWORD TimeOut)
{ {
LoadMasterShipList (); LoadMasterShipList (TaskSwitch);
TaskSwitch (); TaskSwitch ();
InitGameKernel (); InitGameKernel ();
+2
View File
@@ -69,6 +69,8 @@ debugKeyPressed (void)
showSpheres (); showSpheres ();
activateAllShips (); activateAllShips ();
// forwardToNextEvent (TRUE); // forwardToNextEvent (TRUE);
// SET_GAME_STATE (MELNORME_CREDIT1, 100);
// GLOBAL_SIS (ResUnits) = 100000;
// Tests // Tests
// Scale_PerfTest (); // Scale_PerfTest ();