Sanity check for loaded teams.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2640 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Meep-Eep
2007-01-01 16:01:36 +00:00
parent bf50240944
commit a7b19f9f0d
+25 -1
View File
@@ -1005,7 +1005,31 @@ GetTeamValue (TEAM_IMAGE *pTI)
static int static int
ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp) ReadTeamImage (TEAM_IMAGE *pTI, uio_Stream *load_fp)
{ {
return (ReadResFile (pTI, sizeof (*pTI), 1, load_fp) == 1 ? 0 : -1); int status;
FleetShipIndex i;
status = ReadResFile (pTI, sizeof (*pTI), 1, load_fp);
if (status != 1)
return -1;
// Sanity check on the entries.
for (i = 0; i < MELEE_FLEET_SIZE; i++)
{
BYTE StarShip = pTI->ShipList[i];
if (StarShip == MELEE_NONE)
continue;
if (StarShip >= NUM_MELEE_SHIPS)
{
log_add(log_Warning, "Invalid ship type in loaded team (index "
"%d, ship type is %d, max valid is %d).",
i, StarShip, NUM_MELEE_SHIPS - 1);
pTI->ShipList[i] = MELEE_NONE;
}
}
return 0;
} }
static int static int