1 /*-------------------------------------------------------------------------------
2 
3 	BARONY
4 	File: files.hpp
5 	Desc: prototypes for file.cpp, all file access should be mediated
6 		  through this interface
7 
8 	Copyright 2013-2016 (c) Turning Wheel LLC, all rights reserved.
9 	See LICENSE for details.
10 
11 -------------------------------------------------------------------------------*/
12 #pragma once
13 
14 #include <list>
15 #include <string>
16 #include <vector>
17 #include <cstdio>
18 #include <dirent.h>
19 
20 extern char datadir[PATH_MAX]; //PATH_MAX as defined in main.hpp -- maybe define in Config.hpp?
21 extern char outputdir[PATH_MAX];
22 void glLoadTexture(SDL_Surface* image, int texnum);
23 SDL_Surface* loadImage(char const * const filename);
24 voxel_t* loadVoxel(char* filename2);
25 int loadMap(const char* filename, map_t* destmap, list_t* entlist, list_t* creatureList, int *checkMapHash = nullptr);
26 int loadConfig(char* filename);
27 int loadDefaultConfig();
28 int saveMap(const char* filename);
29 char* readFile(char* filename);
30 std::list<std::string> directoryContents(const char* directory, bool includeSubdirectory, bool includeFiles);
31 FILE *openDataFile(const char *const filename, const char * const mode);
32 DIR * openDataDir(const char *const);
33 bool dataPathExists(const char *const);
34 bool completePath(char *dest, const char * const path, const char *base = datadir);
35 void openLogFile();
36 std::vector<std::string> getLinesFromDataFile(std::string filename);
37 int loadMainMenuMap(bool blessedAdditionMaps, bool forceVictoryMap);
38 int physfsLoadMapFile(int levelToLoad, Uint32 seed, bool useRandSeed, int *checkMapHash = nullptr);
39 std::list<std::string> physfsGetFileNamesInDirectory(const char* dir);
40 std::string physfsFormatMapName(char const * const levelfilename);
41 bool physfsModelIndexUpdate(int &start, int &end, bool freePreviousModels);
42 bool physfsSearchModelsToUpdate();
43 bool physfsSearchSoundsToUpdate();
44 void physfsReloadSounds(bool reloadAll);
45 void physfsReloadBooks();
46 bool physfsSearchBooksToUpdate();
47 bool physfsSearchMusicToUpdate();
48 void physfsReloadMusic(bool &introMusicChanged, bool reloadAll);
49 void physfsReloadTiles(bool reloadAll);
50 bool physfsSearchTilesToUpdate();
51 void physfsReloadSprites(bool reloadAll);
52 bool physfsSearchSpritesToUpdate();
53 extern std::vector<int> gamemods_modelsListModifiedIndexes;
54 bool physfsIsMapLevelListModded();
55 bool physfsSearchItemSpritesToUpdate();
56 void physfsReloadItemSprites(bool reloadAll);
57 bool physfsSearchItemsTxtToUpdate();
58 bool physfsSearchItemsGlobalTxtToUpdate();
59 void physfsReloadItemsTxt();
60 bool physfsSearchMonsterLimbFilesToUpdate();
61 void physfsReloadMonsterLimbFiles();
62 void physfsReloadSystemImages();
63 bool physfsSearchSystemImagesToUpdate();
64 void gamemodsUnloadCustomThemeMusic();
65 extern std::vector<std::pair<SDL_Surface**, std::string>> systemResourceImagesToReload;
66 
67 enum MapParameterIndices : int
68 {
69 	LEVELPARAM_CHANCE_SECRET,
70 	LEVELPARAM_CHANCE_DARKNESS,
71 	LEVELPARAM_CHANCE_MINOTAUR,
72 	LEVELPARAM_DISABLE_NORMAL_EXIT
73 };