This commit is contained in:
Trevius 2014-11-24 02:32:54 -06:00
commit bee04c1b53
35 changed files with 2780 additions and 2259 deletions

View File

@ -1,5 +1,8 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50) EQEMu Changelog (Started on Sept 24, 2003 15:50)
------------------------------------------------------- -------------------------------------------------------
== 11/24/2014 ==
Trevius: Added Rule NPC:EnableMeritBasedFaction (disabled by default) - Allows faction gain to work similar to experience.
== 11/22/2014 == == 11/22/2014 ==
Trevius: Grouping with Mercenaries is now considerably less buggy. Trevius: Grouping with Mercenaries is now considerably less buggy.
Trevius: Fixed an issue with Spell Globals related to high Character IDs. Trevius: Fixed an issue with Spell Globals related to high Character IDs.

View File

@ -48,6 +48,7 @@
#include "guilds.h" #include "guilds.h"
#include "string_util.h" #include "string_util.h"
#include "extprofile.h" #include "extprofile.h"
extern Client client; extern Client client;
#ifdef _WINDOWS #ifdef _WINDOWS
@ -322,20 +323,6 @@ bool Database::ReserveName(uint32 account_id, char* name) {
return true; return true;
} }
bool Database::ThrowDBError(std::string ErrorMessage, std::string query_title, std::string query){
if (ErrorMessage != ""){
std::cout << "\nERROR " << query_title << ": " << ErrorMessage << "\n\n" << query << "\n" << std::endl;
/* Write to log file */
std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out);
log << "ERROR " << query_title << ": " << ErrorMessage << "\n" << query << "\n";
log.close();
return true;
}
return false;
}
/* /*
Delete the character with the name "name" Delete the character with the name "name"
returns false on failure, true otherwise returns false on failure, true otherwise
@ -354,39 +341,39 @@ bool Database::DeleteCharacter(char *name) {
for (auto row = results.begin(); row != results.end(); ++row) { charid = atoi(row[0]); } for (auto row = results.begin(); row != results.end(); ++row) { charid = atoi(row[0]); }
if (charid <= 0){ std::cerr << "Database::DeleteCharacter :: Character not found, stopping delete...\n"; return false; } if (charid <= 0){ std::cerr << "Database::DeleteCharacter :: Character not found, stopping delete...\n"; return false; }
query = StringFormat("DELETE FROM `quest_globals` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `quest_globals` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_activities` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_activities` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_enabledtasks` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_enabledtasks` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `completed_tasks` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `completed_tasks` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `friends` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `friends` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `mail` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `mail` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `timers` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `timers` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `inventory` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `inventory` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `char_recipe_list` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `char_recipe_list` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `adventure_stats` WHERE `player_id` ='%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `adventure_stats` WHERE `player_id` ='%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `zone_flags` WHERE `charID` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `zone_flags` WHERE `charID` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `titles` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `titles` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `player_titlesets` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `player_titlesets` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `keyring` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `keyring` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `faction_values` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `faction_values` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `instance_list_player` WHERE `charid` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `instance_list_player` WHERE `charid` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_data` WHERE `id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_data` WHERE `id` = '%d'", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_skills` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_skills` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_languages` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_languages` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_bind` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_bind` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_currency` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_currency` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_data` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_data` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_spells` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_spells` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_disciplines` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_disciplines` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_bandolier` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_bandolier` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_potionbelt` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_potionbelt` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_inspect_messages` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_inspect_messages` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", charid); results = QueryDatabase(query);
query = StringFormat("DELETE FROM `character_alt_currency` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::DeleteCharacter", query); query = StringFormat("DELETE FROM `character_alt_currency` WHERE `char_id` = '%d'", charid); results = QueryDatabase(query);
#ifdef BOTS #ifdef BOTS
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", charid); query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", charid);
#else #else
@ -674,14 +661,13 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
pp->RestTimer // " RestTimer) " pp->RestTimer // " RestTimer) "
); );
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "Database::SaveCharacterCreate Character Data", query);
/* Save Bind Points */ /* Save Bind Points */
query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" 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), " " VALUES (%u, %u, %u, %f, %f, %f, %f, %i), "
"(%u, %u, %u, %f, %f, %f, %f, %i)", "(%u, %u, %u, %f, %f, %f, %f, %i)",
character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading, 0, character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading, 0,
character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading, 1 character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading, 1
); results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::SaveCharacterCreate Bind Point", query); ); results = QueryDatabase(query);
/* Save Skills */ /* Save Skills */
int firstquery = 0; int firstquery = 0;
@ -696,7 +682,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
} }
} }
} }
results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::SaveCharacterCreate Starting Skills", query); results = QueryDatabase(query);
/* Save Language */ /* Save Language */
firstquery = 0; firstquery = 0;
@ -711,7 +697,7 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
} }
} }
} }
results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "Database::SaveCharacterCreate Starting Languages", query); results = QueryDatabase(query);
return true; return true;
} }
@ -910,10 +896,31 @@ static inline void loadbar(unsigned int x, unsigned int n, unsigned int w = 50)
} }
bool Database::CheckDatabaseConversions() { bool Database::CheckDatabaseConversions() {
CheckDatabaseConvertPPDeblob();
CheckDatabaseConvertBotsPostPPDeblob();
CheckDatabaseConvertCorpseDeblob();
/* Fetch Automatic Database Upgrade Script */
if (!std::ifstream("db_update.pl")){
std::cout << "Pulling down automatic database upgrade script...\n" << std::endl;
#ifdef _WIN32
system("perl -MLWP::UserAgent -e \"require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_update.pl'); if ($response->is_success){ open(FILE, '> db_update.pl'); print FILE $response->decoded_content; close(FILE); }\"");
#else
system("wget -O db_update.pl https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_update.pl");
#endif
}
/* Run Automatic Database Upgrade Script */
system("perl db_update.pl ran_from_world");
return true;
}
bool Database::CheckDatabaseConvertPPDeblob(){
unsigned int lengths; unsigned int lengths;
unsigned int lengths_e; unsigned int lengths_e;
std::string squery; std::string squery;
PlayerProfile_Struct* pp; Convert::PlayerProfile_Struct* pp;
ExtendedProfile_Struct* e_pp; ExtendedProfile_Struct* e_pp;
uint32 pplen = 0; uint32 pplen = 0;
uint32 i; uint32 i;
@ -1063,7 +1070,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1; " ") ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_currency` */ /* Check for table `character_currency` */
@ -1095,7 +1101,6 @@ bool Database::CheckDatabaseConversions() {
" ) ENGINE=InnoDB DEFAULT CHARSET=latin1; " " ) ENGINE=InnoDB DEFAULT CHARSET=latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_alternate_abilities` */ /* Check for table `character_alternate_abilities` */
@ -1114,7 +1119,6 @@ bool Database::CheckDatabaseConversions() {
" ) ENGINE = InnoDB DEFAULT CHARSET = latin1; " " ) ENGINE = InnoDB DEFAULT CHARSET = latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_bind` */ /* Check for table `character_bind` */
@ -1137,7 +1141,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_languages` */ /* Check for table `character_languages` */
@ -1155,7 +1158,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_skills` */ /* Check for table `character_skills` */
@ -1173,7 +1175,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_spells` */ /* Check for table `character_spells` */
@ -1191,7 +1192,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_memmed_spells` */ /* Check for table `character_memmed_spells` */
@ -1209,7 +1209,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_disciplines` */ /* Check for table `character_disciplines` */
@ -1227,7 +1226,6 @@ bool Database::CheckDatabaseConversions() {
" ) ENGINE = InnoDB DEFAULT CHARSET = latin1; " " ) ENGINE = InnoDB DEFAULT CHARSET = latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_material` */ /* Check for table `character_material` */
@ -1249,7 +1247,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_tribute` */ /* Check for table `character_tribute` */
@ -1266,7 +1263,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_bandolier` */ /* Check for table `character_bandolier` */
@ -1287,7 +1283,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1; " ") ENGINE = InnoDB DEFAULT CHARSET = latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_potionbelt` */ /* Check for table `character_potionbelt` */
@ -1306,7 +1301,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_potionbelt` */ /* Check for table `character_potionbelt` */
@ -1323,7 +1317,6 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1;" ") ENGINE = InnoDB DEFAULT CHARSET = latin1;"
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Check for table `character_leadership_abilities` */ /* Check for table `character_leadership_abilities` */
@ -1341,15 +1334,13 @@ bool Database::CheckDatabaseConversions() {
") ENGINE = InnoDB DEFAULT CHARSET = latin1; " ") ENGINE = InnoDB DEFAULT CHARSET = latin1; "
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Table create", rquery);
printf(" done...\n"); printf(" done...\n");
} }
/* Done */ /* Done */
printf("Starting conversion...\n\n"); printf("Starting conversion...\n\n");
}
// Testing account = 11001
int char_iter_count = 0; int char_iter_count = 0;
rquery = StringFormat("SELECT `id` FROM `character_`"); rquery = StringFormat("SELECT `id` FROM `character_`");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
@ -1366,7 +1357,7 @@ bool Database::CheckDatabaseConversions() {
squery = StringFormat("SELECT `id`, `profile`, `name`, `level`, `account_id`, `firstlogon`, `lfg`, `lfp`, `mailkey`, `xtargets`, `inspectmessage`, `extprofile` FROM `character_` WHERE `id` = %i", atoi(row[0])); squery = StringFormat("SELECT `id`, `profile`, `name`, `level`, `account_id`, `firstlogon`, `lfg`, `lfp`, `mailkey`, `xtargets`, `inspectmessage`, `extprofile` FROM `character_` WHERE `id` = %i", atoi(row[0]));
auto results2 = QueryDatabase(squery); auto results2 = QueryDatabase(squery);
auto row2 = results2.begin(); auto row2 = results2.begin();
pp = (PlayerProfile_Struct*)row2[1]; pp = (Convert::PlayerProfile_Struct*)row2[1];
e_pp = (ExtendedProfile_Struct*)row2[11]; e_pp = (ExtendedProfile_Struct*)row2[11];
character_id = atoi(row[0]); character_id = atoi(row[0]);
account_id = atoi(row2[4]); account_id = atoi(row2[4]);
@ -1380,13 +1371,13 @@ bool Database::CheckDatabaseConversions() {
/* Verify PP Integrity */ /* Verify PP Integrity */
lengths = results2.LengthOfColumn(1); lengths = results2.LengthOfColumn(1);
if (lengths == sizeof(PlayerProfile_Struct)) { /* If PP is the size it is expected to be */ if (lengths == sizeof(Convert::PlayerProfile_Struct)) { /* If PP is the size it is expected to be */
memcpy(pp, row2[1], sizeof(PlayerProfile_Struct)); memcpy(pp, row2[1], sizeof(Convert::PlayerProfile_Struct));
} }
/* Continue of PP Size does not match (Usually a created character never logged in) */ /* Continue of PP Size does not match (Usually a created character never logged in) */
else { else {
// printf("%s ID: %i profile mismatch, not converting. PP %u - Profile Length %u \n", row2[2] ? row2[2] : "Unknown", character_id, sizeof(PlayerProfile_Struct), lengths); // printf("%s ID: %i profile mismatch, not converting. PP %u - Profile Length %u \n", row2[2] ? row2[2] : "Unknown", character_id, sizeof(PlayerProfile_Struct), lengths);
std::cout << (row2[2] ? row2[2] : "Unknown") << " ID: " << character_id << " size mismatch. Expected Size: " << sizeof(PlayerProfile_Struct) << " Seen: " << lengths << std::endl; std::cout << (row2[2] ? row2[2] : "Unknown") << " ID: " << character_id << " size mismatch. Expected Size: " << sizeof(Convert::PlayerProfile_Struct) << " Seen: " << lengths << std::endl;
continue; continue;
} }
@ -1409,7 +1400,6 @@ bool Database::CheckDatabaseConversions() {
EscapeString(inspectmessage).c_str() EscapeString(inspectmessage).c_str()
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Character Inspect Message Convert", rquery);
} }
/* Run Currency Convert */ /* Run Currency Convert */
@ -1437,7 +1427,6 @@ bool Database::CheckDatabaseConversions() {
pp->careerEbonCrystals pp->careerEbonCrystals
); );
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Character Currency Convert", rquery);
if (pp->tribute_time_remaining < 0 || pp->tribute_time_remaining == 4294967295){ pp->tribute_time_remaining = 0; } if (pp->tribute_time_remaining < 0 || pp->tribute_time_remaining == 4294967295){ pp->tribute_time_remaining = 0; }
@ -1743,7 +1732,6 @@ bool Database::CheckDatabaseConversions() {
e_pp->expended_aa e_pp->expended_aa
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Character Data Convert", rquery);
/* /*
@ -1759,19 +1747,20 @@ bool Database::CheckDatabaseConversions() {
rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)" rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)"
" VALUES (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value); " VALUES (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value);
first_entry = 1; first_entry = 1;
} else { }
else {
rquery = rquery + StringFormat(", (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value); rquery = rquery + StringFormat(", (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value);
} }
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "AA Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Bind Home Convert */ /* Run Bind Home Convert */
if (pp->binds[4].zoneId < 999 && !_ISNAN_(pp->binds[4].x) && !_ISNAN_(pp->binds[4].y) && !_ISNAN_(pp->binds[4].z) && !_ISNAN_(pp->binds[4].heading)) { if (pp->binds[4].zoneId < 999 && !_ISNAN_(pp->binds[4].x) && !_ISNAN_(pp->binds[4].y) && !_ISNAN_(pp->binds[4].z) && !_ISNAN_(pp->binds[4].heading)) {
rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, 1)", " VALUES (%u, %u, %u, %f, %f, %f, %f, 1)",
character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading); character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading);
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Bind Home Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
} }
/* Run Bind Convert */ /* Run Bind Convert */
@ -1779,7 +1768,7 @@ bool Database::CheckDatabaseConversions() {
rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)" rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, 0)", " VALUES (%u, %u, %u, %f, %f, %f, %f, 0)",
character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading); character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading);
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Bind Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
} }
/* Run Language Convert */ /* Run Language Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
@ -1792,7 +1781,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->languages[i]); rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->languages[i]);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Language Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Skill Convert */ /* Run Skill Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < MAX_PP_SKILL; i++){ for (i = 0; i < MAX_PP_SKILL; i++){
@ -1804,7 +1793,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->skills[i]); rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->skills[i]);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Skills Convert Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Spell Convert */ /* Run Spell Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < MAX_PP_REF_SPELLBOOK; i++){ for (i = 0; i < MAX_PP_REF_SPELLBOOK; i++){
@ -1817,7 +1806,7 @@ bool Database::CheckDatabaseConversions() {
} }
} }
// std::cout << rquery << "\n"; // std::cout << rquery << "\n";
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Spell Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Max Memmed Spell Convert */ /* Run Max Memmed Spell Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < MAX_PP_REF_MEMSPELL; i++){ for (i = 0; i < MAX_PP_REF_MEMSPELL; i++){
@ -1829,7 +1818,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->mem_spells[i]); rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->mem_spells[i]);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Memmed Spells Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Discipline Convert */ /* Run Discipline Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < MAX_PP_DISCIPLINES; i++){ for (i = 0; i < MAX_PP_DISCIPLINES; i++){
@ -1841,7 +1830,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->disciplines.values[i]); rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->disciplines.values[i]);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Discipline Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Material Color Convert */ /* Run Material Color Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < _MaterialCount; i++){ for (i = 0; i < _MaterialCount; i++){
@ -1853,7 +1842,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u)", character_id, i, pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint, pp->item_tint[i].color); rquery = rquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u)", character_id, i, pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint, pp->item_tint[i].color);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Material Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Tribute Convert */ /* Run Tribute Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){ for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){
@ -1865,7 +1854,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Tribute Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Bandolier Convert */ /* Run Bandolier Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < EmuConstants::BANDOLIERS_COUNT; i++){ for (i = 0; i < EmuConstants::BANDOLIERS_COUNT; i++){
@ -1881,7 +1870,7 @@ bool Database::CheckDatabaseConversions() {
} }
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Bandolier Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Potion Belt Convert */ /* Run Potion Belt Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){ for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){
@ -1894,7 +1883,7 @@ bool Database::CheckDatabaseConversions() {
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Potion Belt Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
/* Run Leadership AA Convert */ /* Run Leadership AA Convert */
first_entry = 0; rquery = ""; first_entry = 0; rquery = "";
for (i = 0; i < MAX_LEADERSHIP_AA_ARRAY; i++){ for (i = 0; i < MAX_LEADERSHIP_AA_ARRAY; i++){
@ -1906,7 +1895,7 @@ bool Database::CheckDatabaseConversions() {
rquery = rquery + StringFormat(", (%i, %u, %u)", character_id, i, pp->leader_abilities.ranks[i]); rquery = rquery + StringFormat(", (%i, %u, %u)", character_id, i, pp->leader_abilities.ranks[i]);
} }
} }
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "Character Leadership AA Convert", rquery); } if (rquery != ""){ results = QueryDatabase(rquery); }
} }
} }
if (runconvert == 1){ if (runconvert == 1){
@ -1914,15 +1903,17 @@ bool Database::CheckDatabaseConversions() {
printf("\n\nRenaming `character_` table to `character_old`, this is a LARGE table so when you don't need it anymore, I would suggest deleting it yourself...\n"); printf("\n\nRenaming `character_` table to `character_old`, this is a LARGE table so when you don't need it anymore, I would suggest deleting it yourself...\n");
printf("\n\nCharacter blob conversion complete, continuing world bootup...\n"); printf("\n\nCharacter blob conversion complete, continuing world bootup...\n");
} }
}
return true;
}
bool Database::CheckDatabaseConvertBotsPostPPDeblob(){
#ifdef BOTS #ifdef BOTS
int runbotsconvert = 0; int runbotsconvert = 0;
/* Check For Legacy Bot References */ /* Check For Legacy Bot References */
rquery = StringFormat("SHOW CREATE VIEW `vwBotCharacterMobs`"); std::string rquery = StringFormat("SHOW CREATE VIEW `vwBotCharacterMobs`");
results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
if (results.RowCount() == 1){ if (results.RowCount() == 1){
auto row = results.begin(); auto row = results.begin();
std::string table_check = row[1]; std::string table_check = row[1];
@ -1940,9 +1931,6 @@ bool Database::CheckDatabaseConversions() {
std::cin.ignore(1); std::cin.ignore(1);
} }
} }
else{
ThrowDBError(results.ErrorMessage(), "Bot View Discovery", rquery);
}
if (runbotsconvert == 1){ if (runbotsconvert == 1){
printf("Running bot views/function database conversion... \n"); printf("Running bot views/function database conversion... \n");
@ -1950,7 +1938,6 @@ bool Database::CheckDatabaseConversions() {
/* Update view `vwbotcharactermobs` */ /* Update view `vwbotcharactermobs` */
rquery = StringFormat("DROP VIEW `vwBotCharacterMobs`;"); rquery = StringFormat("DROP VIEW `vwBotCharacterMobs`;");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Drop View `vwBotCharacterMobs`", rquery);
rquery = StringFormat( rquery = StringFormat(
"CREATE VIEW `vwBotCharacterMobs` AS\n" "CREATE VIEW `vwBotCharacterMobs` AS\n"
@ -1973,13 +1960,11 @@ bool Database::CheckDatabaseConversions() {
"FROM bots AS b;" "FROM bots AS b;"
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Create View `vwBotCharacterMobs`", rquery);
/* Update function `GetMobType` */ /* Update function `GetMobType` */
rquery = StringFormat("DROP FUNCTION IF EXISTS `GetMobType`;"); rquery = StringFormat("DROP FUNCTION IF EXISTS `GetMobType`;");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Drop Function `GetMobType`", rquery);
rquery = StringFormat( rquery = StringFormat(
"CREATE FUNCTION `GetMobType` (mobname VARCHAR(64)) RETURNS CHAR(1)\n" "CREATE FUNCTION `GetMobType` (mobname VARCHAR(64)) RETURNS CHAR(1)\n"
@ -1998,13 +1983,11 @@ bool Database::CheckDatabaseConversions() {
"END" "END"
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Create Function `GetMobType`", rquery);
/* Update view `vwgroups` */ /* Update view `vwgroups` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwGroups`;"); rquery = StringFormat("DROP VIEW IF EXISTS `vwGroups`;");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Drop View `vwGroups`", rquery);
rquery = StringFormat( rquery = StringFormat(
"CREATE VIEW `vwGroups` AS\n" "CREATE VIEW `vwGroups` AS\n"
@ -2018,13 +2001,11 @@ bool Database::CheckDatabaseConversions() {
"LEFT JOIN `bots` AS b ON g.`name` = b.`Name`;" "LEFT JOIN `bots` AS b ON g.`name` = b.`Name`;"
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Create View `vwGroups`", rquery);
/* Update view `vwbotgroups` */ /* Update view `vwbotgroups` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwBotGroups`;"); rquery = StringFormat("DROP VIEW IF EXISTS `vwBotGroups`;");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Drop View `vwBotGroups`", rquery);
rquery = StringFormat( rquery = StringFormat(
"CREATE VIEW `vwBotGroups` AS\n" "CREATE VIEW `vwBotGroups` AS\n"
@ -2040,13 +2021,11 @@ bool Database::CheckDatabaseConversions() {
"ORDER BY b.`BotOwnerCharacterId`, g.`BotGroupName`;" "ORDER BY b.`BotOwnerCharacterId`, g.`BotGroupName`;"
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Create View `vwBotGroups`", rquery);
/* Update view `vwguildmembers` */ /* Update view `vwguildmembers` */
rquery = StringFormat("DROP VIEW IF EXISTS `vwGuildMembers`;"); rquery = StringFormat("DROP VIEW IF EXISTS `vwGuildMembers`;");
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Drop View `vwGuildMembers`", rquery);
rquery = StringFormat( rquery = StringFormat(
"CREATE VIEW `vwGuildMembers` AS\n" "CREATE VIEW `vwGuildMembers` AS\n"
@ -2075,7 +2054,6 @@ bool Database::CheckDatabaseConversions() {
"FROM `botguildmembers` AS bm;" "FROM `botguildmembers` AS bm;"
); );
results = QueryDatabase(rquery); results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "Create View `vwGuildMembers`", rquery);
} }
if (runbotsconvert == 1){ if (runbotsconvert == 1){
@ -2083,20 +2061,348 @@ bool Database::CheckDatabaseConversions() {
} }
#endif #endif
return true;
/* Fetch Automatic Database Upgrade Script */
if (!std::ifstream("db_update.pl")){
std::cout << "Pulling down automatic database upgrade script...\n" << std::endl;
#ifdef _WIN32
system("perl -MLWP::UserAgent -e \"require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_update.pl'); if ($response->is_success){ open(FILE, '> db_update.pl'); print FILE $response->decoded_content; close(FILE); }\"");
#else
system("wget -O db_update.pl https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_update.pl");
#endif
} }
/* Run Automatic Database Upgrade Script */
system("perl db_update.pl ran_from_world"); bool Database::CheckDatabaseConvertCorpseDeblob(){
Convert::DBPlayerCorpse_Struct_temp* dbpc;
Convert::classic_db_temp::DBPlayerCorpse_Struct_temp* dbpc_c;
uint32 in_datasize;
bool is_sof = false;
std::string c_type;
std::string scquery;
int8 first_entry = 0;
std::string query = StringFormat("SHOW TABLES LIKE 'player_corpses'");
auto results = QueryDatabase(query);
if (results.RowCount() != 0){
query = StringFormat(
"CREATE TABLE `character_corpse_items` ( "
"`corpse_id` int(11) unsigned NOT NULL, "
"`equip_slot` int(11) unsigned NOT NULL, "
"`item_id` int(11) unsigned DEFAULT NULL, "
"`charges` int(11) unsigned DEFAULT NULL, "
"`aug_1` int(11) unsigned DEFAULT '0', "
"`aug_2` int(11) unsigned DEFAULT '0', "
"`aug_3` int(11) unsigned DEFAULT '0', "
"`aug_4` int(11) unsigned DEFAULT '0', "
"`aug_5` int(11) unsigned DEFAULT '0', "
"`attuned` smallint(5) NOT NULL DEFAULT '0', "
"PRIMARY KEY(`corpse_id`, `equip_slot`) "
") ENGINE = InnoDB DEFAULT CHARSET = latin1; "
);
results = QueryDatabase(query);
query = StringFormat("RENAME TABLE `player_corpses` TO `character_corpses`");
results = QueryDatabase(query);
query = StringFormat(
" ALTER TABLE `character_corpses` \n"
" ADD COLUMN `is_locked` tinyint(11) NULL DEFAULT 0 AFTER `WasAtGraveyard`, \n"
" ADD COLUMN `exp` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `size` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `level` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `race` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `gender` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `class` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `deity` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `texture` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `helm_texture` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `copper` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `silver` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `gold` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `platinum` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `hair_color` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `beard_color` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `eye_color_1` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `eye_color_2` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `hair_style` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `face` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `beard` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `drakkin_heritage` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `drakkin_tattoo` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `drakkin_details` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_1` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_2` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_3` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_4` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_5` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_6` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_7` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_8` int(11) UNSIGNED NULL DEFAULT 0, \n"
" ADD COLUMN `wc_9` int(11) UNSIGNED NULL DEFAULT 0, \n"
" CHANGE COLUMN `zoneid` `zone_id` smallint(5) NOT NULL DEFAULT 0 AFTER `charname`, \n"
" CHANGE COLUMN `instanceid` `instance_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `zone_id`, \n"
" CHANGE COLUMN `timeofdeath` `time_of_death` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `data`, \n"
" CHANGE COLUMN `rezzed` `is_rezzed` tinyint(3) UNSIGNED NULL DEFAULT 0 AFTER `time_of_death`, \n"
" CHANGE COLUMN `IsBurried` `is_buried` tinyint(3) NOT NULL DEFAULT 0 AFTER `is_rezzed`; \n"
);
results = QueryDatabase(query);
query = StringFormat(
" ALTER TABLE `character_corpses` \n"
" CHANGE COLUMN `WasAtGraveyard` `was_at_graveyard` tinyint(3) NOT NULL DEFAULT 0 AFTER `is_buried` \n"
);
results = QueryDatabase(query);
}
std::string rquery = StringFormat("SHOW COLUMNS FROM `character_corpses` LIKE 'data'");
results = QueryDatabase(rquery);
if (results.RowCount() != 0){
rquery = StringFormat("SELECT DISTINCT charid FROM character_corpses");
results = QueryDatabase(rquery);
for (auto row = results.begin(); row != results.end(); ++row) {
std::string squery = StringFormat("SELECT id, charname, data, time_of_death, is_rezzed FROM character_corpses WHERE `charid` = %i", atoi(row[0]));
auto results2 = QueryDatabase(squery);
for (auto row2 = results2.begin(); row2 != results2.end(); ++row2) {
in_datasize = results2.LengthOfColumn(2);
dbpc = (Convert::DBPlayerCorpse_Struct_temp*)row2[2];
dbpc_c = (Convert::classic_db_temp::DBPlayerCorpse_Struct_temp*)row2[2];
if (dbpc == nullptr)
continue;
if (dbpc_c == nullptr)
continue;
/* SoF+ */
uint32 esize1 = (sizeof(Convert::DBPlayerCorpse_Struct_temp) + (dbpc->itemcount * sizeof(Convert::player_lootitem_temp::ServerLootItem_Struct_temp)));
uint32 esize2 = (sizeof(Convert::classic_db_temp::DBPlayerCorpse_Struct_temp) + (dbpc_c->itemcount * sizeof(Convert::player_lootitem_temp::ServerLootItem_Struct_temp)));
/* SoF */
if (in_datasize == esize1) {
is_sof = true;
c_type = "SOF";
}
/* Classic */
if (in_datasize == esize2) {
is_sof = false;
c_type = "Legacy";
}
if (in_datasize != esize2 && in_datasize != esize1) {
// std::cout << "[Error] in Corpse Size - OLD SIZE: " << esize1 << " SOF SIZE: " << esize2 << " db_blob_datasize: " << in_datasize << std::endl;
is_sof = false;
c_type = "NULL";
continue;
}
std::cout << "Converting Corpse: [OK] [" << c_type << "]: " << "ID: " << atoi(row2[0]) << std::endl;
if (is_sof){
scquery = StringFormat("UPDATE `character_corpses` SET \n"
"`is_locked` = %d,\n"
"`exp` = %u,\n"
"`size` = %f,\n"
"`level` = %u,\n"
"`race` = %u,\n"
"`gender` = %u,\n"
"`class` = %u,\n"
"`deity` = %u,\n"
"`texture` = %u,\n"
"`helm_texture` = %u,\n"
"`copper` = %u,\n"
"`silver` = %u,\n"
"`gold` = %u,\n"
"`platinum` = %u,\n"
"`hair_color` = %u,\n"
"`beard_color` = %u,\n"
"`eye_color_1` = %u,\n"
"`eye_color_2` = %u,\n"
"`hair_style` = %u,\n"
"`face` = %u,\n"
"`beard` = %u,\n"
"`drakkin_heritage` = %u,\n"
"`drakkin_tattoo` = %u,\n"
"`drakkin_details` = %u,\n"
"`wc_1` = %u,\n"
"`wc_2` = %u,\n"
"`wc_3` = %u,\n"
"`wc_4` = %u,\n"
"`wc_5` = %u,\n"
"`wc_6` = %u,\n"
"`wc_7` = %u,\n"
"`wc_8` = %u,\n"
"`wc_9` = %u \n"
"WHERE `id` = %u \n",
dbpc->locked,
dbpc->exp,
dbpc->size,
dbpc->level,
dbpc->race,
dbpc->gender,
dbpc->class_,
dbpc->deity,
dbpc->texture,
dbpc->helmtexture,
dbpc->copper,
dbpc->silver,
dbpc->gold,
dbpc->plat,
dbpc->haircolor,
dbpc->beardcolor,
dbpc->eyecolor1,
dbpc->eyecolor2,
dbpc->hairstyle,
dbpc->face,
dbpc->beard,
dbpc->drakkin_heritage,
dbpc->drakkin_tattoo,
dbpc->drakkin_details,
dbpc->item_tint[0].color,
dbpc->item_tint[1].color,
dbpc->item_tint[2].color,
dbpc->item_tint[3].color,
dbpc->item_tint[4].color,
dbpc->item_tint[5].color,
dbpc->item_tint[6].color,
dbpc->item_tint[7].color,
dbpc->item_tint[8].color,
atoi(row2[0])
);
if (scquery != ""){ auto sc_results = QueryDatabase(scquery); }
first_entry = 0;
scquery = "";
/* Print Items */
for (unsigned int i = 0; i < dbpc->itemcount; i++) {
if (first_entry != 1){
scquery = 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"
" VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
atoi(row2[0]),
dbpc->items[i].equipSlot,
dbpc->items[i].item_id,
dbpc->items[i].charges,
dbpc->items[i].aug1,
dbpc->items[i].aug2,
dbpc->items[i].aug3,
dbpc->items[i].aug4,
dbpc->items[i].aug5
);
first_entry = 1;
}
else{
scquery = scquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
atoi(row2[0]),
dbpc->items[i].equipSlot,
dbpc->items[i].item_id,
dbpc->items[i].charges,
dbpc->items[i].aug1,
dbpc->items[i].aug2,
dbpc->items[i].aug3,
dbpc->items[i].aug4,
dbpc->items[i].aug5
);
}
}
if (scquery != ""){ auto sc_results = QueryDatabase(scquery); }
}
else{
/* Classic Converter */
scquery = StringFormat("UPDATE `character_corpses` SET \n"
"`is_locked` = %d,\n"
"`exp` = %u,\n"
"`size` = %f,\n"
"`level` = %u,\n"
"`race` = %u,\n"
"`gender` = %u,\n"
"`class` = %u,\n"
"`deity` = %u,\n"
"`texture` = %u,\n"
"`helm_texture` = %u,\n"
"`copper` = %u,\n"
"`silver` = %u,\n"
"`gold` = %u,\n"
"`platinum` = %u,\n"
"`hair_color` = %u,\n"
"`beard_color` = %u,\n"
"`eye_color_1` = %u,\n"
"`eye_color_2` = %u,\n"
"`hair_style` = %u,\n"
"`face` = %u,\n"
"`beard` = %u,\n"
"`wc_1` = %u,\n"
"`wc_2` = %u,\n"
"`wc_3` = %u,\n"
"`wc_4` = %u,\n"
"`wc_5` = %u,\n"
"`wc_6` = %u,\n"
"`wc_7` = %u,\n"
"`wc_8` = %u,\n"
"`wc_9` = %u \n"
"WHERE `id` = %u \n",
dbpc_c->locked,
dbpc_c->exp,
dbpc_c->size,
dbpc_c->level,
dbpc_c->race,
dbpc_c->gender,
dbpc_c->class_,
dbpc_c->deity,
dbpc_c->texture,
dbpc_c->helmtexture,
dbpc_c->copper,
dbpc_c->silver,
dbpc_c->gold,
dbpc_c->plat,
dbpc_c->haircolor,
dbpc_c->beardcolor,
dbpc_c->eyecolor1,
dbpc_c->eyecolor2,
dbpc_c->hairstyle,
dbpc_c->face,
dbpc_c->beard,
dbpc_c->item_tint[0].color,
dbpc_c->item_tint[1].color,
dbpc_c->item_tint[2].color,
dbpc_c->item_tint[3].color,
dbpc_c->item_tint[4].color,
dbpc_c->item_tint[5].color,
dbpc_c->item_tint[6].color,
dbpc_c->item_tint[7].color,
dbpc_c->item_tint[8].color,
atoi(row2[0])
);
if (scquery != ""){ auto sc_results = QueryDatabase(scquery); }
first_entry = 0;
scquery = "";
/* Print Items */
for (unsigned int i = 0; i < dbpc_c->itemcount; i++) {
if (first_entry != 1){
scquery = 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"
" VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
atoi(row2[0]),
dbpc_c->items[i].equipSlot,
dbpc_c->items[i].item_id,
dbpc_c->items[i].charges,
dbpc_c->items[i].aug1,
dbpc_c->items[i].aug2,
dbpc_c->items[i].aug3,
dbpc_c->items[i].aug4,
dbpc_c->items[i].aug5
);
first_entry = 1;
}
else{
scquery = scquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
atoi(row2[0]),
dbpc_c->items[i].equipSlot,
dbpc_c->items[i].item_id,
dbpc_c->items[i].charges,
dbpc_c->items[i].aug1,
dbpc_c->items[i].aug2,
dbpc_c->items[i].aug3,
dbpc_c->items[i].aug4,
dbpc_c->items[i].aug5
);
}
}
if (scquery != ""){ auto sc_results = QueryDatabase(scquery); }
}
}
}
QueryDatabase(StringFormat("ALTER TABLE `character_corpses` DROP COLUMN `data`"));
}
return true; return true;
} }
@ -3641,9 +3947,7 @@ bool Database::RemoveClientsFromInstance(uint16 instance_id)
return results.Success(); return results.Success();
} }
bool Database::CheckInstanceExists(uint16 instance_id) bool Database::CheckInstanceExists(uint16 instance_id) {
{
std::string query = StringFormat("SELECT * FROM instance_list where id=%u", instance_id); std::string query = StringFormat("SELECT * FROM instance_list where id=%u", instance_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
@ -3656,15 +3960,12 @@ bool Database::CheckInstanceExists(uint16 instance_id)
return true; return true;
} }
void Database::BuryCorpsesInInstance(uint16 instance_id) void Database::BuryCorpsesInInstance(uint16 instance_id) {
{ std::string query = StringFormat("UPDATE `character_corpses` SET `is_buried` = 1, `instance_id` =0 WHERE `instance_id` = %u", instance_id);
std::string query = StringFormat("UPDATE player_corpses SET IsBurried=1, instanceid=0 WHERE instanceid=%u", instance_id);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
} }
uint16 Database::GetInstanceVersion(uint16 instance_id) uint16 Database::GetInstanceVersion(uint16 instance_id) {
{
if(instance_id == 0) if(instance_id == 0)
return 0; return 0;
@ -3681,8 +3982,7 @@ uint16 Database::GetInstanceVersion(uint16 instance_id)
return atoi(row[0]); return atoi(row[0]);
} }
uint16 Database::GetInstanceID(const char* zone, uint32 charid, int16 version) uint16 Database::GetInstanceID(const char* zone, uint32 charid, int16 version) {
{
std::string query = StringFormat("SELECT instance_list.id FROM instance_list, instance_list_player " std::string query = StringFormat("SELECT instance_list.id FROM instance_list, instance_list_player "
"WHERE instance_list.zone=%u AND instance_list.version=%u AND instance_list.id=instance_list_player.id AND " "WHERE instance_list.zone=%u AND instance_list.version=%u AND instance_list.id=instance_list_player.id AND "

View File

@ -93,13 +93,417 @@ struct ExtendedProfile_Struct;
struct GuildMember_Struct; struct GuildMember_Struct;
class PTimerList; class PTimerList;
#pragma pack(1)
/* Conversion Structs */
namespace Convert {
struct BindStruct {
/*000*/ uint32 zoneId;
/*004*/ float x;
/*008*/ float y;
/*012*/ float z;
/*016*/ float heading;
};
struct Color_Struct
{
union
{
struct
{
uint8 blue;
uint8 green;
uint8 red;
uint8 use_tint; // if there's a tint this is FF
} rgb;
uint32 color;
};
};
struct AA_Array
{
uint32 AA;
uint32 value;
};
struct SpellBuff_Struct
{
/*000*/ uint8 slotid; //badly named... seems to be 2 for a real buff, 0 otherwise
/*001*/ uint8 level;
/*002*/ uint8 bard_modifier;
/*003*/ uint8 effect; //not real
/*004*/ uint32 spellid;
/*008*/ uint32 duration;
/*012*/ uint32 counters;
/*016*/ uint32 player_id; //'global' ID of the caster, for wearoff messages
/*020*/
};
struct Tribute_Struct {
uint32 tribute;
uint32 tier;
};
struct Disciplines_Struct {
uint32 values[MAX_PP_DISCIPLINES];
};
struct GroupLeadershipAA_Struct {
union {
struct {
uint32 groupAAMarkNPC;
uint32 groupAANPCHealth;
uint32 groupAADelegateMainAssist;
uint32 groupAADelegateMarkNPC;
uint32 groupAA4;
uint32 groupAA5;
uint32 groupAAInspectBuffs;
uint32 groupAA7;
uint32 groupAASpellAwareness;
uint32 groupAAOffenseEnhancement;
uint32 groupAAManaEnhancement;
uint32 groupAAHealthEnhancement;
uint32 groupAAHealthRegeneration;
uint32 groupAAFindPathToPC;
uint32 groupAAHealthOfTargetsTarget;
uint32 groupAA15;
};
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
};
};
struct RaidLeadershipAA_Struct {
union {
struct {
uint32 raidAAMarkNPC;
uint32 raidAANPCHealth;
uint32 raidAADelegateMainAssist;
uint32 raidAADelegateMarkNPC;
uint32 raidAA4;
uint32 raidAA5;
uint32 raidAA6;
uint32 raidAASpellAwareness;
uint32 raidAAOffenseEnhancement;
uint32 raidAAManaEnhancement;
uint32 raidAAHealthEnhancement;
uint32 raidAAHealthRegeneration;
uint32 raidAAFindPathToPC;
uint32 raidAAHealthOfTargetsTarget;
uint32 raidAA14;
uint32 raidAA15;
};
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
};
};
struct LeadershipAA_Struct {
union {
struct {
Convert::GroupLeadershipAA_Struct group;
Convert::RaidLeadershipAA_Struct raid;
};
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
};
typedef struct
{
/*00*/ char Name[64];
/*64*/ uint32 Level;
/*68*/ uint32 Race;
/*72*/ uint32 Class;
/*76*/ uint32 Zone;
/*80*/ uint32 Time;
/*84*/ uint32 Points;
/*88*/
} PVPStatsEntry_Struct;
struct BandolierItem_Struct {
uint32 item_id;
uint32 icon;
char item_name[64];
};
struct Bandolier_Struct {
char name[32];
Convert::BandolierItem_Struct items[EmuConstants::BANDOLIER_SIZE];
};
struct PotionBelt_Struct {
Convert::BandolierItem_Struct items[EmuConstants::POTION_BELT_SIZE];
};
struct SuspendedMinion_Struct
{
/*000*/ uint16 SpellID;
/*002*/ uint32 HP;
/*006*/ uint32 Mana;
/*010*/ Convert::SpellBuff_Struct Buffs[BUFF_COUNT];
/*510*/ uint32 Items[_MaterialCount];
/*546*/ char Name[64];
/*610*/
};
struct PlayerProfile_Struct {
/*0000*/ uint32 checksum; // Checksum from CRC32::SetEQChecksum
/*0004*/ char name[64]; // Name of player sizes not right
/*0068*/ char last_name[32]; // Last name of player sizes not right
/*0100*/ uint32 gender; // Player Gender - 0 Male, 1 Female
/*0104*/ uint32 race; // Player race
/*0108*/ uint32 class_; // Player class
/*0112*/ uint32 unknown0112; //
/*0116*/ uint32 level; // Level of player (might be one byte)
/*0120*/ Convert::BindStruct binds[5]; // Bind points (primary is first, home city is fifth)
/*0220*/ uint32 deity; // deity
/*0224*/ uint32 guild_id;
/*0228*/ uint32 birthday; // characters bday
/*0232*/ uint32 lastlogin; // last login or zone time
/*0236*/ uint32 timePlayedMin; // in minutes
/*0240*/ uint8 pvp;
/*0241*/ uint8 level2; //no idea why this is here, but thats how it is on live
/*0242*/ uint8 anon; // 2=roleplay, 1=anon, 0=not anon
/*0243*/ uint8 gm;
/*0244*/ uint8 guildrank;
/*0245*/ uint8 guildbanker;
/*0246*/ uint8 unknown0246[6]; //
/*0252*/ uint32 intoxication;
/*0256*/ uint32 spellSlotRefresh[MAX_PP_REF_MEMSPELL]; //in ms
/*0292*/ uint32 abilitySlotRefresh;
/*0296*/ uint8 haircolor; // Player hair color
/*0297*/ uint8 beardcolor; // Player beard color
/*0298*/ uint8 eyecolor1; // Player left eye color
/*0299*/ uint8 eyecolor2; // Player right eye color
/*0300*/ uint8 hairstyle; // Player hair style
/*0301*/ uint8 beard; // Beard type
/*0302*/ uint8 ability_time_seconds; //The following four spots are unknown right now.....
/*0303*/ uint8 ability_number; //ability used
/*0304*/ uint8 ability_time_minutes;
/*0305*/ uint8 ability_time_hours; //place holder
/*0306*/ uint8 unknown0306[6]; // @bp Spacer/Flag?
/*0312*/ uint32 item_material[_MaterialCount]; // Item texture/material of worn/held items
/*0348*/ uint8 unknown0348[44];
/*0392*/ Convert::Color_Struct item_tint[_MaterialCount];
/*0428*/ Convert::AA_Array aa_array[MAX_PP_AA_ARRAY];
/*2348*/ float unknown2384; //seen ~128, ~47
/*2352*/ char servername[32]; // length probably not right
/*2384*/ char title[32]; // length might be wrong
/*2416*/ char suffix[32]; // length might be wrong
/*2448*/ uint32 guildid2; //
/*2452*/ uint32 exp; // Current Experience
/*2456*/ uint32 unknown2492;
/*2460*/ uint32 points; // Unspent Practice points
/*2464*/ uint32 mana; // current mana
/*2468*/ uint32 cur_hp; // current hp
/*2472*/ uint32 unknown2508; // 0x05
/*2476*/ uint32 STR; // Strength
/*2480*/ uint32 STA; // Stamina
/*2484*/ uint32 CHA; // Charisma
/*2488*/ uint32 DEX; // Dexterity
/*2492*/ uint32 INT; // Intelligence
/*2496*/ uint32 AGI; // Agility
/*2500*/ uint32 WIS; // Wisdom
/*2504*/ uint8 face; // Player face
/*2505*/ uint8 unknown2541[47]; // ?
/*2552*/ uint8 languages[MAX_PP_LANGUAGE];
/*2580*/ uint8 unknown2616[4];
/*2584*/ uint32 spell_book[MAX_PP_REF_SPELLBOOK];
/*4504*/ uint8 unknown4540[128]; // Was [428] all 0xff
/*4632*/ uint32 mem_spells[MAX_PP_REF_MEMSPELL];
/*4668*/ uint8 unknown4704[32]; //
/*4700*/ float y; // Player y position
/*4704*/ float x; // Player x position
/*4708*/ float z; // Player z position
/*4712*/ float heading; // Direction player is facing
/*4716*/ uint8 unknown4752[4]; //
/*4720*/ int32 platinum; // Platinum Pieces on player
/*4724*/ int32 gold; // Gold Pieces on player
/*4728*/ int32 silver; // Silver Pieces on player
/*4732*/ int32 copper; // Copper Pieces on player
/*4736*/ int32 platinum_bank; // Platinum Pieces in Bank
/*4740*/ int32 gold_bank; // Gold Pieces in Bank
/*4744*/ int32 silver_bank; // Silver Pieces in Bank
/*4748*/ int32 copper_bank; // Copper Pieces in Bank
/*4752*/ int32 platinum_cursor; // Platinum on cursor
/*4756*/ int32 gold_cursor; // Gold on cursor
/*4760*/ int32 silver_cursor; // Silver on cursor
/*4764*/ int32 copper_cursor; // Copper on cursor
/*4768*/ int32 platinum_shared; // Platinum shared between characters
/*4772*/ uint8 unknown4808[24];
/*4796*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer
/*5196*/ uint8 unknown5132[184];
/*5380*/ uint32 pvp2; //
/*5384*/ uint32 unknown5420; //
/*5388*/ uint32 pvptype; //
/*5392*/ uint32 unknown5428; //
/*5396*/ uint32 ability_down; // Guessing
/*5400*/ uint8 unknown5436[8]; //
/*5408*/ uint32 autosplit; //not used right now
/*5412*/ uint8 unknown5448[8];
/*5420*/ uint32 zone_change_count; // Number of times user has zoned in their career (guessing)
/*5424*/ uint8 unknown5460[16]; //
/*5440*/ uint32 drakkin_heritage; //
/*5444*/ uint32 drakkin_tattoo; //
/*5448*/ uint32 drakkin_details; //
/*5452*/ uint32 expansions; // expansion setting, bit field of expansions avaliable
/*5456*/ int32 toxicity; //from drinking potions, seems to increase by 3 each time you drink
/*5460*/ char unknown5496[16]; //
/*5476*/ int32 hunger_level;
/*5480*/ int32 thirst_level;
/*5484*/ uint32 ability_up;
/*5488*/ char unknown5524[16];
/*5504*/ uint16 zone_id; // Current zone of the player
/*5506*/ uint16 zoneInstance; // Instance ID
/*5508*/ Convert::SpellBuff_Struct buffs[BUFF_COUNT]; // Buffs currently on the player
/*6008*/ char groupMembers[6][64];//
/*6392*/ char unknown6428[656];
/*7048*/ uint32 entityid;
/*7052*/ uint32 leadAAActive;
/*7056*/ uint32 unknown7092;
/*7060*/ int32 ldon_points_guk; //client uses these as signed
/*7064*/ int32 ldon_points_mir;
/*7068*/ int32 ldon_points_mmc;
/*7072*/ int32 ldon_points_ruj;
/*7076*/ int32 ldon_points_tak;
/*7080*/ int32 ldon_points_available;
/*7084*/ int32 ldon_wins_guk;
/*7088*/ int32 ldon_wins_mir;
/*7092*/ int32 ldon_wins_mmc;
/*7096*/ int32 ldon_wins_ruj;
/*7100*/ int32 ldon_wins_tak;
/*7104*/ int32 ldon_losses_guk;
/*7108*/ int32 ldon_losses_mir;
/*7112*/ int32 ldon_losses_mmc;
/*7116*/ int32 ldon_losses_ruj;
/*7120*/ int32 ldon_losses_tak;
/*7124*/ uint8 unknown7160[72];
/*7196*/ uint32 tribute_time_remaining; //in miliseconds
/*7200*/ uint32 showhelm;
/*7204*/ uint32 career_tribute_points;
/*7208*/ uint32 unknown7244;
/*7212*/ uint32 tribute_points;
/*7216*/ uint32 unknown7252;
/*7220*/ uint32 tribute_active; //1=active
/*7224*/ Convert::Tribute_Struct tributes[EmuConstants::TRIBUTE_SIZE];
/*7264*/ Convert::Disciplines_Struct disciplines;
/*7664*/ uint32 recastTimers[MAX_RECAST_TYPES]; // Timers (GMT of last use)
/*7744*/ char unknown7780[160];
/*7904*/ uint32 endurance;
/*7908*/ uint32 group_leadership_exp; //0-1000
/*7912*/ uint32 raid_leadership_exp; //0-2000
/*7916*/ uint32 group_leadership_points;
/*7920*/ uint32 raid_leadership_points;
/*7924*/ Convert::LeadershipAA_Struct leader_abilities;
/*8052*/ uint8 unknown8088[132];
/*8184*/ uint32 air_remaining;
/*8188*/ uint32 PVPKills;
/*8192*/ uint32 PVPDeaths;
/*8196*/ uint32 PVPCurrentPoints;
/*8200*/ uint32 PVPCareerPoints;
/*8204*/ uint32 PVPBestKillStreak;
/*8208*/ uint32 PVPWorstDeathStreak;
/*8212*/ uint32 PVPCurrentKillStreak;
/*8216*/ Convert::PVPStatsEntry_Struct PVPLastKill;
/*8304*/ Convert::PVPStatsEntry_Struct PVPLastDeath;
/*8392*/ uint32 PVPNumberOfKillsInLast24Hours;
/*8396*/ Convert::PVPStatsEntry_Struct PVPRecentKills[50];
/*12796*/ uint32 aapoints_spent;
/*12800*/ uint32 expAA;
/*12804*/ uint32 aapoints; //avaliable, unspent
/*12808*/ uint8 unknown12844[36];
/*12844*/ Convert::Bandolier_Struct bandoliers[EmuConstants::BANDOLIERS_COUNT];
/*14124*/ uint8 unknown14160[4506];
/*18630*/ Convert::SuspendedMinion_Struct SuspendedMinion; // No longer in use
/*19240*/ uint32 timeentitledonaccount;
/*19244*/ Convert::PotionBelt_Struct potionbelt; //there should be 3 more of these
/*19532*/ uint8 unknown19568[8];
/*19540*/ uint32 currentRadCrystals; // Current count of radiant crystals
/*19544*/ uint32 careerRadCrystals; // Total count of radiant crystals ever
/*19548*/ uint32 currentEbonCrystals;// Current count of ebon crystals
/*19552*/ uint32 careerEbonCrystals; // Total count of ebon crystals ever
/*19556*/ uint8 groupAutoconsent; // 0=off, 1=on
/*19557*/ uint8 raidAutoconsent; // 0=off, 1=on
/*19558*/ uint8 guildAutoconsent; // 0=off, 1=on
/*19559*/ uint8 unknown19595[5]; // ***Placeholder (6/29/2005)
/*19564*/ uint32 RestTimer;
/*19568*/
};
namespace player_lootitem_temp
{
struct ServerLootItem_Struct_temp {
uint32 item_id;
int16 equipSlot;
uint8 charges;
uint16 lootslot;
uint32 aug1;
uint32 aug2;
uint32 aug3;
uint32 aug4;
uint32 aug5;
};
}
struct DBPlayerCorpse_Struct_temp {
uint32 crc;
bool locked;
uint32 itemcount;
uint32 exp;
float size;
uint8 level;
uint8 race;
uint8 gender;
uint8 class_;
uint8 deity;
uint8 texture;
uint8 helmtexture;
uint32 copper;
uint32 silver;
uint32 gold;
uint32 plat;
Color_Struct item_tint[9];
uint8 haircolor;
uint8 beardcolor;
uint8 eyecolor1;
uint8 eyecolor2;
uint8 hairstyle;
uint8 face;
uint8 beard;
uint32 drakkin_heritage;
uint32 drakkin_tattoo;
uint32 drakkin_details;
player_lootitem_temp::ServerLootItem_Struct_temp items[0];
};
namespace classic_db_temp {
struct DBPlayerCorpse_Struct_temp {
uint32 crc;
bool locked;
uint32 itemcount;
uint32 exp;
float size;
uint8 level;
uint8 race;
uint8 gender;
uint8 class_;
uint8 deity;
uint8 texture;
uint8 helmtexture;
uint32 copper;
uint32 silver;
uint32 gold;
uint32 plat;
Color_Struct item_tint[9];
uint8 haircolor;
uint8 beardcolor;
uint8 eyecolor1;
uint8 eyecolor2;
uint8 hairstyle;
uint8 face;
uint8 beard;
player_lootitem_temp::ServerLootItem_Struct_temp items[0];
};
}
}
#pragma pack()
class Database : public DBcore { class Database : public DBcore {
public: public:
Database(); Database();
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port); Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port); bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
~Database(); ~Database();
bool ThrowDBError(std::string ErrorMessage, std::string query_title, std::string query);
/* /*
@ -221,7 +625,11 @@ public:
void SetRaidGroupLeaderInfo(uint32 gid, uint32 rid); void SetRaidGroupLeaderInfo(uint32 gid, uint32 rid);
void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0); void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0);
/* Database Conversions*/
bool CheckDatabaseConversions(); bool CheckDatabaseConversions();
bool CheckDatabaseConvertPPDeblob();
bool CheckDatabaseConvertCorpseDeblob();
bool CheckDatabaseConvertBotsPostPPDeblob();
/* /*
* Database Variables * Database Variables

View File

@ -4,6 +4,7 @@
#include <winsock2.h> #include <winsock2.h>
#endif #endif
#include <fstream>
#include <iostream> #include <iostream>
#include <errmsg.h> #include <errmsg.h>
#include <mysqld_error.h> #include <mysqld_error.h>
@ -113,6 +114,16 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
#ifdef _EQDEBUG #ifdef _EQDEBUG
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl; std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
#endif #endif
/* Implement Logging at the Root */
if (mysql_errno(&mysql) > 0 && strlen(query) > 0){
std::cout << "\n[MYSQL ERR] " << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << " [Query]: \n" << query << "\n" << std::endl;
/* Write to log file */
std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out);
log << "[MYSQL ERR] " << mysql_error(&mysql) << "\n" << query << "\n";
log.close();
}
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer); return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer);
} }
@ -126,7 +137,6 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql)); MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql));
#if DEBUG_MYSQL_QUERIES >= 1 #if DEBUG_MYSQL_QUERIES >= 1
if (requestResult.Success()) if (requestResult.Success())
{ {
@ -145,95 +155,6 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
return requestResult; return requestResult;
} }
bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
if (errnum)
*errnum = 0;
if (errbuf)
errbuf[0] = 0;
bool ret = false;
LockMutex lock(&MDatabase);
if (pStatus != Connected)
Open();
if (mysql_real_query(&mysql, query, querylen)) {
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
pStatus = Error;
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
if (retry) {
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
if (ret)
std::cout << "Reconnection to database successful." << std::endl;
}
else {
pStatus = Error;
if (errnum)
*errnum = mysql_errno(&mysql);
if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
ret = false;
}
}
else {
if (errnum)
*errnum = mysql_errno(&mysql);
if (errbuf)
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
#ifdef _EQDEBUG
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
#endif
ret = false;
}
}
else {
if (result && mysql_field_count(&mysql)) {
*result = mysql_store_result(&mysql);
#ifdef _EQDEBUG
DBMemLeak::Alloc(*result, query);
#endif
}
else if (result)
*result = 0;
if (affected_rows)
*affected_rows = mysql_affected_rows(&mysql);
if (last_insert_id)
*last_insert_id = (uint32)mysql_insert_id(&mysql);
if (result) {
if (*result) {
ret = true;
}
else {
#ifdef _EQDEBUG
std::cout << "DB Query Error: No Result" << std::endl;
#endif
if (errnum)
*errnum = UINT_MAX;
if (errbuf)
strcpy(errbuf, "DBcore::RunQuery: No Result");
ret = false;
}
}
else {
ret = true;
}
}
#if DEBUG_MYSQL_QUERIES >= 1
if (ret) {
std::cout << "query successful";
if (result && (*result))
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
if (affected_rows)
std::cout << ", " << (*affected_rows) << " rows affected";
std::cout<< std::endl;
}
else {
std::cout << "QUERY: query FAILED" << std::endl;
}
#endif
return ret;
}
void DBcore::TransactionBegin() { void DBcore::TransactionBegin() {
QueryDatabase("START TRANSACTION"); QueryDatabase("START TRANSACTION");
} }

