--- a/hedgewars/uGears.pas Wed Jan 24 21:58:43 2007 +0000
+++ b/hedgewars/uGears.pas Wed Jan 24 22:05:05 2007 +0000
@@ -677,8 +677,6 @@
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
begin
Gear^.dX:= Gear^.dX + (_0_005 * dmg + cHHKick) * hwSign(Gear^.X - X);
- addfilelog(' >> _0_005 * dmg = '+floattostr(_0_005 * dmg));
- addfilelog(' >> dx = '+floattostr(Gear^.dX));
Gear^.dY:= Gear^.dY + (_0_005 * dmg + cHHKick) * hwSign(Gear^.Y - Y);
Gear^.Active:= true;
FollowGear:= Gear
--- a/hedgewars/uLand.pas Wed Jan 24 21:58:43 2007 +0000
+++ b/hedgewars/uLand.pas Wed Jan 24 22:05:05 2007 +0000
@@ -101,7 +101,7 @@
dec(eY, d);
inc(y, sY);
end;
-
+
if ((x and $FFFFF800) = 0) and ((y and $FFFFFC00) = 0) then
Land[y, x]:= Color;
end
@@ -175,6 +175,77 @@
end;
end;
+procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat);
+var x, y, i: integer;
+ tx, ty, vx, vy, vlen, t: hwFloat;
+ r1, r2, r3, r4: hwFloat;
+ x1, y1, x2, y2, cx1, cy1, cx2, cy2, tsq, tcb: hwFloat;
+ opa: TPixAr;
+begin
+opa:= pa;
+pa.Count:= 0;
+vx:= 0;
+vy:= 0;
+with opa do
+for i:= 0 to Count-2 do
+ begin
+ vlen:= Distance(ar[i + 1].x - ar[i].X, ar[i + 1].y - ar[i].y);
+ t:= Distance(ar[i + 1].x - ar[i + 2].X,ar[i + 1].y - ar[i + 2].y);
+ if t<vlen then vlen:= t;
+ vlen:= vlen * _1div3;
+ tx:= ar[i+2].X - ar[i].X;
+ ty:= ar[i+2].y - ar[i].y;
+ t:= Distance(tx, ty);
+ if t.QWordValue = 0 then
+ begin
+ tx:= -tx * 100000;
+ ty:= -ty * 100000;
+ end else
+ begin
+ t:= 1/t;
+ tx:= -tx * t;
+ ty:= -ty * t;
+ end;
+ t:= vlen;
+ tx:= tx*t;
+ ty:= ty*t;
+ x1:= ar[i].x;
+ y1:= ar[i].y;
+ x2:= ar[i + 1].x;
+ y2:= ar[i + 1].y;
+ cx1:= ar[i].X + hwRound(vx);
+ cy1:= ar[i].y + hwRound(vy);
+ cx2:= ar[i+1].X + hwRound(tx);
+ cy2:= ar[i+1].y + hwRound(ty);
+ vx:= -tx;
+ vy:= -ty;
+ t:= 0;
+ while t.Round = 0 do
+ begin
+ tsq:= t * t;
+ tcb:= tsq * t;
+ r1:= (1 - 3*t + 3*tsq - tcb) * x1;
+ r2:= ( 3*t - 6*tsq + 3*tcb) * cx1;
+ r3:= ( 3*tsq - 3*tcb) * cx2;
+ r4:= ( tcb) * x2;
+ X:= hwRound(r1 + r2 + r3 + r4);
+ r1:= (1 - 3*t + 3*tsq - tcb) * y1;
+ r2:= ( 3*t - 6*tsq + 3*tcb) * cy1;
+ r3:= ( 3*tsq - 3*tcb) * cy2;
+ r4:= ( tcb) * y2;
+ Y:= hwRound(r1 + r2 + r3 + r4);
+ t:= t + Delta;
+ pa.ar[pa.Count].x:= X;
+ pa.ar[pa.Count].y:= Y;
+ inc(pa.Count);
+ TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true)
+ end;
+ end;
+pa.ar[pa.Count].x:= opa.ar[Pred(opa.Count)].X;
+pa.ar[pa.Count].y:= opa.ar[Pred(opa.Count)].Y;
+inc(pa.Count)
+end;
+
procedure FillLand(x, y: integer);
var Stack: record
Count: Longword;
@@ -338,7 +409,7 @@
end;
end
end;
-
+(*
procedure NormalizePoints(var pa: TPixAr);
const brd = 32;
var isUP: boolean; // HACK: transform for Y should be exact as one for X
@@ -386,8 +457,43 @@
with pa.ar[i] do
y:= round((y - 1023) * Height div OHeight + 1023)
end;
+end;*)
+
+procedure RandomizePoints(var pa: TPixAr);
+const cEdge = 55;
+ cMinDist = 14;
+var radz: array[0..Pred(cMaxEdgePoints)] of integer;
+ i, k, dist: integer;
+begin
+radz[0]:= 0;
+for i:= 0 to Pred(pa.Count) do
+ with pa.ar[i] do
+ begin
+ radz[i]:= Min(Max(x - cEdge, 0), Max(2048 - cEdge - x, 0));
+ radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(1024 - cEdge - y, 0)));
+ if radz[i] > 0 then
+ for k:= 0 to Pred(i) do
+ begin
+ dist:= Min(Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y)), 50);
+ if radz[k] >= dist then
+ begin
+ radz[k]:= Max(0, dist - cMinDist * 2);
+ radz[i]:= Min(dist - radz[k], radz[i])
+ end;
+ radz[i]:= Min(radz[i], dist)
+ end
+ end;
+
+for i:= 0 to Pred(pa.Count) do
+ with pa.ar[i] do
+ if ((x and $FFFFF800) = 0) and ((y and $FFFFFC00) = 0) then
+ begin
+ x:= x + integer(GetRandom(radz[i] * 2 + 1)) - radz[i];
+ y:= y + integer(GetRandom(radz[i] * 2 + 1)) - radz[i]
+ end
end;
+
procedure GenBlank(var Template: TEdgeTemplate);
var pa: TPixAr;
i: Longword;
@@ -398,7 +504,9 @@
Land[y, x]:= COLOR_LAND;
SetPoints(Template, pa);
-NormalizePoints(pa);
+BezierizeEdge(pa, _1div3);
+for i:= 0 to Pred(Template.RandPassesCount) do RandomizePoints(pa);
+//NormalizePoints(pa);
DrawBezierEdge(pa, 0);
--- a/hedgewars/uLandTemplates.pas Wed Jan 24 21:58:43 2007 +0000
+++ b/hedgewars/uLandTemplates.pas Wed Jan 24 22:05:05 2007 +0000
@@ -28,6 +28,7 @@
BasePointsCount: Longword;
FillPoints: PPointArray;
FillPointsCount: Longword;
+ RandPassesCount: Longword;
canMirror, canFlip: boolean;
end;
@@ -115,18 +116,21 @@
BasePointsCount: Succ(High(Template0Points));
FillPoints: @Template0FPoints;
FillPointsCount: Succ(High(Template0FPoints));
+ RandPassesCount: 4;
canMirror: true; canFlip: false;
),
(BasePoints: @Template1Points;
BasePointsCount: Succ(High(Template1Points));
FillPoints: @Template1FPoints;
FillPointsCount: Succ(High(Template1FPoints));
+ RandPassesCount: 3;
canMirror: true; canFlip: false;
),
(BasePoints: @Template2Points;
BasePointsCount: Succ(High(Template2Points));
FillPoints: @Template2FPoints;
FillPointsCount: Succ(High(Template2FPoints));
+ RandPassesCount: 3;
canMirror: true; canFlip: false;
)
);
--- a/hedgewars/uTeams.pas Wed Jan 24 21:58:43 2007 +0000
+++ b/hedgewars/uTeams.pas Wed Jan 24 22:05:05 2007 +0000
@@ -158,10 +158,8 @@
ResetKbd;
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed);
-addfilelog('SwitchHedgehog 06');
g:= AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1);
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
-addfilelog('SwitchHedgehog 07');
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
ApplyAmmoChanges(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
if CurrentTeam^.ExtDriven then SetDefaultBinds
--- a/tools/runhelper.dpr Wed Jan 24 21:58:43 2007 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-(*
- * Hedgewars, a worms-like game
- * Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * Distributed under the terms of the BSD-modified licence:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * with the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *)
-
-program runhelper;
-{$APPTYPE CONSOLE}
-{$J+}
-uses SDLh;
-var servsock, clsock: PTCPSocket;
- ip: TIPAddress;
- event: TSDL_Event;
-
-procedure Send(s: shortstring);
-begin
-SDLNet_TCP_Send(clsock, @s, succ(byte(s[0])))
-end;
-
-procedure SendConfig;
-begin
-Send('TL');
-Send('e$gmflags 1');
-Send('eseed -=31337=-');
-Send('etheme steel');
-Send('eaddteam');
-Send('ename team "C0CuCKAzZz"');
-Send('ename hh0 "hh0"');
-Send('ename hh1 "hh1');
-Send('ename hh2 "hh2');
-Send('ename hh3 "hh3');
-Send('ename hh4 "hh4');
-Send('ename hh5 "Just hedgehog"');
-Send('ename hh6 "hh5');
-Send('ename hh7 "hh6');
-Send('ebind left "+left"');
-Send('ebind right "+right"');
-Send('ebind up "+up"');
-Send('ebind down "+down"');
-Send('ebind F1 "slot 1"');
-Send('ebind F2 "slot 2"');
-Send('ebind F3 "slot 3"');
-Send('ebind F4 "slot 4"');
-Send('ebind F5 "slot 5"');
-Send('ebind F6 "slot 6"');
-Send('ebind F7 "slot 7"');
-Send('ebind F8 "slot 8"');
-Send('ebind F10 "quit"');
-Send('ebind F11 "capture"');
-Send('ebind space "+attack"');
-Send('ebind return "ljump"');
-Send('ebind backspace "hjump"');
-Send('ebind tab "switch"');
-Send('ebind 1 "timer 1"');
-Send('ebind 2 "timer 2"');
-Send('ebind 3 "timer 3"');
-Send('ebind 4 "timer 4"');
-Send('ebind 5 "timer 5"');
-Send('ebind mousel "put"');
-Send('egrave "coffin"');
-Send('efort "Barrelhouse"');
-Send('ecolor 65535');
-Send('eadd hh0 0');
-Send('eadd hh1 0');
-Send('eadd hh2 0');
-Send('eadd hh3 0');
-Send('eaddteam');
-Send('ename team "-= 1 =-"');
-Send('ename hh0 "hh0"');
-Send('ename hh1 "hh1');
-Send('ename hh2 "hh2');
-Send('ename hh3 "hh3');
-Send('ename hh4 "hh4');
-Send('ename hh5 "Just hedgehog"');
-Send('ename hh6 "hh5');
-Send('ename hh7 "hh6');
-Send('egrave Bone');
-Send('ecolor 16776960');
-Send('eadd hh0 1');
-Send('eadd hh1 1');
-Send('eadd hh2 1');
-Send('eadd hh3 1');
-Send('efort Barrelhouse');
-end;
-
-procedure ParseCmd(s: shortstring);
-begin
-case s[1] of
- '?': Send('!');
- 'C': SendConfig;
- end;
-end;
-
-procedure DoIt;
-const ss: string = '';
-var s: shortstring;
- i: integer;
-begin
-i:= SDLNet_TCP_Recv(clsock, @s[1], 255);
-if i <= 0 then
- begin
- if i = -1 then exit;
- SDLNet_TCP_Close(clsock);
- clsock:= nil;
- ss:= '';
- exit
- end;
-byte(s[0]):= i;
-ss:= ss + s;
-while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
- begin
- s:= copy(ss, 2, byte(ss[1]));
- Delete(ss, 1, Succ(byte(ss[1])));
- ParseCmd(s)
- end;
-end;
-
-begin
-WriteLn('run hwengine 640 480 16 46631 0 1 ru.txt 128');
-SDL_Init(0);
-SDLNet_Init;
-ip.host:= 0;
-ip.port:= $27B6;
-servsock:= SDLNet_TCP_Open(ip);
-repeat
- if clsock = nil then
- clsock:= SDLNet_TCP_Accept(servsock);
- if clsock <> nil then
- DoIt;
- SDL_PollEvent(@event);
- SDL_Delay(1)
-until event.type_ = SDL_QUITEV;
-SDLNet_Quit;
-SDL_Quit
-end.