Thread: Bot Pet Buffs
View Single Post
  #7  
Old 09-01-2015, 02:20 AM
Midgett
Fire Beetle
 
Join Date: May 2009
Location: AL
Posts: 29
Default

Thanks for the sanity check!

Part of my investigation was looking at bots.cpp.

Here is the Load Pet Buffs code block in bots.cpp.

Code:
void Bot::LoadPetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
	if(!petBuffs || botPetSaveId == 0)
        return;

    std::string query = StringFormat("SELECT SpellId, CasterLevel, Duration FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
    auto results = database.QueryDatabase(query);
	if(!results.Success())
		return;

	int buffIndex = 0;
	for (auto row = results.begin();row != results.end(); ++row) {
		if(buffIndex == BUFF_COUNT)
			break;

		petBuffs[buffIndex].spellid = atoi(row[0]);
		petBuffs[buffIndex].level = atoi(row[1]);
		petBuffs[buffIndex].duration = atoi(row[2]);
		buffIndex++;
	}
	query = StringFormat("DELETE FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
	results = database.QueryDatabase(query);
}
Here is the Save Pet Buffs code block in bots.cpp.

Code:
void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
	if(!petBuffs || botPetSaveId == 0)
        return;

	int buffIndex = 0;
	while(buffIndex < BUFF_COUNT) {
        if(petBuffs[buffIndex].spellid > 0 && petBuffs[buffIndex].spellid != SPELL_UNKNOWN) {

            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;
        }
        buffIndex++;
    }
If you notice I printed in RED the database queries. All those fields are present in the botpetbuffs table.

If I copy my botpetbuffs from my old server db (same fields) to my new database, the buffs won't load either.
So not only will the bot pet's buffs won't save, they won't load either.
Reply With Quote