浏览代码

Minor fixes #2

- ChangeLog update
- Updated code for other platforms in CGameInterface
Karol 11 年之前
父节点
当前提交
b2a140149c
共有 2 个文件被更改,包括 19 次插入18 次删除
  1. 2 0
      ChangeLog
  2. 17 18
      lib/CGameInterface.cpp

+ 2 - 0
ChangeLog

@@ -3,6 +3,8 @@ GENERAL:
 * VCMI can now be compiled with SDL2
 * Better upscaling when running in fullscreen mode.
 * Non-latin characters can now be entered in chat window or used for save names.
+* (windows) Moved VCMI data directory from '%userprofile%\vcmi' to '%userprofile%\Documents\My Games\vcmi'
+* (windows, OSX) Moved VCMI save directory from 'VCMI_DATA\Games' to 'VCMI_DATA\Saves'
 
 RANDOM MAP GENERATOR:
 

+ 17 - 18
lib/CGameInterface.cpp

@@ -44,28 +44,27 @@ shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::st
 	TGetAIFun getAI = nullptr;
 	TGetNameFun getName = nullptr;
 
-#ifndef VCMI_WINDOWS
-	std::string dllname = libpath.string();
-		// I don't know other platforms.
-		// Somebody should remove it soon.
-#endif
-
 #ifdef VCMI_ANDROID
 	// this is awful but it seems using shared libraries on some devices is even worse
-	if (dllname.find("libVCAI.so") != std::string::npos) {
+	const std::string filename = libpath.filename().string();
+	if (filename != "libVCAI.so")
+	{
 		getName = (TGetNameFun)VCAI_GetAiName;
 		getAI = (TGetAIFun)VCAI_GetNewAI;
-	} else if (dllname.find("libStupidAI.so") != std::string::npos) {
+	}
+	else if (filename != "libStupidAI.so")
+	{
 		getName = (TGetNameFun)StupidAI_GetAiName;
 		getAI = (TGetAIFun)StupidAI_GetNewBattleAI;
-	} else if (dllname.find("libBattleAI.so") != std::string::npos) {
+	}
+	else if (filename != "libBattleAI.so")
+	{
 		getName = (TGetNameFun)BattleAI_GetAiName;
 		getAI = (TGetAIFun)BattleAI_GetNewBattleAI;
-	} else {
-		throw std::runtime_error("Don't know what to do with " + dllname + " and method " + methodName);
 	}
-#else
-
+	else
+		throw std::runtime_error("Don't know what to do with " + libpath.string() + " and method " + methodName);
+#else // !VCMI_ANDROID
 #ifdef VCMI_WINDOWS
 	HMODULE dll = LoadLibraryW(libpath.c_str());
 	if (dll)
@@ -73,16 +72,16 @@ shared_ptr<rett> createAny(const boost::filesystem::path& libpath, const std::st
 		getName = (TGetNameFun)GetProcAddress(dll, "GetAiName");
 		getAI = (TGetAIFun)GetProcAddress(dll, methodName.c_str());
 	}
-#else
-	void *dll = dlopen(dllname.c_str(), RTLD_LOCAL | RTLD_LAZY);
+#else // !VCMI_WINDOWS
+	void *dll = dlopen(libpath.string().c_str(), RTLD_LOCAL | RTLD_LAZY);
 	if (dll)
 	{
-		getName = (TGetNameFun)dlsym(dll,"GetAiName");
-		getAI = (TGetAIFun)dlsym(dll,methodName.c_str());
+		getName = (TGetNameFun)dlsym(dll, "GetAiName");
+		getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
 	}
 	else
         logGlobal->errorStream() << "Error: " << dlerror();
-#endif
+#endif // VCMI_WINDOWS
 	if (!dll)
 	{
 		logGlobal->errorStream() << "Cannot open dynamic library ("<<libpath<<"). Throwing...";