1093 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1093 if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1094 else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
1094 else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
1095 end; |
1095 end; |
1096 |
1096 |
1097 //////////////////////////////////////////////////////////////////////////////// |
1097 //////////////////////////////////////////////////////////////////////////////// |
1098 const cSorterWorkTime = 640; |
|
1099 var thexchar: array[0..cMaxTeams] of |
|
1100 record |
|
1101 dy, ny, dw: LongInt; |
|
1102 team: PTeam; |
|
1103 SortFactor: QWord; |
|
1104 end; |
|
1105 currsorter: PGear = nil; |
|
1106 |
|
1107 procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
1108 var i: LongInt; |
|
1109 begin |
|
1110 AllInactive:= false; |
|
1111 dec(Gear^.Timer); |
|
1112 if (Gear^.Timer and 15) = 0 then |
|
1113 for i:= 0 to Pred(TeamsCount) do |
|
1114 with thexchar[i] do |
|
1115 begin |
|
1116 {$WARNINGS OFF} |
|
1117 team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
1118 team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
1119 {$WARNINGS ON} |
|
1120 end; |
|
1121 |
|
1122 if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
1123 begin |
|
1124 if currsorter = Gear then currsorter:= nil; |
|
1125 DeleteGear(Gear) |
|
1126 end |
|
1127 end; |
|
1128 |
|
1129 procedure doStepTeamHealthSorter(Gear: PGear); |
|
1130 var i: Longword; |
|
1131 b: boolean; |
|
1132 t: LongInt; |
|
1133 begin |
|
1134 AllInactive:= false; |
|
1135 |
|
1136 for t:= 0 to Pred(TeamsCount) do |
|
1137 with thexchar[t] do |
|
1138 begin |
|
1139 dy:= TeamsArray[t]^.DrawHealthY; |
|
1140 dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1141 team:= TeamsArray[t]; |
|
1142 SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1143 SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1144 SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1145 end; |
|
1146 |
|
1147 if TeamsCount > 1 then |
|
1148 repeat |
|
1149 b:= true; |
|
1150 for t:= 0 to TeamsCount - 2 do |
|
1151 if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1152 begin |
|
1153 thexchar[cMaxTeams]:= thexchar[t]; |
|
1154 thexchar[t]:= thexchar[Succ(t)]; |
|
1155 thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1156 b:= false |
|
1157 end |
|
1158 until b; |
|
1159 |
|
1160 t:= - 4; |
|
1161 for i:= 0 to Pred(TeamsCount) do |
|
1162 with thexchar[i] do |
|
1163 begin |
|
1164 dec(t, team^.HealthTex^.h + 2); |
|
1165 ny:= t; |
|
1166 dy:= dy - ny |
|
1167 end; |
|
1168 |
|
1169 Gear^.Timer:= cSorterWorkTime; |
|
1170 Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
1171 currsorter:= Gear |
|
1172 end; |
|
1173 |
|
1174 //////////////////////////////////////////////////////////////////////////////// |
|
1175 procedure doStepIdle(Gear: PGear); |
1098 procedure doStepIdle(Gear: PGear); |
1176 begin |
1099 begin |
1177 AllInactive:= false; |
1100 AllInactive:= false; |
1178 dec(Gear^.Timer); |
1101 dec(Gear^.Timer); |
1179 if Gear^.Timer = 0 then |
1102 if Gear^.Timer = 0 then |