Engine:
authorsmxx
Thu, 18 Feb 2010 13:23:24 +0000
changeset 2825 db7c35a0e9c1
parent 2824 2d25e49bc2e8
child 2826 fbcfc86ef477
Engine: * Removed memory leaks displaying usage / syntax
hedgewars/hwengine.pas
hedgewars/uConsts.pas
--- a/hedgewars/hwengine.pas	Thu Feb 18 01:02:28 2010 +0000
+++ b/hedgewars/hwengine.pas	Thu Feb 18 13:23:24 2010 +0000
@@ -437,7 +437,6 @@
 	for i:=0 to ParamCount do
 		Write(ParamStr(i) + ' ');
 	WriteLn();
-	halt(1);
 end;
 
 ////////////////////
@@ -509,7 +508,7 @@
 						cFullScreen:= ParamStr(5) = '1';
 						cShowFPS:= ParamStr(6) = '1';
 					end
-					else DisplayUsage;
+					else GameType:= gmtSyntax;
 				end
 			end;
 		end;
@@ -531,7 +530,7 @@
 				cLocaleFName:= ParamStr(10);
 				cFullScreen:= ParamStr(11) = '1';
 			end
-			else DisplayUsage;
+			else GameType:= gmtSyntax;
 		end;
 		15: begin
 			PathPrefix:= ParamStr(1);
@@ -554,9 +553,9 @@
 				val(ParamStr(14), cTimerInterval);
 				cReducedQuality:= ParamStr(15) = '1';
 			end
-			else DisplayUsage;
+			else GameType:= gmtSyntax;
 		end;
-		else DisplayUsage;
+		else GameType:= gmtSyntax;
 	end;
 
 {$IFDEF DEBUGFILE}
@@ -580,8 +579,13 @@
 	Randomize();
 
 	if GameType = gmtLandPreview then GenLandPreview()
+	else if GameType = gmtSyntax then DisplayUsage()
 	else Game();
 	freeEverything();
-	ExitCode:= 0;
+	
+	if GameType = gmtSyntax then
+		ExitCode:= 1
+	else
+		ExitCode:= 0;
 {$ENDIF}
 end.
--- a/hedgewars/uConsts.pas	Thu Feb 18 01:02:28 2010 +0000
+++ b/hedgewars/uConsts.pas	Thu Feb 18 13:23:24 2010 +0000
@@ -41,7 +41,7 @@
 		
 	TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
 
-	TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview);
+	TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax);
 
 	TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps,
 			ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts,