Melee loading fix, from fOSSiL.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@480 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -75,8 +75,6 @@ Glitches (don't crash the game, medium priority):
|
|||||||
Probably the negative shift for GET_STATE and SET_STATE
|
Probably the negative shift for GET_STATE and SET_STATE
|
||||||
- Some font characters are wrong, atleast in the planet scan screen
|
- Some font characters are wrong, atleast in the planet scan screen
|
||||||
when compared to 3DO
|
when compared to 3DO
|
||||||
- When there are more than one page of saved supermelee teams, the last
|
|
||||||
entries will be wrong.
|
|
||||||
- Temp files don't get deleted if the game is exited in full game mode.
|
- Temp files don't get deleted if the game is exited in full game mode.
|
||||||
(and the temp dir doesn't get deleted if it's not empty)
|
(and the temp dir doesn't get deleted if it's not empty)
|
||||||
- From main menu, choose 'load game', then space, and space again and
|
- From main menu, choose 'load game', then space, and space again and
|
||||||
|
|||||||
+41
-25
@@ -664,6 +664,38 @@ ReadTeamImage (TEAM_IMAGE *pTI, FILE *load_fp)
|
|||||||
return (ReadResFile (pTI, sizeof (*pTI), 1, load_fp) == 1 ? 0 : -1);
|
return (ReadResFile (pTI, sizeof (*pTI), 1, load_fp) == 1 ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
LoadTeamImage(DIRENTRY DirEntry, TEAM_IMAGE* pTI,
|
||||||
|
UNICODE* pFilePath, UNICODE** ppFileName)
|
||||||
|
{
|
||||||
|
UNICODE file[PATH_MAX]; // local buf if needed
|
||||||
|
UNICODE *pfile;
|
||||||
|
UNICODE *loc_buf;
|
||||||
|
FILE *load_fp;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
pfile = pFilePath != NULL_PTR ? pFilePath : file;
|
||||||
|
strcpy (pfile, meleeDir);
|
||||||
|
loc_buf = pfile + strlen (pfile);
|
||||||
|
|
||||||
|
GetDirEntryContents (DirEntry, (STRINGPTR)loc_buf, FALSE);
|
||||||
|
if ((load_fp = OpenResFile (pfile, "rb")) == 0)
|
||||||
|
status = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (LengthResFile (load_fp) != sizeof (*pTI))
|
||||||
|
status = -1;
|
||||||
|
else
|
||||||
|
status = ReadTeamImage (pTI, load_fp);
|
||||||
|
CloseResFile (load_fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pFilePath != NULL_PTR && ppFileName != NULL_PTR)
|
||||||
|
*ppFileName = loc_buf;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
DrawFileStrings (PMELEE_STATE pMS, int HiLiteState)
|
DrawFileStrings (PMELEE_STATE pMS, int HiLiteState)
|
||||||
{
|
{
|
||||||
@@ -747,18 +779,14 @@ DrawFileStrings (PMELEE_STATE pMS, int HiLiteState)
|
|||||||
pMS->FileList[bot - top] = pMS->PreBuiltList[bot];
|
pMS->FileList[bot - top] = pMS->PreBuiltList[bot];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *load_fp;
|
pMS->TeamDE = SetAbsDirEntryTableIndex (
|
||||||
|
|
||||||
GetDirEntryContents (SetAbsDirEntryTableIndex (
|
|
||||||
pMS->TeamDE, bot - NUM_PREBUILT
|
pMS->TeamDE, bot - NUM_PREBUILT
|
||||||
), (STRINGPTR)buf, FALSE);
|
);
|
||||||
load_fp = OpenResFile (buf, "rb");
|
if (-1 == LoadTeamImage (pMS->TeamDE,
|
||||||
if (load_fp)
|
&pMS->FileList[bot - top], NULL_PTR, NULL_PTR
|
||||||
|
))
|
||||||
{
|
{
|
||||||
if (LengthResFile (load_fp) != sizeof (pMS->FileList[bot - top])
|
pMS->FileList[bot - top] = pMS->PreBuiltList[0];
|
||||||
|| ReadTeamImage (&pMS->FileList[bot - top], load_fp) == -1)
|
|
||||||
pMS->FileList[bot - top] = pMS->PreBuiltList[0];
|
|
||||||
CloseResFile (load_fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,11 +1046,9 @@ LoadTeamList (PMELEE_STATE pMS, UNICODE *pbuf)
|
|||||||
COUNT num_entries;
|
COUNT num_entries;
|
||||||
char dir[PATH_MAX];
|
char dir[PATH_MAX];
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
char *loc_buf;
|
UNICODE *loc_buf;
|
||||||
|
|
||||||
sprintf (dir, "%s*.mle", meleeDir);
|
sprintf (dir, "%s*.mle", meleeDir);
|
||||||
strcpy (file, meleeDir);
|
|
||||||
loc_buf = file + strlen (file);
|
|
||||||
|
|
||||||
GetNewList:
|
GetNewList:
|
||||||
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->TeamDE));
|
DestroyDirEntryTable (ReleaseDirEntryTable (pMS->TeamDE));
|
||||||
@@ -1034,20 +1060,10 @@ GetNewList:
|
|||||||
while (num_entries--)
|
while (num_entries--)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
FILE *load_fp;
|
|
||||||
TEAM_IMAGE TI;
|
TEAM_IMAGE TI;
|
||||||
|
|
||||||
GetDirEntryContents (pMS->TeamDE, (STRINGPTR)loc_buf, FALSE);
|
status = LoadTeamImage(pMS->TeamDE, &TI, file, &loc_buf);
|
||||||
if ((load_fp = OpenResFile (file, "rb")) == 0)
|
|
||||||
status = -1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (LengthResFile (load_fp) != sizeof (TI))
|
|
||||||
status = -1;
|
|
||||||
else
|
|
||||||
status = ReadTeamImage (&TI, load_fp);
|
|
||||||
CloseResFile (load_fp);
|
|
||||||
}
|
|
||||||
if (status == -1)
|
if (status == -1)
|
||||||
{
|
{
|
||||||
DeleteResFile (file);
|
DeleteResFile (file);
|
||||||
|
|||||||
Reference in New Issue
Block a user