mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-28 12:22:25 +00:00
SavePetInfo converted to QueryDatabase
This commit is contained in:
parent
10d384f131
commit
cf7574d9b8
153
zone/zonedb.cpp
153
zone/zonedb.cpp
@ -2070,95 +2070,94 @@ void ZoneDatabase::LoadBuffs(Client *client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::SavePetInfo(Client *c) {
|
void ZoneDatabase::SavePetInfo(Client *client) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* query = 0;
|
|
||||||
int i = 0;
|
|
||||||
PetInfo *petinfo = c->GetPetInfo(0);
|
|
||||||
PetInfo *suspended = c->GetPetInfo(1);
|
|
||||||
|
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `character_pet_buffs` WHERE `char_id`=%u", c->CharacterID()),
|
PetInfo *petinfo = client->GetPetInfo(0);
|
||||||
errbuf)) {
|
PetInfo *suspended = client->GetPetInfo(1);
|
||||||
safe_delete_array(query);
|
|
||||||
|
std::string query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u", client->CharacterID());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
query = StringFormat("DELETE FROM `character_pet_buffs` WHERE `char_id` = %u", client->CharacterID());
|
||||||
if (!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `character_pet_inventory` WHERE `char_id`=%u", c->CharacterID()),
|
results = database.QueryDatabase(query);
|
||||||
errbuf)) {
|
if(!results.Success())
|
||||||
safe_delete_array(query);
|
|
||||||
// error report
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query,
|
query = StringFormat("INSERT INTO `character_pet_info` "
|
||||||
"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, 0, '%s', %i, %u, %u, %u, %f) "
|
||||||
"ON DUPLICATE KEY UPDATE `petname`='%s', `petpower`=%i, `spell_id`=%u, `hp`=%u, `mana`=%u, `size`=%f",
|
"ON DUPLICATE KEY UPDATE `petname` = '%s', `petpower` = %i, `spell_id` = %u, "
|
||||||
c->CharacterID(), petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size,
|
"`hp` = %u, `mana` = %u, `size` = %f",
|
||||||
petinfo->Name, petinfo->petpower, petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size),
|
client->CharacterID(), petinfo->Name, petinfo->petpower, petinfo->SpellID,
|
||||||
errbuf))
|
petinfo->HP, petinfo->Mana, petinfo->size, petinfo->Name, petinfo->petpower,
|
||||||
{
|
petinfo->SpellID, petinfo->HP, petinfo->Mana, petinfo->size);
|
||||||
safe_delete_array(query);
|
results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
for(i=0; i < RuleI(Spells, MaxTotalSlotsPET); i++) {
|
for(int index = 0; index < RuleI(Spells, MaxTotalSlotsPET); index++) {
|
||||||
if (petinfo->Buffs[i].spellid != SPELL_UNKNOWN && petinfo->Buffs[i].spellid != 0) {
|
if (petinfo->Buffs[index].spellid == SPELL_UNKNOWN || petinfo->Buffs[index].spellid == 0)
|
||||||
database.RunQuery(query, MakeAnyLenString(&query,
|
continue;
|
||||||
"INSERT INTO `character_pet_buffs` (`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
|
||||||
"`ticsremaining`, `counters`) values "
|
query = StringFormat("INSERT INTO `character_pet_buffs` "
|
||||||
"(%u, 0, %u, %u, %u, %u, %d)",
|
"(`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
||||||
c->CharacterID(), i, petinfo->Buffs[i].spellid, petinfo->Buffs[i].level, petinfo->Buffs[i].duration,
|
"`ticsremaining`, `counters`) "
|
||||||
petinfo->Buffs[i].counters),
|
"VALUES (%u, 0, %u, %u, %u, %u, %d)",
|
||||||
errbuf);
|
client->CharacterID(), index, petinfo->Buffs[index].spellid,
|
||||||
safe_delete_array(query);
|
petinfo->Buffs[index].level, petinfo->Buffs[index].duration,
|
||||||
}
|
petinfo->Buffs[index].counters);
|
||||||
if (suspended->Buffs[i].spellid != SPELL_UNKNOWN && suspended->Buffs[i].spellid != 0) {
|
database.QueryDatabase(query);
|
||||||
database.RunQuery(query, MakeAnyLenString(&query,
|
}
|
||||||
"INSERT INTO `character_pet_buffs` (`char_id`, `pet`, `slot`, `spell_id`, `caster_level`, "
|
|
||||||
"`ticsremaining`, `counters`) values "
|
for(int index = 0; index < RuleI(Spells, MaxTotalSlotsPET); index++) {
|
||||||
"(%u, 1, %u, %u, %u, %u, %d)",
|
if (petinfo->Buffs[index].spellid == SPELL_UNKNOWN || petinfo->Buffs[index].spellid == 0)
|
||||||
c->CharacterID(), i, suspended->Buffs[i].spellid, suspended->Buffs[i].level, suspended->Buffs[i].duration,
|
continue;
|
||||||
suspended->Buffs[i].counters),
|
|
||||||
errbuf);
|
query = StringFormat("INSERT INTO `character_pet_buffs` "
|
||||||
safe_delete_array(query);
|
"(`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);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; i++) {
|
for (int index = EmuConstants::EQUIPMENT_BEGIN; index <= EmuConstants::EQUIPMENT_END; index++) {
|
||||||
if(petinfo->Items[i]) {
|
if(!petinfo->Items[index])
|
||||||
database.RunQuery(query, MakeAnyLenString(&query,
|
continue;
|
||||||
"INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 0, %u, %u)",
|
|
||||||
c->CharacterID(), i, petinfo->Items[i]), errbuf);
|
query = StringFormat("INSERT INTO `character_pet_inventory` "
|
||||||
// should check for errors
|
"(`char_id`, `pet`, `slot`, `item_id`) "
|
||||||
safe_delete_array(query);
|
"VALUES (%u, 0, %u, %u)",
|
||||||
}
|
client->CharacterID(), index, petinfo->Items[index]);
|
||||||
|
database.QueryDatabase(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query = StringFormat("INSERT INTO `character_pet_info` "
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query,
|
"(`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
|
||||||
"INSERT INTO `character_pet_info` (`char_id`, `pet`, `petname`, `petpower`, `spell_id`, `hp`, `mana`, `size`) "
|
"VALUES (%u, 1, '%s', %u, %u, %u, %u, %f) "
|
||||||
"values (%u, 1, '%s', %u, %u, %u, %u, %f) "
|
"ON DUPLICATE KEY UPDATE "
|
||||||
"ON DUPLICATE KEY UPDATE `petname`='%s', `petpower`=%i, `spell_id`=%u, `hp`=%u, `mana`=%u, `size`=%f",
|
"`petname`='%s', `petpower`=%i, `spell_id`=%u, `hp`=%u, `mana`=%u, `size`=%f",
|
||||||
c->CharacterID(), suspended->Name, suspended->petpower, suspended->SpellID, suspended->HP, suspended->Mana, suspended->size,
|
client->CharacterID(), suspended->Name, suspended->petpower, suspended->SpellID,
|
||||||
suspended->Name, suspended->petpower, suspended->SpellID, suspended->HP, suspended->Mana, suspended->size),
|
suspended->HP, suspended->Mana, suspended->size, suspended->Name, suspended->petpower,
|
||||||
errbuf))
|
suspended->SpellID, suspended->HP, suspended->Mana, suspended->size);
|
||||||
{
|
results = database.QueryDatabase(query);
|
||||||
safe_delete_array(query);
|
if(!results.Success())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
for (i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; i++) {
|
|
||||||
if(suspended->Items[i]) {
|
for (int index = EmuConstants::EQUIPMENT_BEGIN; index <= EmuConstants::EQUIPMENT_END; index++) {
|
||||||
database.RunQuery(query, MakeAnyLenString(&query,
|
if(!suspended->Items[index])
|
||||||
"INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 1, %u, %u)",
|
continue;
|
||||||
c->CharacterID(), i, suspended->Items[i]), errbuf);
|
|
||||||
// should check for errors
|
query = StringFormat("INSERT INTO `character_pet_inventory` "
|
||||||
safe_delete_array(query);
|
"(`char_id`, `pet`, `slot`, `item_id`) "
|
||||||
}
|
"VALUES (%u, 1, %u, %u)",
|
||||||
|
client->CharacterID(), index, suspended->Items[index]);
|
||||||
|
database.QueryDatabase(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user