View File

@ -23,7 +23,6 @@ public:
DBcore(); DBcore();
~DBcore(); ~DBcore();
eStatus GetStatus() { return pStatus; } eStatus GetStatus() { return pStatus; }
bool RunQuery(const char* query, uint32 querylen, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0, bool retry = true);
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true); MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true); MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
void TransactionBegin(); void TransactionBegin();

View File

@ -5209,17 +5209,17 @@ struct MercenaryMerchantResponse_Struct {
}; };
struct ServerLootItem_Struct { struct ServerLootItem_Struct {
uint32 item_id; uint32 item_id; // uint32 item_id;
int16 equipSlot; int16 equip_slot; // int16 equip_slot;
uint8 charges; uint16 charges; // uint8 charges;
uint16 lootslot; uint16 lootslot; // uint16 lootslot;
uint32 aug1; uint32 aug_1; // uint32 aug_1;
uint32 aug2; uint32 aug_2; // uint32 aug_2;
uint32 aug3; uint32 aug_3; // uint32 aug_3;
uint32 aug4; uint32 aug_4; // uint32 aug_4;
uint32 aug5; uint32 aug_5; // uint32 aug_5;
uint8 minlevel; uint8 min_level; //
uint8 maxlevel; uint8 max_level; //
}; };
//Found in client near a ref to the string: //Found in client near a ref to the string:

