Untangling ship queues, stage 1: STARSHIP struct abuse cleanup (not complete)
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2777 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -7,14 +7,14 @@ GlobData.Game_state.avail_race_q:
|
|||||||
It contains information about the various races, not really about
|
It contains information about the various races, not really about
|
||||||
specific ships.
|
specific ships.
|
||||||
Filled in InitSIS().
|
Filled in InitSIS().
|
||||||
ShipInfo->RaceDescPtr is an actual pointer.
|
RaceDescPtr is an actual pointer, but to EXTENDED_SHIP_INFO
|
||||||
Several pointers point to within master_q (TODO: more info).
|
and not RACE_DESC
|
||||||
Partially included in savegames.
|
Partially included in savegames.
|
||||||
|
|
||||||
GlobData.Game_state.built_ship_q:
|
GlobData.Game_state.built_ship_q:
|
||||||
The fleet accompanying the flagship.
|
The fleet accompanying the flagship.
|
||||||
Elements are of type SHIP_FRAGMENT.
|
Elements are of type SHIP_FRAGMENT.
|
||||||
ShipInfo->RaceDescPtr is abused to store the captain's name index,
|
RaceDescPtr is abused to store the captain's name index.
|
||||||
and the side that this ship is on (always GOOD_GUY here).
|
and the side that this ship is on (always GOOD_GUY here).
|
||||||
Partially included in savegames.
|
Partially included in savegames.
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@ master_q:
|
|||||||
Elements are of type SHIP_FRAGMENT.
|
Elements are of type SHIP_FRAGMENT.
|
||||||
Sorted on the (abbreviated) race name (see doc/racestrings).
|
Sorted on the (abbreviated) race name (see doc/racestrings).
|
||||||
Filled in LoadMasterShipList().
|
Filled in LoadMasterShipList().
|
||||||
ShipInfo->RaceDescPtr is an actual pointer.
|
RaceDescPtr is an actual pointer, but to SHIP_INFO and not RACE_DESC
|
||||||
|
|
||||||
GlobData.Game_state.npc_built_ship_q:
|
GlobData.Game_state.npc_built_ship_q:
|
||||||
The npc ships in an encounter. Empty when not in an encounter.
|
The npc ships in an encounter. Empty when not in an encounter.
|
||||||
Elements are of type SHIP_FRAGMENT.
|
Elements are of type SHIP_FRAGMENT.
|
||||||
For encounters with an infinite number of ships, the queue consists
|
For encounters with an infinite number of ships, the queue consists
|
||||||
of a single ship with ShipInfo.crew_level set to (BYTE)~0.
|
of a single ship with ShipInfo.crew_level set to (BYTE)~0.
|
||||||
ShipInfo->RaceDescPtr is abused to store the captain's name index,
|
RaceDescPtr is abused to store the captain's name index.
|
||||||
and the side that this ship is on.
|
and the side that this ship is on.
|
||||||
Partially included in savegames.
|
Partially included in savegames.
|
||||||
|
|
||||||
@@ -38,7 +38,9 @@ race_q[NUM_PLAYERS]:
|
|||||||
Contains the ships participating in a battle for each player.
|
Contains the ships participating in a battle for each player.
|
||||||
Elements are of type STARSHIP.
|
Elements are of type STARSHIP.
|
||||||
Filled in BuildBattle().
|
Filled in BuildBattle().
|
||||||
ShipInfo->RaceDescPtr is abused to store the captain's name index,
|
RaceDescPtr is abused to store the captain's name index,
|
||||||
|
until the ship is loaded in spawn_ship(), at which time
|
||||||
|
it becomes an actual pointer to RACE_DESC.
|
||||||
and the side that this ship is on.
|
and the side that this ship is on.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ Build (QUEUE *pQueue, DWORD RaceResIndex, COUNT which_player, BYTE
|
|||||||
{
|
{
|
||||||
HSTARSHIP hNewShip;
|
HSTARSHIP hNewShip;
|
||||||
|
|
||||||
if ((hNewShip = AllocStarShip (pQueue)) != 0)
|
hNewShip = AllocStarShip (pQueue);
|
||||||
|
if (hNewShip != 0)
|
||||||
{
|
{
|
||||||
STARSHIP *StarShipPtr;
|
STARSHIP *StarShipPtr;
|
||||||
|
|
||||||
@@ -256,7 +257,7 @@ ActivateStarShip (COUNT which_ship, SIZE state)
|
|||||||
HSTARSHIP hOldShip;
|
HSTARSHIP hOldShip;
|
||||||
SHIP_FRAGMENT *StarShipPtr;
|
SHIP_FRAGMENT *StarShipPtr;
|
||||||
|
|
||||||
hStarShip = CloneShipFragment ((COUNT) which_ship,
|
hStarShip = CloneShipFragment (which_ship,
|
||||||
&GLOBAL (built_ship_q), 0);
|
&GLOBAL (built_ship_q), 0);
|
||||||
if (!hStarShip)
|
if (!hStarShip)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ extern COUNT GetIndexFromStarShip (QUEUE *pShipQ, HSTARSHIP hStarShip);
|
|||||||
extern int SetEscortCrewComplement (COUNT which_ship, COUNT crew_level,
|
extern int SetEscortCrewComplement (COUNT which_ship, COUNT crew_level,
|
||||||
BYTE captain);
|
BYTE captain);
|
||||||
|
|
||||||
extern MEM_HANDLE load_ship (STARSHIP *StarShipPtr, BOOLEAN
|
extern RACE_DESC *load_ship (DWORD RaceResIndex, BOOLEAN LoadBattleData);
|
||||||
LoadBattleData);
|
extern void free_ship (RACE_DESC *RaceDescPtr, BOOLEAN FreeIconData,
|
||||||
extern void free_ship (STARSHIP *StarShipPtr, BOOLEAN FreeBattleData);
|
BOOLEAN FreeBattleData);
|
||||||
|
|
||||||
extern void DrawCrewFuelString (COORD y, SIZE state);
|
extern void DrawCrewFuelString (COORD y, SIZE state);
|
||||||
extern void ClearShipStatus (COORD y);
|
extern void ClearShipStatus (COORD y);
|
||||||
|
|||||||
@@ -1037,6 +1037,7 @@ tactical_intelligence (COUNT player, STARSHIP *StarShipPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShipMoved = TRUE;
|
ShipMoved = TRUE;
|
||||||
|
/* Disable ship's special completely for the Standard AI */
|
||||||
if (PlayerControl[player] & STANDARD_RATING)
|
if (PlayerControl[player] & STANDARD_RATING)
|
||||||
++StarShipPtr->special_counter;
|
++StarShipPtr->special_counter;
|
||||||
|
|
||||||
|
|||||||
+28
-18
@@ -82,6 +82,7 @@ DoSelectAction (MENU_STATE *pMS)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called by comm code to intialize battle fleets during encounter
|
||||||
void
|
void
|
||||||
BuildBattle (COUNT which_player)
|
BuildBattle (COUNT which_player)
|
||||||
{
|
{
|
||||||
@@ -135,15 +136,19 @@ BuildBattle (COUNT which_player)
|
|||||||
if (hBuiltShip)
|
if (hBuiltShip)
|
||||||
{
|
{
|
||||||
BuiltShipPtr = LockStarShip (&race_q[which_player], hBuiltShip);
|
BuiltShipPtr = LockStarShip (&race_q[which_player], hBuiltShip);
|
||||||
BuiltShipPtr->captains_name_index =
|
BuiltShipPtr->captains_name_index = StarShipCaptain (BuiltShipPtr);
|
||||||
StarShipCaptain (BuiltShipPtr);
|
BuiltShipPtr->which_side = StarShipPlayer (BuiltShipPtr);
|
||||||
BuiltShipPtr->cur_status_flags =
|
|
||||||
StarShipPlayer (BuiltShipPtr);
|
|
||||||
if (FragPtr->ShipInfo.crew_level != INFINITE_FLEET)
|
if (FragPtr->ShipInfo.crew_level != INFINITE_FLEET)
|
||||||
BuiltShipPtr->special_counter = FragPtr->ShipInfo.crew_level;
|
BuiltShipPtr->crew_level = FragPtr->ShipInfo.crew_level;
|
||||||
else /* if infinite ships */
|
else /* if infinite ships */
|
||||||
BuiltShipPtr->special_counter = FragPtr->ShipInfo.max_crew;
|
BuiltShipPtr->crew_level = FragPtr->ShipInfo.max_crew;
|
||||||
BuiltShipPtr->RaceDescPtr = (RACE_DESC*)&FragPtr->ShipInfo;
|
BuiltShipPtr->max_crew = FragPtr->ShipInfo.max_crew;
|
||||||
|
BuiltShipPtr->race_strings = FragPtr->ShipInfo.race_strings;
|
||||||
|
BuiltShipPtr->icons = FragPtr->ShipInfo.icons;
|
||||||
|
BuiltShipPtr->index = FragPtr->ShipInfo.var2;
|
||||||
|
/* This is not technically necessary, but still */
|
||||||
|
BuiltShipPtr->ship_cost = FragPtr->ShipInfo.ship_cost;
|
||||||
|
BuiltShipPtr->RaceDescPtr = 0;
|
||||||
|
|
||||||
UnlockStarShip (&race_q[which_player], hBuiltShip);
|
UnlockStarShip (&race_q[which_player], hBuiltShip);
|
||||||
}
|
}
|
||||||
@@ -156,11 +161,17 @@ BuildBattle (COUNT which_player)
|
|||||||
{
|
{
|
||||||
BuiltShipPtr = LockStarShip (&race_q[0], hBuiltShip);
|
BuiltShipPtr = LockStarShip (&race_q[0], hBuiltShip);
|
||||||
BuiltShipPtr->captains_name_index = StarShipCaptain (BuiltShipPtr);
|
BuiltShipPtr->captains_name_index = StarShipCaptain (BuiltShipPtr);
|
||||||
BuiltShipPtr->cur_status_flags = StarShipPlayer (BuiltShipPtr);
|
BuiltShipPtr->which_side = StarShipPlayer (BuiltShipPtr);
|
||||||
BuiltShipPtr->special_counter = 0;
|
BuiltShipPtr->crew_level = 0;
|
||||||
|
BuiltShipPtr->max_crew = 0;
|
||||||
// Crew will be copied directly from
|
// Crew will be copied directly from
|
||||||
// GLOBAL_SIS (CrewEnlisted) later.
|
// GLOBAL_SIS (CrewEnlisted) later.
|
||||||
|
BuiltShipPtr->race_strings = 0;
|
||||||
|
BuiltShipPtr->icons = 0;
|
||||||
|
BuiltShipPtr->index = -1;
|
||||||
|
BuiltShipPtr->ship_cost = 0;
|
||||||
BuiltShipPtr->energy_counter = MAX_ENERGY_SIZE;
|
BuiltShipPtr->energy_counter = MAX_ENERGY_SIZE;
|
||||||
|
BuiltShipPtr->RaceDescPtr = 0;
|
||||||
UnlockStarShip (&race_q[0], hBuiltShip);
|
UnlockStarShip (&race_q[0], hBuiltShip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,16 +278,16 @@ InitEncounter (void)
|
|||||||
{-44, -27},
|
{-44, -27},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (hStarShip = GetHeadLink (&race_q[1]), i = 0;
|
for (hStarShip = GetHeadLink (&GLOBAL (npc_built_ship_q)), i = 0;
|
||||||
hStarShip && i < 60; hStarShip = hNextShip, ++i)
|
hStarShip && i < 60; hStarShip = hNextShip, ++i)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
STARSHIP *StarShipPtr;
|
SHIP_FRAGMENT *FragPtr;
|
||||||
|
|
||||||
StarShipPtr = LockStarShip (&race_q[1], hStarShip);
|
FragPtr = (SHIP_FRAGMENT *) LockStarShip (
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.crew_level !=
|
&GLOBAL (npc_built_ship_q), hStarShip);
|
||||||
INFINITE_FLEET)
|
if (FragPtr->ShipInfo.crew_level != INFINITE_FLEET)
|
||||||
hNextShip = _GetSuccLink (StarShipPtr);
|
hNextShip = _GetSuccLink (FragPtr);
|
||||||
else /* if infinite ships */
|
else /* if infinite ships */
|
||||||
hNextShip = hStarShip;
|
hNextShip = hStarShip;
|
||||||
|
|
||||||
@@ -293,14 +304,13 @@ InitEncounter (void)
|
|||||||
s.origin.x = COSINE (angle, radius);
|
s.origin.x = COSINE (angle, radius);
|
||||||
s.origin.y = SINE (angle, radius);
|
s.origin.y = SINE (angle, radius);
|
||||||
}
|
}
|
||||||
s.frame = SetAbsFrameIndex (
|
s.frame = SetAbsFrameIndex (FragPtr->ShipInfo.icons, 0);
|
||||||
StarShipPtr->RaceDescPtr->ship_info.icons, 0);
|
|
||||||
GetFrameRect (s.frame, &r);
|
GetFrameRect (s.frame, &r);
|
||||||
s.origin.x += (SIS_SCREEN_WIDTH >> 1) - (r.extent.width >> 1);
|
s.origin.x += (SIS_SCREEN_WIDTH >> 1) - (r.extent.width >> 1);
|
||||||
s.origin.y += (SIS_SCREEN_HEIGHT >> 1) - (r.extent.height >> 1);
|
s.origin.y += (SIS_SCREEN_HEIGHT >> 1) - (r.extent.height >> 1);
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
|
|
||||||
UnlockStarShip (&race_q[1], hStarShip);
|
UnlockStarShip (&GLOBAL (npc_built_ship_q), hStarShip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-12
@@ -218,27 +218,30 @@ InitSIS (void)
|
|||||||
if (i < num_ships - 1)
|
if (i < num_ships - 1)
|
||||||
{
|
{
|
||||||
HSTARSHIP hMasterShip;
|
HSTARSHIP hMasterShip;
|
||||||
STARSHIP *MasterShipPtr;
|
SHIP_FRAGMENT *MasterShipPtr;
|
||||||
|
|
||||||
hMasterShip = FindMasterShip (ship_ref);
|
hMasterShip = FindMasterShip (ship_ref);
|
||||||
MasterShipPtr = LockStarShip (&master_q, hMasterShip);
|
MasterShipPtr = (SHIP_FRAGMENT *) LockStarShip (&master_q,
|
||||||
FragPtr->ShipInfo =
|
hMasterShip);
|
||||||
((SHIP_FRAGMENT*)MasterShipPtr)->ShipInfo;
|
// Grab a copy of loaded icons and strings (not owned)
|
||||||
|
FragPtr->ShipInfo = MasterShipPtr->ShipInfo;
|
||||||
UnlockStarShip (&master_q, hMasterShip);
|
UnlockStarShip (&master_q, hMasterShip);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ur-Quan probe.
|
// Ur-Quan probe.
|
||||||
load_ship ((STARSHIP*)FragPtr, FALSE);
|
RACE_DESC *RDPtr = load_ship (FragPtr->RaceResIndex,
|
||||||
FragPtr->ShipInfo = FragPtr->RaceDescPtr->ship_info;
|
FALSE);
|
||||||
FragPtr->RaceDescPtr->ship_info.melee_icon = 0;
|
if (RDPtr)
|
||||||
FragPtr->RaceDescPtr->ship_info.icons = 0;
|
{ // Grab a copy of loaded icons and strings
|
||||||
FragPtr->RaceDescPtr->ship_info.race_strings = 0;
|
// avail_race_q owns these resources now
|
||||||
free_ship ((STARSHIP*)FragPtr, FALSE);
|
FragPtr->ShipInfo = RDPtr->ship_info;
|
||||||
|
free_ship (RDPtr, FALSE, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FragPtr->ShipInfo.ship_flags = BAD_GUY;
|
|
||||||
ExtFragPtr = (EXTENDED_SHIP_FRAGMENT*)FragPtr;
|
ExtFragPtr = (EXTENDED_SHIP_FRAGMENT*)FragPtr;
|
||||||
|
ExtFragPtr->ShipInfo.ship_flags = BAD_GUY;
|
||||||
ExtFragPtr->ShipInfo.known_strength = 0;
|
ExtFragPtr->ShipInfo.known_strength = 0;
|
||||||
ExtFragPtr->ShipInfo.known_loc = ExtFragPtr->ShipInfo.loc;
|
ExtFragPtr->ShipInfo.known_loc = ExtFragPtr->ShipInfo.loc;
|
||||||
if (FragPtr->ShipInfo.var2 == (BYTE)~0)
|
if (FragPtr->ShipInfo.var2 == (BYTE)~0)
|
||||||
@@ -252,7 +255,7 @@ InitSIS (void)
|
|||||||
ExtFragPtr->ShipInfo.growth_err_term = 255 >> 1;
|
ExtFragPtr->ShipInfo.growth_err_term = 255 >> 1;
|
||||||
ExtFragPtr->ShipInfo.energy_level = 0;
|
ExtFragPtr->ShipInfo.energy_level = 0;
|
||||||
ExtFragPtr->ShipInfo.days_left = 0;
|
ExtFragPtr->ShipInfo.days_left = 0;
|
||||||
FragPtr->RaceDescPtr = (RACE_DESC*)&ExtFragPtr->ShipInfo;
|
ExtFragPtr->ExtShipInfoPtr = &ExtFragPtr->ShipInfo;
|
||||||
|
|
||||||
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
|
||||||
}
|
}
|
||||||
@@ -380,6 +383,8 @@ UninitSIS (void)
|
|||||||
|
|
||||||
// FreeSC2Data ();
|
// FreeSC2Data ();
|
||||||
|
|
||||||
|
// The only resources avail_race_q owns are the Ur-Quan probe's
|
||||||
|
// so free them now
|
||||||
hStarShip = GetTailLink (&GLOBAL (avail_race_q));
|
hStarShip = GetTailLink (&GLOBAL (avail_race_q));
|
||||||
if (hStarShip)
|
if (hStarShip)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -275,12 +275,12 @@ UninitShips (void)
|
|||||||
if (StarShipPtr->RaceDescPtr->uninit_func != NULL)
|
if (StarShipPtr->RaceDescPtr->uninit_func != NULL)
|
||||||
(*StarShipPtr->RaceDescPtr->uninit_func) (
|
(*StarShipPtr->RaceDescPtr->uninit_func) (
|
||||||
StarShipPtr->RaceDescPtr);
|
StarShipPtr->RaceDescPtr);
|
||||||
StarShipPtr->ShipFacing =
|
/* Record crew left after battle */
|
||||||
StarShipPtr->RaceDescPtr->ship_info.var2;
|
StarShipPtr->crew_level =
|
||||||
StarShipPtr->special_counter =
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.crew_level;
|
StarShipPtr->RaceDescPtr->ship_info.crew_level;
|
||||||
SPtr[WHICH_SIDE (ElementPtr->state_flags)] = StarShipPtr;
|
SPtr[WHICH_SIDE (ElementPtr->state_flags)] = StarShipPtr;
|
||||||
free_ship (StarShipPtr, TRUE);
|
free_ship (StarShipPtr->RaceDescPtr, TRUE, TRUE);
|
||||||
|
StarShipPtr->RaceDescPtr = 0;
|
||||||
}
|
}
|
||||||
UnlockElement (hElement);
|
UnlockElement (hElement);
|
||||||
}
|
}
|
||||||
@@ -293,8 +293,10 @@ UninitShips (void)
|
|||||||
else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER
|
else if (LOBYTE (GLOBAL (CurrentActivity)) <= IN_ENCOUNTER
|
||||||
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||||
{
|
{
|
||||||
// XXX: What is the reason for this? At least for SuperMelee,
|
// XXX: This has no purpose for SuperMelee
|
||||||
// it has no purpose (it will return immediately).
|
// In full-game, the sole purpose of this is to record the crew
|
||||||
|
// left in the last ship standing. The crew left is first recorded
|
||||||
|
// into STARSHIP.crew_level just a few lines above here.
|
||||||
for (i = NUM_PLAYERS - 1; i >= 0; --i)
|
for (i = NUM_PLAYERS - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (SPtr[i])
|
if (SPtr[i])
|
||||||
|
|||||||
+42
-53
@@ -23,65 +23,51 @@
|
|||||||
#include "races.h"
|
#include "races.h"
|
||||||
|
|
||||||
|
|
||||||
MEM_HANDLE
|
RACE_DESC *
|
||||||
load_ship (STARSHIP *StarShipPtr, BOOLEAN LoadBattleData)
|
load_ship (DWORD RaceResIndex, BOOLEAN LoadBattleData)
|
||||||
{
|
{
|
||||||
BOOLEAN retval;
|
|
||||||
MEM_HANDLE h;
|
MEM_HANDLE h;
|
||||||
|
RACE_DESC *RDPtr = 0;
|
||||||
h = OpenResourceIndexInstance (StarShipPtr->RaceResIndex);
|
|
||||||
|
|
||||||
retval = FALSE;
|
|
||||||
if (h)
|
|
||||||
{
|
|
||||||
#define INITIAL_CODE_RES MAKE_RESOURCE (1, CODE, 0)
|
#define INITIAL_CODE_RES MAKE_RESOURCE (1, CODE, 0)
|
||||||
BYTE captains_name_index;
|
|
||||||
void *CodeRef;
|
void *CodeRef;
|
||||||
MEM_HANDLE hOldIndex;
|
MEM_HANDLE hOldIndex;
|
||||||
COUNT which_player;
|
|
||||||
|
|
||||||
captains_name_index = StarShipCaptain (StarShipPtr);
|
h = OpenResourceIndexInstance (RaceResIndex);
|
||||||
which_player = StarShipPlayer (StarShipPtr);
|
if (!h)
|
||||||
|
return 0;
|
||||||
|
|
||||||
hOldIndex = SetResourceIndex (h);
|
hOldIndex = SetResourceIndex (h);
|
||||||
|
|
||||||
CodeRef = CaptureCodeRes (LoadCodeRes (INITIAL_CODE_RES),
|
CodeRef = CaptureCodeRes (LoadCodeRes (INITIAL_CODE_RES),
|
||||||
&GlobData, &StarShipPtr->RaceDescPtr);
|
&GlobData, &RDPtr);
|
||||||
if (CodeRef == 0)
|
if (!CodeRef)
|
||||||
goto BadLoad;
|
goto BadLoad;
|
||||||
StarShipPtr->RaceDescPtr->CodeRef = CodeRef;
|
RDPtr->CodeRef = CodeRef;
|
||||||
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.icons =
|
RDPtr->ship_info.icons = CaptureDrawable (LoadGraphic (
|
||||||
CaptureDrawable (LoadGraphic (
|
(RESOURCE)RDPtr->ship_info.icons));
|
||||||
(RESOURCE)StarShipPtr->RaceDescPtr->ship_info.icons));
|
if (!RDPtr->ship_info.icons)
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.icons == 0)
|
|
||||||
{
|
{
|
||||||
/* goto BadLoad */
|
/* goto BadLoad */
|
||||||
}
|
}
|
||||||
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.melee_icon =
|
RDPtr->ship_info.melee_icon = CaptureDrawable (LoadGraphic (
|
||||||
CaptureDrawable (LoadGraphic (
|
(RESOURCE)RDPtr->ship_info.melee_icon));
|
||||||
(RESOURCE)StarShipPtr->RaceDescPtr->ship_info.melee_icon));
|
if (!RDPtr->ship_info.melee_icon)
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.melee_icon == 0)
|
|
||||||
{
|
{
|
||||||
/* goto BadLoad */
|
/* goto BadLoad */
|
||||||
}
|
}
|
||||||
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.race_strings =
|
RDPtr->ship_info.race_strings = CaptureStringTable (LoadStringTable (
|
||||||
CaptureStringTable (LoadStringTable (
|
(RESOURCE)RDPtr->ship_info.race_strings));
|
||||||
(RESOURCE)StarShipPtr->RaceDescPtr->ship_info.race_strings));
|
if (!RDPtr->ship_info.race_strings)
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.race_strings == 0)
|
|
||||||
{
|
{
|
||||||
/* goto BadLoad */
|
/* goto BadLoad */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoadBattleData)
|
if (LoadBattleData)
|
||||||
{
|
{
|
||||||
DATA_STUFF *RawPtr;
|
DATA_STUFF *RawPtr = &RDPtr->ship_data;
|
||||||
|
|
||||||
StarShipPtr->captains_name_index = captains_name_index;
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.ship_flags |= which_player;
|
|
||||||
|
|
||||||
RawPtr = &StarShipPtr->RaceDescPtr->ship_data;
|
|
||||||
if (!load_animation (RawPtr->ship,
|
if (!load_animation (RawPtr->ship,
|
||||||
(RESOURCE)RawPtr->ship[0],
|
(RESOURCE)RawPtr->ship[0],
|
||||||
(RESOURCE)RawPtr->ship[1],
|
(RESOURCE)RawPtr->ship[1],
|
||||||
@@ -108,10 +94,9 @@ load_ship (STARSHIP *StarShipPtr, BOOLEAN LoadBattleData)
|
|||||||
|
|
||||||
if (RawPtr->captain_control.background != 0)
|
if (RawPtr->captain_control.background != 0)
|
||||||
{
|
{
|
||||||
RawPtr->captain_control.background =
|
RawPtr->captain_control.background = CaptureDrawable (LoadGraphic (
|
||||||
CaptureDrawable (LoadGraphic (
|
|
||||||
(RESOURCE)RawPtr->captain_control.background));
|
(RESOURCE)RawPtr->captain_control.background));
|
||||||
if (RawPtr->captain_control.background == 0)
|
if (!RawPtr->captain_control.background)
|
||||||
goto BadLoad;
|
goto BadLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +104,7 @@ load_ship (STARSHIP *StarShipPtr, BOOLEAN LoadBattleData)
|
|||||||
{
|
{
|
||||||
RawPtr->victory_ditty =
|
RawPtr->victory_ditty =
|
||||||
LoadMusic ((RESOURCE)RawPtr->victory_ditty);
|
LoadMusic ((RESOURCE)RawPtr->victory_ditty);
|
||||||
if (RawPtr->victory_ditty == 0)
|
if (!RawPtr->victory_ditty)
|
||||||
goto BadLoad;
|
goto BadLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,30 +112,31 @@ load_ship (STARSHIP *StarShipPtr, BOOLEAN LoadBattleData)
|
|||||||
{
|
{
|
||||||
RawPtr->ship_sounds = CaptureSound (
|
RawPtr->ship_sounds = CaptureSound (
|
||||||
LoadSound ((RESOURCE)RawPtr->ship_sounds));
|
LoadSound ((RESOURCE)RawPtr->ship_sounds));
|
||||||
if (RawPtr->ship_sounds == 0)
|
if (!RawPtr->ship_sounds)
|
||||||
goto BadLoad;
|
goto BadLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.icons)
|
|
||||||
StarShipPtr->silhouette = IncFrameIndex (
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.icons);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = TRUE;
|
ExitFunc:
|
||||||
BadLoad:
|
|
||||||
SetResourceIndex (hOldIndex);
|
SetResourceIndex (hOldIndex);
|
||||||
CloseResourceIndex (h);
|
CloseResourceIndex (h);
|
||||||
}
|
|
||||||
|
|
||||||
return (retval);
|
return RDPtr;
|
||||||
|
|
||||||
|
// TODO: We should really free the resources that did load here
|
||||||
|
BadLoad:
|
||||||
|
if (CodeRef)
|
||||||
|
DestroyCodeRes (ReleaseCodeRes (CodeRef));
|
||||||
|
|
||||||
|
RDPtr = 0; /* failed */
|
||||||
|
|
||||||
|
goto ExitFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
free_ship (STARSHIP *StarShipPtr, BOOLEAN FreeBattleData)
|
free_ship (RACE_DESC *raceDescPtr, BOOLEAN FreeIconData,
|
||||||
|
BOOLEAN FreeBattleData)
|
||||||
{
|
{
|
||||||
RACE_DESC *raceDescPtr = StarShipPtr->RaceDescPtr;
|
|
||||||
SHIP_INFO *shipInfo = &raceDescPtr->ship_info;
|
|
||||||
|
|
||||||
if (FreeBattleData)
|
if (FreeBattleData)
|
||||||
{
|
{
|
||||||
DATA_STUFF *shipData = &raceDescPtr->ship_data;
|
DATA_STUFF *shipData = &raceDescPtr->ship_data;
|
||||||
@@ -165,13 +151,16 @@ free_ship (STARSHIP *StarShipPtr, BOOLEAN FreeBattleData)
|
|||||||
DestroySound (ReleaseSound (shipData->ship_sounds));
|
DestroySound (ReleaseSound (shipData->ship_sounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FreeIconData)
|
||||||
|
{
|
||||||
|
SHIP_INFO *shipInfo = &raceDescPtr->ship_info;
|
||||||
|
|
||||||
DestroyDrawable (ReleaseDrawable (shipInfo->melee_icon));
|
DestroyDrawable (ReleaseDrawable (shipInfo->melee_icon));
|
||||||
DestroyDrawable (ReleaseDrawable (shipInfo->icons));
|
DestroyDrawable (ReleaseDrawable (shipInfo->icons));
|
||||||
DestroyStringTable (ReleaseStringTable (shipInfo->race_strings));
|
DestroyStringTable (ReleaseStringTable (shipInfo->race_strings));
|
||||||
|
}
|
||||||
|
|
||||||
DestroyCodeRes (ReleaseCodeRes (raceDescPtr->CodeRef));
|
DestroyCodeRes (ReleaseCodeRes (raceDescPtr->CodeRef));
|
||||||
|
|
||||||
StarShipPtr->RaceDescPtr = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+36
-41
@@ -42,32 +42,36 @@ LoadMasterShipList (void (* YieldProcessing)(void))
|
|||||||
while (num_entries--)
|
while (num_entries--)
|
||||||
{
|
{
|
||||||
HSTARSHIP hBuiltShip;
|
HSTARSHIP hBuiltShip;
|
||||||
|
|
||||||
hBuiltShip = Build (&master_q, MAKE_RESOURCE (rp++, rt, ri++), 0, 0);
|
|
||||||
if (hBuiltShip)
|
|
||||||
{
|
|
||||||
char built_buf[30];
|
char built_buf[30];
|
||||||
HSTARSHIP hStarShip, hNextShip;
|
HSTARSHIP hStarShip, hNextShip;
|
||||||
STARSHIP *BuiltShipPtr;
|
SHIP_FRAGMENT *BuiltFragPtr;
|
||||||
SHIP_INFO *ShipInfoPtr;
|
RACE_DESC *RDPtr;
|
||||||
|
|
||||||
|
hBuiltShip = Build (&master_q, MAKE_RESOURCE (rp++, rt, ri++), 0, 0);
|
||||||
|
if (!hBuiltShip)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Allow other things to run
|
// Allow other things to run
|
||||||
// supposedly, loading ship packages and data takes some time
|
// supposedly, loading ship packages and data takes some time
|
||||||
if (YieldProcessing)
|
if (YieldProcessing)
|
||||||
YieldProcessing ();
|
YieldProcessing ();
|
||||||
|
|
||||||
BuiltShipPtr = LockStarShip (&master_q, hBuiltShip);
|
BuiltFragPtr = (SHIP_FRAGMENT *) LockStarShip (&master_q, hBuiltShip);
|
||||||
load_ship (BuiltShipPtr, FALSE);
|
RDPtr = load_ship (BuiltFragPtr->RaceResIndex, FALSE);
|
||||||
ShipInfoPtr = &((SHIP_FRAGMENT*)BuiltShipPtr)->ShipInfo;
|
if (!RDPtr)
|
||||||
*ShipInfoPtr = BuiltShipPtr->RaceDescPtr->ship_info;
|
{
|
||||||
BuiltShipPtr->RaceDescPtr->ship_info.melee_icon = 0;
|
UnlockStarShip (&master_q, hBuiltShip);
|
||||||
BuiltShipPtr->RaceDescPtr->ship_info.icons = 0;
|
RemoveQueue (&master_q, hBuiltShip);
|
||||||
BuiltShipPtr->RaceDescPtr->ship_info.race_strings = 0;
|
continue;
|
||||||
free_ship (BuiltShipPtr, FALSE);
|
}
|
||||||
BuiltShipPtr->RaceDescPtr = (RACE_DESC*)ShipInfoPtr;
|
|
||||||
|
// Grab a copy of loaded icons and strings
|
||||||
|
BuiltFragPtr->ShipInfo = RDPtr->ship_info;
|
||||||
|
free_ship (RDPtr, FALSE, FALSE);
|
||||||
|
BuiltFragPtr->ShipInfoPtr = &BuiltFragPtr->ShipInfo;
|
||||||
|
|
||||||
GetStringContents (SetAbsStringTableIndex (
|
GetStringContents (SetAbsStringTableIndex (
|
||||||
BuiltShipPtr->RaceDescPtr->ship_info.race_strings, 2
|
BuiltFragPtr->ShipInfo.race_strings, 2
|
||||||
), (STRINGPTR)built_buf, FALSE);
|
), (STRINGPTR)built_buf, FALSE);
|
||||||
UnlockStarShip (&master_q, hBuiltShip);
|
UnlockStarShip (&master_q, hBuiltShip);
|
||||||
|
|
||||||
@@ -79,12 +83,12 @@ LoadMasterShipList (void (* YieldProcessing)(void))
|
|||||||
hStarShip; hStarShip = hNextShip)
|
hStarShip; hStarShip = hNextShip)
|
||||||
{
|
{
|
||||||
char ship_buf[30];
|
char ship_buf[30];
|
||||||
STARSHIP *StarShipPtr;
|
SHIP_FRAGMENT *FragPtr;
|
||||||
|
|
||||||
StarShipPtr = LockStarShip (&master_q, hStarShip);
|
FragPtr = (SHIP_FRAGMENT *) LockStarShip (&master_q, hStarShip);
|
||||||
hNextShip = _GetSuccLink (StarShipPtr);
|
hNextShip = _GetSuccLink (FragPtr);
|
||||||
GetStringContents (SetAbsStringTableIndex (
|
GetStringContents (SetAbsStringTableIndex (
|
||||||
StarShipPtr->RaceDescPtr->ship_info.race_strings, 2
|
FragPtr->ShipInfo.race_strings, 2
|
||||||
), (STRINGPTR)ship_buf, FALSE);
|
), (STRINGPTR)ship_buf, FALSE);
|
||||||
UnlockStarShip (&master_q, hStarShip);
|
UnlockStarShip (&master_q, hStarShip);
|
||||||
|
|
||||||
@@ -93,7 +97,6 @@ LoadMasterShipList (void (* YieldProcessing)(void))
|
|||||||
}
|
}
|
||||||
InsertQueue (&master_q, hBuiltShip, hStarShip);
|
InsertQueue (&master_q, hBuiltShip, hStarShip);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -104,17 +107,15 @@ FreeMasterShipList (void)
|
|||||||
for (hStarShip = GetHeadLink (&master_q);
|
for (hStarShip = GetHeadLink (&master_q);
|
||||||
hStarShip != 0; hStarShip = hNextShip)
|
hStarShip != 0; hStarShip = hNextShip)
|
||||||
{
|
{
|
||||||
STARSHIP *StarShipPtr;
|
SHIP_FRAGMENT *FragPtr;
|
||||||
|
|
||||||
StarShipPtr = LockStarShip (&master_q, hStarShip);
|
FragPtr = (SHIP_FRAGMENT *) LockStarShip (&master_q, hStarShip);
|
||||||
hNextShip = _GetSuccLink (StarShipPtr);
|
hNextShip = _GetSuccLink (FragPtr);
|
||||||
|
|
||||||
DestroyDrawable (ReleaseDrawable (
|
DestroyDrawable (ReleaseDrawable (FragPtr->ShipInfo.melee_icon));
|
||||||
StarShipPtr->RaceDescPtr->ship_info.melee_icon));
|
DestroyDrawable (ReleaseDrawable (FragPtr->ShipInfo.icons));
|
||||||
DestroyDrawable (ReleaseDrawable (
|
|
||||||
StarShipPtr->RaceDescPtr->ship_info.icons));
|
|
||||||
DestroyStringTable (ReleaseStringTable (
|
DestroyStringTable (ReleaseStringTable (
|
||||||
StarShipPtr->RaceDescPtr->ship_info.race_strings));
|
FragPtr->ShipInfo.race_strings));
|
||||||
|
|
||||||
UnlockStarShip (&master_q, hStarShip);
|
UnlockStarShip (&master_q, hStarShip);
|
||||||
}
|
}
|
||||||
@@ -126,26 +127,20 @@ HSTARSHIP
|
|||||||
FindMasterShip (DWORD ship_ref)
|
FindMasterShip (DWORD ship_ref)
|
||||||
{
|
{
|
||||||
HSTARSHIP hStarShip;
|
HSTARSHIP hStarShip;
|
||||||
|
HSTARSHIP hNextShip;
|
||||||
|
|
||||||
hStarShip = GetHeadLink (&master_q);
|
for (hStarShip = GetHeadLink (&master_q); hStarShip; hStarShip = hNextShip)
|
||||||
if (hStarShip)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
DWORD ref;
|
DWORD ref;
|
||||||
HSTARSHIP hNextShip;
|
SHIP_FRAGMENT *FragPtr;
|
||||||
STARSHIP *StarShipPtr;
|
|
||||||
|
|
||||||
StarShipPtr = LockStarShip (&master_q, hStarShip);
|
FragPtr = (SHIP_FRAGMENT *) LockStarShip (&master_q, hStarShip);
|
||||||
hNextShip = _GetSuccLink (StarShipPtr);
|
hNextShip = _GetSuccLink (FragPtr);
|
||||||
ref = StarShipPtr->RaceResIndex;
|
ref = FragPtr->RaceResIndex;
|
||||||
UnlockStarShip (&master_q, hStarShip);
|
UnlockStarShip (&master_q, hStarShip);
|
||||||
|
|
||||||
if (ref == ship_ref)
|
if (ref == ship_ref)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
hStarShip = hNextShip;
|
|
||||||
} while (hStarShip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (hStarShip);
|
return (hStarShip);
|
||||||
|
|||||||
@@ -2128,11 +2128,17 @@ BuildAndDrawShipList (MELEE_STATE *pMS)
|
|||||||
UnlockStarShip (&master_q, hStarShip);
|
UnlockStarShip (&master_q, hStarShip);
|
||||||
|
|
||||||
BuiltShipPtr = LockStarShip (&race_q[side], hBuiltShip);
|
BuiltShipPtr = LockStarShip (&race_q[side], hBuiltShip);
|
||||||
BuiltShipPtr->ShipFacing = index;
|
BuiltShipPtr->index = index;
|
||||||
BuiltShipPtr->special_counter = ship_cost;
|
BuiltShipPtr->ship_cost = ship_cost;
|
||||||
|
BuiltShipPtr->which_side = 1 << side;
|
||||||
BuiltShipPtr->captains_name_index =
|
BuiltShipPtr->captains_name_index =
|
||||||
StarShipCaptain (BuiltShipPtr);
|
StarShipCaptain (BuiltShipPtr);
|
||||||
BuiltShipPtr->RaceDescPtr = StarShipPtr->RaceDescPtr;
|
// The next ones are not used in Melee
|
||||||
|
BuiltShipPtr->crew_level = 0;
|
||||||
|
BuiltShipPtr->max_crew = 0;
|
||||||
|
BuiltShipPtr->race_strings = 0;
|
||||||
|
BuiltShipPtr->icons = 0;
|
||||||
|
BuiltShipPtr->RaceDescPtr = 0;
|
||||||
UnlockStarShip (&race_q[side], hBuiltShip);
|
UnlockStarShip (&race_q[side], hBuiltShip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ MeleeShipByQueueIndex (const QUEUE *queue, COUNT index)
|
|||||||
for (hShip = GetHeadLink (queue); hShip != 0; hShip = hNextShip)
|
for (hShip = GetHeadLink (queue); hShip != 0; hShip = hNextShip)
|
||||||
{
|
{
|
||||||
STARSHIP *StarShipPtr = LockStarShip (queue, hShip);
|
STARSHIP *StarShipPtr = LockStarShip (queue, hShip);
|
||||||
if (StarShipPtr->ShipFacing == index)
|
if (StarShipPtr->index == index)
|
||||||
{
|
{
|
||||||
hNextShip = hShip;
|
hNextShip = hShip;
|
||||||
if (StarShipPtr->RaceResIndex == 0)
|
if (StarShipPtr->RaceResIndex == 0)
|
||||||
@@ -128,7 +128,7 @@ queueIndexFromShip (HSTARSHIP hShip)
|
|||||||
{
|
{
|
||||||
COUNT result;
|
COUNT result;
|
||||||
STARSHIP *StarShipPtr = LockStarShip (queue, hShip);
|
STARSHIP *StarShipPtr = LockStarShip (queue, hShip);
|
||||||
result = StarShipPtr->ShipFacing;
|
result = StarShipPtr->index;
|
||||||
UnlockStarShip (queue, hShip);
|
UnlockStarShip (queue, hShip);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -380,7 +380,7 @@ GetRaceQueueValue (const QUEUE *queue) {
|
|||||||
if (StarShipPtr->RaceResIndex == 0)
|
if (StarShipPtr->RaceResIndex == 0)
|
||||||
continue; // Not active any more.
|
continue; // Not active any more.
|
||||||
|
|
||||||
result += StarShipPtr->special_counter;
|
result += StarShipPtr->ship_cost;
|
||||||
|
|
||||||
UnlockStarShip (queue, hBattleShip);
|
UnlockStarShip (queue, hBattleShip);
|
||||||
}
|
}
|
||||||
@@ -517,7 +517,7 @@ MeleeShipDeath (STARSHIP *ship, COUNT which_player) {
|
|||||||
ship->RaceResIndex = 0;
|
ship->RaceResIndex = 0;
|
||||||
|
|
||||||
frame = SetAbsFrameIndex (PickMeleeFrame, which_player);
|
frame = SetAbsFrameIndex (PickMeleeFrame, which_player);
|
||||||
CrossOutShip (frame, ship->ShipFacing);
|
CrossOutShip (frame, ship->index);
|
||||||
UpdatePickMeleeFleetValue (frame, which_player);
|
UpdatePickMeleeFleetValue (frame, which_player);
|
||||||
|
|
||||||
if (battle_counter[0] == 0 || battle_counter[1] == 0)
|
if (battle_counter[0] == 0 || battle_counter[1] == 0)
|
||||||
|
|||||||
+23
-23
@@ -146,9 +146,8 @@ ChangeSelection:
|
|||||||
hBattleShip = hNextShip)
|
hBattleShip = hNextShip)
|
||||||
{
|
{
|
||||||
StarShipPtr = LockStarShip (&race_q[0], hBattleShip);
|
StarShipPtr = LockStarShip (&race_q[0], hBattleShip);
|
||||||
if ((COUNT)LONIBBLE (
|
if (StarShipPtr->index == ship_index
|
||||||
StarShipPtr->RaceDescPtr->ship_info.var2
|
&& StarShipPtr->RaceResIndex)
|
||||||
) == ship_index && StarShipPtr->RaceResIndex)
|
|
||||||
{
|
{
|
||||||
UnlockStarShip (&race_q[0], hBattleShip);
|
UnlockStarShip (&race_q[0], hBattleShip);
|
||||||
break;
|
break;
|
||||||
@@ -198,12 +197,12 @@ ChangeSelection:
|
|||||||
STRING locString;
|
STRING locString;
|
||||||
|
|
||||||
locString = SetAbsStringTableIndex (
|
locString = SetAbsStringTableIndex (
|
||||||
StarShipPtr->RaceDescPtr->ship_info.race_strings,
|
StarShipPtr->race_strings,
|
||||||
StarShipPtr->captains_name_index);
|
StarShipPtr->captains_name_index);
|
||||||
t.pStr = (UNICODE *)GetStringAddress (locString);
|
t.pStr = (UNICODE *)GetStringAddress (locString);
|
||||||
t.CharCount = GetStringLength (locString);
|
t.CharCount = GetStringLength (locString);
|
||||||
crew_level = StarShipPtr->RaceDescPtr->ship_info.crew_level;
|
crew_level = StarShipPtr->crew_level;
|
||||||
max_crew = StarShipPtr->RaceDescPtr->ship_info.max_crew;
|
max_crew = StarShipPtr->max_crew;
|
||||||
}
|
}
|
||||||
UnlockStarShip (&race_q[0], hBattleShip);
|
UnlockStarShip (&race_q[0], hBattleShip);
|
||||||
|
|
||||||
@@ -314,11 +313,9 @@ GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player)
|
|||||||
|
|
||||||
if (!(GLOBAL (CurrentActivity) & IN_BATTLE))
|
if (!(GLOBAL (CurrentActivity) & IN_BATTLE))
|
||||||
{
|
{
|
||||||
// XXX: This check should not be needed, but Uninitships()
|
// XXX: This check is needed, because UninitShips() calls
|
||||||
// calls this function after the battle is over for some
|
// this function after the battle is over to record
|
||||||
// reason. Perhaps because one of the non-supermelee cases.
|
// the crew left in the last ship standing.
|
||||||
// (Note that the reason isn't to display the battle
|
|
||||||
// summary; that has already been done).
|
|
||||||
hBattleShip = 0;
|
hBattleShip = 0;
|
||||||
}
|
}
|
||||||
else if (!MeleeShipDeath (LastStarShipPtr, which_player))
|
else if (!MeleeShipDeath (LastStarShipPtr, which_player))
|
||||||
@@ -387,16 +384,20 @@ GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player)
|
|||||||
{
|
{
|
||||||
if (FragPtr->ShipInfo.crew_level != INFINITE_FLEET)
|
if (FragPtr->ShipInfo.crew_level != INFINITE_FLEET)
|
||||||
{
|
{
|
||||||
FragPtr->ShipInfo.crew_level = SPtr->special_counter;
|
/* Record crew left after the battle */
|
||||||
SPtr->RaceDescPtr = (RACE_DESC*)&FragPtr->ShipInfo;
|
FragPtr->ShipInfo.crew_level = SPtr->crew_level;
|
||||||
if (GLOBAL (CurrentActivity) & IN_BATTLE)
|
if (GLOBAL (CurrentActivity) & IN_BATTLE)
|
||||||
SPtr->RaceResIndex = 0;
|
SPtr->RaceResIndex = 0;
|
||||||
|
// deactivates the ship
|
||||||
}
|
}
|
||||||
else /* if infinite ships */
|
else /* if infinite ships */
|
||||||
{
|
{
|
||||||
hBattleShip = GetTailLink (&race_q[which_player]);
|
hBattleShip = GetTailLink (&race_q[which_player]);
|
||||||
SPtr->special_counter = FragPtr->ShipInfo.max_crew;
|
/* XXX: Note that if Syreen had a homeworld you could
|
||||||
SPtr->cur_status_flags = 1 << which_player;
|
* fight, all Syreen ships there would be crewed to
|
||||||
|
* the maximum, instead of the normal level */
|
||||||
|
SPtr->crew_level = FragPtr->ShipInfo.max_crew;
|
||||||
|
SPtr->which_side = 1 << which_player;
|
||||||
SPtr->captains_name_index = PickCaptainName ();
|
SPtr->captains_name_index = PickCaptainName ();
|
||||||
|
|
||||||
battle_counter[1]++;
|
battle_counter[1]++;
|
||||||
@@ -417,7 +418,7 @@ GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player)
|
|||||||
{
|
{
|
||||||
#define RUN_AWAY_FUEL_COST (5 * FUEL_TANK_SCALE)
|
#define RUN_AWAY_FUEL_COST (5 * FUEL_TANK_SCALE)
|
||||||
hBattleShip = 0;
|
hBattleShip = 0;
|
||||||
if (LastStarShipPtr->special_counter == 0)
|
if (LastStarShipPtr->crew_level == 0)
|
||||||
{
|
{
|
||||||
/* Died in the line of duty */
|
/* Died in the line of duty */
|
||||||
GLOBAL_SIS (CrewEnlisted) = (COUNT)~0;
|
GLOBAL_SIS (CrewEnlisted) = (COUNT)~0;
|
||||||
@@ -434,10 +435,11 @@ GetEncounterStarShip (STARSHIP *LastStarShipPtr, COUNT which_player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX: STARSHIP refactor; this whole thing is not really needed anymore
|
||||||
if (hBattleShip)
|
if (hBattleShip)
|
||||||
{
|
{
|
||||||
SPtr = LockStarShip (&race_q[which_player], hBattleShip);
|
SPtr = LockStarShip (&race_q[which_player], hBattleShip);
|
||||||
OwnStarShip (SPtr, SPtr->cur_status_flags,
|
OwnStarShip (SPtr, SPtr->which_side,
|
||||||
SPtr->captains_name_index);
|
SPtr->captains_name_index);
|
||||||
UnlockStarShip (&race_q[which_player], hBattleShip);
|
UnlockStarShip (&race_q[which_player], hBattleShip);
|
||||||
}
|
}
|
||||||
@@ -513,11 +515,10 @@ DrawArmadaPickShip (BOOLEAN draw_salvage_frame, RECT *pPickRect)
|
|||||||
StarShipPtr = LockStarShip (&race_q[0], hBattleShip);
|
StarShipPtr = LockStarShip (&race_q[0], hBattleShip);
|
||||||
|
|
||||||
if (StarShipPtr->captains_name_index)
|
if (StarShipPtr->captains_name_index)
|
||||||
{
|
{ // Escort ship, not SIS
|
||||||
COUNT ship_index;
|
COUNT ship_index;
|
||||||
|
|
||||||
ship_index = (COUNT)LONIBBLE (
|
ship_index = StarShipPtr->index;
|
||||||
StarShipPtr->RaceDescPtr->ship_info.var2);
|
|
||||||
|
|
||||||
s.origin.x = pick_r.corner.x
|
s.origin.x = pick_r.corner.x
|
||||||
+ (5 + ((ICON_WIDTH + 4)
|
+ (5 + ((ICON_WIDTH + 4)
|
||||||
@@ -528,12 +529,11 @@ DrawArmadaPickShip (BOOLEAN draw_salvage_frame, RECT *pPickRect)
|
|||||||
s.origin.y = pick_r.corner.y
|
s.origin.y = pick_r.corner.y
|
||||||
+ (16 + ((ICON_HEIGHT + 4)
|
+ (16 + ((ICON_HEIGHT + 4)
|
||||||
* (ship_index / NUM_PICK_SHIP_COLUMNS)));
|
* (ship_index / NUM_PICK_SHIP_COLUMNS)));
|
||||||
s.frame = StarShipPtr->RaceDescPtr->ship_info.icons;
|
s.frame = StarShipPtr->icons;
|
||||||
r.corner = s.origin;
|
r.corner = s.origin;
|
||||||
SetContextForeGroundColor (BLACK_COLOR);
|
SetContextForeGroundColor (BLACK_COLOR);
|
||||||
DrawFilledRectangle (&r);
|
DrawFilledRectangle (&r);
|
||||||
if (StarShipPtr->RaceResIndex
|
if (StarShipPtr->RaceResIndex || StarShipPtr->crew_level == 0)
|
||||||
|| StarShipPtr->RaceDescPtr->ship_info.crew_level == 0)
|
|
||||||
{
|
{
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
if (StarShipPtr->RaceResIndex == 0)
|
if (StarShipPtr->RaceResIndex == 0)
|
||||||
|
|||||||
+32
-5
@@ -25,6 +25,7 @@
|
|||||||
#include "libs/sndlib.h"
|
#include "libs/sndlib.h"
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: remove RACES_PER_PLAYER remnant of SC1
|
||||||
#define RACES_PER_PLAYER 7
|
#define RACES_PER_PLAYER 7
|
||||||
#define MAX_SHIPS_PER_SIDE 14
|
#define MAX_SHIPS_PER_SIDE 14
|
||||||
|
|
||||||
@@ -265,7 +266,8 @@ typedef QUEUE_HANDLE HSTARSHIP;
|
|||||||
* to each other in many places. Some of those are unsafe and potentially
|
* to each other in many places. Some of those are unsafe and potentially
|
||||||
* destructive if the code is changed later.
|
* destructive if the code is changed later.
|
||||||
* Currently, the first 4 members of each struct MUST remain the same,
|
* Currently, the first 4 members of each struct MUST remain the same,
|
||||||
* the first 2 being the queue links.
|
* the first 2 being the queue links. Functions Build() and CloneShipFragment()
|
||||||
|
* expect these 4 members to be there.
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -288,20 +290,37 @@ typedef struct
|
|||||||
} s;
|
} s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Ship information
|
||||||
BYTE captains_name_index;
|
BYTE captains_name_index;
|
||||||
|
// Also used in full-game to detect if a STARSHIP is an escort
|
||||||
|
// or the flagship (captains_name_index == 0)
|
||||||
|
|
||||||
|
BYTE crew_level;
|
||||||
|
// In full-game battles: crew left
|
||||||
|
// In SuperMelee: irrelevant
|
||||||
|
COUNT max_crew;
|
||||||
|
BYTE ship_cost;
|
||||||
|
// In Super Melee ship queue: ship cost
|
||||||
|
// In full-game: irrelevant
|
||||||
|
UWORD which_side;
|
||||||
|
// In race_q: side the ship is on
|
||||||
|
COUNT index;
|
||||||
|
// original queue index
|
||||||
|
STRING race_strings;
|
||||||
|
FRAME icons;
|
||||||
|
|
||||||
|
// Battle states
|
||||||
BYTE weapon_counter;
|
BYTE weapon_counter;
|
||||||
|
// In battle: frames left before primary weapon can be used
|
||||||
BYTE special_counter;
|
BYTE special_counter;
|
||||||
// In the ship queue: Ship cost
|
// In battle: frames left before special can be used
|
||||||
// In between battles: crew left
|
|
||||||
// In battle: ship dependant
|
|
||||||
BYTE energy_counter;
|
BYTE energy_counter;
|
||||||
|
// In battle: frames left before energy regeneration
|
||||||
|
|
||||||
BYTE ship_input_state;
|
BYTE ship_input_state;
|
||||||
UWORD cur_status_flags _ALIGNED_ON(sizeof (UWORD));
|
UWORD cur_status_flags _ALIGNED_ON(sizeof (UWORD));
|
||||||
UWORD old_status_flags _ALIGNED_ON(sizeof (UWORD));
|
UWORD old_status_flags _ALIGNED_ON(sizeof (UWORD));
|
||||||
|
|
||||||
FRAME silhouette _ALIGNED_ON(sizeof (FRAME));
|
|
||||||
HELEMENT hShip _ALIGNED_ON(sizeof (HELEMENT));
|
HELEMENT hShip _ALIGNED_ON(sizeof (HELEMENT));
|
||||||
COUNT ShipFacing _ALIGNED_ON(sizeof (COUNT));
|
COUNT ShipFacing _ALIGNED_ON(sizeof (COUNT));
|
||||||
} STARSHIP;
|
} STARSHIP;
|
||||||
@@ -320,7 +339,10 @@ typedef struct
|
|||||||
* the ship (accessed through StarShipCaptain()).
|
* the ship (accessed through StarShipCaptain()).
|
||||||
* These values are set using OwnStarShip(). */
|
* These values are set using OwnStarShip(). */
|
||||||
union {
|
union {
|
||||||
|
// TODO: make RaceDescPtr inaccessible
|
||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
|
SHIP_INFO *ShipInfoPtr;
|
||||||
|
EXTENDED_SHIP_INFO *ExtShipInfoPtr;
|
||||||
struct {
|
struct {
|
||||||
COUNT Player;
|
COUNT Player;
|
||||||
BYTE Captain;
|
BYTE Captain;
|
||||||
@@ -342,7 +364,12 @@ typedef struct
|
|||||||
* instead of a RACE_DESC when GLOBAL(avail_race_q) is initialized
|
* instead of a RACE_DESC when GLOBAL(avail_race_q) is initialized
|
||||||
* [see InitSIS]. For this reason, RACE_DESC must maintain a SHIP_INFO
|
* [see InitSIS]. For this reason, RACE_DESC must maintain a SHIP_INFO
|
||||||
* as the first member. */
|
* as the first member. */
|
||||||
|
union {
|
||||||
|
// TODO: make RaceDescPtr inaccessible
|
||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
|
SHIP_INFO *ShipInfoPtr;
|
||||||
|
EXTENDED_SHIP_INFO *ExtShipInfoPtr;
|
||||||
|
};
|
||||||
|
|
||||||
EXTENDED_SHIP_INFO ShipInfo;
|
EXTENDED_SHIP_INFO ShipInfo;
|
||||||
} EXTENDED_SHIP_FRAGMENT;
|
} EXTENDED_SHIP_FRAGMENT;
|
||||||
|
|||||||
+11
-6
@@ -380,11 +380,16 @@ spawn_ship (STARSHIP *StarShipPtr)
|
|||||||
HELEMENT hShip;
|
HELEMENT hShip;
|
||||||
RACE_DESC *RDPtr;
|
RACE_DESC *RDPtr;
|
||||||
|
|
||||||
if (!load_ship (StarShipPtr, TRUE))
|
RDPtr = load_ship (StarShipPtr->RaceResIndex, TRUE);
|
||||||
return (FALSE);
|
if (!RDPtr)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
RDPtr = StarShipPtr->RaceDescPtr;
|
// XXX: Ship captain and side are stored in RaceDescPtr, so
|
||||||
RDPtr->ship_info.var2 = (BYTE)StarShipPtr->ShipFacing;
|
// get them first
|
||||||
|
StarShipPtr->captains_name_index = StarShipCaptain (StarShipPtr);
|
||||||
|
RDPtr->ship_info.ship_flags |= StarShipPlayer (StarShipPtr);
|
||||||
|
|
||||||
|
StarShipPtr->RaceDescPtr = RDPtr;
|
||||||
|
|
||||||
StarShipPtr->ship_input_state = 0;
|
StarShipPtr->ship_input_state = 0;
|
||||||
StarShipPtr->cur_status_flags = 0;
|
StarShipPtr->cur_status_flags = 0;
|
||||||
@@ -393,13 +398,13 @@ spawn_ship (STARSHIP *StarShipPtr)
|
|||||||
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_ENCOUNTER
|
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_ENCOUNTER
|
||||||
|| LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
|| LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)
|
||||||
{
|
{
|
||||||
if (StarShipPtr->special_counter == 0)
|
if (StarShipPtr->crew_level == 0)
|
||||||
{
|
{
|
||||||
// SIS, already handled from sis_ship.c.
|
// SIS, already handled from sis_ship.c.
|
||||||
// RDPtr->ship_info.crew_level = GLOBAL_SIS (CrewEnlisted);
|
// RDPtr->ship_info.crew_level = GLOBAL_SIS (CrewEnlisted);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RDPtr->ship_info.crew_level = StarShipPtr->special_counter;
|
RDPtr->ship_info.crew_level = StarShipPtr->crew_level;
|
||||||
|
|
||||||
if (RDPtr->ship_info.crew_level > RDPtr->ship_info.max_crew)
|
if (RDPtr->ship_info.crew_level > RDPtr->ship_info.max_crew)
|
||||||
RDPtr->ship_info.crew_level = RDPtr->ship_info.max_crew;
|
RDPtr->ship_info.crew_level = RDPtr->ship_info.max_crew;
|
||||||
|
|||||||
@@ -241,11 +241,10 @@ new_ship (ELEMENT *DeadShipPtr)
|
|||||||
BOOLEAN MusicStarted;
|
BOOLEAN MusicStarted;
|
||||||
HELEMENT hElement, hSuccElement;
|
HELEMENT hElement, hSuccElement;
|
||||||
|
|
||||||
DeadStarShipPtr->ShipFacing =
|
/* Record crew left after the battle */
|
||||||
DeadStarShipPtr->RaceDescPtr->ship_info.var2;
|
DeadStarShipPtr->crew_level =
|
||||||
DeadStarShipPtr->special_counter =
|
|
||||||
DeadStarShipPtr->RaceDescPtr->ship_info.crew_level;
|
DeadStarShipPtr->RaceDescPtr->ship_info.crew_level;
|
||||||
if (DeadStarShipPtr->special_counter)
|
if (DeadStarShipPtr->crew_level)
|
||||||
{
|
{
|
||||||
// We've just warped out. new_ship() will still be called
|
// We've just warped out. new_ship() will still be called
|
||||||
// a few times, to process the trace left behind (I assume).
|
// a few times, to process the trace left behind (I assume).
|
||||||
@@ -336,7 +335,8 @@ new_ship (ELEMENT *DeadShipPtr)
|
|||||||
if (DeadStarShipPtr->RaceDescPtr->uninit_func != NULL)
|
if (DeadStarShipPtr->RaceDescPtr->uninit_func != NULL)
|
||||||
(*DeadStarShipPtr->RaceDescPtr->uninit_func) (
|
(*DeadStarShipPtr->RaceDescPtr->uninit_func) (
|
||||||
DeadStarShipPtr->RaceDescPtr);
|
DeadStarShipPtr->RaceDescPtr);
|
||||||
free_ship (DeadStarShipPtr, TRUE);
|
free_ship (DeadStarShipPtr->RaceDescPtr, TRUE, TRUE);
|
||||||
|
DeadStarShipPtr->RaceDescPtr = 0;
|
||||||
UnbatchGraphics ();
|
UnbatchGraphics ();
|
||||||
|
|
||||||
#ifdef NETPLAY
|
#ifdef NETPLAY
|
||||||
|
|||||||
@@ -251,7 +251,8 @@ ModifySilhouette (ELEMENT *ElementPtr, STAMP *modify_stamp,
|
|||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
if (modify_flags & MODIFY_IMAGE)
|
if (modify_flags & MODIFY_IMAGE)
|
||||||
{
|
{
|
||||||
ShipIntersect.IntersectStamp.frame = StarShipPtr->silhouette;
|
ShipIntersect.IntersectStamp.frame = SetAbsFrameIndex (
|
||||||
|
StarShipPtr->RaceDescPtr->ship_info.icons, 1);
|
||||||
if (ShipIntersect.IntersectStamp.frame == 0)
|
if (ShipIntersect.IntersectStamp.frame == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user