Patch by koda:
authorunc0rr
Sun, 19 Apr 2009 13:36:51 +0000
changeset 2008 fc2fb5c938c3
parent 2007 159d14fe4e93
child 2009 91f461c218ab
Patch by koda: - Variable commands to the commandline version of hwengine
hedgewars/hwengine.dpr
hedgewars/uKeys.pas
hedgewars/uMisc.pas
share/Info.plist.in
--- a/hedgewars/hwengine.dpr	Sun Apr 19 13:22:17 2009 +0000
+++ b/hedgewars/hwengine.dpr	Sun Apr 19 13:36:51 2009 +0000
@@ -27,7 +27,7 @@
 // these procedures/functions to the PascalImports.h file (also in the "Pascal Sources" group)
 // to make these functions available in the C/C++/Objective-C source files
 // (add "#include PascalImports.h" near the top of these files if it is not there yet)
-//Library PascalLibrary;
+
 program hwengine;
 uses
 	SDLh in 'SDLh.pas',
@@ -64,7 +64,7 @@
 	uFloat in 'uFloat.pas',
 	uStats in 'uStats.pas',
 	uChat in 'uChat.pas',
-	uLandTexture;
+	uLandTexture in 'uLandTexture.pas';
 
 {$INCLUDE options.inc}
 
@@ -186,6 +186,23 @@
 until isTerminated
 end;
 
+/////////////////////
+procedure DisplayUsage;
+begin
+	WriteLn('Wrong argument format: correct configurations is');
+	WriteLn();
+	WriteLn('  hwengine <path to data folder> <path to replay file> [option]');
+	WriteLn();
+	WriteLn('where [option] must be specified either as');
+	WriteLn(' --set-video [screen height] [screen width] [color dept]');
+	WriteLn(' --set-audio [volume] [enable music] [enable sounds]');
+	WriteLn(' --set-other [language file] [full screen] [show FPS]');
+	WriteLn(' --set-multimedia [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]');
+	WriteLn(' --set-everything [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]');
+	WriteLn();
+	WriteLn('Read documentation online at http://www.hedgewars.org/ for more information');
+end;
+
 ////////////////////
 procedure GetParams;
 var
@@ -228,30 +245,98 @@
      GameType:= gmtLandPreview;
      if ParamStr(3) <> 'landpreview' then OutError(errmsgShouldntRun, true);
      end;
- 14: begin
-     PathPrefix:= ParamStr(1);
-     recordFileName:= ParamStr(2);
-     val(ParamStr(3), cScreenWidth);
-     val(ParamStr(4), cScreenHeight);
-     cInitWidth:= cScreenWidth;
-     cInitHeight:= cScreenHeight;
-     cBitsStr:= ParamStr(5);
-     val(cBitsStr, cBits);
-     cFullScreen:= ParamStr(6) = '1';
-     isSoundEnabled:= ParamStr(7) = '1';
-     cLocaleFName:= ParamStr(8);
-     val(ParamStr(9), cInitVolume);
-     val(ParamStr(10), cTimerInterval);
-     cShowFPS:= ParamStr(11) = '1';
-     cAltDamage:= ParamStr(12) = '1';
-     isMusicEnabled:= ParamStr(13) = '1';
-     cReducedQuality:= ParamStr(14) = '1';
-     for p:= Succ(Low(TPathType)) to High(TPathType) do
-         if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
-     end;
-   else
-   OutError(errmsgShouldntRun, true)
-   end
+  2: begin
+		PathPrefix:= ParamStr(1);
+		recordFileName:= ParamStr(2);
+	 
+		for p:= Succ(Low(TPathType)) to High(TPathType) do
+			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
+	end;
+  6: begin
+		PathPrefix:= ParamStr(1);
+		recordFileName:= ParamStr(2);
+	 
+		if ParamStr(3) = '--set-video'	then
+		begin
+			val(ParamStr(4), cScreenWidth);
+			val(ParamStr(5), cScreenHeight);
+			cInitWidth:= cScreenWidth;
+			cInitHeight:= cScreenHeight;
+			cBitsStr:= ParamStr(6);
+			val(cBitsStr, cBits);
+		end
+		else
+		begin
+			if ParamStr(3) = '--set-audio' then
+			begin
+				val(ParamStr(4), cInitVolume);
+				isMusicEnabled:= ParamStr(5) = '1';
+				isSoundEnabled:= ParamStr(6) = '1';
+			end
+			else
+			begin
+				if ParamStr(3) = '--set-other' then
+				begin
+					cLocaleFName:= ParamStr(4);
+					cFullScreen:= ParamStr(5) = '1';
+					cShowFPS:= ParamStr(6) = '1';
+				end
+				else DisplayUsage;
+			end
+		end;
+		
+		for p:= Succ(Low(TPathType)) to High(TPathType) do
+			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
+	end;
+ 11: begin
+		PathPrefix:= ParamStr(1);
+		recordFileName:= ParamStr(2);
+	
+		if ParamStr(3) = '--set-multimedia' then
+		begin
+			val(ParamStr(4), cScreenWidth);
+			val(ParamStr(5), cScreenHeight);
+			cInitWidth:= cScreenWidth;
+			cInitHeight:= cScreenHeight;
+			cBitsStr:= ParamStr(6);
+			val(cBitsStr, cBits);
+			val(ParamStr(7), cInitVolume);
+			isMusicEnabled:= ParamStr(8) = '1';
+			isSoundEnabled:= ParamStr(9) = '1';
+			cLocaleFName:= ParamStr(10);
+			cFullScreen:= ParamStr(11) = '1';
+		end
+		else DisplayUsage;
+		
+		for p:= Succ(Low(TPathType)) to High(TPathType) do
+			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
+	end;
+ 15: begin
+		if ParamStr(3) = '--set-everything' then
+		begin
+			val(ParamStr(4), cScreenWidth);
+			val(ParamStr(5), cScreenHeight);
+			cInitWidth:= cScreenWidth;
+			cInitHeight:= cScreenHeight;
+			cBitsStr:= ParamStr(6);
+			val(cBitsStr, cBits);
+			val(ParamStr(7), cInitVolume);
+			isMusicEnabled:= ParamStr(8) = '1';
+			isSoundEnabled:= ParamStr(9) = '1';
+			cLocaleFName:= ParamStr(10);
+			cFullScreen:= ParamStr(11) = '1';
+			cAltDamage:= ParamStr(12) = '1';
+			cShowFPS:= ParamStr(13) = '1';
+			val(ParamStr(14), cTimerInterval);
+			cReducedQuality:= ParamStr(15) = '1';
+		end
+		else DisplayUsage;
+		
+		for p:= Succ(Low(TPathType)) to High(TPathType) do
+			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
+	end;
+	else DisplayUsage;
+	end;
 end;
 
 procedure ShowMainWindow;
