diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index a93f936d..e499bb45 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -241,8 +241,6 @@ void FILESYSTEM_loadZip(const char* filename) } } -bool FILESYSTEM_assetsmounted = false; - void FILESYSTEM_mountassets(const char* path) { const size_t path_size = SDL_strlen(path); @@ -288,8 +286,6 @@ void FILESYSTEM_mountassets(const char* path) FILESYSTEM_mount(zip_data); graphics.reloadresources(); - - FILESYSTEM_assetsmounted = true; } else if (zip_normal != NULL && endsWith(zip_normal, ".zip")) { @@ -323,8 +319,6 @@ void FILESYSTEM_mountassets(const char* path) SDL_strlcpy(assetDir, zip_data, sizeof(assetDir)); } - FILESYSTEM_assetsmounted = true; - graphics.reloadresources(); } else if (FILESYSTEM_exists(dir)) @@ -334,14 +328,10 @@ void FILESYSTEM_mountassets(const char* path) FILESYSTEM_mount(dir); graphics.reloadresources(); - - FILESYSTEM_assetsmounted = true; } else { puts("Custom asset directory does not exist"); - - FILESYSTEM_assetsmounted = false; } } @@ -358,7 +348,6 @@ void FILESYSTEM_unmountassets(void) { printf("Cannot unmount when no asset directory is mounted\n"); } - FILESYSTEM_assetsmounted = false; } bool FILESYSTEM_isAssetMounted(const char* filename) diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h index e9c885f8..fd6b6d81 100644 --- a/desktop_version/src/FileSystemUtils.h +++ b/desktop_version/src/FileSystemUtils.h @@ -17,7 +17,6 @@ bool FILESYSTEM_isMounted(const char* filename); void FILESYSTEM_mount(const char *fname); void FILESYSTEM_loadZip(const char* filename); -extern bool FILESYSTEM_assetsmounted; void FILESYSTEM_mountassets(const char *path); void FILESYSTEM_unmountassets(void); bool FILESYSTEM_isAssetMounted(const char* filename); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index c47fa02e..ce677c7b 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -146,6 +146,11 @@ void Graphics::init(void) col_tb = 0; kludgeswnlinewidth = false; + +#ifndef NO_CUSTOM_LEVELS + tiles1_mounted = false; + tiles2_mounted = false; +#endif } void Graphics::destroy(void) @@ -710,10 +715,10 @@ void Graphics::drawsprite(int x, int y, int t, Uint32 c) } #ifndef NO_CUSTOM_LEVELS -bool Graphics::shouldrecoloroneway(const int tilenum) +bool Graphics::shouldrecoloroneway(const int tilenum, const bool mounted) { return (tilenum >= 14 && tilenum <= 17 - && (!FILESYSTEM_assetsmounted + && (!mounted || ed.onewaycol_override)); } #endif @@ -729,7 +734,7 @@ void Graphics::drawtile( int x, int y, int t ) SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; #if !defined(NO_CUSTOM_LEVELS) - if (shouldrecoloroneway(t)) + if (shouldrecoloroneway(t, tiles1_mounted)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect); @@ -753,7 +758,7 @@ void Graphics::drawtile2( int x, int y, int t ) SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; #if !defined(NO_CUSTOM_LEVELS) - if (shouldrecoloroneway(t)) + if (shouldrecoloroneway(t, tiles2_mounted)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect); @@ -3153,7 +3158,7 @@ void Graphics::drawforetile(int x, int y, int t) setRect(rect, x,y,tiles_rect.w, tiles_rect.h); #if !defined(NO_CUSTOM_LEVELS) - if (shouldrecoloroneway(t)) + if (shouldrecoloroneway(t, tiles1_mounted)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect); @@ -3177,7 +3182,7 @@ void Graphics::drawforetile2(int x, int y, int t) setRect(rect, x,y,tiles_rect.w, tiles_rect.h); #if !defined(NO_CUSTOM_LEVELS) - if (shouldrecoloroneway(t)) + if (shouldrecoloroneway(t, tiles2_mounted)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect); @@ -3268,6 +3273,11 @@ void Graphics::reloadresources() music.destroy(); music.init(); + +#ifndef NO_CUSTOM_LEVELS + tiles1_mounted = FILESYSTEM_isAssetMounted("graphics/tiles.png"); + tiles2_mounted = FILESYSTEM_isAssetMounted("graphics/tiles2.png"); +#endif } Uint32 Graphics::crewcolourreal(int t) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 67aef918..2664ca58 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -162,7 +162,7 @@ public: void drawbackground(int t); void updatebackground(int t); #ifndef NO_CUSTOM_LEVELS - bool shouldrecoloroneway(const int tilenum); + bool shouldrecoloroneway(const int tilenum, const bool mounted); #endif void drawtile3( int x, int y, int t, int off, int height_subtract = 0 ); void drawtile2( int x, int y, int t ); @@ -187,6 +187,10 @@ public: bool onscreen(int t); void reloadresources(void); +#ifndef NO_CUSTOM_LEVELS + bool tiles1_mounted; + bool tiles2_mounted; +#endif void menuoffrender(void);