- Teams health bars sorting
authorunc0rr
Sun, 15 Jan 2006 14:14:12 +0000
changeset 49 3afe33c1cf06
parent 48 0f396d0c429d
child 50 9ab4067dabec
- Teams health bars sorting - Fixed slow walking on hedgehog - Fixed accidently disabled bots' ammo - Fixed exception when runnig engine without command line parameters - One more template
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
hedgewars/uLandTemplates.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Jan 15 14:14:12 2006 +0000
@@ -687,3 +687,60 @@
    doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound)
    end
 end;
+
+////////////////////////////////////////////////////////////////////////////////
+var thexchar: array[0..5] of record
+                             oy, ny: integer;
+                             team: PTeam;
+                             end;
+    thexchcnt: Longword;
+
+procedure doStepTeamHealthSorterWork(Gear: PGear);
+var i: integer;
+begin
+AllInactive:= false;
+dec(Gear.Timer);
+if (Gear.Timer and 15) = 0 then
+   for i:= 0 to Pred(thexchcnt) do
+       with thexchar[i] do
+            {$WARNINGS OFF}
+            team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
+            {$WARNINGS ON}
+if Gear.Timer = 0 then
+   DeleteGear(Gear)
+end;
+
+procedure doStepTeamHealthSorter(Gear: PGear);
+var team: PTeam;
+    i, t: Longword;
+begin
+AllInactive:= false;
+team:= TeamsList;
+i:= 0;
+while team <> nil do
+      begin
+      thexchar[i].oy:= team.DrawHealthY;
+      thexchar[i].team:= team;
+      inc(i);
+      team:= team.Next
+      end;
+thexchcnt:= i;
+for i:= 1 to thexchcnt do
+    for t:= 0 to thexchcnt - 2 do
+        if thexchar[t].team.TeamHealth > thexchar[Succ(t)].team.TeamHealth then
+           begin
+           thexchar[5]:= thexchar[t];
+           thexchar[t]:= thexchar[Succ(t)];
+           thexchar[Succ(t)]:= thexchar[5]
+           end;
+t:= cScreenHeight - 4;
+for i:= 0 to Pred(thexchcnt) do
+    with thexchar[i] do
+         begin
+         dec(t, team.HealthRect.h + 2);
+         ny:= t
+         end;
+Gear.Timer:= 640;
+Gear.doStep:= doStepTeamHealthSorterWork
+end;
+
--- a/hedgewars/HHHandlers.inc	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Jan 15 14:14:12 2006 +0000
@@ -338,6 +338,7 @@
       end;
    if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX;
 
+   AddIntersectorsCR(Gear);
    if not HHTestCollisionYwithGear(Gear, 1) then
    begin
    Gear.Y:= Gear.Y + 1;
@@ -369,7 +370,6 @@
    end
    end
    end;
-   AddIntersectorsCR(Gear);
    SetAllHHToActive
    end
 end;
--- a/hedgewars/uAIAmmoTests.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -49,10 +49,10 @@
                     Test: TAmmoTestProc;
                     Flags: Longword;
                     end = (
-                    ( Test: nil;//TestGrenade;
+                    ( Test: TestGrenade;
                       Flags: ctfNotFull;
                     ),
-                    ( Test: nil;//TestBazooka;
+                    ( Test: TestBazooka;
                       Flags: ctfNotFull or ctfBreach;
                     ),
                     ( Test: nil;
--- a/hedgewars/uConsts.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uConsts.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -47,7 +47,8 @@
                    sprMineOn, sprCase, sprFAid, sprDynamite);
      TGearType  = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
                    gtGrave, gtUFO, gtShotgunShot, gtActionTimer, gtPickHammer, gtRope,
-                   gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite);
+                   gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite,
+                   gtTeamHealthSorter);
      TGearsType = set of TGearType;
      TSound     = (sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, sndSplash,
                    sndShotgunReload, sndShotgunFire, sndGraveImpact, sndMineTick);
--- a/hedgewars/uGears.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uGears.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -114,7 +114,8 @@
                                                                doStepMine,
                                                                doStepCase,
                                                                doStepDEagleShot,
-                                                               doStepDynamite
+                                                               doStepDynamite,
+                                                               doStepTeamHealthSorter
                                                                );
 
 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