@@ -336,7 +421,8 @@
 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine');
 GetParams;
 Randomize;
-{ /home/nemo/games/bin/hwengine /home/nemo/games/hedgewars/Data ~/.hedgewars/Saves/2009-03-22_19-54.hws_24 480 320 32 0 1 en.txt 128 33 0 1 1 0}
+
 if GameType = gmtLandPreview then GenLandPreview
                              else Game
 end.
+
--- a/hedgewars/uKeys.pas	Sun Apr 19 13:22:17 2009 +0000
+++ b/hedgewars/uKeys.pas	Sun Apr 19 13:36:51 2009 +0000
@@ -115,6 +115,7 @@
 DefaultBinds[ 27]:= 'quit';
 DefaultBinds[ 48]:= '+volup';
 DefaultBinds[ 57]:= '+voldown';
+DefaultBinds[ 44]:= 'history';	// , instead of `
 DefaultBinds[ 96]:= 'history';
 DefaultBinds[ 99]:= 'capture';
 DefaultBinds[104]:= 'findhh';
--- a/hedgewars/uMisc.pas	Sun Apr 19 13:22:17 2009 +0000
+++ b/hedgewars/uMisc.pas	Sun Apr 19 13:36:51 2009 +0000
@@ -55,8 +55,8 @@
 	cScreenHeight    : LongInt = 768;
 	cInitWidth       : LongInt = 1024;
 	cInitHeight      : LongInt = 768;
-	cBits            : LongInt = 16;
-	cBitsStr         : string[2] = '16';
+	cBits            : LongInt = 32;
+	cBitsStr         : string[2] = '32';
 	cTagsMask        : byte = 7;
 
 	cWaterLine       : LongInt = LAND_HEIGHT;
@@ -73,7 +73,7 @@
 	cColorNearBlack       : Longword = $FF000010;
 	cExplosionBorderColor : LongWord = $808080;
 
-	cShowFPS      : boolean = true;
+	cShowFPS      : boolean = false;
 	cCaseFactor   : Longword = 5;  {0..9}
 	cLandAdditions: Longword = 4;
 	cFullScreen   : boolean = false;
@@ -82,7 +82,7 @@
 	cSeed         : shortstring = '';
 	cInitVolume   : LongInt = 128;
 	cVolumeDelta  : LongInt = 0;
-	cTimerInterval   : Longword = 5;
+	cTimerInterval   : Longword = 8;
 	cHasFocus     : boolean = true;
 	cInactDelay   : Longword = 1250;
 
@@ -551,13 +551,21 @@
 
 {$IFDEF DEBUGFILE}
 {$I-}
-if ParamCount > 0 then
+if ParamCount >= 0 then
+ //this check prevents a crash in Mac OS X
+ if ParamCount = 0 then
+ begin
+	Assign(f, '/tmp/debug.txt');
+    rewrite(f);
+ end else
+ begin
   for i:= 0 to 7 do
     begin
     Assign(f, ParamStr(1) + '/debug' + inttostr(i) + '.txt');
     rewrite(f);
     if IOResult = 0 then break
     end;
+ end;
 {$I+}
 
 finalization
--- a/share/Info.plist.in	Sun Apr 19 13:22:17 2009 +0000
+++ b/share/Info.plist.in	Sun Apr 19 13:36:51 2009 +0000
@@ -5,7 +5,7 @@
 	<key>CFBundleExecutable</key>
 	<string>hedgewars</string>
 	<key>CFBundleGetInfoString</key>
-	<string>Hedgewars, a Worms-like game</string>
+	<string>http://www.hedgewars.org</string>
 	<key>CFBundleIconFile</key>
 	<string>Icon.icns</string>
 	<key>CFBundleIdentifier</key>