SavePetBuffs converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 15:47:14 -07:00
parent ab76783f8b
commit fe753f05df

View File

@ -2717,33 +2717,28 @@ uint32 Bot::SavePetStats(std::string petName, uint16 petMana, uint16 petHitPoint
} }
void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) { void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
if(petBuffs && botPetSaveId > 0) { if(!petBuffs || botPetSaveId == 0)
std::string errorMessage; return;
char* Query = 0;
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
int BuffCount = 0;
while(BuffCount < BUFF_COUNT) { int buffIndex = 0;
if(petBuffs[BuffCount].spellid > 0 && petBuffs[BuffCount].spellid != SPELL_UNKNOWN) {
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "INSERT INTO botpetbuffs (BotPetsId, SpellId, CasterLevel, Duration) VALUES(%u, %u, %u, %u);", botPetSaveId, petBuffs[BuffCount].spellid, petBuffs[BuffCount].level, petBuffs[BuffCount].duration), TempErrorMessageBuffer)) { while(buffIndex < BUFF_COUNT) {
errorMessage = std::string(TempErrorMessageBuffer); if(petBuffs[buffIndex].spellid > 0 && petBuffs[buffIndex].spellid != SPELL_UNKNOWN) {
safe_delete(Query);
Query = 0; std::string query = StringFormat("INSERT INTO botpetbuffs "
"(BotPetsId, SpellId, CasterLevel, Duration) "
"VALUES(%u, %u, %u, %u);",
botPetSaveId, petBuffs[buffIndex].spellid,
petBuffs[buffIndex].level, petBuffs[buffIndex].duration);
auto results = database.QueryDatabase(query);
if(!results.Success())
break; break;
}
else {
safe_delete(Query);
Query = 0;
}
} }
BuffCount++; buffIndex++;
} }
if(!errorMessage.empty()) {
// TODO: Record this error message to zone error log
}
}
} }
void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) { void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) {