Generalised some functions.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3757 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+42
-13
@@ -271,18 +271,19 @@ StartSphereTracking (COUNT race)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if and only if a ship of the specified race is among the
|
* Returns the number of ships of the specified race among the
|
||||||
* escort ships.
|
* escort ships.
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
COUNT
|
||||||
HaveEscortShip (COUNT race)
|
CountEscortShips (COUNT race)
|
||||||
{
|
{
|
||||||
HFLEETINFO hFleet;
|
HFLEETINFO hFleet;
|
||||||
HSHIPFRAG hStarShip, hNextShip;
|
HSHIPFRAG hStarShip, hNextShip;
|
||||||
|
COUNT result = 0;
|
||||||
|
|
||||||
hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race);
|
hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race);
|
||||||
if (!hFleet)
|
if (!hFleet)
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
|
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
|
||||||
hStarShip = hNextShip)
|
hStarShip = hNextShip)
|
||||||
@@ -296,9 +297,19 @@ HaveEscortShip (COUNT race)
|
|||||||
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
|
||||||
if (ship_type == race)
|
if (ship_type == race)
|
||||||
return TRUE;
|
result++;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns true if and only if a ship of the specified race is among the
|
||||||
|
* escort ships.
|
||||||
|
*/
|
||||||
|
BOOLEAN
|
||||||
|
HaveEscortShip (COUNT race)
|
||||||
|
{
|
||||||
|
return (CountEscortShips (race) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -342,13 +353,17 @@ CheckAlliance (COUNT race)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove all escort ships of the specified race.
|
* Remove a number of escort ships of the specified race (if present).
|
||||||
|
* Returns the number of escort ships removed.
|
||||||
*/
|
*/
|
||||||
void
|
COUNT
|
||||||
RemoveEscortShips (COUNT race)
|
RemoveSomeEscortShips (COUNT race, COUNT count)
|
||||||
{
|
{
|
||||||
HSHIPFRAG hStarShip, hNextShip;
|
HSHIPFRAG hStarShip;
|
||||||
BOOLEAN ShipRemoved = FALSE;
|
HSHIPFRAG hNextShip;
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
|
for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip;
|
||||||
hStarShip = hNextShip)
|
hStarShip = hNextShip)
|
||||||
@@ -363,18 +378,32 @@ RemoveEscortShips (COUNT race)
|
|||||||
|
|
||||||
if (RemoveShip)
|
if (RemoveShip)
|
||||||
{
|
{
|
||||||
ShipRemoved = TRUE;
|
|
||||||
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
RemoveQueue (&GLOBAL (built_ship_q), hStarShip);
|
||||||
FreeShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
FreeShipFrag (&GLOBAL (built_ship_q), hStarShip);
|
||||||
|
count--;
|
||||||
|
if (count == 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShipRemoved)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
|
// Update the display.
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove all escort ships of the specified race.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RemoveEscortShips (COUNT race)
|
||||||
|
{
|
||||||
|
RemoveSomeEscortShips (race, (COUNT) -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
COUNT
|
COUNT
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ extern COUNT CalculateEscortsWorth (void);
|
|||||||
//extern COUNT GetRaceKnownSize (COUNT race);
|
//extern COUNT GetRaceKnownSize (COUNT race);
|
||||||
extern COUNT SetRaceAllied (COUNT race, BOOLEAN flag);
|
extern COUNT SetRaceAllied (COUNT race, BOOLEAN flag);
|
||||||
extern COUNT StartSphereTracking (COUNT race);
|
extern COUNT StartSphereTracking (COUNT race);
|
||||||
|
extern COUNT CountEscortShips (COUNT race);
|
||||||
extern BOOLEAN HaveEscortShip (COUNT race);
|
extern BOOLEAN HaveEscortShip (COUNT race);
|
||||||
extern COUNT EscortFeasibilityStudy (COUNT race);
|
extern COUNT EscortFeasibilityStudy (COUNT race);
|
||||||
extern COUNT CheckAlliance (COUNT race);
|
extern COUNT CheckAlliance (COUNT race);
|
||||||
|
extern COUNT RemoveSomeEscortShips (COUNT race, COUNT count);
|
||||||
extern void RemoveEscortShips (COUNT race);
|
extern void RemoveEscortShips (COUNT race);
|
||||||
|
|
||||||
extern RACE_DESC *load_ship (SPECIES_ID SpeciesID, BOOLEAN LoadBattleData);
|
extern RACE_DESC *load_ship (SPECIES_ID SpeciesID, BOOLEAN LoadBattleData);
|
||||||
|
|||||||
Reference in New Issue
Block a user