# HG changeset patch # User unc0rr # Date 1169676305 0 # Node ID 52cb4d6f84b75e365d9cab8ef5e155eec32a6ec0 # Parent c0d788307314b7be8c50a12af911b1ecfd3a0cb5 - Better land generator - Fix compilation without debug file diff -r c0d788307314 -r 52cb4d6f84b7 hedgewars/uGears.pas --- 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 diff -r c0d788307314 -r 52cb4d6f84b7 hedgewars/uLand.pas --- 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 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); diff -r c0d788307314 -r 52cb4d6f84b7 hedgewars/uLandTemplates.pas --- 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; ) ); diff -r c0d788307314 -r 52cb4d6f84b7 hedgewars/uTeams.pas --- 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 diff -r c0d788307314 -r 52cb4d6f84b7 tools/runhelper.dpr --- 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 - * - * 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.