From 18382251923ac04007a59077f513184a3e66e5ec Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 28 May 2011 13:55:05 +0000 Subject: [PATCH] (svn r22511) -Add: Function to make heightmap file paths. --- src/fios.cpp | 16 ++++++++++++++++ src/fios.h | 1 + src/screenshot.cpp | 6 ++++++ src/screenshot.h | 1 + 4 files changed, 24 insertions(+) diff --git a/src/fios.cpp b/src/fios.cpp index b51b7c9195..ba2f84ded1 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -16,6 +16,7 @@ #include "fios.h" #include "fileio_func.h" #include "tar_type.h" +#include "screenshot.h" #include "string_func.h" #include @@ -185,6 +186,21 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size) FiosMakeFilename(buf, _fios_path, name, extension, size); } +/** + * Construct a filename for a height map. + * @param buf Destination buffer. + * @param name Filename. + * @param size Size of \a buf. + */ +void FiosMakeHeightmapName(char *buf, const char *name, size_t size) +{ + char ext[5]; + ext[0] = '.'; + strecpy(ext + 1, GetCurrentScreenshotExtension(), lastof(ext)); + + FiosMakeFilename(buf, _fios_path, name, ext, size); +} + /** * Delete a file. * @param name Filename to delete. diff --git a/src/fios.h b/src/fios.h index f666eb5bf6..e9a20a9fb7 100644 --- a/src/fios.h +++ b/src/fios.h @@ -164,6 +164,7 @@ const char *FiosBrowseTo(const FiosItem *item); StringID FiosGetDescText(const char **path, uint64 *total_free); bool FiosDelete(const char *name); +void FiosMakeHeightmapName(char *buf,const char *name, size_t size); void FiosMakeSavegameName(char *buf, const char *name, size_t size); FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last); diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 87cc143cd4..78a9b1af39 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -577,6 +577,12 @@ static const ScreenshotFormat _screenshot_formats[] = { {"PCX", "pcx", &MakePCXImage}, }; +/** Get filename extension of current screenshot file format. */ +const char *GetCurrentScreenshotExtension() +{ + return _screenshot_formats[_cur_screenshot_format].extension; +} + /** Initialize screenshot format information on startup, with #_screenshot_format_name filled from the loadsave code. */ void InitializeScreenshotFormats() { diff --git a/src/screenshot.h b/src/screenshot.h index acd694f2bb..64c5881783 100644 --- a/src/screenshot.h +++ b/src/screenshot.h @@ -16,6 +16,7 @@ void InitializeScreenshotFormats(); const char *GetScreenshotFormatDesc(int i); void SetScreenshotFormat(uint i); +const char *GetCurrentScreenshotExtension(); /** Type of requested screenshot */ enum ScreenshotType {