@@ -277,7 +278,7 @@
             Gear.Damage:= 0
             end;
       Gear:= Gear.NextGear
-      end;
+      end
 end;
 
 procedure ProcessGears;
--- a/hedgewars/uIO.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uIO.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -49,7 +49,7 @@
 implementation
 uses uConsole, uConsts, uWorld, uMisc, uRandom, uLand;
 const isPonged: boolean = false;
-var  IPCSock: PTCPSocket;
+var  IPCSock: PTCPSocket = nil;
      fds: PSDLNet_SocketSet;
 
      extcmd: array[word] of packed record
@@ -134,12 +134,14 @@
 
 procedure SendIPC(s: shortstring);
 begin
-//WriteLnToConsole(s);
-if s[0]>#251 then s[0]:= #251;
-PLongWord(@s[Succ(byte(s[0]))])^:= GameTicks;
-{$IFDEF DEBUGFILE}AddFileLog('IPC send: '+s);{$ENDIF}
-inc(s[0],4);
-SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0])))
+if IPCSock <> nil then
+   begin
+   if s[0]>#251 then s[0]:= #251;
+   PLongWord(@s[Succ(byte(s[0]))])^:= GameTicks;
+   {$IFDEF DEBUGFILE}AddFileLog('IPC send: '+s);{$ENDIF}
+   inc(s[0],4);
+   SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0])))
+   end
 end;
 
 procedure SendIPCAndWaitReply(s: shortstring);
--- a/hedgewars/uLandTemplates.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uLandTemplates.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -218,7 +218,60 @@
        (x: 1023; y: 1023)
       );
 
-const EdgeTemplates: array[0..6] of TEdgeTemplate =
+const Template7Points: array[0..43] of TPoint =
+      (
+       (x:  180; y: 1485),
+       (x:  411; y: 1020),
+       (x:  402; y:  912),
+       (x:  141; y:  897),
+       (x:  156; y:  729),
+       (x:  417; y:  813),
+       (x:  432; y:  585),
+       (x:  147; y:  570),
+       (x:  138; y:  435),
+       (x:  444; y:  417),
+       (x:  447; y:  207),
+       (x:  573; y:  261),
+       (x:  663; y:  201),
+       (x:  711; y:  375),
+       (x:  897; y:  411),
+       (x:  936; y:  498),
+       (x:  663; y:  558),
+       (x:  669; y:  762),
+       (x:  957; y:  723),
+       (x:  984; y:  864),
+       (x:  729; y:  879),
+       (x:  879; y: 1020),
+       (x:  981; y: 1449),
+       (x: 1242; y: 1449),
+       (x: 1476; y: 1020),
+       (x: 1470; y:  900),
+       (x: 1284; y:  897),
+       (x: 1218; y:  774),
+       (x: 1464; y:  765),
+       (x: 1464; y:  672),
+       (x: 1119; y:  630),
+       (x: 1116; y:  537),
+       (x: 1485; y:  501),
+       (x: 1167; y:  246),
+       (x: 1263; y:  180),
+       (x: 1572; y:  312),
+       (x: 1767; y:  162),
+       (x: 1827; y:  306),
+       (x: 1647; y:  465),
+       (x: 1875; y:  621),
+       (x: 1683; y:  747),
+       (x: 1665; y:  831),
+       (x: 1818; y:  951),
+       (x: 1893; y: 1476)
+       );
+      Template7FPoints: array[0..1] of TPoint =
+      (
+       (x: 630; y: 1023),
+       (x:1655; y: 1023)
+      );
+
+const EdgeTemplates: array[0..7] of TEdgeTemplate =
       (
        (BasePoints: @Template0Points;
         BasePointsCount: Succ(High(Template0Points));
@@ -269,7 +322,7 @@
         FillPoints: @Template4FPoints;
         FillPointsCount: Succ(High(Template4FPoints));
         canMirror: true; canFlip: false;
-       ),       
+       ),
        (BasePoints: @Template5Points;
         BasePointsCount: Succ(High(Template5Points));
         BezPassCnt: 4;
@@ -289,6 +342,16 @@
        FillPoints: @Template6FPoints;
        FillPointsCount: Succ(High(Template6FPoints));
        canMirror: true; canFlip: false;
+      ),
+      (BasePoints: @Template7Points;
+       BasePointsCount: Succ(High(Template7Points));
+       BezPassCnt: 3;
+       PassMin: 12; PassDelta: 4;
+       WaveAmplMin:     5; WaveAmplDelta: 15;
+       WaveFreqMin: 0.015; WaveFreqDelta: 0.002;
+       FillPoints: @Template7FPoints;
+       FillPointsCount: Succ(High(Template7FPoints));
+       canMirror: true; canFlip: false;
       )
        
       );