View File

@ -1215,10 +1215,10 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges)
} }
int32 SharedDatabase::DeleteStalePlayerCorpses() { int32 SharedDatabase::DeleteStalePlayerCorpses() {
if(RuleB(Zone, EnableShadowrest)) if(RuleB(Zone, EnableShadowrest)) {
{ std::string query = StringFormat(
std::string query = StringFormat("UPDATE player_corpses SET IsBurried = 1 WHERE IsBurried = 0 AND " "UPDATE `character_corpses` SET `is_buried` = 1 WHERE `is_buried` = 0 AND "
"(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > %d AND NOT timeofdeath = 0", "(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d AND NOT time_of_death = 0",
(RuleI(Character, CorpseDecayTimeMS) / 1000)); (RuleI(Character, CorpseDecayTimeMS) / 1000));
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
@ -1227,18 +1227,9 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
return results.RowsAffected(); return results.RowsAffected();
} }
std::string query = StringFormat("DELETE FROM player_corpses WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > %d " std::string query = StringFormat(
"AND NOT timeofdeath = 0", (RuleI(Character, CorpseDecayTimeMS) / 1000)); "DELETE FROM `character_corpses` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d "
auto results = QueryDatabase(query); "AND NOT time_of_death = 0", (RuleI(Character, CorpseDecayTimeMS) / 1000));
if (!results.Success())
return -1;
return results.RowsAffected();
}
int32 SharedDatabase::DeleteStalePlayerBackups() {
// 1209600 seconds = 2 weeks
const std::string query = "DELETE FROM player_corpses_backup WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > 1209600";
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if (!results.Success()) if (!results.Success())
return -1; return -1;
@ -1915,7 +1906,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message) { void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message) {
std::string query = StringFormat("SELECT `inspect_message` FROM `character_inspect_messages` WHERE `id` = %u LIMIT 1", character_id); std::string query = StringFormat("SELECT `inspect_message` FROM `character_inspect_messages` WHERE `id` = %u LIMIT 1", character_id);
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::LoadCharacterInspectMessage", query); auto results = QueryDatabase(query);
auto row = results.begin(); auto row = results.begin();
memcpy(message, "", sizeof(InspectMessage_Struct)); memcpy(message, "", sizeof(InspectMessage_Struct));
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
@ -1925,7 +1916,7 @@ void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMes
void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message) { void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message) {
std::string query = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message) VALUES (%u, '%s')", character_id, EscapeString(message->text).c_str()); std::string query = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message) VALUES (%u, '%s')", character_id, EscapeString(message->text).c_str());
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::SaveCharacterInspectMessage", query); auto results = QueryDatabase(query);
} }
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) { void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {

View File

@ -41,7 +41,6 @@ public:
uint8 GetGMSpeed(uint32 account_id); uint8 GetGMSpeed(uint32 account_id);
bool SetHideMe(uint32 account_id, uint8 hideme); bool SetHideMe(uint32 account_id, uint8 hideme);
int32 DeleteStalePlayerCorpses(); int32 DeleteStalePlayerCorpses();
int32 DeleteStalePlayerBackups();
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message); void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message); void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message); void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);

