Skip to content

Commit

Permalink
When doing a map preview, no need to process stuff that is only usefu…
Browse files Browse the repository at this point in the history
…l in-game.

This speeds up the preview screen back to 2.x speeds.
  • Loading branch information
buginator committed Nov 9, 2010
1 parent 1a6fb8a commit 5f42d00
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -2784,7 +2784,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
aFileName[fileExten] = '\0';
strcat(aFileName, "mission.map");
/* Load in the chosen file data */
if (!mapLoad(aFileName))
if (!mapLoad(aFileName, false))
{
debug(LOG_ERROR, "Failed to load map");
return false;
Expand Down Expand Up @@ -2932,7 +2932,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
//load in the map file
aFileName[fileExten] = '\0';
strcat(aFileName, "game.map");
if (!mapLoad(aFileName))
if (!mapLoad(aFileName, false))

{
debug( LOG_NEVER, "loadgame: Fail7\n" );
Expand Down
9 changes: 8 additions & 1 deletion src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ static BOOL mapSetGroundTypes(void)
}

/* Initialise the map structure */
BOOL mapLoad(char *filename)
BOOL mapLoad(char *filename, BOOL preview)
{
UDWORD numGw, width, height;
char aFileType[4];
Expand Down Expand Up @@ -835,6 +835,12 @@ BOOL mapLoad(char *filename)
}
}

if (preview)
{
// no need to do anything else for the map preview
goto ok;
}

if (!PHYSFS_readULE32(fp, &version) || !PHYSFS_readULE32(fp, &numGw) || version != 1)
{
debug(LOG_ERROR, "Bad gateway in %s", filename);
Expand Down Expand Up @@ -887,6 +893,7 @@ BOOL mapLoad(char *filename)

mapFloodFillContinents();

ok:
PHYSFS_close(fp);
return true;

Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ extern BOOL mapShutdown(void);
extern BOOL mapNew(UDWORD width, UDWORD height);

/* Load the map data */
extern BOOL mapLoad(char *filename);
extern BOOL mapLoad(char *filename, BOOL preview);

/* Save the map data */
extern BOOL mapSave(char **ppFileData, UDWORD *pFileSize);
Expand Down
2 changes: 1 addition & 1 deletion src/multiint.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void loadMapPreview(bool hideInterface)
ptr = strrchr(aFileName, '/');
ASSERT(ptr, "this string was supposed to contain a /");
strcpy(ptr, "/game.map");
if (!mapLoad(aFileName))
if (!mapLoad(aFileName, true))
{
debug(LOG_ERROR, "loadMapPreview: Failed to load map");
return;
Expand Down

0 comments on commit 5f42d00

Please sign in to comment.