--- a/hedgewars/uStore.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uStore.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -343,9 +343,11 @@
     var Team: PTeam;
         i: integer;
         r, rr: TSDL_Rect;
+        drY: integer;
     begin
     r.x:= 0;
     r.y:= 272;
+    drY:= cSCreenHeight - 4;
     Team:= TeamsList;
     while Team<>nil do
       begin
@@ -360,6 +362,8 @@
       inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
       DrawRoundRect(@rr, Team.Color, Team.Color, StoreSurface);
       inc(r.y, r.h);
+      dec(drY, r.h + 2);
+      Team.DrawHealthY:= drY;
       for i:= 0 to 7 do
           if Team.Hedgehogs[i].Gear<>nil then
              begin
--- a/hedgewars/uTeams.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uTeams.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -65,6 +65,7 @@
              GraveName: string;
              FortName: string;
              TeamHealth: integer;
+             DrawHealthY: integer;
              AttackBar: LongWord;
              end;
 
@@ -307,7 +308,8 @@
         MaxTeamHealth:= TeamHealth;
         RecountAllTeamsHealth;
         end else TeamHealth:= (TeamHealth * cTeamHealthWidth) div MaxTeamHealth
-     end
+     end;
+AddGear(0, 0, gtTeamHealthSorter, 0)
 end;
 
 initialization
--- a/hedgewars/uWorld.pas	Thu Jan 12 22:07:36 2006 +0000
+++ b/hedgewars/uWorld.pas	Sun Jan 15 14:14:12 2006 +0000
@@ -201,20 +201,21 @@
 
 // Teams Healths
 team:= TeamsList;
-i:= cSCreenHeight - 32;
 while team <> nil do
       begin
-      DrawFromStoreRect(cScreenWidth div 2 - team.NameRect.w - 3, i,
+      DrawFromStoreRect(cScreenWidth div 2 - team.NameRect.w - 3,
+                        Team.DrawHealthY,
                         @team.NameRect, Surface);
       r:= team.HealthRect;
       r.w:= 3 + team.TeamHealth;
-      DrawFromStoreRect(cScreenWidth div 2, i,
+      DrawFromStoreRect(cScreenWidth div 2,
+                        Team.DrawHealthY,
                         @r, Surface);
       inc(r.x, cTeamHealthWidth + 3);
       r.w:= 2;
-      DrawFromStoreRect(cScreenWidth div 2 + team.TeamHealth + 3, i,
+      DrawFromStoreRect(cScreenWidth div 2 + team.TeamHealth + 3,
+                        Team.DrawHealthY,
                         @r, Surface);
-      dec(i, team.HealthRect.h + 2);
       team:= team.Next
       end;