- Improved speed of character database conversion x1000 by changing query style

- Adjusted AA MySQL saves for 100x speed increase
- Removed StoreCharacter lookup methods as they will no longer be necessary
- Some other cleanup
This commit is contained in:
akkadius
2014-09-06 13:53:54 -05:00
parent 4432c07081
commit ca7dd7d741
5 changed files with 108 additions and 70 deletions
+5 -6
View File
@@ -1035,8 +1035,7 @@ void Client::BuyAA(AA_Action* action)
uint32 real_cost;
std::map<uint32, AALevelCost_Struct>::iterator RequiredLevel = AARequiredLevelAndCost.find(action->ability);
if(RequiredLevel != AARequiredLevelAndCost.end())
{
if(RequiredLevel != AARequiredLevelAndCost.end()) {
real_cost = RequiredLevel->second.Cost;
}
else
@@ -1064,8 +1063,10 @@ void Client::BuyAA(AA_Action* action)
SendAATable();
//we are building these messages ourself instead of using the stringID to work around patch discrepencies
//these are AA_GAIN_ABILITY (410) & AA_IMPROVE (411), respectively, in both Titanium & SoF. not sure about 6.2
/*
We are building these messages ourself instead of using the stringID to work around patch discrepencies
these are AA_GAIN_ABILITY (410) & AA_IMPROVE (411), respectively, in both Titanium & SoF. not sure about 6.2
*/
/* Initial purchase of an AA ability */
if (cur_level < 1){
@@ -1088,8 +1089,6 @@ void Client::BuyAA(AA_Action* action)
}
}
SendAAStats();
CalcBonuses();
+11 -17
View File
@@ -477,13 +477,10 @@ void Client::ReportConnectingState() {
};
}
inline double clock_diff_to_sec(long clock_diff)
{
return double(clock_diff) / CLOCKS_PER_SEC;
}
bool Client::SaveAA(){
clock_t t = std::clock(); /* Function timer start */
int first_entry = 0;
std::string rquery;
/* Save Player AA */
int spentpoints = 0;
for (int a = 0; a < MAX_PP_AA_ARRAY; a++) {
@@ -509,12 +506,15 @@ bool Client::SaveAA(){
m_pp.aapoints_spent = spentpoints + m_epp.expended_aa;
for (int a = 0; a < MAX_PP_AA_ARRAY; a++) {
if (aa[a]->AA > 0 && aa[a]->value){
std::string rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)"
" VALUES (%u, %u, %u, %u)",
character_id, a, aa[a]->AA, aa[a]->value);
auto results = database.QueryDatabase(rquery);
if (first_entry != 1){
rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)"
" VALUES (%u, %u, %u, %u)", character_id, a, aa[a]->AA, aa[a]->value);
first_entry = 1;
}
rquery = rquery + StringFormat(", (%u, %u, %u, %u)", character_id, a, aa[a]->AA, aa[a]->value);
}
}
auto results = database.QueryDatabase(rquery);
LogFile->write(EQEMuLog::Status, "Issuing Client AA Save... CID: %i Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
return true;
}
@@ -581,15 +581,9 @@ bool Client::Save(uint8 iCommitNow) {
p_timers.Store(&database);
database.SaveCharacterTribute(this->CharacterID(), &m_pp);
SaveTaskState(); /* Save Character Task */
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp); /* Save Character Data */
/* Save Character Task */
SaveTaskState();
/* Save Character Data */
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp);
/* Mirror Character Data */
database.StoreCharacterLookup(this->CharacterID());
LogFile->write(EQEMuLog::Status, "Client::Save %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
return true;
}
-10
View File
@@ -3841,13 +3841,3 @@ bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, std::list<struct NPCFactio
}
return true;
}
void ZoneDatabase::StoreCharacterLookup(uint32 char_id) {
std::string c_lookup = StringFormat("REPLACE INTO `character_lookup` (id, account_id, `name`, timelaston, x, y, z, zonename, zoneid, instanceid, pktime, groupid, class, `level`, lfp, lfg, mailkey, xtargets, firstlogon, inspectmessage)"
" SELECT id, account_id, `name`, timelaston, x, y, z, zonename, zoneid, instanceid, pktime, groupid, class, `level`, lfp, lfg, mailkey, xtargets, firstlogon, inspectmessage"
" FROM `character_` "
" WHERE `id` = %i ", char_id);
QueryDatabase(c_lookup);
}
-1
View File
@@ -239,7 +239,6 @@ public:
void UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity);
/* General Character Related Stuff */
void StoreCharacterLookup(uint32 char_id);
bool SetServerFilters(char* name, ServerSideFilters_Struct *ssfs);
uint32 GetServerFilters(char* name, ServerSideFilters_Struct *ssfs);