47{
49
51
52
53 QueryResult result =
WorldDatabase.Query(
"SELECT spellId, reqSpell, reqSkillValue, chance FROM skill_discovery_template");
54
55 if (!result)
56 {
57 LOG_WARN(
"server.loading",
">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty.");
59 return;
60 }
61
63
64 std::ostringstream ssNonDiscoverableEntries;
65 std::set<uint32> reportedReqSpells;
66
67 do
68 {
69 Field* fields = result->Fetch();
70
74 float chance = fields[3].
Get<
float>();
75
76 if (chance <= 0)
77 {
78 ssNonDiscoverableEntries << "spellId = " << spellId << " reqSkillOrSpell = " << reqSkillOrSpell
79 << " reqSkillValue = " << reqSkillValue << " chance = " << chance << "(chance problem)\n";
80 continue;
81 }
82
83 if (reqSkillOrSpell > 0)
84 {
87 if (!reqSpellInfo)
88 {
89 if (reportedReqSpells.find(absReqSkillOrSpell) == reportedReqSpells.end())
90 {
91 LOG_ERROR(
"sql.sql",
"Spell (ID: {}) have not existed spell (ID: {}) in `reqSpell` field in `skill_discovery_template` table", spellId, reqSkillOrSpell);
92 reportedReqSpells.insert(absReqSkillOrSpell);
93 }
94 continue;
95 }
96
97
99
101 {
102 if (reportedReqSpells.find(absReqSkillOrSpell) == reportedReqSpells.end())
103 {
104 LOG_ERROR(
"sql.sql",
"Spell (ID: {}) not have MECHANIC_DISCOVERY (28) value in Mechanic field in spell.dbc"
105 " and not 100% chance random discovery ability but listed for spellId {} (and maybe more) in `skill_discovery_template` table",
106 absReqSkillOrSpell, spellId);
107 reportedReqSpells.insert(absReqSkillOrSpell);
108 }
109 continue;
110 }
111
113 }
114 else if (reqSkillOrSpell == 0)
115 {
117
118 if (bounds.first == bounds.second)
119 {
120 LOG_ERROR(
"sql.sql",
"Spell (ID: {}) not listed in `SkillLineAbility.dbc` but listed with `reqSpell`=0 in `skill_discovery_template` table", spellId);
121 continue;
122 }
123
124 for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
126 }
127 else
128 {
129 LOG_ERROR(
"sql.sql",
"Spell (ID: {}) have negative value in `reqSpell` field in `skill_discovery_template` table", spellId);
130 continue;
131 }
132
133 ++count;
134 } while (result->NextRow());
135
136 if (!ssNonDiscoverableEntries.str().empty())
137 LOG_ERROR(
"sql.sql",
"Some items can't be successfully discovered: have in chance field value < 0.000001 in `skill_discovery_template` DB table . List:\n{}", ssNonDiscoverableEntries.str());
138
139
140 for (
uint32 spell_id = 1; spell_id <
sSpellMgr->GetSpellInfoStoreSize(); ++spell_id)
141 {
143 if (!spellInfo)
144 continue;
145
146
148 continue;
149
151 LOG_ERROR(
"sql.sql",
"Spell (ID: {}) is 100% chance random discovery ability but not have data in `skill_discovery_template` table", spell_id);
152 }
153
156}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::uint16_t uint16
Definition: Define.h:108
@ MECHANIC_DISCOVERY
Definition: SharedDefines.h:1353
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
Definition: SpellInfo.h:316
bool IsExplicitDiscovery() const
Definition: SpellInfo.cpp:917
uint32 Mechanic
Definition: SpellInfo.h:323