32 struct RandomBonusListIds
34 std::vector<int32> BonusListIDs;
35 std::vector<double> Chances;
38 std::unordered_map<uint32, RandomBonusListIds> _storage;
56 Field* fields = result->Fetch();
64 TC_LOG_ERROR(
"sql.sql",
"Bonus list {} used in `item_random_bonus_list_template` by id {} doesn't have exist in ItemBonus.db2", bonusListId,
id);
68 if (chance < 0.000001f || chance > 100.0f)
70 TC_LOG_ERROR(
"sql.sql",
"Bonus list {} used in `item_random_bonus_list_template` by id {} has invalid chance {}", bonusListId,
id, chance);
74 RandomBonusListIds& ids = _storage[id];
75 ids.BonusListIDs.push_back(bonusListId);
76 ids.Chances.push_back(chance);
79 }
while (result->NextRow());
84 TC_LOG_INFO(
"server.loading",
">> Loaded 0 Random item bonus list definitions. DB table `item_random_bonus_list_template` is empty.");
98 if (tab == _storage.end())
100 TC_LOG_ERROR(
"sql.sql",
"Item RandomBonusListTemplateId id #{} used in `item_template_addon` but it does not have records in `item_random_bonus_list_template` table.", itemProto->
RandomBonusListTemplateId);
111 switch (inventoryType)
157 if (!randPropPointsEntry)
163 return randPropPointsEntry->
GoodF[propIndex];
166 return randPropPointsEntry->
SuperiorF[propIndex];
170 return randPropPointsEntry->
EpicF[propIndex];
DB2Storage< RandPropPointsEntry > sRandPropPointsStore("RandPropPoints.db2", &RandPropPointsLoadInfo::Instance)
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
TC_GAME_API float GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType, uint32 subClass)
void LoadItemRandomBonusListTemplates()
ItemRandomBonusListId GenerateItemRandomBonusListId(uint32 item_id)
uint32 ItemRandomBonusListId
@ ITEM_SUBCLASS_WEAPON_WAND
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Class used to access individual fields of database query result.
std::span< ItemBonusEntry const * > GetItemBonuses(uint32 bonusListId)
auto SelectRandomWeightedContainerElement(C const &container, std::span< double > const &weights) -> decltype(std::begin(container))
uint32 RandomBonusListTemplateId
std::array< float, 5 > SuperiorF
std::array< float, 5 > GoodF
std::array< float, 5 > EpicF