Engine gets Data path from frontend
authorunc0rr
Thu, 23 Nov 2006 21:51:47 +0000
changeset 267 bf7c1503f569
parent 266 53f46353d029
child 268 88809d92e504
Engine gets Data path from frontend
QTfrontend/CMakeLists.txt
QTfrontend/game.cpp
QTfrontend/main.cpp
hedgewars/hwengine.dpr
hedgewars/uConsts.pas
--- a/QTfrontend/CMakeLists.txt	Thu Nov 23 21:33:22 2006 +0000
+++ b/QTfrontend/CMakeLists.txt	Thu Nov 23 21:51:47 2006 +0000
@@ -6,6 +6,7 @@
 
 if(WIN32 AND NOT UNIX)
 	set(HEDGEWARS_BINDIR ".")
+	set(HEDGEWARS_DATADIR "../share/")
 else(WIN32 AND NOT UNIX)
 	set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX})
 	if(DEFINED DATA_INSTALL_DIR)
--- a/QTfrontend/game.cpp	Thu Nov 23 21:33:22 2006 +0000
+++ b/QTfrontend/game.cpp	Thu Nov 23 21:51:47 2006 +0000
@@ -194,6 +194,7 @@
 	arguments << (config->isSoundEnabled() ? "1" : "0");
 	arguments << tr("en.txt");
 	arguments << "128";
+	arguments << datadir->absolutePath();
 	return arguments;
 }
 
--- a/QTfrontend/main.cpp	Thu Nov 23 21:33:22 2006 +0000
+++ b/QTfrontend/main.cpp	Thu Nov 23 21:51:47 2006 +0000
@@ -71,8 +71,8 @@
 	}
 	cfgdir->cd(".hedgewars");
 
-	datadir = new QDir(mydir);
-	datadir->cd("../share/hedgewars/Data");
+	datadir = new QDir("../share/");
+	datadir->cd("hedgewars/Data");
 
 	HWForm *Form = new HWForm();
 	Form->show();
--- a/hedgewars/hwengine.dpr	Thu Nov 23 21:33:22 2006 +0000
+++ b/hedgewars/hwengine.dpr	Thu Nov 23 21:51:47 2006 +0000
@@ -148,29 +148,19 @@
 ////////////////////
 procedure GetParams;
 var c: integer;
-    i: integer;
+{$IFDEF DEBUGFILE}
+    i: integer;    
+{$ENDIF}
     p: TPathType;
 begin
-PathPrefix:= ParamStr(0);
-for i:= 1 to Length(PathPrefix) do
-    if PathPrefix[i] = '\' then PathPrefix[i]:= '/';
-i:= Length(PathPrefix);
-while (i > 0) and not (PathPrefix[i] = '/') do dec(i);
-Delete(PathPrefix, i, Length(PathPrefix) - i + 1);
-dec(i);
-while (i > 0) and not (PathPrefix[i] = '/') do dec(i);
-Delete(PathPrefix, i, Length(PathPrefix) - i + 1);
-PathPrefix:= PathPrefix + '/share/hedgewars/';
-for p:= Low(TPathType) to High(TPathType) do
-    if p <> ptMapCurrent then Pathz[p]:= PathPrefix + Pathz[p];
-
 {$IFDEF DEBUGFILE}
 AddFileLog('Prefix: "' + PathPrefix +'"');
 for i:= 0 to ParamCount do
     AddFileLog(inttostr(i) + ': ' + ParamStr(i));
 {$ENDIF}
+
 case ParamCount of
-  8: begin
+  9: begin
      val(ParamStr(1), cScreenWidth, c);
      val(ParamStr(2), cScreenHeight, c);
      cBitsStr:= ParamStr(3);
@@ -180,6 +170,9 @@
      isSoundEnabled:= ParamStr(6) = '1';
      cLocaleFName:= ParamStr(7);
      val(ParamStr(8), cInitVolume, c);
+     PathPrefix:= ParamStr(9);
+     for p:= Succ(Low(TPathType)) to High(TPathType) do
+         if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p];
      end;
   2: begin
      val(ParamStr(1), ipcPort, c);
--- a/hedgewars/uConsts.pas	Thu Nov 23 21:33:22 2006 +0000
+++ b/hedgewars/uConsts.pas	Thu Nov 23 21:51:47 2006 +0000
@@ -175,20 +175,20 @@
       PathPrefix: string = './';
       Pathz: array[TPathType] of string      = (
                                                '',                              // ptNone      
-                                               'Data',                          // ptData
-                                               'Data/Graphics',                 // ptGraphics
-                                               'Data/Themes',                   // ptThemes
-                                               'Data/Themes/avematan',          // ptCurrTheme
-                                               'Data/Teams',                    // ptTeams
-                                               'Data/Maps',                     // ptMaps
+                                               '',                              // ptData
+                                               'Graphics',                      // ptGraphics
+                                               'Themes',                        // ptThemes
+                                               'Themes/avematan',               // ptCurrTheme
+                                               'Teams',                         // ptTeams
+                                               'Maps',                          // ptMaps
                                                '',                              // ptMapCurrent
-                                               'Data/Demos',                    // ptDemos
-                                               'Data/Sounds',                   // ptSounds
-                                               'Data/Graphics/Graves',          // ptGraves
-                                               'Data/Fonts',                    // ptFonts
-                                               'Data/Forts',                    // ptForts
-                                               'Data/Locale',                   // ptLocale
-                                               'Data/Graphics/AmmoMenu'          // ptAmmoMenu
+                                               'Demos',                         // ptDemos
+                                               'Sounds',                        // ptSounds
+                                               'Graphics/Graves',               // ptGraves
+                                               'Fonts',                         // ptFonts
+                                               'Forts',                         // ptForts
+                                               'Locale',                        // ptLocale
+                                               'Graphics/AmmoMenu'              // ptAmmoMenu
                                                );
 
       StuffLoadData: array[TStuff] of record