View File

@ -0,0 +1 @@
INSERT INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (1, 'NPC:EnableMeritBasedFaction', 'false', 'If set to true, faction will given in the same way as experience (solo/group/raid).');

View File

@ -376,7 +376,7 @@ void Adventure::MoveCorpsesToGraveyard()
std::list<uint32> dbid_list; std::list<uint32> dbid_list;
std::list<uint32> charid_list; std::list<uint32> charid_list;
std::string query = StringFormat("SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID()); std::string query = StringFormat("SELECT id, charid FROM character_corpses WHERE instanceid=%d", GetInstanceID());
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
if(!results.Success()) if(!results.Success())
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), results.ErrorMessage().c_str());
@ -392,7 +392,7 @@ void Adventure::MoveCorpsesToGraveyard()
float y = GetTemplate()->graveyard_y + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); float y = GetTemplate()->graveyard_y + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float z = GetTemplate()->graveyard_z; float z = GetTemplate()->graveyard_z;
query = StringFormat("UPDATE player_corpses " query = StringFormat("UPDATE character_corpses "
"SET zoneid = %d, instanceid = 0, " "SET zoneid = %d, instanceid = 0, "
"x = %f, y = %f, z = %f WHERE instanceid = %d", "x = %f, y = %f, z = %f WHERE instanceid = %d",
GetTemplate()->graveyard_zone_id, GetTemplate()->graveyard_zone_id,

View File

@ -336,9 +336,6 @@ int main(int argc, char** argv) {
_log(WORLD__INIT, "Reboot zone modes %s",holdzones ? "ON" : "OFF"); _log(WORLD__INIT, "Reboot zone modes %s",holdzones ? "ON" : "OFF");
_log(WORLD__INIT, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses()); _log(WORLD__INIT, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses());
if (RuleB(World, DeleteStaleCorpeBackups) == true) {
_log(WORLD__INIT, "Deleted %i stale player backups from database", database.DeleteStalePlayerBackups());
}
_log(WORLD__INIT, "Loading adventures..."); _log(WORLD__INIT, "Loading adventures...");
if(!adventure_manager.LoadAdventureTemplates()) if(!adventure_manager.LoadAdventureTemplates())

View File

@ -142,14 +142,14 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
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)", " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)",
character_id, pp.binds[4].zoneId, 0, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z, pp.binds[4].heading, 1); character_id, pp.binds[4].zoneId, 0, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z, pp.binds[4].heading, 1);
auto results_bset = QueryDatabase(query); ThrowDBError(results_bset.ErrorMessage(), "WorldDatabase::GetCharSelectInfo Set Home Point", query); auto results_bset = QueryDatabase(query);
} }
/* If no regular bind set, set it */ /* If no regular bind set, set it */
if (has_bind == 0){ if (has_bind == 0){
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)", " VALUES (%u, %u, %u, %f, %f, %f, %f, %i)",
character_id, pp.binds[0].zoneId, 0, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z, pp.binds[0].heading, 0); character_id, pp.binds[0].zoneId, 0, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z, pp.binds[0].heading, 0);
auto results_bset = QueryDatabase(query); ThrowDBError(results_bset.ErrorMessage(), "WorldDatabase::GetCharSelectInfo Set Bind Point", query); auto results_bset = QueryDatabase(query);
} }
} }
/* Bind End */ /* Bind End */

