ZoneDatabase::InsertDoor converted to xyz_heading

This commit is contained in:
Arthur Ice 2014-12-01 12:30:07 -08:00
parent 5af1998167
commit 31d32682b0
3 changed files with 127 additions and 126 deletions

View File

@ -735,6 +735,6 @@ void Doors::CreateDatabaseEntry()
{ {
return; return;
} }
database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), m_Position.m_X, m_Position.m_Y, m_Position.m_Z, m_Position.m_Heading, GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize()); database.InsertDoor(GetDoorDBID(), GetDoorID(), GetDoorName(), m_Position, GetOpenType(), GetGuildID(), GetLockpick(), GetKeyItem(), GetDoorParam(), GetInvertState(), GetIncline(), GetSize());
} }

View File

@ -567,7 +567,7 @@ TraderCharges_Struct* ZoneDatabase::LoadTraderItemWithCharges(uint32 char_id)
return loadti; return loadti;
} }
ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) { ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) {
std::string query = StringFormat("SELECT * FROM trader WHERE char_id = %i AND serialnumber = %i " std::string query = StringFormat("SELECT * FROM trader WHERE char_id = %i AND serialnumber = %i "
"ORDER BY slot_id LIMIT 80", CharID, SerialNumber); "ORDER BY slot_id LIMIT 80", CharID, SerialNumber);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -624,7 +624,7 @@ void ZoneDatabase::SaveTraderItem(uint32 CharID, uint32 ItemID, uint32 SerialNum
} }
void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) { void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) {
_log(TRADING__CLIENT, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges); _log(TRADING__CLIENT, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges);
std::string query = StringFormat("UPDATE trader SET charges = %i WHERE char_id = %i AND serialnumber = %i", std::string query = StringFormat("UPDATE trader SET charges = %i WHERE char_id = %i AND serialnumber = %i",
@ -718,7 +718,7 @@ void ZoneDatabase::DeleteBuyLines(uint32 CharID) {
} }
void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) { void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) {
std::string query = StringFormat("REPLACE INTO buyer VALUES(%i, %i, %i, \"%s\", %i, %i)", std::string query = StringFormat("REPLACE INTO buyer VALUES(%i, %i, %i, \"%s\", %i, %i)",
CharID, BuySlot, ItemID, ItemName, Quantity, Price); CharID, BuySlot, ItemID, ItemName, Quantity, Price);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -727,7 +727,7 @@ void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, cons
} }
void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) { void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) {
std::string query = StringFormat("DELETE FROM buyer WHERE charid = %i AND buyslot = %i", CharID, BuySlot); std::string query = StringFormat("DELETE FROM buyer WHERE charid = %i AND buyslot = %i", CharID, BuySlot);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
@ -735,7 +735,7 @@ void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) {
} }
void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) { void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) {
if(Quantity <= 0) { if(Quantity <= 0) {
RemoveBuyLine(CharID, BuySlot); RemoveBuyLine(CharID, BuySlot);
return; return;
@ -959,16 +959,16 @@ bool ZoneDatabase::LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_
"FROM " "FROM "
"`character_memmed_spells` " "`character_memmed_spells` "
"WHERE `id` = %u ORDER BY `slot_id`", character_id); "WHERE `id` = %u ORDER BY `slot_id`", character_id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
int i = 0; int i = 0;
/* Initialize Spells */ /* Initialize Spells */
for (i = 0; i < MAX_PP_MEMSPELL; i++){ for (i = 0; i < MAX_PP_MEMSPELL; i++){
pp->mem_spells[i] = 0xFFFFFFFF; pp->mem_spells[i] = 0xFFFFFFFF;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]); i = atoi(row[0]);
if (i < MAX_PP_MEMSPELL && atoi(row[1]) <= SPDAT_RECORDS){ if (i < MAX_PP_MEMSPELL && atoi(row[1]) <= SPDAT_RECORDS){
pp->mem_spells[i] = atoi(row[1]); pp->mem_spells[i] = atoi(row[1]);
} }
} }
return true; return true;
@ -982,36 +982,36 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str
"FROM " "FROM "
"`character_spells` " "`character_spells` "
"WHERE `id` = %u ORDER BY `slot_id`", character_id); "WHERE `id` = %u ORDER BY `slot_id`", character_id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
int i = 0; int i = 0;
/* Initialize Spells */ /* Initialize Spells */
for (i = 0; i < MAX_PP_SPELLBOOK; i++){ for (i = 0; i < MAX_PP_SPELLBOOK; i++){
pp->spell_book[i] = 0xFFFFFFFF; pp->spell_book[i] = 0xFFFFFFFF;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]); i = atoi(row[0]);
if (i < MAX_PP_SPELLBOOK && atoi(row[1]) <= SPDAT_RECORDS){ if (i < MAX_PP_SPELLBOOK && atoi(row[1]) <= SPDAT_RECORDS){
pp->spell_book[i] = atoi(row[1]); pp->spell_book[i] = atoi(row[1]);
} }
} }
return true; return true;
} }
bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat( std::string query = StringFormat(
"SELECT " "SELECT "
"lang_id, " "lang_id, "
"`value` " "`value` "
"FROM " "FROM "
"`character_languages` " "`character_languages` "
"WHERE `id` = %u ORDER BY `lang_id`", character_id); "WHERE `id` = %u ORDER BY `lang_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0; auto results = database.QueryDatabase(query); int i = 0;
/* Initialize Languages */ /* Initialize Languages */
for (i = 0; i < MAX_PP_LANGUAGE; i++){ for (i = 0; i < MAX_PP_LANGUAGE; i++){
pp->languages[i] = 0; pp->languages[i] = 0;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]); i = atoi(row[0]);
if (i < MAX_PP_LANGUAGE){ if (i < MAX_PP_LANGUAGE){
pp->languages[i] = atoi(row[1]); pp->languages[i] = atoi(row[1]);
} }
@ -1022,9 +1022,9 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str
bool ZoneDatabase::LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT slot, rank FROM character_leadership_abilities WHERE `id` = %u", character_id); std::string query = StringFormat("SELECT slot, rank FROM character_leadership_abilities WHERE `id` = %u", character_id);
auto results = database.QueryDatabase(query); uint32 slot = 0; auto results = database.QueryDatabase(query); uint32 slot = 0;
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
slot = atoi(row[0]); slot = atoi(row[0]);
pp->leader_abilities.ranks[slot] = atoi(row[1]); pp->leader_abilities.ranks[slot] = atoi(row[1]);
} }
return true; return true;
} }
@ -1036,17 +1036,17 @@ bool ZoneDatabase::LoadCharacterDisciplines(uint32 character_id, PlayerProfile_S
"FROM " "FROM "
"`character_disciplines`" "`character_disciplines`"
"WHERE `id` = %u ORDER BY `slot_id`", character_id); "WHERE `id` = %u ORDER BY `slot_id`", character_id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
int i = 0; int i = 0;
/* Initialize Disciplines */ /* Initialize Disciplines */
memset(pp->disciplines.values, 0, (sizeof(pp->disciplines.values[0]) * MAX_PP_DISCIPLINES)); memset(pp->disciplines.values, 0, (sizeof(pp->disciplines.values[0]) * MAX_PP_DISCIPLINES));
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
if (i < MAX_PP_DISCIPLINES){ if (i < MAX_PP_DISCIPLINES){
pp->disciplines.values[i] = atoi(row[0]); pp->disciplines.values[i] = atoi(row[0]);
} }
i++; i++;
} }
return true; return true;
} }
bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct* pp){
@ -1057,13 +1057,13 @@ bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct
"FROM " "FROM "
"`character_skills` " "`character_skills` "
"WHERE `id` = %u ORDER BY `skill_id`", character_id); "WHERE `id` = %u ORDER BY `skill_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0; auto results = database.QueryDatabase(query); int i = 0;
/* Initialize Skill */ /* Initialize Skill */
for (i = 0; i < MAX_PP_SKILL; i++){ for (i = 0; i < MAX_PP_SKILL; i++){
pp->skills[i] = 0; pp->skills[i] = 0;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]); i = atoi(row[0]);
if (i < MAX_PP_SKILL){ if (i < MAX_PP_SKILL){
pp->skills[i] = atoi(row[1]); pp->skills[i] = atoi(row[1]);
} }
@ -1091,7 +1091,7 @@ bool ZoneDatabase::LoadCharacterCurrency(uint32 character_id, PlayerProfile_Stru
"ebon_crystals, " "ebon_crystals, "
"career_ebon_crystals " "career_ebon_crystals "
"FROM " "FROM "
"character_currency " "character_currency "
"WHERE `id` = %i ", character_id); "WHERE `id` = %i ", character_id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
@ -1134,7 +1134,7 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str
auto results = database.QueryDatabase(query); int i = 0; int r = 0; int si = 0; auto results = database.QueryDatabase(query); int i = 0; int r = 0; int si = 0;
for (i = 0; i <= EmuConstants::BANDOLIERS_COUNT; i++){ for (i = 0; i <= EmuConstants::BANDOLIERS_COUNT; i++){
for (int si = 0; si < EmuConstants::BANDOLIER_SIZE; si++){ for (int si = 0; si < EmuConstants::BANDOLIER_SIZE; si++){
pp->bandoliers[i].items[si].icon = 0; pp->bandoliers[i].items[si].icon = 0;
} }
} }
@ -1142,9 +1142,9 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str
r = 0; r = 0;
i = atoi(row[r]); /* Bandolier ID */ r++; i = atoi(row[r]); /* Bandolier ID */ r++;
si = atoi(row[r]); /* Bandolier Slot */ r++; si = atoi(row[r]); /* Bandolier Slot */ r++;
pp->bandoliers[i].items[si].item_id = atoi(row[r]); r++; pp->bandoliers[i].items[si].item_id = atoi(row[r]); r++;
pp->bandoliers[i].items[si].icon = atoi(row[r]); r++; pp->bandoliers[i].items[si].icon = atoi(row[r]); r++;
strcpy(pp->bandoliers[i].name, row[r]); r++; strcpy(pp->bandoliers[i].name, row[r]); r++;
si++; si++;
} }
return true; return true;
@ -1152,7 +1152,7 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str
bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `tier`, `tribute` FROM `character_tribute` WHERE `id` = %u", character_id); std::string query = StringFormat("SELECT `tier`, `tribute` FROM `character_tribute` WHERE `id` = %u", character_id);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
int i = 0; int i = 0;
for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){ for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){
pp->tributes[i].tribute = 0xFFFFFFFF; pp->tributes[i].tribute = 0xFFFFFFFF;
@ -1170,7 +1170,7 @@ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struc
} }
bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id); std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id);
auto results = database.QueryDatabase(query); int i = 0; auto results = database.QueryDatabase(query); int i = 0;
for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){ for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){
pp->potionbelt.items[i].icon = 0; pp->potionbelt.items[i].icon = 0;
@ -1194,10 +1194,10 @@ bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struc
bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `is_home` FROM `character_bind` WHERE `id` = %u LIMIT 2", character_id); std::string query = StringFormat("SELECT `zone_id`, `instance_id`, `x`, `y`, `z`, `heading`, `is_home` FROM `character_bind` WHERE `id` = %u LIMIT 2", character_id);
auto results = database.QueryDatabase(query); int i = 0; auto results = database.QueryDatabase(query); int i = 0;
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
i = 0; i = 0;
/* Is home bind */ /* Is home bind */
if (atoi(row[6]) == 1){ if (atoi(row[6]) == 1){
pp->binds[4].zoneId = atoi(row[i++]); pp->binds[4].zoneId = atoi(row[i++]);
pp->binds[4].instance_id = atoi(row[i++]); pp->binds[4].instance_id = atoi(row[i++]);
pp->binds[4].x = atoi(row[i++]); pp->binds[4].x = atoi(row[i++]);
@ -1225,7 +1225,7 @@ bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, ui
} }
bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home){ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home){
if (zone_id <= 0) { if (zone_id <= 0) {
return false; return false;
} }
@ -1233,7 +1233,7 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, u
std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, x, y, z, heading, is_home); " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, x, y, z, heading, is_home);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u x: %f y: %f z: %f heading: %f ishome: %u", character_id, zone_id, instance_id, x, y, z, heading, is_home); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u x: %f y: %f z: %f heading: %f ishome: %u", character_id, zone_id, instance_id, x, y, z, heading, is_home);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.RowsAffected()) { if (!results.RowsAffected()) {
LogFile->write(EQEMuLog::Debug, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), query.c_str()); LogFile->write(EQEMuLog::Debug, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), query.c_str());
} }
@ -1241,9 +1241,9 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, u
} }
bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color){ bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color){
uint8 red = (color & 0x00FF0000) >> 16; uint8 red = (color & 0x00FF0000) >> 16;
uint8 green = (color & 0x0000FF00) >> 8; uint8 green = (color & 0x0000FF00) >> 8;
uint8 blue = (color & 0x000000FF); uint8 blue = (color & 0x000000FF);
std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, red, green, blue, color, use_tint) VALUES (%u, %u, %u, %u, %u, %u, 255)", character_id, slot_id, red, green, blue, color); auto results = QueryDatabase(query); std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, red, green, blue, color, use_tint) VALUES (%u, %u, %u, %u, %u, %u, 255)", character_id, slot_id, red, green, blue, color); auto results = QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color);
@ -1257,30 +1257,30 @@ bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint
} }
bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id){ bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id){
std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id); std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u done", character_id, slot_id, disc_id); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u done", character_id, slot_id, disc_id);
return true; return true;
} }
bool ZoneDatabase::SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){ bool ZoneDatabase::SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", character_id); std::string query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", character_id);
QueryDatabase(query); QueryDatabase(query);
/* Save Tributes only if we have values... */ /* Save Tributes only if we have values... */
for (int i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){ for (int i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){
if (pp->tributes[i].tribute > 0 && pp->tributes[i].tribute != TRIBUTE_NONE){ if (pp->tributes[i].tribute > 0 && pp->tributes[i].tribute != TRIBUTE_NONE){
std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute);
QueryDatabase(query); QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute);
} }
} }
return true; return true;
} }
bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name){ bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name){
char bandolier_name_esc[64]; char bandolier_name_esc[64];
DoEscapeString(bandolier_name_esc, bandolier_name, strlen(bandolier_name)); DoEscapeString(bandolier_name_esc, bandolier_name, strlen(bandolier_name));
std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc); std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name);
if (!results.RowsAffected()){ std::cout << "ERROR Bandolier Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; } if (!results.RowsAffected()){ std::cout << "ERROR Bandolier Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
@ -1501,7 +1501,7 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
"%u," // e_aa_effects "%u," // e_aa_effects
"%u," // e_percent_to_aa "%u," // e_percent_to_aa
"%u" // e_expended_aa_spent "%u" // e_expended_aa_spent
")", ")",
character_id, // " id, " character_id, // " id, "
account_id, // " account_id, " account_id, // " account_id, "
EscapeString(pp->name).c_str(), // " `name`, " EscapeString(pp->name).c_str(), // " `name`, "
@ -1637,8 +1637,8 @@ bool ZoneDatabase::SaveCharacterCurrency(uint32 character_id, PlayerProfile_Stru
pp->careerRadCrystals, pp->careerRadCrystals,
pp->currentEbonCrystals, pp->currentEbonCrystals,
pp->careerEbonCrystals); pp->careerEbonCrystals);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "Saving Currency for character ID: %i, done", character_id); LogFile->write(EQEMuLog::Debug, "Saving Currency for character ID: %i, done", character_id);
return true; return true;
} }
@ -1653,62 +1653,62 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur
bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
if (spell_id > SPDAT_RECORDS){ return false; } if (spell_id > SPDAT_RECORDS){ return false; }
std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
if (spell_id > SPDAT_RECORDS){ return false; } if (spell_id > SPDAT_RECORDS){ return false; }
std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ bool ZoneDatabase::DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterDisc(uint32 character_id, uint32 slot_id){ bool ZoneDatabase::DeleteCharacterDisc(uint32 character_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterBandolier(uint32 character_id, uint32 band_id){ bool ZoneDatabase::DeleteCharacterBandolier(uint32 character_id, uint32 band_id){
std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id); std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterLeadershipAAs(uint32 character_id){ bool ZoneDatabase::DeleteCharacterLeadershipAAs(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id); std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterAAs(uint32 character_id){ bool ZoneDatabase::DeleteCharacterAAs(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id); std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterDye(uint32 character_id){ bool ZoneDatabase::DeleteCharacterDye(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", character_id); std::string query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){ bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query); QueryDatabase(query);
return true; return true;
} }
bool ZoneDatabase::NoRentExpired(const char* name){ bool ZoneDatabase::NoRentExpired(const char* name){
std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM `character_data` WHERE name = '%s'", name); std::string query = StringFormat("SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM `character_data` WHERE name = '%s'", name);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
return false; return false;
@ -2113,7 +2113,7 @@ bool ZoneDatabase::LoadMercInfo(Client *client) {
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
return false; return false;
if(results.RowCount() == 0) if(results.RowCount() == 0)
return false; return false;
@ -2169,7 +2169,7 @@ bool ZoneDatabase::LoadCurrentMerc(Client *client) {
if(!results.Success()) if(!results.Success())
return false; return false;
if(results.RowCount() == 0) if(results.RowCount() == 0)
return false; return false;
@ -2750,7 +2750,7 @@ void ZoneDatabase::QGlobalPurge()
database.QueryDatabase(query); database.QueryDatabase(query);
} }
void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, float dxpos, float dypos, float dzpos, float dheading, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){ void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize){
std::string query = StringFormat("REPLACE INTO doors (id, doorid, zone, version, name, " std::string query = StringFormat("REPLACE INTO doors (id, doorid, zone, version, name, "
"pos_x, pos_y, pos_z, heading, opentype, guild, lockpick, " "pos_x, pos_y, pos_z, heading, opentype, guild, lockpick, "
@ -2758,8 +2758,8 @@ void ZoneDatabase::InsertDoor(uint32 ddoordbid, uint16 ddoorid, const char* ddoo
"VALUES('%i', '%i', '%s', '%i', '%s', '%f', '%f', " "VALUES('%i', '%i', '%s', '%i', '%s', '%f', '%f', "
"'%f', '%f', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i')", "'%f', '%f', '%i', '%i', '%i', '%i', '%i', '%i', '%i', '%i')",
ddoordbid, ddoorid, zone->GetShortName(), zone->GetInstanceVersion(), ddoordbid, ddoorid, zone->GetShortName(), zone->GetInstanceVersion(),
ddoor_name, dxpos, dypos, dzpos, dheading, dopentype, dguildid, ddoor_name, position.m_X, position.m_Y, position.m_Z, position.m_Heading,
dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize); dopentype, dguildid, dlockpick, dkeyitem, ddoor_param, dinvert, dincline, dsize);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
std::cerr << "Error in InsertDoor" << query << "' " << results.ErrorMessage() << std::endl; std::cerr << "Error in InsertDoor" << query << "' " << results.ErrorMessage() << std::endl;
@ -3332,13 +3332,13 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
if (results.Success() && results2.Success()){ if (results.Success() && results2.Success()){
return true; return true;
} }
return false; return false;
} }
uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) { uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
std::string query = StringFormat( std::string query = StringFormat(
"UPDATE `zone` SET `graveyard_id` = %u WHERE `zone_idnumber` = %u AND `version` = 0", "UPDATE `zone` SET `graveyard_id` = %u WHERE `zone_idnumber` = %u AND `version` = 0",
graveyard_id, zone_id graveyard_id, zone_id
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3347,7 +3347,7 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) { uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) {
std::string query = StringFormat( std::string query = StringFormat(
"INSERT INTO `graveyard` SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f", "INSERT INTO `graveyard` SET `zone_id` = %u, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f",
graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, graveyard_heading graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, graveyard_heading
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3360,7 +3360,7 @@ uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id,
std::string query = StringFormat( std::string query = StringFormat(
"UPDATE `character_corpses` " "UPDATE `character_corpses` "
"SET `zone_id` = %u, `instance_id` = 0, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, `was_at_graveyard` = 1 " "SET `zone_id` = %u, `instance_id` = 0, `x` = %1.1f, `y` = %1.1f, `z` = %1.1f, `heading` = %1.1f, `was_at_graveyard` = 1 "
"WHERE `id` = %d", "WHERE `id` = %d",
zone_id, x, y, z, heading, dbid zone_id, x, y, z, heading, dbid
); );
QueryDatabase(query); QueryDatabase(query);
@ -3372,7 +3372,7 @@ uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
auto row = results.begin(); auto row = results.begin();
if (results.Success() && results.RowsAffected() != 0){ if (results.Success() && results.RowsAffected() != 0){
return atoll(row[0]); return atoll(row[0]);
} }
return 0; return 0;
} }
@ -3421,12 +3421,12 @@ uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const c
"`wc_8` = %u,\n" "`wc_8` = %u,\n"
"`wc_9` = %u \n" "`wc_9` = %u \n"
"WHERE `id` = %u", "WHERE `id` = %u",
EscapeString(char_name).c_str(), EscapeString(char_name).c_str(),
zone_id, zone_id,
instance_id, instance_id,
char_id, char_id,
x, x,
y, y,
z, z,
heading, heading,
dbpc->locked, dbpc->locked,
@ -3562,29 +3562,29 @@ uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, ui
dbpc->item_tint[7].color, dbpc->item_tint[7].color,
dbpc->item_tint[8].color dbpc->item_tint[8].color
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
uint32 last_insert_id = results.LastInsertedID(); uint32 last_insert_id = results.LastInsertedID();
/* Dump Items from Inventory */ /* Dump Items from Inventory */
uint8 first_entry = 0; uint8 first_entry = 0;
for (unsigned int i = 0; i < dbpc->itemcount; i++) { for (unsigned int i = 0; i < dbpc->itemcount; i++) {
if (first_entry != 1){ if (first_entry != 1){
query = StringFormat("REPLACE INTO `character_corpse_items` \n" query = StringFormat("REPLACE INTO `character_corpse_items` \n"
" (corpse_id, equip_slot, item_id, charges, aug_1, aug_2, aug_3, aug_4, aug_5, attuned) \n" " (corpse_id, equip_slot, item_id, charges, aug_1, aug_2, aug_3, aug_4, aug_5, attuned) \n"
" VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n", " VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
last_insert_id, last_insert_id,
dbpc->items[i].equip_slot, dbpc->items[i].equip_slot,
dbpc->items[i].item_id, dbpc->items[i].item_id,
dbpc->items[i].charges, dbpc->items[i].charges,
dbpc->items[i].aug_1, dbpc->items[i].aug_1,
dbpc->items[i].aug_2, dbpc->items[i].aug_2,
dbpc->items[i].aug_3, dbpc->items[i].aug_3,
dbpc->items[i].aug_4, dbpc->items[i].aug_4,
dbpc->items[i].aug_5 dbpc->items[i].aug_5
); );
first_entry = 1; first_entry = 1;
} }
else{ else{
query = query + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n", query = query + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
last_insert_id, last_insert_id,
dbpc->items[i].equip_slot, dbpc->items[i].equip_slot,
@ -3598,13 +3598,13 @@ uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, ui
); );
} }
} }
auto sc_results = QueryDatabase(query); auto sc_results = QueryDatabase(query);
return last_insert_id; return last_insert_id;
} }
uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) { uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) {
std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1", char_id); std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1", char_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]); return atoi(row[0]);
@ -3614,7 +3614,7 @@ uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) {
uint32 ZoneDatabase::GetCharacterCorpseCount(uint32 char_id) { uint32 ZoneDatabase::GetCharacterCorpseCount(uint32 char_id) {
std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u'", char_id); std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u'", char_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]); return atoi(row[0]);
@ -3698,7 +3698,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct
"WHERE `id` = %u LIMIT 1\n", "WHERE `id` = %u LIMIT 1\n",
corpse_id corpse_id
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
uint16 i = 0; uint16 i = 0;
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
pcs->locked = atoi(row[i++]); // is_locked, pcs->locked = atoi(row[i++]); // is_locked,
@ -3755,7 +3755,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct
); );
results = QueryDatabase(query); results = QueryDatabase(query);
i = 0; i = 0;
pcs->itemcount = results.RowCount(); pcs->itemcount = results.RowCount();
uint16 r = 0; uint16 r = 0;
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
@ -3778,7 +3778,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct
Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) { Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zone_id, uint16 dest_instance_id, float dest_x, float dest_y, float dest_z, float dest_heading) {
Corpse* NewCorpse = 0; Corpse* NewCorpse = 0;
std::string query = StringFormat( std::string query = StringFormat(
"SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1 ORDER BY `time_of_death` LIMIT 1", "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 1 ORDER BY `time_of_death` LIMIT 1",
char_id char_id
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3796,7 +3796,7 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z
atoi(row[3]) == 1, // bool rezzed atoi(row[3]) == 1, // bool rezzed
false // bool was_at_graveyard false // bool was_at_graveyard
); );
if (NewCorpse) { if (NewCorpse) {
entity_list.AddCorpse(NewCorpse); entity_list.AddCorpse(NewCorpse);
NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
NewCorpse->Spawn(); NewCorpse->Spawn();
@ -3820,7 +3820,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id
query = StringFormat( query = StringFormat(
"SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u'" "SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u'"
"ORDER BY time_of_death", "ORDER BY time_of_death",
char_id char_id
); );
results = QueryDatabase(query); results = QueryDatabase(query);
@ -3853,7 +3853,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id
bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, float new_x, float new_y, float new_z, float new_heading) { bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, float new_x, float new_y, float new_z, float new_heading) {
std::string query = StringFormat( std::string query = StringFormat(
"UPDATE `character_corpses` SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, `x` = %f, `y` = %f, `z` = %f, `heading` = %f, `time_of_death` = Now(), `was_at_graveyard` = 0 WHERE `id` = %u", "UPDATE `character_corpses` SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, `x` = %f, `y` = %f, `z` = %f, `heading` = %f, `time_of_death` = Now(), `was_at_graveyard` = 0 WHERE `id` = %u",
new_zone_id, new_instance_id, new_x, new_y, new_z, new_heading, db_id new_zone_id, new_instance_id, new_x, new_y, new_z, new_heading, db_id
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3866,7 +3866,7 @@ bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint1
Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) { Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) {
Corpse* NewCorpse = 0; Corpse* NewCorpse = 0;
std::string query = StringFormat( std::string query = StringFormat(
"SELECT `id`, `charid`, `charname`, `x`, `y`, `z`, `heading`, `time_of_death`, `is_rezzed`, `was_at_graveyard` FROM `character_corpses` WHERE `id` = '%u' LIMIT 1", "SELECT `id`, `charid`, `charname`, `x`, `y`, `z`, `heading`, `time_of_death`, `is_rezzed`, `was_at_graveyard` FROM `character_corpses` WHERE `id` = '%u' LIMIT 1",
player_corpse_id player_corpse_id
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3889,7 +3889,7 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) {
} }
bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
std::string query; std::string query;
if (!RuleB(Zone, EnableShadowrest)){ if (!RuleB(Zone, EnableShadowrest)){
query = StringFormat("SELECT id, charid, charname, x, y, z, heading, time_of_death, is_rezzed, was_at_graveyard FROM character_corpses WHERE zone_id='%u' AND instance_id='%u'", zone_id, instance_id); query = StringFormat("SELECT id, charid, charname, x, y, z, heading, time_of_death, is_rezzed, was_at_graveyard FROM character_corpses WHERE zone_id='%u' AND instance_id='%u'", zone_id, instance_id);
} }
@ -3905,7 +3905,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
// std::cout << row[3] << std::endl; // std::cout << row[3] << std::endl;
// std::cout << row[4] << std::endl; // std::cout << row[4] << std::endl;
// std::cout << row[5] << std::endl; // std::cout << row[5] << std::endl;
// std::cout << row[6] << std::endl; // std::cout << row[6] << std::endl;
// std::cout << row[7] << std::endl; // std::cout << row[7] << std::endl;
// std::cout << row[8] << std::endl; // std::cout << row[8] << std::endl;
// std::cout << row[9] << std::endl; // std::cout << row[9] << std::endl;
@ -3914,7 +3914,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
Corpse::LoadFromDBData( Corpse::LoadFromDBData(
atoll(row[0]), // id uint32 in_dbid atoll(row[0]), // id uint32 in_dbid
atoll(row[1]), // charid uint32 in_charid atoll(row[1]), // charid uint32 in_charid
row[2], // char_name row[2], // char_name
atof(row[3]), // x float in_x atof(row[3]), // x float in_x
atof(row[4]), // y float in_y atof(row[4]), // y float in_y
atof(row[5]), // z float in_z atof(row[5]), // z float in_z
@ -3929,7 +3929,7 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
} }
uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) { uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 0 ORDER BY `time_of_death` LIMIT 1", char_id); std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 0 ORDER BY `time_of_death` LIMIT 1", char_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]); return atoi(row[0]);
@ -3940,10 +3940,10 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
bool ZoneDatabase::ClearCorpseItems(uint32 db_id){ bool ZoneDatabase::ClearCorpseItems(uint32 db_id){
std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u", db_id); std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u", db_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){ if (results.Success() && results.RowsAffected() != 0){
return true; return true;
} }
return false; return false;
} }
bool ZoneDatabase::DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id){ bool ZoneDatabase::DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id){
@ -3978,7 +3978,7 @@ bool ZoneDatabase::BuryAllCharacterCorpses(uint32 char_id) {
bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) { bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) {
std::string query = StringFormat("DELETE FROM `character_corpses` WHERE `id` = %d", db_id); std::string query = StringFormat("DELETE FROM `character_corpses` WHERE `id` = %d", db_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){ if (results.Success() && results.RowsAffected() != 0){
return true; return true;
} }
return false; return false;

View File

@ -5,6 +5,7 @@
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/loottable.h" #include "../common/loottable.h"
#include "zonedump.h" #include "zonedump.h"
#include "position.h"
#include "../common/faction.h" #include "../common/faction.h"
#include <limits> #include <limits>
@ -226,7 +227,7 @@ public:
/* Traders */ /* Traders */
void SaveTraderItem(uint32 char_id,uint32 itemid,uint32 uniqueid, int32 charges,uint32 itemcost,uint8 slot); void SaveTraderItem(uint32 char_id,uint32 itemid,uint32 uniqueid, int32 charges,uint32 itemcost,uint8 slot);
void UpdateTraderItemCharges(int char_id, uint32 ItemInstID, int32 charges); void UpdateTraderItemCharges(int char_id, uint32 ItemInstID, int32 charges);
void UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice); void UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice);
void DeleteTraderItem(uint32 char_id); void DeleteTraderItem(uint32 char_id);
void DeleteTraderItem(uint32 char_id,uint16 slot_id); void DeleteTraderItem(uint32 char_id,uint16 slot_id);
@ -302,14 +303,14 @@ public:
Corpse* LoadCharacterCorpse(uint32 player_corpse_id); Corpse* LoadCharacterCorpse(uint32 player_corpse_id);
Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); Corpse* SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading);
void MarkCorpseAsRezzed(uint32 dbid); void MarkCorpseAsRezzed(uint32 dbid);
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
bool BuryCharacterCorpse(uint32 dbid); bool BuryCharacterCorpse(uint32 dbid);
bool BuryAllCharacterCorpses(uint32 charid); bool BuryAllCharacterCorpses(uint32 charid);
bool DeleteCharacterCorpse(uint32 dbid); bool DeleteCharacterCorpse(uint32 dbid);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading);
bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading); bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading); bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID); bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID);
bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id); uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id); uint32 GetCharacterBuriedCorpseCount(uint32 char_id);
@ -378,7 +379,7 @@ public:
int GetHighestWaypoint(uint32 zoneid, uint32 gridid); int GetHighestWaypoint(uint32 zoneid, uint32 gridid);
/* NPCs */ /* NPCs */
uint32 NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn = 0, uint32 extra = 0); // 0 = Create 1 = Add; 2 = Update; 3 = Remove; 4 = Delete uint32 NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn = 0, uint32 extra = 0); // 0 = Create 1 = Add; 2 = Update; 3 = Remove; 4 = Delete
uint32 CreateNewNPCCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 extra); uint32 CreateNewNPCCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 extra);
uint32 AddNewNPCSpawnGroupCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 respawnTime); uint32 AddNewNPCSpawnGroupCommand(const char* zone, uint32 zone_version, Client *client, NPC* spawn, uint32 respawnTime);
@ -445,7 +446,7 @@ public:
int32 GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version); int32 GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version);
int32 GetDoorsCountPlusOne(const char *zone_name, int16 version); int32 GetDoorsCountPlusOne(const char *zone_name, int16 version);
int32 GetDoorsDBCountPlusOne(const char *zone_name, int16 version); int32 GetDoorsDBCountPlusOne(const char *zone_name, int16 version);
void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, float dxpos, float dypos, float dzpos, float dheading, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize); void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, const xyz_heading& position, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize);
/* Blocked Spells */ /* Blocked Spells */
int32 GetBlockedSpellsCount(uint32 zoneid); int32 GetBlockedSpellsCount(uint32 zoneid);