Skip to content

Commit 1d9a75c

Browse files
author
linencloth
committed
Core/CharacterDatabaseCleaner: Cleanup
--HG-- branch : trunk
1 parent 9b73cb1 commit 1d9a75c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/server/game/Tools/CharacterDatabaseCleaner.cpp

+25-19
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,45 @@
2525
void CharacterDatabaseCleaner::CleanDatabase()
2626
{
2727
// config to disable
28-
if(!sWorld->getBoolConfig(CONFIG_CLEAN_CHARACTER_DB))
28+
if (!sWorld->getBoolConfig(CONFIG_CLEAN_CHARACTER_DB))
2929
return;
3030

3131
sLog->outString("Cleaning character database...");
3232

3333
uint32 oldMSTime = getMSTime();
3434

3535
// 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)
3838
return;
39+
3940
uint32 flags = (*result)[0].GetUInt32();
4041

4142
// clean up
42-
if(flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
43+
if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
4344
CleanCharacterAchievementProgress();
44-
if(flags & CLEANING_FLAG_SKILLS)
45+
46+
if (flags & CLEANING_FLAG_SKILLS)
4547
CleanCharacterSkills();
46-
if(flags & CLEANING_FLAG_SPELLS)
48+
49+
if (flags & CLEANING_FLAG_SPELLS)
4750
CleanCharacterSpell();
48-
if(flags & CLEANING_FLAG_TALENTS)
51+
52+
if (flags & CLEANING_FLAG_TALENTS)
4953
CleanCharacterTalent();
50-
CharacterDatabase.Query("UPDATE worldstates SET value = 0 WHERE entry=20004");
54+
55+
CharacterDatabase.DirectExecute("UPDATE worldstates SET value = 0 WHERE entry = 20004");
5156

5257
sLog->outString(">> Cleaned character database in %u ms", GetMSTimeDiffToNow(oldMSTime));
5358
sLog->outString();
5459
}
5560

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))
5862
{
5963
QueryResult result = CharacterDatabase.PQuery("SELECT DISTINCT %s FROM %s", column, table);
60-
if(!result)
64+
if (!result)
6165
{
62-
sLog->outString( "Table %s is empty.", table );
66+
sLog->outString("Table %s is empty.", table);
6367
return;
6468
}
6569

@@ -72,24 +76,25 @@ char* table, bool (*check)(uint32))
7276

7377
uint32 id = fields[0].GetUInt32();
7478

75-
if(!check(id))
79+
if (!check(id))
7680
{
77-
if(!found)
81+
if (!found)
7882
{
7983
ss << "DELETE FROM " << table << " WHERE " << column << " IN (";
8084
found = true;
8185
}
8286
else
8387
ss << ",";
88+
8489
ss << id;
8590
}
8691
}
87-
while( result->NextRow() );
92+
while(result->NextRow());
8893

8994
if (found)
9095
{
9196
ss << ")";
92-
CharacterDatabase.Execute( ss.str().c_str() );
97+
CharacterDatabase.Execute(ss.str().c_str());
9398
}
9499
}
95100

@@ -125,10 +130,11 @@ void CharacterDatabaseCleaner::CleanCharacterSpell()
125130

126131
bool CharacterDatabaseCleaner::TalentCheck(uint32 talent_id)
127132
{
128-
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id );
129-
if(!talentInfo)
133+
TalentEntry const *talentInfo = sTalentStore.LookupEntry(talent_id);
134+
if (!talentInfo)
130135
return false;
131-
return sTalentTabStore.LookupEntry( talentInfo->TalentTab );
136+
137+
return sTalentTabStore.LookupEntry(talentInfo->TalentTab);
132138
}
133139

134140
void CharacterDatabaseCleaner::CleanCharacterTalent()

0 commit comments

Comments
 (0)