Преглед изворни кода

Let user add maps in his home directory. Linux only.

Frank Zago пре 14 година
родитељ
комит
ddd3d166b1
3 измењених фајлова са 8 додато и 2 уклоњено
  1. 5 0
      client/CPreGame.cpp
  2. 0 2
      global.h
  3. 3 0
      lib/VCMIDirs.h

+ 5 - 0
client/CPreGame.cpp

@@ -956,6 +956,11 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(
 		{
 		{
 		case CMenuScreen::newGame:
 		case CMenuScreen::newGame:
 			getFiles(toParse, DATA_DIR "/Maps", "h3m"); //get all maps
 			getFiles(toParse, DATA_DIR "/Maps", "h3m"); //get all maps
+			/* Load maps from user directory too, unless it is also the
+			 * same as the data directory (as is the case on
+			 * windows). */
+			if (GVCMIDirs.UserPath != DATA_DIR)
+				getFiles(toParse, GVCMIDirs.UserPath + "/Maps", "h3m"); //get all maps
 			parseMaps(toParse);
 			parseMaps(toParse);
 			positions = 18;
 			positions = 18;
 			break;
 			break;

+ 0 - 2
global.h

@@ -46,13 +46,11 @@ extern std::string NAME_AFFIX; //client / server
 
 
 /* 
 /* 
  * DATA_DIR contains the game data (Data/, MP3/, ...).
  * DATA_DIR contains the game data (Data/, MP3/, ...).
- * USER_DIR is where to save games (Games/) and the config.
  * BIN_DIR is where the vcmiclient/vcmiserver binaries reside
  * BIN_DIR is where the vcmiclient/vcmiserver binaries reside
  * LIB_DIR is where the AI libraries reside (linux only)
  * LIB_DIR is where the AI libraries reside (linux only)
  */
  */
 #ifdef _WIN32
 #ifdef _WIN32
 	#define DATA_DIR "."
 	#define DATA_DIR "."
-	#define USER_DIR  "."
 	#define BIN_DIR  "."
 	#define BIN_DIR  "."
 	#define LIB_DIR "."
 	#define LIB_DIR "."
 	#define SERVER_NAME "VCMI_server.exe"
 	#define SERVER_NAME "VCMI_server.exe"

+ 3 - 0
lib/VCMIDirs.h

@@ -41,6 +41,9 @@ public:
 			create_directory(UserPath);
 			create_directory(UserPath);
 			create_directory(UserPath + "/config");
 			create_directory(UserPath + "/config");
 			create_directory(UserPath + "/Games");
 			create_directory(UserPath + "/Games");
+
+			/* Home directory can contain some extra maps. */
+			create_directory(UserPath + "/Maps");
 		}
 		}
 		catch(const std::exception & e)
 		catch(const std::exception & e)
 		{
 		{