View File

@ -2582,38 +2582,6 @@ void Client::LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32
} }
} }
void Client::LogLoot(Client* player, Corpse* corpse, const Item_Struct* item){
char* logtext;
char itemid[100];
char itemname[100];
char coinloot[100];
if (item!=0){
memset(itemid,0,sizeof(itemid));
memset(itemname,0,sizeof(itemid));
itoa(item->ID,itemid,10);
sprintf(itemname,"%s",item->Name);
logtext=itemname;
strcat(logtext,"(");
strcat(logtext,itemid);
strcat(logtext,") Looted");
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),corpse->orgname,"Looting Item",logtext,4);
}
else{
if ((corpse->GetPlatinum() + corpse->GetGold() + corpse->GetSilver() + corpse->GetCopper())>0) {
memset(coinloot,0,sizeof(coinloot));
sprintf(coinloot,"%i PP %i GP %i SP %i CP",corpse->GetPlatinum(),corpse->GetGold(),corpse->GetSilver(),corpse->GetCopper());
logtext=coinloot;
strcat(logtext," Looted");
if (corpse->GetPlatinum()>10000)
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),corpse->orgname,"Excessive Loot!",logtext,9);
else
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),corpse->orgname,"Looting Money",logtext,5);
}
}
}
bool Client::BindWound(Mob* bindmob, bool start, bool fail){ bool Client::BindWound(Mob* bindmob, bool start, bool fail){
EQApplicationPacket* outapp = 0; EQApplicationPacket* outapp = 0;
if(!fail) { if(!fail) {
@ -4969,7 +4937,7 @@ void Client::SummonAndRezzAllCorpses()
entity_list.RemoveAllCorpsesByCharID(CharacterID()); entity_list.RemoveAllCorpsesByCharID(CharacterID());
int CorpseCount = database.SummonAllPlayerCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(),
GetX(), GetY(), GetZ(), GetHeading()); GetX(), GetY(), GetZ(), GetHeading());
if(CorpseCount <= 0) if(CorpseCount <= 0)
{ {
@ -5007,7 +4975,7 @@ void Client::SummonAllCorpses(float dest_x, float dest_y, float dest_z, float de
entity_list.RemoveAllCorpsesByCharID(CharacterID()); entity_list.RemoveAllCorpsesByCharID(CharacterID());
int CorpseCount = database.SummonAllPlayerCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(), int CorpseCount = database.SummonAllCharacterCorpses(CharacterID(), zone->GetZoneID(), zone->GetInstanceID(),
dest_x, dest_y, dest_z, dest_heading); dest_x, dest_y, dest_z, dest_heading);
if(CorpseCount <= 0) if(CorpseCount <= 0)
{ {
@ -5051,7 +5019,7 @@ void Client::DepopPlayerCorpse(uint32 dbid)
void Client::BuryPlayerCorpses() void Client::BuryPlayerCorpses()
{ {
database.BuryAllPlayerCorpses(CharacterID()); database.BuryAllCharacterCorpses(CharacterID());
} }
void Client::NotifyNewTitlesAvailable() void Client::NotifyNewTitlesAvailable()

View File

@ -335,7 +335,6 @@ public:
bool CheckAccess(int16 iDBLevel, int16 iDefaultLevel); bool CheckAccess(int16 iDBLevel, int16 iDefaultLevel);
void CheckQuests(const char* zonename, const char* message, uint32 npc_id, uint32 item_id, Mob* other); void CheckQuests(const char* zonename, const char* message, uint32 npc_id, uint32 item_id, Mob* other);
void LogLoot(Client* player,Corpse* corpse,const Item_Struct* item);
bool AutoAttackEnabled() const { return auto_attack; } bool AutoAttackEnabled() const { return auto_attack; }
bool AutoFireEnabled() const { return auto_fire; } bool AutoFireEnabled() const { return auto_fire; }
void MakeCorpse(uint32 exploss); void MakeCorpse(uint32 exploss);
@ -1031,9 +1030,9 @@ void SetConsumption(int32 in_hunger, int32 in_thirst);
void DepopAllCorpses(); void DepopAllCorpses();
void DepopPlayerCorpse(uint32 dbid); void DepopPlayerCorpse(uint32 dbid);
void BuryPlayerCorpses(); void BuryPlayerCorpses();
uint32 GetCorpseCount() { return database.GetPlayerCorpseCount(CharacterID()); } uint32 GetCorpseCount() { return database.GetCharacterCorpseCount(CharacterID()); }
uint32 GetCorpseID(int corpse) { return database.GetPlayerCorpseID(CharacterID(), corpse); } uint32 GetCorpseID(int corpse) { return database.GetCharacterCorpseID(CharacterID(), corpse); }
uint32 GetCorpseItemAt(int corpse_id, int slot_id) { return database.GetPlayerCorpseItemAt(corpse_id, slot_id); } uint32 GetCorpseItemAt(int corpse_id, int slot_id) { return database.GetCharacterCorpseItemAt(corpse_id, slot_id); }
void SuspendMinion(); void SuspendMinion();
void Doppelganger(uint16 spell_id, Mob *target, const char *name_override, int pet_count, int pet_duration); void Doppelganger(uint16 spell_id, Mob *target, const char *name_override, int pet_count, int pet_duration);
void NotifyNewTitlesAvailable(); void NotifyNewTitlesAvailable();

View File

@ -4827,7 +4827,7 @@ void Client::Handle_OP_ConsiderCorpse(const EQApplicationPacket *app)
else else
Message(0, "This corpse will decay in %i minutes and %i seconds.", min, sec); Message(0, "This corpse will decay in %i minutes and %i seconds.", min, sec);
Message(0, "This corpse %s be resurrected.", tcorpse->Rezzed() ? "cannot" : "can"); Message(0, "This corpse %s be resurrected.", tcorpse->IsRezzed() ? "cannot" : "can");
/* /*
hour = 0; hour = 0;
@ -6175,8 +6175,8 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
char *escSearchString = new char[129]; char *escSearchString = new char[129];
database.DoEscapeString(escSearchString, gmscs->Name, strlen(gmscs->Name)); database.DoEscapeString(escSearchString, gmscs->Name, strlen(gmscs->Name));
std::string query = StringFormat("SELECT charname, zoneid, x, y, z, timeofdeath, rezzed, IsBurried " std::string query = StringFormat("SELECT charname, zoneid, x, y, z, time_of_death, rezzed, IsBurried "
"FROM player_corpses WheRE charname LIKE '%%%s%%' ORDER BY charname LIMIT %i", "FROM character_corpses WheRE charname LIKE '%%%s%%' ORDER BY charname LIMIT %i",
escSearchString, maxResults); escSearchString, maxResults);
safe_delete_array(escSearchString); safe_delete_array(escSearchString);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
@ -6193,7 +6193,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
else else
Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", results.RowCount(), gmscs->Name); Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", results.RowCount(), gmscs->Name);
char charName[64], timeOfDeath[20]; char charName[64], time_of_death[20];
std::string popupText = "<table><tr><td>Name</td><td>Zone</td><td>X</td><td>Y</td><td>Z</td><td>Date</td><td>" std::string popupText = "<table><tr><td>Name</td><td>Zone</td><td>X</td><td>Y</td><td>Z</td><td>Date</td><td>"
"Rezzed</td><td>Buried</td></tr><tr><td>&nbsp</td><td></td><td></td><td></td><td></td><td>" "Rezzed</td><td>Buried</td></tr><tr><td>&nbsp</td><td></td><td></td><td></td><td></td><td>"
@ -6208,13 +6208,13 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
float CorpseY = atof(row[3]); float CorpseY = atof(row[3]);
float CorpseZ = atof(row[4]); float CorpseZ = atof(row[4]);
strn0cpy(timeOfDeath, row[5], sizeof(timeOfDeath)); strn0cpy(time_of_death, row[5], sizeof(time_of_death));
bool corpseRezzed = atoi(row[6]); bool corpseRezzed = atoi(row[6]);
bool corpseBuried = atoi(row[7]); bool corpseBuried = atoi(row[7]);
popupText += StringFormat("<tr><td>%s</td><td>%s</td><td>%8.0f</td><td>%8.0f</td><td>%8.0f</td><td>%s</td><td>%s</td><td>%s</td></tr>", popupText += StringFormat("<tr><td>%s</td><td>%s</td><td>%8.0f</td><td>%8.0f</td><td>%8.0f</td><td>%s</td><td>%s</td><td>%s</td></tr>",
charName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, timeOfDeath, charName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, time_of_death,
corpseRezzed ? "Yes" : "No", corpseBuried ? "Yes" : "No"); corpseRezzed ? "Yes" : "No", corpseBuried ? "Yes" : "No");
if (popupText.size() > 4000) { if (popupText.size() > 4000) {

View File

@ -2173,7 +2173,7 @@ void Client::HandleRespawnFromHover(uint32 Option)
_log(SPELLS__REZ, "Found corpse. Marking corpse as rezzed."); _log(SPELLS__REZ, "Found corpse. Marking corpse as rezzed.");
corpse->Rezzed(true); corpse->IsRezzed(true);
corpse->CompleteRezz(); corpse->CompleteRezz();
} }
} }

View File

@ -8456,7 +8456,7 @@ void command_setgraveyard(Client *c, const Seperator *sep)
zoneid = database.GetZoneID(sep->arg[1]); zoneid = database.GetZoneID(sep->arg[1]);
if(zoneid > 0) { if(zoneid > 0) {
graveyard_id = database.NewGraveyardRecord(zoneid, t->GetX(), t->GetY(), t->GetZ(), t->GetHeading()); graveyard_id = database.CreateGraveyardRecord(zoneid, t->GetX(), t->GetY(), t->GetZ(), t->GetHeading());
if(graveyard_id > 0) { if(graveyard_id > 0) {
c->Message(0, "Successfuly added a new record for this graveyard!"); c->Message(0, "Successfuly added a new record for this graveyard!");
@ -8519,7 +8519,7 @@ void command_summonburriedplayercorpse(Client *c, const Seperator *sep)
return; return;
} }
Corpse* PlayerCorpse = database.SummonBurriedPlayerCorpse(t->CharacterID(), t->GetZoneID(), zone->GetInstanceID(), t->GetX(), t->GetY(), t->GetZ(), t->GetHeading()); Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(t->CharacterID(), t->GetZoneID(), zone->GetInstanceID(), t->GetX(), t->GetY(), t->GetZ(), t->GetHeading());
if(!PlayerCorpse) if(!PlayerCorpse)
c->Message(0, "Your target doesn't have any burried corpses."); c->Message(0, "Your target doesn't have any burried corpses.");
@ -8538,7 +8538,7 @@ void command_getplayerburriedcorpsecount(Client *c, const Seperator *sep)
return; return;
} }
uint32 CorpseCount = database.GetPlayerBurriedCorpseCount(t->CharacterID()); uint32 CorpseCount = database.GetCharacterBuriedCorpseCount(t->CharacterID());
if(CorpseCount > 0) if(CorpseCount > 0)
c->Message(0, "Your target has a total of %u burried corpses.", CorpseCount); c->Message(0, "Your target has a total of %u burried corpses.", CorpseCount);

File diff suppressed because it is too large Load Diff

View File

@ -26,23 +26,23 @@ class NPC;
#define MAX_LOOTERS 72 #define MAX_LOOTERS 72
class Corpse : public Mob class Corpse : public Mob {
{
public: public:
static void SendEndLootErrorPacket(Client* client); static void SendEndLootErrorPacket(Client* client);
static void SendLootReqErrorPacket(Client* client, uint8 response = 2); static void SendLootReqErrorPacket(Client* client, uint8 response = 2);
static Corpse* LoadFromDBData(uint32 in_corpseid, uint32 in_charid, char* in_charname, uchar* in_data, uint32 in_datasize, float in_x, float in_y, float in_z, float in_heading, char* timeofdeath, bool rezzed = false, bool wasAtGraveyard = false);
Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000); Corpse(NPC* in_npc, ItemList* in_itemlist, uint32 in_npctypeid, const NPCType** in_npctypedata, uint32 in_decaytime = 600000);
Corpse(Client* client, int32 in_rezexp); Corpse(Client* client, int32 in_rezexp);
Corpse(uint32 in_corpseid, uint32 in_charid, char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture,uint32 in_rezexp, bool wasAtGraveyard = false); Corpse(uint32 in_corpseid, uint32 in_charid, const char* in_charname, ItemList* in_itemlist, uint32 in_copper, uint32 in_silver, uint32 in_gold, uint32 in_plat, float in_x, float in_y, float in_z, float in_heading, float in_size, uint8 in_gender, uint16 in_race, uint8 in_class, uint8 in_deity, uint8 in_level, uint8 in_texture, uint8 in_helmtexture, uint32 in_rezexp, bool wasAtGraveyard = false);
~Corpse(); ~Corpse();
static Corpse* LoadFromDBData(uint32 in_dbid, uint32 in_charid, std::string in_charname, float in_x, float in_y, float in_z, float in_heading, std::string time_of_death, bool rezzed, bool was_at_graveyard);
//abstract virtual function implementations requird by base abstract class //abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; } virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, SkillUseTypes attack_skill) { return true; }
virtual void Damage(Mob* from, int32 damage, uint16 spell_id, SkillUseTypes attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false) { return; } virtual void Damage(Mob* from, int32 damage, uint16 spell_id, SkillUseTypes attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false) { return; }
virtual bool Attack(Mob* other, int Hand = MainPrimary, bool FromRiposte = false, bool IsStrikethrough = true, bool IsFromSpell = false, virtual bool Attack(Mob* other, int Hand = MainPrimary, bool FromRiposte = false,
ExtraAttackOptions *opts = nullptr) { return false; } bool IsStrikethrough = true, bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) { return false; }
virtual bool HasRaid() { return false; } virtual bool HasRaid() { return false; }
virtual bool HasGroup() { return false; } virtual bool HasGroup() { return false; }
virtual Raid* GetRaid() { return 0; } virtual Raid* GetRaid() { return 0; }
@ -51,22 +51,22 @@ public:
void LoadPlayerCorpseDecayTime(uint32 dbid); void LoadPlayerCorpseDecayTime(uint32 dbid);
bool IsCorpse() const { return true; } bool IsCorpse() const { return true; }
bool IsPlayerCorpse() const { return p_PlayerCorpse; } bool IsPlayerCorpse() const { return is_player_corpse; }
bool IsNPCCorpse() const { return !p_PlayerCorpse; } bool IsNPCCorpse() const { return !is_player_corpse; }
bool IsBecomeNPCCorpse() const { return become_npc; } bool IsBecomeNPCCorpse() const { return become_npc; }
bool Process(); bool Process();
bool Save(); bool Save();
uint32 GetCharID() { return charid; } uint32 GetCharID() { return char_id; }
uint32 SetCharID(uint32 iCharID) { if (IsPlayerCorpse()) { return (charid=iCharID); } return 0xFFFFFFFF; }; uint32 SetCharID(uint32 iCharID) { if (IsPlayerCorpse()) { return (char_id = iCharID); } return 0xFFFFFFFF; };
uint32 GetDecayTime() { if (!corpse_decay_timer.Enabled()) return 0xFFFFFFFF; else return corpse_decay_timer.GetRemainingTime(); } uint32 GetDecayTime() { if (!corpse_decay_timer.Enabled()) return 0xFFFFFFFF; else return corpse_decay_timer.GetRemainingTime(); }
uint32 GetResTime() { if (!corpse_res_timer.Enabled()) return 0; else return corpse_res_timer.GetRemainingTime(); } uint32 GetResTime() { if (!corpse_res_timer.Enabled()) return 0; else return corpse_res_timer.GetRemainingTime(); }
void CalcCorpseName(); void CalcCorpseName();
inline void Lock() { pLocked = true; } inline void Lock() { is_locked = true; }
inline void UnLock() { pLocked = false; } inline void UnLock() { is_locked = false; }
inline bool IsLocked() { return pLocked; } inline bool IsLocked() { return is_locked; }
inline void ResetLooter() { BeingLootedBy = 0xFFFFFFFF; } inline void ResetLooter() { being_looted_by = 0xFFFFFFFF; }
inline bool IsBeingLooted() { return (BeingLootedBy != 0xFFFFFFFF); } inline bool IsBeingLooted() { return (being_looted_by != 0xFFFFFFFF); }
inline uint32 GetDBID() { return dbid; } inline uint32 GetDBID() { return corpse_db_id; }
inline char* GetOwnerName() { return orgname;} inline char* GetOwnerName() { return orgname;}
void SetDecayTimer(uint32 decaytime); void SetDecayTimer(uint32 decaytime);
@ -97,13 +97,13 @@ public:
bool Summon(Client* client, bool spell, bool CheckDistance); bool Summon(Client* client, bool spell, bool CheckDistance);
void CastRezz(uint16 spellid, Mob* Caster); void CastRezz(uint16 spellid, Mob* Caster);
void CompleteRezz(); void CompleteRezz();
void SetPKItem(int32 id) { pkitem = id; } void SetPKItem(int32 id) { player_kill_item = id; }
int32 GetPKItem() { return pkitem; } int32 GetPKItem() { return player_kill_item; }
bool CanMobLoot(int charid); bool CanMobLoot(int charid);
void AllowMobLoot(Mob *them, uint8 slot); void AllowMobLoot(Mob *them, uint8 slot);
void AddLooter(Mob *who); void AddLooter(Mob *who);
bool Rezzed() { return rez; } bool IsRezzed() { return rez; }
void Rezzed(bool in_rez) { rez = in_rez; } void IsRezzed(bool in_rez) { rez = in_rez; }
void Spawn(); void Spawn();
char orgname[64]; char orgname[64];
@ -119,23 +119,24 @@ protected:
std::list<uint32> MoveItemToCorpse(Client *client, ItemInst *item, int16 equipslot); std::list<uint32> MoveItemToCorpse(Client *client, ItemInst *item, int16 equipslot);
private: private:
bool p_PlayerCorpse; bool pIsChanged; bool is_player_corpse;
bool pLocked; bool is_corpse_changed;
int32 pkitem; bool is_locked;
uint32 dbid; int32 player_kill_item;
uint32 charid; uint32 corpse_db_id;
uint32 char_id;
ItemList itemlist; ItemList itemlist;
uint32 copper; uint32 copper;
uint32 silver; uint32 silver;
uint32 gold; uint32 gold;
uint32 platinum; uint32 platinum;
bool p_depop; bool player_corpse_depop;
uint32 BeingLootedBy; uint32 being_looted_by;
uint32 rezzexp; uint32 rezzexp;
bool rez; bool rez;
bool can_rez; bool can_rez;
bool become_npc; bool become_npc;
int looters[MAX_LOOTERS]; // People allowed to loot the corpse, character id int allowed_looters[MAX_LOOTERS]; // People allowed to loot the corpse, character id
Timer corpse_decay_timer; Timer corpse_decay_timer;
Timer corpse_res_timer; Timer corpse_res_timer;
Timer corpse_delay_timer; Timer corpse_delay_timer;

View File

@ -50,7 +50,7 @@ Doors::Doors(const Door* door)
incline = door->incline; incline = door->incline;
opentype = door->opentype; opentype = door->opentype;
guild_id = door->guild_id; guild_id = door->guild_id;
lockpick = door->lockpick; lockpick = door->lock_pick;
keyitem = door->keyitem; keyitem = door->keyitem;
nokeyring = door->nokeyring; nokeyring = door->nokeyring;
trigger_door = door->trigger_door; trigger_door = door->trigger_door;
@ -678,7 +678,7 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
into[rowIndex].heading = (float)atof(row[7]); into[rowIndex].heading = (float)atof(row[7]);
into[rowIndex].opentype = atoi(row[8]); into[rowIndex].opentype = atoi(row[8]);
into[rowIndex].guild_id = atoi(row[9]); into[rowIndex].guild_id = atoi(row[9]);
into[rowIndex].lockpick = atoi(row[10]); into[rowIndex].lock_pick = atoi(row[10]);
into[rowIndex].keyitem = atoi(row[11]); into[rowIndex].keyitem = atoi(row[11]);
into[rowIndex].nokeyring = atoi(row[12]); into[rowIndex].nokeyring = atoi(row[12]);
into[rowIndex].trigger_door = atoi(row[13]); into[rowIndex].trigger_door = atoi(row[13]);

View File

@ -1678,7 +1678,7 @@ int EntityList::RezzAllCorpsesByCharID(uint32 charid)
while (it != corpse_list.end()) { while (it != corpse_list.end()) {
if (it->second->GetCharID() == charid) { if (it->second->GetCharID() == charid) {
RezzExp += it->second->GetRezzExp(); RezzExp += it->second->GetRezzExp();
it->second->Rezzed(true); it->second->IsRezzed(true);
it->second->CompleteRezz(); it->second->CompleteRezz();
} }
++it; ++it;

View File

@ -858,7 +858,7 @@ void Client::PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootI
{ {
if(bag_item_data[i] == nullptr) if(bag_item_data[i] == nullptr)
continue; continue;
const ItemInst *bagitem = database.CreateItem(bag_item_data[i]->item_id, bag_item_data[i]->charges, bag_item_data[i]->aug1, bag_item_data[i]->aug2, bag_item_data[i]->aug3, bag_item_data[i]->aug4, bag_item_data[i]->aug5); const ItemInst *bagitem = database.CreateItem(bag_item_data[i]->item_id, bag_item_data[i]->charges, bag_item_data[i]->aug_1, bag_item_data[i]->aug_2, bag_item_data[i]->aug_3, bag_item_data[i]->aug_4, bag_item_data[i]->aug_5);
interior_slot = Inventory::CalcSlotId(slot_id, i); interior_slot = Inventory::CalcSlotId(slot_id, i);
mlog(INVENTORY__SLOTS, "Putting bag loot item %s (%d) into slot %d (bag slot %d)", inst.GetItem()->Name, inst.GetItem()->ID, interior_slot, i); mlog(INVENTORY__SLOTS, "Putting bag loot item %s (%d) into slot %d (bag slot %d)", inst.GetItem()->Name, inst.GetItem()->ID, interior_slot, i);
PutLootInInventory(interior_slot, *bagitem); PutLootInInventory(interior_slot, *bagitem);

View File

@ -195,13 +195,13 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge
item->item_id = item2->ID; item->item_id = item2->ID;
item->charges = charges; item->charges = charges;
item->aug1 = 0; item->aug_1 = 0;
item->aug2 = 0; item->aug_2 = 0;
item->aug3 = 0; item->aug_3 = 0;
item->aug4 = 0; item->aug_4 = 0;
item->aug5 = 0; item->aug_5 = 0;
item->minlevel = minlevel; item->min_level = minlevel;
item->maxlevel = maxlevel; item->max_level = maxlevel;
if (equipit) { if (equipit) {
uint8 eslot = 0xFF; uint8 eslot = 0xFF;
char newid[20]; char newid[20];
@ -339,7 +339,7 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge
if (found) { if (found) {
CalcBonuses(); // This is less than ideal for bulk adding of items CalcBonuses(); // This is less than ideal for bulk adding of items
} }
item->equipSlot = item2->Slots; item->equip_slot = item2->Slots;
} }
if(itemlist != nullptr) if(itemlist != nullptr)

View File

@ -44,7 +44,7 @@ uint32 Lua_Corpse::GetDBID() {
bool Lua_Corpse::IsRezzed() { bool Lua_Corpse::IsRezzed() {
Lua_Safe_Call_Bool(); Lua_Safe_Call_Bool();
return self->Rezzed(); return self->IsRezzed();
} }
const char* Lua_Corpse::GetOwnerName() { const char* Lua_Corpse::GetOwnerName() {

View File

@ -4338,7 +4338,7 @@ Corpse* Merc::GetGroupMemberCorpse() {
if(g->members[i] && g->members[i]->IsClient()) { if(g->members[i] && g->members[i]->IsClient()) {
corpse = entity_list.GetCorpseByOwnerWithinRange(g->members[i]->CastToClient(), this, RuleI(Mercs, ResurrectRadius)); corpse = entity_list.GetCorpseByOwnerWithinRange(g->members[i]->CastToClient(), this, RuleI(Mercs, ResurrectRadius));
if(corpse && !corpse->Rezzed()) { if(corpse && !corpse->IsRezzed()) {
return corpse; return corpse;
} }
} }

View File

@ -429,7 +429,7 @@ ServerLootItem_Struct* NPC::GetItem(int slot_id) {
end = itemlist.end(); end = itemlist.end();
for(; cur != end; ++cur) { for(; cur != end; ++cur) {
ServerLootItem_Struct* item = *cur; ServerLootItem_Struct* item = *cur;
if (item->equipSlot == slot_id) { if (item->equip_slot == slot_id) {
return item; return item;
} }
} }
@ -446,7 +446,7 @@ void NPC::RemoveItem(uint32 item_id, uint16 quantity, uint16 slot) {
itemlist.erase(cur); itemlist.erase(cur);
return; return;
} }
else if (item->item_id == item_id && item->equipSlot == slot && quantity >= 1) { else if (item->item_id == item_id && item->equip_slot == slot && quantity >= 1) {
//std::cout<<"NPC::RemoveItem"<<" equipSlot:"<<iterator.GetData()->equipSlot<<" quantity:"<< quantity<<std::endl; // iterator undefined [CODEBUG] //std::cout<<"NPC::RemoveItem"<<" equipSlot:"<<iterator.GetData()->equipSlot<<" quantity:"<< quantity<<std::endl; // iterator undefined [CODEBUG]
if (item->charges <= quantity) if (item->charges <= quantity)
itemlist.erase(cur); itemlist.erase(cur);
@ -471,9 +471,9 @@ void NPC::CheckMinMaxLevel(Mob *them)
if(!(*cur)) if(!(*cur))
return; return;
if(themlevel < (*cur)->minlevel || themlevel > (*cur)->maxlevel) if(themlevel < (*cur)->min_level || themlevel > (*cur)->max_level)
{ {
material = Inventory::CalcMaterialFromSlot((*cur)->equipSlot); material = Inventory::CalcMaterialFromSlot((*cur)->equip_slot);
if(material != 0xFF) if(material != 0xFF)
SendWearChange(material); SendWearChange(material);
@ -508,15 +508,15 @@ void NPC::QueryLoot(Client* to) {
if (item) if (item)
if (to->GetClientVersion() >= EQClientRoF) if (to->GetClientVersion() >= EQClientRoF)
{ {
to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X0000000000000000000000000000000000000000000000000%s%c",(*cur)->minlevel, (*cur)->maxlevel, (int) item->ID,0x12, item->ID, item->Name, 0x12); to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X0000000000000000000000000000000000000000000000000%s%c",(*cur)->min_level, (*cur)->max_level, (int) item->ID,0x12, item->ID, item->Name, 0x12);
} }
else if (to->GetClientVersion() >= EQClientSoF) else if (to->GetClientVersion() >= EQClientSoF)
{ {
to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X00000000000000000000000000000000000000000000%s%c",(*cur)->minlevel, (*cur)->maxlevel, (int) item->ID,0x12, item->ID, item->Name, 0x12); to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X00000000000000000000000000000000000000000000%s%c",(*cur)->min_level, (*cur)->max_level, (int) item->ID,0x12, item->ID, item->Name, 0x12);
} }
else else
{ {
to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X000000000000000000000000000000000000000%s%c",(*cur)->minlevel, (*cur)->maxlevel, (int) item->ID,0x12, item->ID, item->Name, 0x12); to->Message(0, "minlvl: %i maxlvl: %i %i: %c%06X000000000000000000000000000000000000000%s%c",(*cur)->min_level, (*cur)->max_level, (int) item->ID,0x12, item->ID, item->Name, 0x12);
} }
else else
LogFile->write(EQEMuLog::Error, "Database error, invalid item"); LogFile->write(EQEMuLog::Error, "Database error, invalid item");

View File

@ -780,7 +780,7 @@ XS(XS_Corpse_IsRezzed)
if(THIS == nullptr) if(THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->Rezzed(); RETVAL = THIS->IsRezzed();
ST(0) = boolSV(RETVAL); ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0)); sv_2mortal(ST(0));
} }

View File

@ -1744,7 +1744,7 @@ bool QuestManager::summonburriedplayercorpse(uint32 char_id, float dest_x, float
bool Result = false; bool Result = false;
if(char_id > 0) { if(char_id > 0) {
Corpse* PlayerCorpse = database.SummonBurriedPlayerCorpse(char_id, zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading); Corpse* PlayerCorpse = database.SummonBuriedCharacterCorpses(char_id, zone->GetZoneID(), zone->GetInstanceID(), dest_x, dest_y, dest_z, dest_heading);
if(PlayerCorpse) { if(PlayerCorpse) {
Result = true; Result = true;
} }
@ -1767,7 +1767,7 @@ uint32 QuestManager::getplayerburriedcorpsecount(uint32 char_id) {
uint32 Result = 0; uint32 Result = 0;
if(char_id > 0) { if(char_id > 0) {
Result = database.GetPlayerBurriedCorpseCount(char_id); Result = database.GetCharacterBuriedCorpseCount(char_id);
} }
return Result; return Result;
} }
@ -1781,7 +1781,7 @@ bool QuestManager::buryplayercorpse(uint32 char_id)
uint32 PlayerCorpse = database.GetFirstCorpseID(char_id); uint32 PlayerCorpse = database.GetFirstCorpseID(char_id);
if(PlayerCorpse > 0) if(PlayerCorpse > 0)
{ {
database.BuryPlayerCorpse(PlayerCorpse); database.BuryCharacterCorpse(PlayerCorpse);
Corpse* corpse = entity_list.GetCorpseByDBID(PlayerCorpse); Corpse* corpse = entity_list.GetCorpseByDBID(PlayerCorpse);
if(corpse) if(corpse)
{ {

View File

@ -736,8 +736,6 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
//clear out old stuff.. //clear out old stuff..
spawn_conditions.clear(); spawn_conditions.clear();
std::string query = StringFormat("SELECT id, onchange, value " std::string query = StringFormat("SELECT id, onchange, value "
"FROM spawn_conditions " "FROM spawn_conditions "
"WHERE zone = '%s'", zone_name); "WHERE zone = '%s'", zone_name);

View File

@ -3806,9 +3806,9 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r
void Corpse::CastRezz(uint16 spellid, Mob* Caster) void Corpse::CastRezz(uint16 spellid, Mob* Caster)
{ {
_log(SPELLS__REZ, "Corpse::CastRezz spellid %i, Rezzed() is %i, rezzexp is %i", spellid,Rezzed(),rezzexp); _log(SPELLS__REZ, "Corpse::CastRezz spellid %i, Rezzed() is %i, rezzexp is %i", spellid,IsRezzed(),rezzexp);
if(Rezzed()){ if(IsRezzed()){
if(Caster && Caster->IsClient()) if(Caster && Caster->IsClient())
Caster->Message(13,"This character has already been resurrected."); Caster->Message(13,"This character has already been resurrected.");
@ -3838,7 +3838,7 @@ void Corpse::CastRezz(uint16 spellid, Mob* Caster)
rezz->unknown020 = 0x00000000; rezz->unknown020 = 0x00000000;
rezz->unknown088 = 0x00000000; rezz->unknown088 = 0x00000000;
// We send this to world, because it needs to go to the player who may not be in this zone. // We send this to world, because it needs to go to the player who may not be in this zone.
worldserver.RezzPlayer(outapp, rezzexp, dbid, OP_RezzRequest); worldserver.RezzPlayer(outapp, rezzexp, corpse_db_id, OP_RezzRequest);
_pkt(SPELLS__REZ, outapp); _pkt(SPELLS__REZ, outapp);
safe_delete(outapp); safe_delete(outapp);
} }

View File

@ -704,7 +704,7 @@ void WorldServer::Process() {
_log(SPELLS__REZ, "Found corpse. Marking corpse as rezzed."); _log(SPELLS__REZ, "Found corpse. Marking corpse as rezzed.");
// I don't know why Rezzed is not set to true in CompleteRezz(). // I don't know why Rezzed is not set to true in CompleteRezz().
corpse->Rezzed(true); corpse->IsRezzed(true);
corpse->CompleteRezz(); corpse->CompleteRezz();
} }
} }
@ -1382,7 +1382,7 @@ void WorldServer::Process() {
case ServerOP_SpawnPlayerCorpse: { case ServerOP_SpawnPlayerCorpse: {
SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
Corpse* NewCorpse = database.LoadPlayerCorpse(s->player_corpse_id); Corpse* NewCorpse = database.LoadCharacterCorpse(s->player_corpse_id);
if(NewCorpse) if(NewCorpse)
NewCorpse->Spawn(); NewCorpse->Spawn();
else else

View File

@ -917,7 +917,7 @@ bool Zone::Init(bool iStaticZone) {
} }
LogFile->write(EQEMuLog::Status, "Loading player corpses..."); LogFile->write(EQEMuLog::Status, "Loading player corpses...");
if (!database.LoadPlayerCorpses(zoneid, instanceid)) { if (!database.LoadCharacterCorpses(zoneid, instanceid)) {
LogFile->write(EQEMuLog::Error, "Loading player corpses failed."); LogFile->write(EQEMuLog::Error, "Loading player corpses failed.");
return false; return false;
} }

View File

@ -7,6 +7,7 @@
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "../common/rdtsc.h" #include "../common/rdtsc.h"
#include "zone.h" #include "zone.h"
#include "corpse.h"
#include "client.h" #include "client.h"
#include "merc.h" #include "merc.h"
#include "groups.h" #include "groups.h"
@ -1236,7 +1237,6 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, u
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());
} }
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterBindPoint", query);
return true; return true;
} }
@ -1247,14 +1247,12 @@ bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_i
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);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterMaterialColor", query);
return true; return true;
} }
bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value){ bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value){
std::string query = StringFormat("REPLACE INTO `character_skills` (id, skill_id, value) VALUES (%u, %u, %u)", character_id, skill_id, value); auto results = QueryDatabase(query); std::string query = StringFormat("REPLACE INTO `character_skills` (id, skill_id, value) VALUES (%u, %u, %u)", character_id, skill_id, value); auto results = QueryDatabase(query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterSkill for character ID: %i, skill_id:%u value:%u done", character_id, skill_id, value); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterSkill for character ID: %i, skill_id:%u value:%u done", character_id, skill_id, value);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterSkill", query);
return true; return true;
} }
@ -1262,7 +1260,6 @@ bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32
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);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterDisc", query);
return true; return true;
} }
@ -1285,7 +1282,6 @@ bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_i
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);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterBandolier", 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; }
return true; return true;
@ -1294,7 +1290,6 @@ bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_i
bool ZoneDatabase::SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon) { bool ZoneDatabase::SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon) {
std::string query = StringFormat("REPLACE INTO `character_potionbelt` (id, potion_id, item_id, icon) VALUES (%u, %u, %u, %u)", character_id, potion_id, item_id, icon); std::string query = StringFormat("REPLACE INTO `character_potionbelt` (id, potion_id, item_id, icon) VALUES (%u, %u, %u, %u)", character_id, potion_id, item_id, icon);
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterPotionBelt", query);
if (!results.RowsAffected()){ std::cout << "ERROR Potionbelt Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; } if (!results.RowsAffected()){ std::cout << "ERROR Potionbelt Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
return true; return true;
} }
@ -1311,7 +1306,6 @@ bool ZoneDatabase::SaveCharacterLeadershipAA(uint32 character_id, PlayerProfile_
} }
} }
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterLeadershipAA", query);
return true; return true;
} }
@ -1603,7 +1597,6 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
m_epp->expended_aa m_epp->expended_aa
); );
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase:SaveCharacterData", query);
LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); LogFile->write(EQEMuLog::Debug, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
return true; return true;
} }
@ -1645,7 +1638,6 @@ bool ZoneDatabase::SaveCharacterCurrency(uint32 character_id, PlayerProfile_Stru
pp->currentEbonCrystals, pp->currentEbonCrystals,
pp->careerEbonCrystals); pp->careerEbonCrystals);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterCurrency", 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;
} }
@ -1655,7 +1647,6 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur
" VALUES (%u, %u, %u)", " VALUES (%u, %u, %u)",
character_id, aa_id, current_level); character_id, aa_id, current_level);
auto results = QueryDatabase(rquery); auto results = QueryDatabase(rquery);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterAA", rquery);
LogFile->write(EQEMuLog::Debug, "Saving AA for character ID: %u, aa_id: %u current_level: %u", character_id, aa_id, current_level); LogFile->write(EQEMuLog::Debug, "Saving AA for character ID: %u, aa_id: %u current_level: %u", character_id, aa_id, current_level);
return true; return true;
} }
@ -3328,3 +3319,667 @@ bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, std::list<struct NPCFactio
} }
return true; return true;
} }
/* Corpse Queries */
bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
std::string query = StringFormat( "UPDATE `zone` SET `graveyard_id` = 0 WHERE `zone_idnumber` = %u AND `version` = 0", zone_id);
auto results = QueryDatabase(query);
query = StringFormat("DELETE FROM `graveyard` WHERE `id` = %u", graveyard_id);
auto results2 = QueryDatabase(query);
if (results.Success() && results2.Success()){
return true;
}
return false;
}
uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
std::string query = StringFormat(
"UPDATE `zone` SET `graveyard_id` = %u WHERE `zone_idnumber` = %u AND `version` = 0",
graveyard_id, zone_id
);
auto results = QueryDatabase(query);
return zone_id;
}
uint32 ZoneDatabase::CreateGraveyardRecord(uint32 graveyard_zone_id, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) {
std::string query = StringFormat(
"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
);
auto results = QueryDatabase(query);
if (results.Success()){
return results.LastInsertedID();
}
return 0;
}
uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id, uint16 instance_id, float x, float y, float z, float heading) {
std::string query = StringFormat(
"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 "
"WHERE `id` = %d",
zone_id, x, y, z, heading, dbid
);
QueryDatabase(query);
return dbid;
}
uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){
std::string query = StringFormat("SELECT(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) FROM `character_corpses` WHERE `id` = %d AND NOT `time_of_death` = 0", corpse_db_id);
auto results = QueryDatabase(query);
auto row = results.begin();
if (results.Success() && results.RowsAffected() != 0){
return atoll(row[0]);
}
return 0;
}
uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool is_rezzed) {
std::string query = StringFormat("UPDATE `character_corpses` SET \n"
"`charname` = '%s',\n"
"`zone_id` = %u,\n"
"`instance_id` = %u,\n"
"`charid` = %d,\n"
"`x` = %1.1f,\n"
"`y` = %1.1f,\n"
"`z` = %1.1f,\n"
"`heading` = %1.1f,\n"
"`is_locked` = %d,\n"
"`exp` = %u,\n"
"`size` = %f,\n"
"`level` = %u,\n"
"`race` = %u,\n"
"`gender` = %u,\n"
"`class` = %u,\n"
"`deity` = %u,\n"
"`texture` = %u,\n"
"`helm_texture` = %u,\n"
"`copper` = %u,\n"
"`silver` = %u,\n"
"`gold` = %u,\n"
"`platinum` = %u,\n"
"`hair_color` = %u,\n"
"`beard_color` = %u,\n"
"`eye_color_1` = %u,\n"
"`eye_color_2` = %u,\n"
"`hair_style` = %u,\n"
"`face` = %u,\n"
"`beard` = %u,\n"
"`drakkin_heritage` = %u,\n"
"`drakkin_tattoo` = %u,\n"
"`drakkin_details` = %u,\n"
"`wc_1` = %u,\n"
"`wc_2` = %u,\n"
"`wc_3` = %u,\n"
"`wc_4` = %u,\n"
"`wc_5` = %u,\n"
"`wc_6` = %u,\n"
"`wc_7` = %u,\n"
"`wc_8` = %u,\n"
"`wc_9` = %u \n"
"WHERE `id` = %u",
EscapeString(char_name).c_str(),
zone_id,
instance_id,
char_id,
x,
y,
z,
heading,
dbpc->locked,
dbpc->exp,
dbpc->size,
dbpc->level,
dbpc->race,
dbpc->gender,
dbpc->class_,
dbpc->deity,
dbpc->texture,
dbpc->helmtexture,
dbpc->copper,
dbpc->silver,
dbpc->gold,
dbpc->plat,
dbpc->haircolor,
dbpc->beardcolor,
dbpc->eyecolor1,
dbpc->eyecolor2,
dbpc->hairstyle,
dbpc->face,
dbpc->beard,
dbpc->drakkin_heritage,
dbpc->drakkin_tattoo,
dbpc->drakkin_details,
dbpc->item_tint[0].color,
dbpc->item_tint[1].color,
dbpc->item_tint[2].color,
dbpc->item_tint[3].color,
dbpc->item_tint[4].color,
dbpc->item_tint[5].color,
dbpc->item_tint[6].color,
dbpc->item_tint[7].color,
dbpc->item_tint[8].color,
db_id
);
auto results = QueryDatabase(query);
return db_id;
}
void ZoneDatabase::MarkCorpseAsRezzed(uint32 db_id) {
std::string query = StringFormat("UPDATE `character_corpses` SET `is_rezzed` = 1 WHERE `id` = %i", db_id);
auto results = QueryDatabase(query);
}
uint32 ZoneDatabase::SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading) {
/* Dump Basic Corpse Data */
std::string query = StringFormat("INSERT INTO `character_corpses` SET \n"
"`charname` = '%s',\n"
"`zone_id` = %u,\n"
"`instance_id` = %u,\n"
"`charid` = %d,\n"
"`x` = %1.1f,\n"
"`y` = %1.1f,\n"
"`z` = %1.1f,\n"
"`heading` = %1.1f,\n"
"`time_of_death` = NOW(),\n"
"`is_buried` = 0,"
"`is_locked` = %d,\n"
"`exp` = %u,\n"
"`size` = %f,\n"
"`level` = %u,\n"
"`race` = %u,\n"
"`gender` = %u,\n"
"`class` = %u,\n"
"`deity` = %u,\n"
"`texture` = %u,\n"
"`helm_texture` = %u,\n"
"`copper` = %u,\n"
"`silver` = %u,\n"
"`gold` = %u,\n"
"`platinum` = %u,\n"
"`hair_color` = %u,\n"
"`beard_color` = %u,\n"
"`eye_color_1` = %u,\n"
"`eye_color_2` = %u,\n"
"`hair_style` = %u,\n"
"`face` = %u,\n"
"`beard` = %u,\n"
"`drakkin_heritage` = %u,\n"
"`drakkin_tattoo` = %u,\n"
"`drakkin_details` = %u,\n"
"`wc_1` = %u,\n"
"`wc_2` = %u,\n"
"`wc_3` = %u,\n"
"`wc_4` = %u,\n"
"`wc_5` = %u,\n"
"`wc_6` = %u,\n"
"`wc_7` = %u,\n"
"`wc_8` = %u,\n"
"`wc_9` = %u \n",
EscapeString(charname).c_str(),
zoneid,
instanceid,
charid,
x,
y,
z,
heading,
dbpc->locked,
dbpc->exp,
dbpc->size,
dbpc->level,
dbpc->race,
dbpc->gender,
dbpc->class_,
dbpc->deity,
dbpc->texture,
dbpc->helmtexture,
dbpc->copper,
dbpc->silver,
dbpc->gold,
dbpc->plat,
dbpc->haircolor,
dbpc->beardcolor,
dbpc->eyecolor1,
dbpc->eyecolor2,
dbpc->hairstyle,
dbpc->face,
dbpc->beard,
dbpc->drakkin_heritage,
dbpc->drakkin_tattoo,
dbpc->drakkin_details,
dbpc->item_tint[0].color,
dbpc->item_tint[1].color,
dbpc->item_tint[2].color,
dbpc->item_tint[3].color,
dbpc->item_tint[4].color,
dbpc->item_tint[5].color,
dbpc->item_tint[6].color,
dbpc->item_tint[7].color,
dbpc->item_tint[8].color
);
auto results = QueryDatabase(query);
uint32 last_insert_id = results.LastInsertedID();
/* Dump Items from Inventory */
uint8 first_entry = 0;
for (unsigned int i = 0; i < dbpc->itemcount; i++) {
if (first_entry != 1){
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"
" VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
last_insert_id,
dbpc->items[i].equip_slot,
dbpc->items[i].item_id,
dbpc->items[i].charges,
dbpc->items[i].aug_1,
dbpc->items[i].aug_2,
dbpc->items[i].aug_3,
dbpc->items[i].aug_4,
dbpc->items[i].aug_5
);
first_entry = 1;
}
else{
query = query + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, 0) \n",
last_insert_id,
dbpc->items[i].equip_slot,
dbpc->items[i].item_id,
dbpc->items[i].charges,
dbpc->items[i].aug_1,
dbpc->items[i].aug_2,
dbpc->items[i].aug_3,
dbpc->items[i].aug_4,
dbpc->items[i].aug_5
);
}
}
auto sc_results = QueryDatabase(query);
return last_insert_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);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]);
}
return 0;
}
uint32 ZoneDatabase::GetCharacterCorpseCount(uint32 char_id) {
std::string query = StringFormat("SELECT COUNT(*) FROM `character_corpses` WHERE `charid` = '%u'", char_id);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]);
}
return 0;
}
uint32 ZoneDatabase::GetCharacterCorpseID(uint32 char_id, uint8 corpse) {
std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u'", char_id);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
for (int i = 0; i < corpse; i++) {
return atoll(row[0]);
}
}
return 0;
}
uint32 ZoneDatabase::GetCharacterCorpseItemCount(uint32 corpse_id){
std::string query = StringFormat("SELECT COUNT(*) FROM character_corpse_items WHERE `corpse_id` = %u",
corpse_id
);
auto results = QueryDatabase(query);
auto row = results.begin();
if (results.Success() && results.RowsAffected() != 0){
return atoi(row[0]);
}
return 0;
}
uint32 ZoneDatabase::GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slotid) {
Corpse* tmp = LoadCharacterCorpse(corpse_id);
uint32 itemid = 0;
if (tmp) {
itemid = tmp->GetWornItem(slotid);
tmp->DepopCorpse();
}
return itemid;
}
bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct* pcs){
std::string query = StringFormat(
"SELECT \n"
"is_locked, \n"
"exp, \n"
"size, \n"
"`level`, \n"
"race, \n"
"gender, \n"
"class, \n"
"deity, \n"
"texture, \n"
"helm_texture, \n"
"copper, \n"
"silver, \n"
"gold, \n"
"platinum, \n"
"hair_color, \n"
"beard_color, \n"
"eye_color_1, \n"
"eye_color_2, \n"
"hair_style, \n"
"face, \n"
"beard, \n"
"drakkin_heritage,\n"
"drakkin_tattoo, \n"
"drakkin_details, \n"
"wc_1, \n"
"wc_2, \n"
"wc_3, \n"
"wc_4, \n"
"wc_5, \n"
"wc_6, \n"
"wc_7, \n"
"wc_8, \n"
"wc_9 \n"
"FROM \n"
"character_corpses\n"
"WHERE `id` = %u LIMIT 1\n",
corpse_id
);
auto results = QueryDatabase(query);
uint16 i = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
pcs->locked = atoi(row[i++]); // is_locked,
pcs->exp = atoll(row[i++]); // exp,
pcs->size = atoi(row[i++]); // size,
pcs->level = atoi(row[i++]); // `level`,
pcs->race = atoi(row[i++]); // race,
pcs->gender = atoi(row[i++]); // gender,
pcs->class_ = atoi(row[i++]); // class,
pcs->deity = atoi(row[i++]); // deity,
pcs->texture = atoi(row[i++]); // texture,
pcs->helmtexture = atoi(row[i++]); // helm_texture,
pcs->copper = atoll(row[i++]); // copper,
pcs->silver = atoll(row[i++]); // silver,
pcs->gold = atoll(row[i++]); // gold,
pcs->plat = atoll(row[i++]); // platinum,
pcs->haircolor = atoi(row[i++]); // hair_color,
pcs->beardcolor = atoi(row[i++]); // beard_color,
pcs->eyecolor1 = atoi(row[i++]); // eye_color_1,
pcs->eyecolor2 = atoi(row[i++]); // eye_color_2,
pcs->hairstyle = atoi(row[i++]); // hair_style,
pcs->face = atoi(row[i++]); // face,
pcs->beard = atoi(row[i++]); // beard,
pcs->drakkin_heritage = atoll(row[i++]); // drakkin_heritage,
pcs->drakkin_tattoo = atoll(row[i++]); // drakkin_tattoo,
pcs->drakkin_details = atoll(row[i++]); // drakkin_details,
pcs->item_tint[0].color = atoll(row[i++]); // wc_1,
pcs->item_tint[1].color = atoll(row[i++]); // wc_2,
pcs->item_tint[2].color = atoll(row[i++]); // wc_3,
pcs->item_tint[3].color = atoll(row[i++]); // wc_4,
pcs->item_tint[4].color = atoll(row[i++]); // wc_5,
pcs->item_tint[5].color = atoll(row[i++]); // wc_6,
pcs->item_tint[6].color = atoll(row[i++]); // wc_7,
pcs->item_tint[7].color = atoll(row[i++]); // wc_8,
pcs->item_tint[8].color = atoll(row[i++]); // wc_9
}
query = StringFormat(
"SELECT \n"
"equip_slot, \n"
"item_id, \n"
"charges, \n"
"aug_1, \n"
"aug_2, \n"
"aug_3, \n"
"aug_4, \n"
"aug_5, \n"
"attuned \n"
"FROM \n"
"character_corpse_items \n"
"WHERE `corpse_id` = %u\n"
// "ORDER BY `equip_slot`"
,
corpse_id
);
results = QueryDatabase(query);
i = 0;
pcs->itemcount = results.RowCount();
uint16 r = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
memset(&pcs->items[i], 0, sizeof (player_lootitem::ServerLootItem_Struct));
pcs->items[i].equip_slot = atoi(row[r++]); // equip_slot,
pcs->items[i].item_id = atoll(row[r++]); // item_id,
pcs->items[i].charges = atoi(row[r++]); // charges,
pcs->items[i].aug_1 = atoi(row[r++]); // aug_1,
pcs->items[i].aug_2 = atoi(row[r++]); // aug_2,
pcs->items[i].aug_3 = atoi(row[r++]); // aug_3,
pcs->items[i].aug_4 = atoi(row[r++]); // aug_4,
pcs->items[i].aug_5 = atoi(row[r++]); // aug_5,
r = 0;
i++;
}
return true;
}
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;
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",
char_id
);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
NewCorpse = Corpse::LoadFromDBData(
atoll(row[0]), // uint32 in_dbid
char_id, // uint32 in_charid
row[1], // char* in_charname
dest_x, // float in_x
dest_y, // float in_y
dest_z, // float in_z
dest_heading, // float in_heading
row[2], // char* time_of_death
atoi(row[3]) == 1, // bool rezzed
false // bool was_at_graveyard
);
if (NewCorpse) {
entity_list.AddCorpse(NewCorpse);
NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
NewCorpse->Spawn();
if (!UnburyCharacterCorpse(NewCorpse->GetDBID(), dest_zone_id, dest_instance_id, dest_x, dest_y, dest_z, dest_heading))
LogFile->write(EQEMuLog::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id);
}
}
return NewCorpse;
}
bool ZoneDatabase::SummonAllCharacterCorpses(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;
int CorpseCount = 0;
std::string query = StringFormat(
"UPDATE character_corpses SET zone_id = %i, instance_id = %i, x = %f, y = %f, z = %f, heading = %f, is_buried = 0, was_at_graveyard = 0 WHERE charid = %i",
dest_zone_id, dest_instance_id, dest_x, dest_y, dest_z, dest_heading, char_id
);
auto results = QueryDatabase(query);
query = StringFormat(
"SELECT `id`, `charname`, `time_of_death`, `is_rezzed` FROM `character_corpses` WHERE `charid` = '%u'"
"ORDER BY time_of_death",
char_id
);
results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
NewCorpse = Corpse::LoadFromDBData(
atoll(row[0]),
char_id,
row[1],
dest_x,
dest_y,
dest_z,
dest_heading,
row[2],
atoi(row[3]) == 1,
false);
if (NewCorpse) {
entity_list.AddCorpse(NewCorpse);
NewCorpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS));
NewCorpse->Spawn();
++CorpseCount;
}
else{
LogFile->write(EQEMuLog::Error, "Unable to construct a player corpse for character id %u.", char_id);
}
}
return (CorpseCount > 0);
}
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(
"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
);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){
return true;
}
return false;
}
Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) {
Corpse* NewCorpse = 0;
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",
player_corpse_id
);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
NewCorpse = Corpse::LoadFromDBData(
atoll(row[0]), // id uint32 in_dbid
atoll(row[1]), // charid uint32 in_charid
row[2], // char_name
atof(row[3]), // x float in_x
atof(row[4]), // y float in_y
atof(row[5]), // z float in_z
atof(row[6]), // heading float in_heading
row[7], // time_of_death char* time_of_death
atoi(row[8]) == 1, // is_rezzed bool rezzed
atoi(row[9]) // was_at_graveyard bool was_at_graveyard
);
entity_list.AddCorpse(NewCorpse);
}
return NewCorpse;
}
bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) {
std::string query;
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);
}
else{
query = StringFormat("SELECT id, charid, charname, x, y, z, heading, time_of_death, is_rezzed, 0 as was_at_graveyard FROM character_corpses WHERE zone_id='%u' AND instance_id='%u' AND is_buried=0", zone_id, instance_id);
}
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
// std::cout << row[0] << std::endl;
// std::cout << row[1] << std::endl;
// std::cout << row[2] << std::endl;
// std::cout << row[3] << std::endl;
// std::cout << row[4] << std::endl;
// std::cout << row[5] << std::endl;
// std::cout << row[6] << std::endl;
// std::cout << row[7] << std::endl;
// std::cout << row[8] << std::endl;
// std::cout << row[9] << std::endl;
entity_list.AddCorpse(
Corpse::LoadFromDBData(
atoll(row[0]), // id uint32 in_dbid
atoll(row[1]), // charid uint32 in_charid
row[2], // char_name
atof(row[3]), // x float in_x
atof(row[4]), // y float in_y
atof(row[5]), // z float in_z
atof(row[6]), // heading float in_heading
row[7], // time_of_death char* time_of_death
atoi(row[8]) == 1, // is_rezzed bool rezzed
atoi(row[9]))
);
}
return true;
}
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);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]);
}
return 0;
}
bool ZoneDatabase::ClearCorpseItems(uint32 db_id){
std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u", db_id);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){
return true;
}
return false;
}
bool ZoneDatabase::DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id){
std::string query = StringFormat("DELETE FROM `character_corpse_items` WHERE `corpse_id` = %u AND equip_slot = %u AND item_id = %u", db_id, equip_slot, item_id);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){
return true;
}
return false;
}
bool ZoneDatabase::BuryCharacterCorpse(uint32 db_id) {
std::string query = StringFormat("UPDATE `character_corpses` SET `is_buried` = 1 WHERE `id` = %u", db_id);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){
ClearCorpseItems(db_id);
return true;
}
return false;
}
bool ZoneDatabase::BuryAllCharacterCorpses(uint32 char_id) {
std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = %u", char_id);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
BuryCharacterCorpse(atoi(row[0]));
return true;
}
return false;
}
bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) {
std::string query = StringFormat("DELETE FROM `character_corpses` WHERE `id` = %d", db_id);
auto results = QueryDatabase(query);
if (results.Success() && results.RowsAffected() != 0){
return true;
}
return false;
}

