mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-08 10:02:26 +00:00
LoadAAs converted to QueryDatabase
This commit is contained in:
parent
ca84040a39
commit
118c2a9db9
60
zone/bot.cpp
60
zone/bot.cpp
@ -1466,35 +1466,37 @@ void Bot::GenerateAABonuses(StatBonuses* newbon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bot::LoadAAs() {
|
void Bot::LoadAAs() {
|
||||||
std::string errorMessage;
|
|
||||||
char* Query = 0;
|
|
||||||
int length = 0;
|
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
int maxAAExpansion = RuleI(Bots, BotAAExpansion); //get expansion to get AAs up to
|
int maxAAExpansion = RuleI(Bots, BotAAExpansion); //get expansion to get AAs up to
|
||||||
botAAs.clear(); //start fresh
|
botAAs.clear(); //start fresh
|
||||||
|
|
||||||
if(GetClass() == BERSERKER)
|
std::string query;
|
||||||
length = MakeAnyLenString(&Query, "SELECT skill_id FROM altadv_vars WHERE berserker = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetLevel(), maxAAExpansion);
|
|
||||||
else
|
|
||||||
length = MakeAnyLenString(&Query, "SELECT skill_id FROM altadv_vars WHERE ((classes & ( 1 << %i )) >> %i) = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetClass(), GetClass(), GetLevel(), maxAAExpansion);
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, length, TempErrorMessageBuffer, &DatasetResult)) {
|
if(GetClass() == BERSERKER)
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
query = StringFormat("SELECT skill_id FROM altadv_vars WHERE berserker = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetLevel(), maxAAExpansion);
|
||||||
|
else
|
||||||
|
query = StringFormat("SELECT skill_id FROM altadv_vars WHERE ((classes & ( 1 << %i )) >> %i) = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetClass(), GetClass(), GetLevel(), maxAAExpansion);
|
||||||
|
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
if(!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadAAs()");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
int totalAAs = database.CountAAs();
|
int totalAAs = database.CountAAs();
|
||||||
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
uint32 skill_id = 0;
|
uint32 skill_id = 0;
|
||||||
skill_id = atoi(DataRow[0]);
|
skill_id = atoi(row[0]);
|
||||||
|
|
||||||
|
if(skill_id <= 0 || skill_id >= totalAAs)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(skill_id > 0 && skill_id < totalAAs) {
|
|
||||||
SendAA_Struct *sendAA = zone->FindAA(skill_id);
|
SendAA_Struct *sendAA = zone->FindAA(skill_id);
|
||||||
|
|
||||||
if(sendAA) {
|
if(!sendAA)
|
||||||
|
continue;
|
||||||
|
|
||||||
for(int i=0; i<sendAA->max_level; i++) {
|
for(int i=0; i<sendAA->max_level; i++) {
|
||||||
//Get AA info & add to list
|
//Get AA info & add to list
|
||||||
uint32 aaid = sendAA->id + i;
|
uint32 aaid = sendAA->id + i;
|
||||||
@ -1514,8 +1516,10 @@ void Bot::LoadAAs() {
|
|||||||
//Bot is high enough level for AA
|
//Bot is high enough level for AA
|
||||||
std::map<uint32, BotAA>::iterator foundAA = botAAs.find(aaid);
|
std::map<uint32, BotAA>::iterator foundAA = botAAs.find(aaid);
|
||||||
|
|
||||||
// AA is not already in list
|
// AA is already in list
|
||||||
if(foundAA == botAAs.end()) {
|
if(foundAA != botAAs.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
if(sendAA->id == aaid) {
|
if(sendAA->id == aaid) {
|
||||||
BotAA newAA;
|
BotAA newAA;
|
||||||
|
|
||||||
@ -1526,25 +1530,11 @@ void Bot::LoadAAs() {
|
|||||||
|
|
||||||
botAAs[aaid] = newAA; //add to list
|
botAAs[aaid] = newAA; //add to list
|
||||||
}
|
}
|
||||||
else {
|
else //update master AA record with number of levels a bot has in AA, based on level.
|
||||||
//update master AA record with number of levels a bot has in AA, based on level.
|
|
||||||
botAAs[sendAA->id].total_levels+=1;
|
botAAs[sendAA->id].total_levels+=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete(Query);
|
|
||||||
Query = 0;
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadAAs()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::GetAA(uint32 aa_id) {
|
uint32 Bot::GetAA(uint32 aa_id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user