<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40341 >

> [dmarks - So 29. Jun 2008, 07:00:43]:
> 
> > [dmarks - Sun Jun 29 06:57:38 2008]:
> >
> > Windows Vista SP1, Freeciv 2.1.5 & 2.0.9:
> >
> > Civserver says a game has been saved, but no file is created on
> disk.
> >
> > Caused by WinVista's 'improved' file access control.
> >
> > Seems to be solved if you give the group "Users" the rights to
> modify the
> > containing directory. Dunno about any security implications caused
> by this
> > change.
> >
> > Best,
> >   ~Daniel
> >
> >
> >
> 
> Giving this to you Christian. Installer issue, I presume?
> 
> Best,
>  ~Daniel
> 

The savegames shouldn't be stored in the game directory anyway, as Jason
pointed out in PR#39582. The attached patch makes them be stored in the
user's home directory by the internal server, like on the other platforms.

I'm still thinking about what to do with external civserver, stderr.txt,
stdout.txt and the crash report files.

Index: client/connectdlg_common.c
===================================================================
--- client/connectdlg_common.c	(revision 14985)
+++ client/connectdlg_common.c	(working copy)
@@ -195,7 +195,8 @@
 # ifdef WIN32_NATIVE
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
-  
+
+  char savesdir[MAX_LEN_PATH];
   char options[512];
   char cmdline1[512];
   char cmdline2[512];
@@ -310,8 +311,10 @@
 		scriptfile);
   }
 
-  my_snprintf(options, sizeof(options), "-p %d -q 1 -e%s%s",
-	      internal_server_port, logcmdline, scriptcmdline);
+  interpret_tilde(savesdir, sizeof(savesdir), "~/.freeciv/saves");
+
+  my_snprintf(options, sizeof(options), "-p %d -q 1 -e%s%s --saves \"%s\"",
+	      internal_server_port, logcmdline, scriptcmdline, savesdir);
   my_snprintf(cmdline1, sizeof(cmdline1), "./ser %s", options);
   my_snprintf(cmdline2, sizeof(cmdline2), "./server/civserver %s", options);
   my_snprintf(cmdline3, sizeof(cmdline3), "civserver %s", options);
Index: utility/shared.c
===================================================================
--- utility/shared.c	(revision 14985)
+++ utility/shared.c	(working copy)
@@ -40,6 +40,7 @@
 #ifdef WIN32_NATIVE
 #include <windows.h>
 #include <lmcons.h>	/* UNLEN */
+#include <shlobj.h>
 #endif
 
 #include "astring.h"
@@ -697,12 +698,36 @@
       home_dir = mystrdup(env);	        /* never free()d */
       freelog(LOG_VERBOSE, "HOME is %s", home_dir);
     } else {
+
 #ifdef WIN32_NATIVE
-      home_dir=fc_malloc(PATH_MAX);
-      if (!getcwd(home_dir,PATH_MAX)) {
-	free(home_dir);
-	home_dir=NULL;
-	freelog(LOG_ERROR, "Could not find home directory (HOME is not set)");
+
+      /* some documentation at: 
+       * http://justcheckingonall.wordpress.com/2008/05/16/find-shell-folders-win32/
+       * http://archives.seul.org/or/cvs/Oct-2004/msg00082.html */
+
+      LPITEMIDLIST pidl;
+      LPMALLOC pMalloc;
+      
+      if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl))) {
+        
+        home_dir = fc_malloc(PATH_MAX);
+        
+        if (!SUCCEEDED(SHGetPathFromIDList(pidl, home_dir))) {
+          free(home_dir);
+          home_dir = NULL;
+          freelog(LOG_ERROR,
+            "Could not find home directory (SHGetPathFromIDList() failed)");
+        }
+        
+        SHGetMalloc(&pMalloc);
+        if (pMalloc) {
+          pMalloc->lpVtbl->Free(pMalloc, pidl);
+          pMalloc->lpVtbl->Release(pMalloc);
+        }
+
+      } else {
+        freelog(LOG_ERROR,
+          "Could not find home directory (SHGetSpecialFolderLocation() failed)");
       }
 #else
       freelog(LOG_ERROR, "Could not find home directory (HOME is not set)");
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to