25
25
void CharacterDatabaseCleaner::CleanDatabase ()
26
26
{
27
27
// config to disable
28
- if (!sWorld ->getBoolConfig (CONFIG_CLEAN_CHARACTER_DB))
28
+ if (!sWorld ->getBoolConfig (CONFIG_CLEAN_CHARACTER_DB))
29
29
return ;
30
30
31
31
sLog ->outString (" Cleaning character database..." );
32
32
33
33
uint32 oldMSTime = getMSTime ();
34
34
35
35
// check flags which clean ups are necessary
36
- QueryResult result = CharacterDatabase.Query (" SELECT value FROM worldstates WHERE entry= 20004" );
37
- if (!result)
36
+ QueryResult result = CharacterDatabase.Query (" SELECT value FROM worldstates WHERE entry = 20004" );
37
+ if (!result)
38
38
return ;
39
+
39
40
uint32 flags = (*result)[0 ].GetUInt32 ();
40
41
41
42
// clean up
42
- if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
43
+ if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
43
44
CleanCharacterAchievementProgress ();
44
- if (flags & CLEANING_FLAG_SKILLS)
45
+
46
+ if (flags & CLEANING_FLAG_SKILLS)
45
47
CleanCharacterSkills ();
46
- if (flags & CLEANING_FLAG_SPELLS)
48
+
49
+ if (flags & CLEANING_FLAG_SPELLS)
47
50
CleanCharacterSpell ();
48
- if (flags & CLEANING_FLAG_TALENTS)
51
+
52
+ if (flags & CLEANING_FLAG_TALENTS)
49
53
CleanCharacterTalent ();
50
- CharacterDatabase.Query (" UPDATE worldstates SET value = 0 WHERE entry=20004" );
54
+
55
+ CharacterDatabase.DirectExecute (" UPDATE worldstates SET value = 0 WHERE entry = 20004" );
51
56
52
57
sLog ->outString (" >> Cleaned character database in %u ms" , GetMSTimeDiffToNow (oldMSTime));
53
58
sLog ->outString ();
54
59
}
55
60
56
- void CharacterDatabaseCleaner::CheckUnique (const char * column, const
57
- char * table, bool (*check)(uint32))
61
+ void CharacterDatabaseCleaner::CheckUnique (const char * column, const char * table, bool (*check)(uint32))
58
62
{
59
63
QueryResult result = CharacterDatabase.PQuery (" SELECT DISTINCT %s FROM %s" , column, table);
60
- if (!result)
64
+ if (!result)
61
65
{
62
- sLog ->outString ( " Table %s is empty." , table );
66
+ sLog ->outString (" Table %s is empty." , table);
63
67
return ;
64
68
}
65
69
@@ -72,24 +76,25 @@ char* table, bool (*check)(uint32))
72
76
73
77
uint32 id = fields[0 ].GetUInt32 ();
74
78
75
- if (!check (id))
79
+ if (!check (id))
76
80
{
77
- if (!found)
81
+ if (!found)
78
82
{
79
83
ss << " DELETE FROM " << table << " WHERE " << column << " IN (" ;
80
84
found = true ;
81
85
}
82
86
else
83
87
ss << " ," ;
88
+
84
89
ss << id;
85
90
}
86
91
}
87
- while ( result->NextRow () );
92
+ while (result->NextRow ());
88
93
89
94
if (found)
90
95
{
91
96
ss << " )" ;
92
- CharacterDatabase.Execute ( ss.str ().c_str () );
97
+ CharacterDatabase.Execute (ss.str ().c_str ());
93
98
}
94
99
}
95
100
@@ -125,10 +130,11 @@ void CharacterDatabaseCleaner::CleanCharacterSpell()
125
130
126
131
bool CharacterDatabaseCleaner::TalentCheck (uint32 talent_id)
127
132
{
128
- TalentEntry const *talentInfo = sTalentStore .LookupEntry ( talent_id );
129
- if (!talentInfo)
133
+ TalentEntry const *talentInfo = sTalentStore .LookupEntry (talent_id);
134
+ if (!talentInfo)
130
135
return false ;
131
- return sTalentTabStore .LookupEntry ( talentInfo->TalentTab );
136
+
137
+ return sTalentTabStore .LookupEntry (talentInfo->TalentTab );
132
138
}
133
139
134
140
void CharacterDatabaseCleaner::CleanCharacterTalent ()
0 commit comments