171 bool hasForcedExclusiveTrait =
false;
172 std::list<GarrAbilityEntry const*> result;
178 abilities = &itr->second;
180 std::list<GarrAbilityEntry const*> abilityList, forcedAbilities, traitList, forcedTraits;
191 forcedAbilities.push_back(ability);
193 abilityList.push_back(ability);
204 forcedTraits.push_back(ability);
206 traitList.push_back(ability);
216 forcedAbilities.splice(forcedAbilities.end(), abilityList);
217 forcedTraits.splice(forcedTraits.end(), traitList);
220 forcedAbilities.sort();
230 hasForcedExclusiveTrait =
true;
235 if (slots[0] > forcedAbilities.size() + abilityList.size())
238 std::list<GarrAbilityEntry const*> classSpecAbilitiesTemp, classSpecAbilitiesTemp2;
239 classSpecAbilitiesTemp2.swap(abilityList);
240 std::set_difference(classSpecAbilities.begin(), classSpecAbilities.end(), forcedAbilities.begin(), forcedAbilities.end(), std::back_inserter(classSpecAbilitiesTemp));
241 std::set_union(classSpecAbilitiesTemp.begin(), classSpecAbilitiesTemp.end(), classSpecAbilitiesTemp2.begin(), classSpecAbilitiesTemp2.end(), std::back_inserter(abilityList));
246 if (slots[1] > forcedTraits.size() + traitList.size())
248 std::list<GarrAbilityEntry const*> genericTraits, genericTraitsTemp;
260 genericTraitsTemp.push_back(ability);
263 std::set_difference(genericTraitsTemp.begin(), genericTraitsTemp.end(), forcedTraits.begin(), forcedTraits.end(), std::back_inserter(genericTraits));
264 genericTraits.splice(genericTraits.begin(), traitList);
273 return a1->
ID < a2->
ID;
275 genericTraits.unique();
277 std::size_t firstExclusive = 0, total = genericTraits.size();
278 for (
auto genericTraitItr = genericTraits.begin(); genericTraitItr != genericTraits.end(); ++genericTraitItr, ++firstExclusive)
282 while (traitList.size() < size_t(std::max<int32>(0, slots[1] - forcedTraits.size())) && total)
284 auto genericTraitItr = genericTraits.begin();
287 total = firstExclusive;
291 traitList.push_back(*genericTraitItr);
292 genericTraits.erase(genericTraitItr);
296 result.splice(result.end(), forcedAbilities);
297 result.splice(result.end(), abilityList);
298 result.splice(result.end(), forcedTraits);
299 result.splice(result.end(), traitList);
std::unordered_set< GarrAbilityEntry const * > Traits
Definition: GarrisonMgr.h:38
uint32 Flags
Definition: DB2Structure.h:430
void RandomResizeList(std::list< T > &list, uint32 size)
Definition: Containers.h:34
Definition: Garrison.h:51
void advance(octet_iterator &it, distance_type n, octet_iterator end)
Definition: checked.h:190
Definition: Garrison.h:50
std::unordered_map< uint32, GarrAbilities > _garrisonFollowerAbilities[2]
Definition: GarrisonMgr.h:70
std::set< GarrAbilityEntry const * > _garrisonFollowerRandomTraits
Definition: GarrisonMgr.h:72
std::unordered_set< GarrAbilityEntry const * > Counters
Definition: GarrisonMgr.h:37
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
std::list< GarrAbilityEntry const * > GetClassSpecAbilities(GarrFollowerEntry const *follower, uint32 faction) const
Definition: GarrisonMgr.cpp:304
uint32_t uint32
Definition: Define.h:150
uint32 ID
Definition: DB2Structure.h:429
Definition: Garrison.h:27
Definition: DB2Structure.h:427
uint32 const AbilitiesForQuality[][2]
Definition: GarrisonMgr.cpp:156
#define ASSERT
Definition: Errors.h:55
Definition: Garrison.h:52
Definition: Garrison.h:26
Definition: Garrison.h:53
Definition: GarrisonMgr.h:35