Skip to content

Commit 5f42d00

Browse files
committed
When doing a map preview, no need to process stuff that is only useful in-game.
This speeds up the preview screen back to 2.x speeds.
1 parent 1a6fb8a commit 5f42d00

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/game.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
27842784
aFileName[fileExten] = '\0';
27852785
strcat(aFileName, "mission.map");
27862786
/* Load in the chosen file data */
2787-
if (!mapLoad(aFileName))
2787+
if (!mapLoad(aFileName, false))
27882788
{
27892789
debug(LOG_ERROR, "Failed to load map");
27902790
return false;
@@ -2932,7 +2932,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
29322932
//load in the map file
29332933
aFileName[fileExten] = '\0';
29342934
strcat(aFileName, "game.map");
2935-
if (!mapLoad(aFileName))
2935+
if (!mapLoad(aFileName, false))
29362936

29372937
{
29382938
debug( LOG_NEVER, "loadgame: Fail7\n" );

src/map.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static BOOL mapSetGroundTypes(void)
749749
}
750750

751751
/* Initialise the map structure */
752-
BOOL mapLoad(char *filename)
752+
BOOL mapLoad(char *filename, BOOL preview)
753753
{
754754
UDWORD numGw, width, height;
755755
char aFileType[4];
@@ -835,6 +835,12 @@ BOOL mapLoad(char *filename)
835835
}
836836
}
837837

838+
if (preview)
839+
{
840+
// no need to do anything else for the map preview
841+
goto ok;
842+
}
843+
838844
if (!PHYSFS_readULE32(fp, &version) || !PHYSFS_readULE32(fp, &numGw) || version != 1)
839845
{
840846
debug(LOG_ERROR, "Bad gateway in %s", filename);
@@ -887,6 +893,7 @@ BOOL mapLoad(char *filename)
887893

888894
mapFloodFillContinents();
889895

896+
ok:
890897
PHYSFS_close(fp);
891898
return true;
892899

src/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ extern BOOL mapShutdown(void);
292292
extern BOOL mapNew(UDWORD width, UDWORD height);
293293

294294
/* Load the map data */
295-
extern BOOL mapLoad(char *filename);
295+
extern BOOL mapLoad(char *filename, BOOL preview);
296296

297297
/* Save the map data */
298298
extern BOOL mapSave(char **ppFileData, UDWORD *pFileSize);

src/multiint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void loadMapPreview(bool hideInterface)
308308
ptr = strrchr(aFileName, '/');
309309
ASSERT(ptr, "this string was supposed to contain a /");
310310
strcpy(ptr, "/game.map");
311-
if (!mapLoad(aFileName))
311+
if (!mapLoad(aFileName, true))
312312
{
313313
debug(LOG_ERROR, "loadMapPreview: Failed to load map");
314314
return;

0 commit comments

Comments
 (0)