# HG changeset patch # User unc0rr # Date 1322949618 -10800 # Node ID 71db3c0daa0a161cd77818765550b2e9416ab574 # Parent 736479f3d348ab787c5229b8ac37facbf98669c7 No more nested functions in code diff -r 736479f3d348 -r 71db3c0daa0a hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Sun Dec 04 00:56:07 2011 +0300 +++ b/hedgewars/uLandObjects.pas Sun Dec 04 01:00:18 2011 +0300 @@ -151,22 +151,22 @@ CheckIntersect:= res; end; + +function CountNonZeroz(x, y: LongInt): Longword; +var i: LongInt; + lRes: Longword; +begin + lRes:= 0; + for i:= y to y + 15 do + if Land[i, x] <> 0 then inc(lRes); + CountNonZeroz:= lRes; +end; + function AddGirder(gX: LongInt): boolean; var tmpsurf: PSDL_Surface; x1, x2, y, k, i: LongInt; rr: TSDL_Rect; bRes: boolean; - - function CountNonZeroz(x, y: LongInt): Longword; - var i: LongInt; - lRes: Longword; - begin - lRes:= 0; - for i:= y to y + 15 do - if Land[i, x] <> 0 then inc(lRes); - CountNonZeroz:= lRes; - end; - begin y:= topY+150; repeat @@ -376,19 +376,21 @@ TryPut:= bRes; end; + +procedure CheckRect(Width, Height, x, y, w, h: LongWord); +begin + if (x + w > Width) then + OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); + if (y + h > Height) then + OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); +end; + procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects); var s, key: shortstring; f: textfile; i: LongInt; ii, t: Longword; c2: TSDL_Color; - - procedure CheckRect(Width, Height, x, y, w, h: LongWord); - begin - if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); - if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); - end; - begin AddProgress; diff -r 736479f3d348 -r 71db3c0daa0a hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sun Dec 04 00:56:07 2011 +0300 +++ b/hedgewars/uStore.pas Sun Dec 04 01:00:18 2011 +0300 @@ -118,16 +118,15 @@ SDL_FreeSurface(tmpsurf) end; -procedure StoreLoad(reload: boolean); -var s: shortstring; - procedure WriteNames(Font: THWFont); - var t: LongInt; - i: LongInt; - r, rr: TSDL_Rect; - drY: LongInt; - texsurf, flagsurf, iconsurf: PSDL_Surface; - begin +procedure WriteNames(Font: THWFont); +var t: LongInt; + i: LongInt; + r, rr: TSDL_Rect; + drY: LongInt; + texsurf, flagsurf, iconsurf: PSDL_Surface; + s: shortstring; +begin r.x:= 0; r.y:= 0; drY:= - 4; @@ -220,11 +219,11 @@ SDL_FreeSurface(iconsurf); iconsurf:= nil; end; - end; +end; - procedure InitHealth; - var i, t: LongInt; - begin +procedure InitHealth; +var i, t: LongInt; +begin for t:= 0 to Pred(TeamsCount) do if TeamsArray[t] <> nil then with TeamsArray[t]^ do @@ -233,12 +232,12 @@ if Hedgehogs[i].Gear <> nil then RenderHealth(Hedgehogs[i]); end - end; +end; - procedure LoadGraves; - var t: LongInt; - texsurf: PSDL_Surface; - begin +procedure LoadGraves; +var t: LongInt; + texsurf: PSDL_Surface; +begin for t:= 0 to Pred(TeamsCount) do if TeamsArray[t] <> nil then with TeamsArray[t]^ do @@ -251,9 +250,11 @@ GraveTex:= Surface2Tex(texsurf, false); SDL_FreeSurface(texsurf) end - end; +end; -var ii: TSprite; +procedure StoreLoad(reload: boolean); +var s: shortstring; + ii: TSprite; fi: THWFont; ai: TAmmoType; tmpsurf: PSDL_Surface; diff -r 736479f3d348 -r 71db3c0daa0a hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Dec 04 00:56:07 2011 +0300 +++ b/hedgewars/uWorld.pas Sun Dec 04 01:00:18 2011 +0300 @@ -82,29 +82,30 @@ cStereo_Water_near = 0.0025; cStereo_Outside = -0.0400; + +// helper functions to create the goal/game mode string +function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; +var t: ansistring; +begin + if (GameFlags and gf) <> 0 then + begin + t:= inttostr(i); + s:= s + format(trgoal[si], t) + '|' + end; + AddGoal:= s; +end; + +function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; +begin + if (GameFlags and gf) <> 0 then + s:= s + trgoal[si] + '|'; + AddGoal:= s; +end; + procedure InitWorld; var i, t: LongInt; cp: PClan; g: ansistring; - - // helper functions to create the goal/game mode string - function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; - var t: ansistring; - begin - if (GameFlags and gf) <> 0 then - begin - t:= inttostr(i); - s:= s + format(trgoal[si], t) + '|' - end; - AddGoal:= s; - end; - - function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; - begin - if (GameFlags and gf) <> 0 then - s:= s + trgoal[si] + '|'; - AddGoal:= s; - end; begin missionTimer:= 0;