846 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
846 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
847 else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
847 else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
848 end; |
848 end; |
849 |
849 |
850 //////////////////////////////////////////////////////////////////////////////// |
850 //////////////////////////////////////////////////////////////////////////////// |
851 var thexchar: array[0..5] of record |
851 const cSorterWorkTime = 640; |
852 oy, ny: LongInt; |
852 var thexchar: array[0..cMaxTeams] of |
|
853 record |
|
854 dy, ny, dw: LongInt; |
853 team: PTeam; |
855 team: PTeam; |
|
856 SortFactor: QWord; |
854 end; |
857 end; |
855 thexchcnt: Longword; |
|
856 currsorter: PGear; |
858 currsorter: PGear; |
857 |
859 |
858 procedure doStepTeamHealthSorterWork(Gear: PGear); |
860 procedure doStepTeamHealthSorterWork(Gear: PGear); |
859 var i: LongInt; |
861 var i: LongInt; |
860 begin |
862 begin |
861 AllInactive:= false; |
863 AllInactive:= false; |
862 dec(Gear^.Timer); |
864 dec(Gear^.Timer); |
863 if (Gear^.Timer and 15) = 0 then |
865 if (Gear^.Timer and 15) = 0 then |
864 for i:= 0 to Pred(thexchcnt) do |
866 for i:= 0 to Pred(TeamsCount) do |
865 with thexchar[i] do |
867 with thexchar[i] do |
|
868 begin |
866 {$WARNINGS OFF} |
869 {$WARNINGS OFF} |
867 team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640; |
870 team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
871 team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
868 {$WARNINGS ON} |
872 {$WARNINGS ON} |
|
873 end; |
869 if (Gear^.Timer = 0) or (currsorter <> Gear) then |
874 if (Gear^.Timer = 0) or (currsorter <> Gear) then |
870 begin |
875 begin |
871 if currsorter = Gear then currsorter:= nil; |
876 if currsorter = Gear then currsorter:= nil; |
872 DeleteGear(Gear) |
877 DeleteGear(Gear) |
873 end |
878 end |
874 end; |
879 end; |
875 |
880 |
876 procedure doStepTeamHealthSorter(Gear: PGear); |
881 procedure doStepTeamHealthSorter(Gear: PGear); |
877 var i, t: Longword; |
882 var i, t: Longword; |
878 begin |
883 b: boolean; |
879 AllInactive:= false; |
884 begin |
880 i:= 0; |
885 AllInactive:= false; |
|
886 |
881 for t:= 0 to Pred(TeamsCount) do |
887 for t:= 0 to Pred(TeamsCount) do |
882 with TeamsArray[t]^ do |
888 with thexchar[t] do |
883 begin |
889 begin |
884 thexchar[i].oy:= DrawHealthY; |
890 dy:= TeamsArray[t]^.DrawHealthY; |
885 thexchar[i].team:= TeamsArray[t]; |
891 dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
886 inc(i); |
892 team:= TeamsArray[t]; |
|
893 SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
894 SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
895 SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
887 end; |
896 end; |
888 |
897 |
889 thexchcnt:= i; |
898 repeat |
890 for i:= 1 to thexchcnt do |
899 b:= true; |
891 for t:= 0 to thexchcnt - 2 do |
900 for t:= 0 to TeamsCount - 2 do |
892 if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then |
901 if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
893 begin |
902 begin |
894 thexchar[5]:= thexchar[t]; |
903 thexchar[cMaxTeams]:= thexchar[t]; |
895 thexchar[t]:= thexchar[Succ(t)]; |
904 thexchar[t]:= thexchar[Succ(t)]; |
896 thexchar[Succ(t)]:= thexchar[5] |
905 thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
897 end; |
906 b:= false |
898 |
907 end |
|
908 until b; |
|
909 |
899 t:= cScreenHeight - 4; |
910 t:= cScreenHeight - 4; |
900 for i:= 0 to Pred(thexchcnt) do |
911 for i:= 0 to Pred(TeamsCount) do |
901 with thexchar[i] do |
912 with thexchar[i] do |
902 begin |
913 begin |
903 dec(t, team^.HealthRect.h + 2); |
914 dec(t, team^.HealthRect.h + 2); |
904 ny:= t |
915 ny:= t; |
|
916 dy:= dy - ny |
905 end; |
917 end; |
906 |
918 |
907 Gear^.Timer:= 640; |
919 Gear^.Timer:= cSorterWorkTime; |
908 Gear^.doStep:= @doStepTeamHealthSorterWork; |
920 Gear^.doStep:= @doStepTeamHealthSorterWork; |
909 currsorter:= Gear |
921 currsorter:= Gear |
910 end; |
922 end; |
911 |
923 |
912 //////////////////////////////////////////////////////////////////////////////// |
924 //////////////////////////////////////////////////////////////////////////////// |