hedgewars/VGSHandlers.inc
changeset 7644 ed7fecd0f5fd
parent 7375 16ae2e1c9005
child 7808 cc1805cd9138
equal deleted inserted replaced
7643:97b98bcfd056 7644:ed7fecd0f5fd
   432     currsorter: PVisualGear = nil;
   432     currsorter: PVisualGear = nil;
   433 
   433 
   434 procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword);
   434 procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword);
   435 var i, t: LongInt;
   435 var i, t: LongInt;
   436 begin
   436 begin
   437 for t:= 1 to Steps do
   437 for t:= 1 to min(Steps, Gear^.Timer) do
   438     begin
   438     begin
   439     dec(Gear^.Timer);
   439     dec(Gear^.Timer);
   440     if (Gear^.Timer and 15) = 0 then
   440     if (Gear^.Timer and 15) = 0 then
   441         for i:= 0 to Pred(TeamsCount) do
   441         for i:= 0 to Pred(TeamsCount) do
   442             with thexchar[i] do
   442             with thexchar[i] do
   443                 begin
   443                 begin
   444                 {$WARNINGS OFF}
   444                 {$WARNINGS OFF}
   445                 team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640;
   445                 team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div cSorterWorkTime;
   446                 team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime;
   446                 team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime;
   447                 {$WARNINGS ON}
   447                 {$WARNINGS ON}
   448                 end;
   448                 end;
   449 
   449     end;
   450     if (Gear^.Timer = 0) or (currsorter <> Gear) then
   450 
   451         begin
   451 if (Gear^.Timer = 0) or (currsorter <> Gear) then
   452         if currsorter = Gear then
   452     begin
   453             currsorter:= nil;
   453     if currsorter = Gear then
   454         DeleteVisualGear(Gear);
   454         currsorter:= nil;
   455         exit
   455     DeleteVisualGear(Gear);
   456         end
   456     exit
   457     end
   457     end
   458 end;
   458 end;
   459 
   459 
   460 procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword);
   460 procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword);
   461 var i: Longword;
   461 var i: Longword;
   462     b: boolean;
   462     b: boolean;
   463     t: LongInt;
   463     t: LongInt;
   464 begin
   464 begin
   465 Steps:= Steps; // avoid compiler hint
   465 Steps:= Steps; // avoid compiler hint
       
   466 
   466 for t:= 0 to Pred(TeamsCount) do
   467 for t:= 0 to Pred(TeamsCount) do
   467     with thexchar[t] do
   468     with thexchar[t] do
   468         begin
   469         begin
   469         dy:= TeamsArray[t]^.DrawHealthY;
       
   470         dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth;
       
   471         team:= TeamsArray[t];
   470         team:= TeamsArray[t];
   472         SortFactor:= TeamsArray[t]^.Clan^.ClanHealth;
   471         dy:= team^.DrawHealthY;
   473         SortFactor:= (SortFactor shl  3) + TeamsArray[t]^.Clan^.ClanIndex;
   472         dw:= team^.TeamHealthBarWidth - team^.NewTeamHealthBarWidth;
   474         SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth;
   473         if team^.TeamHealth > 0 then
       
   474             begin
       
   475             SortFactor:= team^.Clan^.ClanHealth;
       
   476             SortFactor:= (SortFactor shl  3) + team^.Clan^.ClanIndex;
       
   477             SortFactor:= (SortFactor shl 30) + team^.TeamHealth;
       
   478             end
       
   479         else
       
   480             SortFactor:= 0;
   475         end;
   481         end;
   476 
   482 
   477 if TeamsCount > 1 then
   483 if TeamsCount > 1 then
   478     repeat
   484     repeat
   479     b:= true;
   485     b:= true;
   487             end
   493             end
   488     until b;
   494     until b;
   489 
   495 
   490 t:= - 4;
   496 t:= - 4;
   491 for i:= 0 to Pred(TeamsCount) do
   497 for i:= 0 to Pred(TeamsCount) do
   492     with thexchar[i] do
   498         with thexchar[i] do
   493         begin
   499           if team^.TeamHealth > 0 then
   494         dec(t, team^.HealthTex^.h + 2);
   500             begin
   495         ny:= t;
   501             dec(t, team^.HealthTex^.h + 2);
   496         dy:= dy - ny
   502             ny:= t;
   497         end;
   503             dy:= dy - ny
       
   504             end;
   498 
   505 
   499 Gear^.Timer:= cSorterWorkTime;
   506 Gear^.Timer:= cSorterWorkTime;
   500 Gear^.doStep:= @doStepTeamHealthSorterWork;
   507 Gear^.doStep:= @doStepTeamHealthSorterWork;
   501 currsorter:= Gear;
   508 currsorter:= Gear;
   502 //doStepTeamHealthSorterWork(Gear, Steps)
   509 //doStepTeamHealthSorterWork(Gear, Steps)