- Better landgen
authorunc0rr
Tue, 26 Sep 2006 20:25:42 +0000
changeset 173 004493dd60e4
parent 172 5294ada3910b
child 174 0b2c5b22f644
- Better landgen - Small fixes
QTfrontend/main.cpp
hedgewars/CMakeLists.txt
hedgewars/uLand.pas
--- a/QTfrontend/main.cpp	Tue Sep 26 20:24:32 2006 +0000
+++ b/QTfrontend/main.cpp	Tue Sep 26 20:25:42 2006 +0000
@@ -73,7 +73,7 @@
 	Translator.load(":/translations/hedgewars_" + QLocale::system().name());
 	app.installTranslator(&Translator);
 
-	QDir mydir("/home/igor/sources/hedgewars");
+	QDir mydir(".");
 	mydir.cd("bin");
 
 	bindir = new QDir(mydir);
--- a/hedgewars/CMakeLists.txt	Tue Sep 26 20:24:32 2006 +0000
+++ b/hedgewars/CMakeLists.txt	Tue Sep 26 20:25:42 2006 +0000
@@ -24,12 +24,12 @@
 		string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
 		string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
 		math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
-		if (fpc_ver LESS "010902")
-			message("Minimum required version of FreePascal is 1.9.2")
-		else (fpc_ver LESS "010902")
+		if (${fpc_ver} LESS "010906")
+			message("Minimum required version of FreePascal is 2.0.5")
+		else (${fpc_ver} LESS "010906")
 			set(pascal_compiler ${fpc_executable})
 			set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project})
-		endif (fpc_ver LESS "010902")
+		endif (${fpc_ver} LESS "010906")
 	endif (fpc_version)
 endif (dcc32version)
 
--- a/hedgewars/uLand.pas	Tue Sep 26 20:24:32 2006 +0000
+++ b/hedgewars/uLand.pas	Tue Sep 26 20:25:42 2006 +0000
@@ -329,11 +329,18 @@
     end;
 end;
 
+function rndSign(num: Double): Double;
+begin
+if getrandom(2) = 0 then Result:=   num
+                    else Result:= - num
+end;
+
+
 procedure PointWave(var Template: TEdgeTemplate; var pa: TPixAr);
 const MAXPASSES = 32;
-var ar: array[0..MAXPASSES, 0..5] of Double;
+var ar: array[0..MAXPASSES, 0..9] of Double;
     i, k: integer;
-    rx, ry, oy: Double;
+    rx, ry, ox, oy: Double;
     PassesNum: Longword;
 begin
 with Template do
@@ -350,11 +357,10 @@
          ar[i, 3]:= WaveAmplMin + getrandom * WaveAmplDelta;
          ar[i, 4]:= ar[i - 1, 4] + (getrandom * 0.7 + 0.3) * WaveFreqDelta;
          ar[i, 5]:= getrandom * pi * 2;
-         {$IFDEF DEBUGFILE}
-         AddFileLog('Wave params ¹' + inttostr(i) + ':');
-         AddFileLog('X: ampl = ' + floattostr(ar[i, 0]) + '; freq = ' + floattostr(ar[i, 1]) + '; shift = ' + floattostr(ar[i, 2]));
-         AddFileLog('Y: ampl = ' + floattostr(ar[i, 3]) + '; freq = ' + floattostr(ar[i, 4]) + '; shift = ' + floattostr(ar[i, 5]));
-         {$ENDIF}
+         ar[i, 6]:= ar[i, 1] * (getrandom * 2 - 1);
+         ar[i, 7]:= ar[i, 1] * rndSign(sqrt(1 - sqr(ar[i, 6])));
+         ar[i, 8]:= ar[i, 4] * (getrandom * 2 - 1);
+         ar[i, 9]:= ar[i, 4] * rndSign(sqrt(1 - sqr(ar[i, 8])));
          end;
      end;
 
@@ -364,9 +370,10 @@
     ry:= pa.ar[k].y;
     for i:= 1 to PassesNum do
         begin
+        ox:= rx;
         oy:= ry;
-        ry:= ry + ar[i, 0] * sin(ar[i, 1] * rx + ar[i, 2]);
-        rx:= rx + ar[i, 3] * sin(ar[i, 4] * oy + ar[i, 5]);
+        ry:= ry + ar[i, 0] * sin(ox * ar[i, 6] + oy * ar[i, 7] + ar[i, 2]);
+        rx:= rx + ar[i, 3] * sin(ox * ar[i, 8] + oy * ar[i, 9] + ar[i, 5]);
         end;
     pa.ar[k].x:= round(rx);
     pa.ar[k].y:= round(ry);