View File

@ -227,9 +227,10 @@ public:
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);
ItemInst* LoadSingleTraderItem(uint32 char_id, int uniqueid);
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);
ItemInst* LoadSingleTraderItem(uint32 char_id, int uniqueid);
Trader_Struct* LoadTraderItem(uint32 char_id); Trader_Struct* LoadTraderItem(uint32 char_id);
TraderCharges_Struct* LoadTraderItemWithCharges(uint32 char_id); TraderCharges_Struct* LoadTraderItemWithCharges(uint32 char_id);
@ -294,29 +295,33 @@ public:
bool NoRentExpired(const char* name); bool NoRentExpired(const char* name);
/* Corpses */ /* Corpses */
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes); bool ClearCorpseItems(uint32 db_id);
uint32 CreatePlayerCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading); bool DeleteItemOffCharacterCorpse(uint32 db_id, uint32 equip_slot, uint32 item_id);
bool CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading); uint32 GetCharacterCorpseItemCount(uint32 corpse_id);
uint32 UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading, bool rezzed = false); bool LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct* pcs);
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);
void MarkCorpseAsRezzed(uint32 dbid); void MarkCorpseAsRezzed(uint32 dbid);
bool BuryPlayerCorpse(uint32 dbid); bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
bool BuryAllPlayerCorpses(uint32 charid); bool BuryCharacterCorpse(uint32 dbid);
bool DeletePlayerCorpse(uint32 dbid); bool BuryAllCharacterCorpses(uint32 charid);
uint32 GetPlayerBurriedCorpseCount(uint32 char_id); bool DeleteCharacterCorpse(uint32 dbid);
Corpse* SummonBurriedPlayerCorpse(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 SummonAllPlayerCorpses(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);
Corpse* LoadPlayerCorpse(uint32 player_corpse_id); bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading);
bool UnburyPlayerCorpse(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 LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID);
uint32 GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading);
uint32 NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading);
uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id);
bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id); bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading);
uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading);
uint32 AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id);
uint32 SaveCharacterCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading);
uint32 UpdateCharacterCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool rezzed = false);
uint32 GetFirstCorpseID(uint32 char_id); uint32 GetFirstCorpseID(uint32 char_id);
uint32 GetPlayerCorpseCount(uint32 char_id); uint32 GetCharacterCorpseCount(uint32 char_id);
uint32 GetPlayerCorpseID(uint32 char_id, uint8 corpse); uint32 GetCharacterCorpseID(uint32 char_id, uint8 corpse);
uint32 GetPlayerCorpseItemAt(uint32 corpse_id, uint16 slotid); uint32 GetCharacterCorpseItemAt(uint32 corpse_id, uint16 slotid);
uint32 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type); uint32 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type);
/* Faction */ /* Faction */
@ -361,7 +366,6 @@ public:
uint32 GetFreeGrid(uint16 zoneid); uint32 GetFreeGrid(uint16 zoneid);
void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid); void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too, uint16 zoneid);
void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid); void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid);
// uint32 AddWP(Client *c, uint32 sg2, uint16 grid_num, uint8 wp_num, float xpos, float ypos, float zpos, uint32 pause, float xpos1, float ypos1, float zpos1, int type1, int type2,uint16 zoneid);
void AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading); void AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading);
uint32 AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading); uint32 AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading);
void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0); void ModifyGrid(Client *c, bool remove, uint32 id, uint8 type = 0, uint8 type2 = 0, uint16 zoneid = 0);
@ -374,7 +378,7 @@ public:
int GetHighestWaypoint(uint32 zoneid, uint32 gridid); int GetHighestWaypoint(uint32 zoneid, uint32 gridid);
/* NPCs */ /* NPCs */
const NPCType* GetNPCType(uint32 id);
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);
@ -391,8 +395,10 @@ public:
void AddLootDropToNPC(NPC* npc, uint32 lootdrop_id, ItemList* itemlist, uint8 droplimit, uint8 mindrop); void AddLootDropToNPC(NPC* npc, uint32 lootdrop_id, ItemList* itemlist, uint8 droplimit, uint8 mindrop);
uint32 GetMaxNPCSpellsID(); uint32 GetMaxNPCSpellsID();
uint32 GetMaxNPCSpellsEffectsID(); uint32 GetMaxNPCSpellsEffectsID();
DBnpcspells_Struct* GetNPCSpells(uint32 iDBSpellsID); DBnpcspells_Struct* GetNPCSpells(uint32 iDBSpellsID);
DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID); DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID);
const NPCType* GetNPCType(uint32 id);
/* Mercs */ /* Mercs */
const NPCType* GetMercType(uint32 id, uint16 raceid, uint32 clientlevel); const NPCType* GetMercType(uint32 id, uint16 raceid, uint32 clientlevel);
@ -403,8 +409,6 @@ public:
bool LoadCurrentMerc(Client *c); bool LoadCurrentMerc(Client *c);
bool SaveMerc(Merc *merc); bool SaveMerc(Merc *merc);
bool DeleteMerc(uint32 merc_id); bool DeleteMerc(uint32 merc_id);
//void LoadMercTypesForMercMerchant(NPC *merchant);
//void LoadMercsForMercMerchant(NPC *merchant);
/* Petitions */ /* Petitions */
void UpdateBug(BugStruct* bug); void UpdateBug(BugStruct* bug);

