mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-01 11:22:28 +00:00
Merge branch 'master' of https://github.com/EQEmu/Server
This commit is contained in:
commit
16c5ead887
@ -2895,96 +2895,74 @@ void ZoneDatabase::LoadBuffs(Client *client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::SavePetInfo(Client *client) {
|
void ZoneDatabase::SavePetInfo(Client *client)
|
||||||
|
{
|
||||||
PetInfo *petinfo = client->GetPetInfo(0);
|
PetInfo *petinfo = nullptr;
|
||||||
PetInfo *suspended = client->GetPetInfo(1);
|
|
||||||
|
|
||||||
std::string query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u", client->CharacterID());
|
std::string query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u", client->CharacterID());
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u", client->CharacterID());
|
query = StringFormat("DELETE FROM `character_pet_inventory` WHERE `char_id` = %u", client->CharacterID());
|
||||||
results = database.QueryDatabase(query);
|
results = database.QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (int pet = 0; pet < 2; pet++) {
|
||||||
|
petinfo = client->GetPetInfo(pet);
|
||||||
|
if (!petinfo)
|
||||||
|
continue;
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO `character_pet_info` "
|
query = StringFormat("INSERT INTO `character_pet_info` "
|
||||||
"(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
|
"(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
|
||||||
"VALUES (%u, 0, '%s', %i, %u, %u, %u, %f) "
|
"VALUES (%u, %u, '%s', %i, %u, %u, %u, %f) "
|
||||||
"ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, "
|
"ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, "
|
||||||
"`hp` = %u, `mana` = %u, `size` = %f",
|
"`hp` = %u, `mana` = %u, `size` = %f",
|
||||||
client->CharacterID(), petinfo->Name, petinfo->petpower, petinfo->SpellID,
|
client->CharacterID(), pet, petinfo->Name, petinfo->petpower, petinfo->SpellID,
|
||||||
petinfo->HP, petinfo->Mana, petinfo->size, petinfo->Name, petinfo->petpower,
|
petinfo->HP, petinfo->Mana, petinfo->size, // and now the ON DUPLICATE ENTRIES
|
||||||
petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size);
|
petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size);
|
||||||
results = database.QueryDatabase(query);
|
results = database.QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return;
|
return;
|
||||||
|
query.clear();
|
||||||
|
|
||||||
|
// pet buffs!
|
||||||
for (int index = 0; index < RuleI(Spells, MaxTotalSlotsPET); index++) {
|
for (int index = 0; index < RuleI(Spells, MaxTotalSlotsPET); index++) {
|
||||||
if (petinfo->Buffs[index].spellid == SPELL_UNKNOWN || petinfo->Buffs[index].spellid == 0)
|
if (petinfo->Buffs[index].spellid == SPELL_UNKNOWN || petinfo->Buffs[index].spellid == 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (query.length() == 0)
|
||||||
query = StringFormat("INSERT INTO `character_pet_buffs` "
|
query = StringFormat("INSERT INTO `character_pet_buffs` "
|
||||||
"(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
"(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
||||||
"`ticsremaining`, `counters`) "
|
"`ticsremaining`, `counters`) "
|
||||||
"VALUES (%u, 0, %u, %u, %u, %u, %d)",
|
"VALUES (%u, %u, %u, %u, %u, %u, %d)",
|
||||||
client->CharacterID(), index, petinfo->Buffs[index].spellid,
|
client->CharacterID(), pet, index, petinfo->Buffs[index].spellid,
|
||||||
|
petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
|
||||||
|
petinfo->Buffs[index].counters);
|
||||||
|
else
|
||||||
|
query += StringFormat(", (%u, %u, %u, %u, %u, %u, %d)",
|
||||||
|
client->CharacterID(), pet, index, petinfo->Buffs[index].spellid,
|
||||||
petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
|
petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
|
||||||
petinfo->Buffs[index].counters);
|
petinfo->Buffs[index].counters);
|
||||||
database.QueryDatabase(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int index = 0; index < RuleI(Spells, MaxTotalSlotsPET); index++) {
|
|
||||||
if (petinfo->Buffs[index].spellid == SPELL_UNKNOWN || petinfo->Buffs[index].spellid == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO `character_pet_buffs` "
|
|
||||||
"(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
|
||||||
"`ticsremaining`, `counters`) "
|
|
||||||
"VALUES (%u, 1, %u, %u, %u, %u, %d)",
|
|
||||||
client->CharacterID(), index, suspended->Buffs[index].spellid,
|
|
||||||
suspended->Buffs[index].level, suspended->Buffs[index].duration,
|
|
||||||
suspended->Buffs[index].counters);
|
|
||||||
database.QueryDatabase(query);
|
database.QueryDatabase(query);
|
||||||
}
|
query.clear();
|
||||||
|
|
||||||
|
// pet inventory!
|
||||||
for (int index = EmuConstants::EQUIPMENT_BEGIN; index <= EmuConstants::EQUIPMENT_END; index++) {
|
for (int index = EmuConstants::EQUIPMENT_BEGIN; index <= EmuConstants::EQUIPMENT_END; index++) {
|
||||||
if (!petinfo->Items[index])
|
if (!petinfo->Items[index])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (query.length() == 0)
|
||||||
query = StringFormat("INSERT INTO `character_pet_inventory` "
|
query = StringFormat("INSERT INTO `character_pet_inventory` "
|
||||||
"(`char_id`, `pet`, `slot`, `item_id`) "
|
"(`char_id`, `pet`, `slot`, `item_id`) "
|
||||||
"VALUES (%u, 0, %u, %u)",
|
"VALUES (%u, %u, %u, %u)",
|
||||||
client->CharacterID(), index, petinfo->Items[index]);
|
client->CharacterID(), pet, index, petinfo->Items[index]);
|
||||||
|
else
|
||||||
|
query += StringFormat(", (%u, %u, %u, %u)", client->CharacterID(), pet, index, petinfo->Items[index]);
|
||||||
|
}
|
||||||
database.QueryDatabase(query);
|
database.QueryDatabase(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO `character_pet_info` "
|
|
||||||
"(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
|
|
||||||
"VALUES (%u, 1, '%s', %u, %u, %u, %u, %f) "
|
|
||||||
"ON DUPLICATE KEY UPDATE "
|
|
||||||
"`petname`='%s', `petpower`=%i, `spell_id`=%u, `hp`=%u, `mana`=%u, `size`=%f",
|
|
||||||
client->CharacterID(), suspended->Name, suspended->petpower, suspended->SpellID,
|
|
||||||
suspended->HP, suspended->Mana, suspended->size, suspended->Name, suspended->petpower,
|
|
||||||
suspended->SpellID, suspended->HP, suspended->Mana, suspended->size);
|
|
||||||
results = database.QueryDatabase(query);
|
|
||||||
if(!results.Success())
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
for (int index = EmuConstants::EQUIPMENT_BEGIN; index <= EmuConstants::EQUIPMENT_END; index++) {
|
|
||||||
if(!suspended->Items[index])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
query = StringFormat("INSERT INTO `character_pet_inventory` "
|
|
||||||
"(`char_id`, `pet`, `slot`, `item_id`) "
|
|
||||||
"VALUES (%u, 1, %u, %u)",
|
|
||||||
client->CharacterID(), index, suspended->Items[index]);
|
|
||||||
database.QueryDatabase(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::RemoveTempFactions(Client *client) {
|
void ZoneDatabase::RemoveTempFactions(Client *client) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user