View File

@ -36,10 +36,8 @@ struct NPCType
{ {
char name[64]; char name[64];
char lastname[70]; char lastname[70];
int32 cur_hp; int32 cur_hp;
int32 max_hp; int32 max_hp;
float size; float size;
float runspeed; float runspeed;
uint8 gender; uint8 gender;
@ -130,38 +128,30 @@ struct NPCType
uint8 probability; uint8 probability;
}; };
/* namespace player_lootitem {
Below are the blob structures for saving player corpses to the database
-Quagmire
create table player_corpses (id int(11) unsigned not null auto_increment primary key, charid int(11) unsigned not null,
charname varchar(30) not null, zonename varchar(16)not null, x float not null, y float not null, z float not null,
heading float not null, data blob not null, time timestamp(14), index zonename (zonename));
*/
namespace player_lootitem
{
struct ServerLootItem_Struct { struct ServerLootItem_Struct {
uint32 item_id; uint32 item_id;
int16 equipSlot; int16 equip_slot;
uint8 charges; uint16 charges;
uint16 lootslot; uint16 lootslot;
uint32 aug1; uint32 aug_1;
uint32 aug2; uint32 aug_2;
uint32 aug3; uint32 aug_3;
uint32 aug4; uint32 aug_4;
uint32 aug5; uint32 aug_5;
uint8 min_level; //
uint8 max_level; //
}; };
} }
struct DBPlayerCorpse_Struct { struct PlayerCorpse_Struct {
uint32 crc; uint32 crc;
bool locked; bool locked;
uint32 itemcount; uint32 itemcount;
uint32 exp; uint32 exp;
float size; float size;
uint8 level; uint8 level;
uint8 race; uint32 race;
uint8 gender; uint8 gender;
uint8 class_; uint8 class_;
uint8 deity; uint8 deity;
@ -183,39 +173,9 @@ struct DBPlayerCorpse_Struct {
uint32 drakkin_tattoo; uint32 drakkin_tattoo;
uint32 drakkin_details; uint32 drakkin_details;
player_lootitem::ServerLootItem_Struct items[0]; player_lootitem::ServerLootItem_Struct items[0];
//std::list<player_lootitem::ServerLootItem_Struct*> items;
}; };
namespace classic_db
{
struct DBPlayerCorpse_Struct {
uint32 crc;
bool locked;
uint32 itemcount;
uint32 exp;
float size;
uint8 level;
uint8 race;
uint8 gender;
uint8 class_;
uint8 deity;
uint8 texture;
uint8 helmtexture;
uint32 copper;
uint32 silver;
uint32 gold;
uint32 plat;
Color_Struct item_tint[9];
uint8 haircolor;
uint8 beardcolor;
uint8 eyecolor1;
uint8 eyecolor2;
uint8 hairstyle;
uint8 face;
uint8 beard;
player_lootitem::ServerLootItem_Struct items[0];
};
}
struct Door { struct Door {
uint32 db_id; uint32 db_id;
uint8 door_id; uint8 door_id;
@ -228,7 +188,7 @@ struct Door {
int incline; int incline;
uint8 opentype; uint8 opentype;
uint32 guild_id; uint32 guild_id;
uint16 lockpick; uint16 lock_pick;
uint32 keyitem; uint32 keyitem;
uint8 nokeyring; uint8 nokeyring;
uint8 trigger_door; uint8 trigger_door;