From 22367622bebe4600420e842bc299003548f5410c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 10:51:08 -0700 Subject: [PATCH 001/217] LoadGuilds converted to QueryDatabase --- common/guild_base.cpp | 51 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 494139778..dc7d1fcae 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -40,6 +40,8 @@ BaseGuildManager::~BaseGuildManager() { ClearGuilds(); } + + bool BaseGuildManager::LoadGuilds() { ClearGuilds(); @@ -49,36 +51,34 @@ bool BaseGuildManager::LoadGuilds() { return(false); } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query("SELECT id, name, leader, minstatus, motd, motd_setter,channel,url FROM guilds"); std::map::iterator res; - // load up all the guilds - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "SELECT id, name, leader, minstatus, motd, motd_setter,channel,url FROM guilds"), errbuf, &result)) { - _log(GUILDS__ERROR, "Error loading guilds '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); - } - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) { - _CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]); - } - mysql_free_result(result); + auto results = m_db->QueryDatabase(query); - //load up the rank info for each guild. - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks"), errbuf, &result)) { - _log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); + if (!results.Success()) + { + _log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) { + + for (auto row=results.begin();row!=results.end();++row) + _CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]); + + query = "SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks"; + results = m_db->QueryDatabase(query); + + if (!results.Success()) + { + _log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; + } + + for (auto row=results.begin();row!=results.end();++row) + { uint32 guild_id = atoi(row[0]); uint8 rankn = atoi(row[1]); + if(rankn > GUILD_MAX_RANK) { _log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); continue; @@ -102,9 +102,8 @@ bool BaseGuildManager::LoadGuilds() { rank.permissions[GUILD_MOTD] = (row[9][0] == '1')?true:false; rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1')?true:false; } - mysql_free_result(result); - return(true); + return true; } bool BaseGuildManager::RefreshGuild(uint32 guild_id) { From a91b6a0db83bd62577c5cfc9973ead54607d5621 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 10:59:24 -0700 Subject: [PATCH 002/217] RefreshGuild converted to QueryDatabase --- common/guild_base.cpp | 71 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index dc7d1fcae..c8ba2fb0e 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -112,63 +112,64 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { return(false); } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = StringFormat("SELECT name, leader, minstatus, motd, motd_setter, channel,url FROM guilds WHERE id=%lu", (unsigned long)guild_id); std::map::iterator res; GuildInfo *info; // load up all the guilds - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "SELECT name, leader, minstatus, motd, motd_setter, channel,url FROM guilds WHERE id=%lu", (unsigned long)guild_id), errbuf, &result)) { - _log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) + { + _log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - if ((row = mysql_fetch_row(result))) { - //delete the old entry and create the new one. - info = _CreateGuild(guild_id, row[0], atoi(row[1]), atoi(row[2]), row[3], row[4], row[5], row[6]); - } else { + + if (results.RowCount() == 0) + { _log(GUILDS__ERROR, "Unable to find guild %d in the database.", guild_id); - return(false); + return false; } - mysql_free_result(result); - //load up the rank info for each guild. - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "SELECT guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace " - "FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), errbuf, &result)) { - _log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); + auto row = results.begin(); + + info = _CreateGuild(guild_id, row[0], atoi(row[1]), atoi(row[2]), row[3], row[4], row[5], row[6]); + + query = StringFormat("SELECT guild_id, rank, title, can_hear, can_speak, can_invite, can_remove, can_promote, can_demote, can_motd, can_warpeace " + "FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id); + results = m_db->QueryDatabase(query); + + if (!results.Success()) + { + _log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { + for (auto row=results.begin();row!=results.end();++row) + { uint8 rankn = atoi(row[1]); + if(rankn > GUILD_MAX_RANK) { _log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); continue; } + RankInfo &rank = info->ranks[rankn]; rank.name = row[2]; - rank.permissions[GUILD_HEAR] = (row[3][0] == '1')?true:false; - rank.permissions[GUILD_SPEAK] = (row[4][0] == '1')?true:false; - rank.permissions[GUILD_INVITE] = (row[5][0] == '1')?true:false; - rank.permissions[GUILD_REMOVE] = (row[6][0] == '1')?true:false; - rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1')?true:false; - rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1')?true:false; - rank.permissions[GUILD_MOTD] = (row[9][0] == '1')?true:false; - rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1')?true:false; + rank.permissions[GUILD_HEAR] = (row[3][0] == '1') ? true: false; + rank.permissions[GUILD_SPEAK] = (row[4][0] == '1') ? true: false; + rank.permissions[GUILD_INVITE] = (row[5][0] == '1') ? true: false; + rank.permissions[GUILD_REMOVE] = (row[6][0] == '1') ? true: false; + rank.permissions[GUILD_PROMOTE] = (row[7][0] == '1') ? true: false; + rank.permissions[GUILD_DEMOTE] = (row[8][0] == '1') ? true: false; + rank.permissions[GUILD_MOTD] = (row[9][0] == '1') ? true: false; + rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false; } - mysql_free_result(result); _log(GUILDS__DB, "Successfully refreshed guild %d from the database.", guild_id); - return(true); + return true; } BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, const char *guild_name, uint32 leader_char_id, uint8 minstatus, const char *guild_motd, const char *motd_setter, const char *Channel, const char *URL) From a2d437676390ab29d52109351e022f6dc77c5bef Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:08:41 -0700 Subject: [PATCH 003/217] _StoreGuildDB converted to QueryDatabase --- common/guild_base.cpp | 75 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index c8ba2fb0e..ce01b4070 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -231,24 +231,20 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { } GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + std::string query = StringFormat("DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id); //clear out old `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id), errbuf)) - { - _log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query, errbuf); - } - safe_delete_array(query); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) + _log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str()); //clear out old `guild_ranks` entries - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), errbuf)) - { - _log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query, errbuf); - } - safe_delete_array(query); + query = StringFormat("DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id); + results = m_db->QueryDatabase(query); + + if (!results.Success()) + _log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str()); //escape our strings. char *name_esc = new char[info->name.length()*2+1]; @@ -259,18 +255,18 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { m_db->DoEscapeString(motd_set_esc, info->motd_setter.c_str(), info->motd_setter.length()); //insert the new `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO guilds (id,name,leader,minstatus,motd,motd_setter) VALUES(%lu,'%s',%lu,%d,'%s', '%s')", - (unsigned long)guild_id, name_esc, (unsigned long)info->leader_char_id, info->minstatus, motd_esc, motd_set_esc), errbuf)) + query = StringFormat("INSERT INTO guilds (id,name,leader,minstatus,motd,motd_setter) VALUES(%lu,'%s',%lu,%d,'%s', '%s')", + (unsigned long)guild_id, name_esc, (unsigned long)info->leader_char_id, info->minstatus, motd_esc, motd_set_esc); + results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str()); safe_delete_array(name_esc); safe_delete_array(motd_esc); safe_delete_array(motd_set_esc); - return(false); + return false; } - safe_delete_array(query); safe_delete_array(name_esc); safe_delete_array(motd_esc); safe_delete_array(motd_set_esc); @@ -278,36 +274,37 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { //now insert the new ranks uint8 rank; for(rank = 0; rank <= GUILD_MAX_RANK; rank++) { - const RankInfo &r = info->ranks[rank]; + const RankInfo &rankInfo = info->ranks[rank]; - char *title_esc = new char[r.name.length()*2+1]; - m_db->DoEscapeString(title_esc, r.name.c_str(), r.name.length()); + char *title_esc = new char[rankInfo.name.length()*2+1]; + m_db->DoEscapeString(title_esc, rankInfo.name.c_str(), rankInfo.name.length()); - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO guild_ranks (guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace)" + query = StringFormat("INSERT INTO guild_ranks " + "(guild_id,rank,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace)" " VALUES(%d,%d,'%s',%d,%d,%d,%d,%d,%d,%d,%d)", guild_id, rank, title_esc, - r.permissions[GUILD_HEAR], - r.permissions[GUILD_SPEAK], - r.permissions[GUILD_INVITE], - r.permissions[GUILD_REMOVE], - r.permissions[GUILD_PROMOTE], - r.permissions[GUILD_DEMOTE], - r.permissions[GUILD_MOTD], - r.permissions[GUILD_WARPEACE]), errbuf)) + rankInfo.permissions[GUILD_HEAR], + rankInfo.permissions[GUILD_SPEAK], + rankInfo.permissions[GUILD_INVITE], + rankInfo.permissions[GUILD_REMOVE], + rankInfo.permissions[GUILD_PROMOTE], + rankInfo.permissions[GUILD_DEMOTE], + rankInfo.permissions[GUILD_MOTD], + rankInfo.permissions[GUILD_WARPEACE]); + results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query.c_str(), results.ErrorMessage().c_str()); safe_delete_array(title_esc); - return(false); + return false; } - safe_delete_array(query); safe_delete_array(title_esc); } _log(GUILDS__DB, "Stored guild %d in the database", guild_id); - return(true); + return true; } uint32 BaseGuildManager::_GetFreeGuildID() { From 7b440bbd9fc9713374a8959f208f8bad2d1fa59e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:11:56 -0700 Subject: [PATCH 004/217] _GetFeeGuildID converted to QueryDatabase --- common/guild_base.cpp | 44 +++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index ce01b4070..792f2e799 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -313,27 +313,39 @@ uint32 BaseGuildManager::_GetFreeGuildID() { return(GUILD_NONE); } - char errbuf[MYSQL_ERRMSG_SIZE]; - char query[100]; - MYSQL_RES *result; - + std::string query; //this has got to be one of the more retarded things I have seen. //none the less, im too lazy to rewrite it right now. + //possibly: + // + // SELECT t1.id + 1 + // FROM guilds t1 + // WHERE NOT EXISTS ( + // SELECT * + // FROM guilds t2 + // WHERE t2.id = t1.id + 1 + // ) + // LIMIT 1 + // + // Seems likely what we should be doing is auto incrementing the guild table + // inserting, then getting the id. NOT getting a free id then inserting. + // could be a race condition. - uint16 x; - for (x = 1; x < MAX_NUMBER_GUILDS; x++) { - snprintf(query, 100, "SELECT id FROM guilds where id=%i;", x); + for (auto index = 1; index < MAX_NUMBER_GUILDS; ++index) + { + query = StringFormat("SELECT id FROM guilds where id=%i;", index); + auto results = m_db->QueryDatabase(query); - if (m_db->RunQuery(query, strlen(query), errbuf, &result)) { - if (mysql_num_rows(result) == 0) { - mysql_free_result(result); - _log(GUILDS__DB, "Located free guild ID %d in the database", x); - return x; - } - mysql_free_result(result); + if (!results.Success()) + { + LogFile->write(EQEMuLog::Error, "Error in _GetFreeGuildID query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + continue; } - else { - LogFile->write(EQEMuLog::Error, "Error in _GetFreeGuildID query '%s': %s", query, errbuf); + + if (results.RowCount() == 0) + { + _log(GUILDS__DB, "Located free guild ID %d in the database", index); + return index; } } From cca9ddab4318b36d174087429398232229398ce5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:19:56 -0700 Subject: [PATCH 005/217] _RunQuery renamed QueryWithLogging --- common/guild_base.cpp | 18 +++++++++--------- common/guild_base.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 792f2e799..3edbaf69c 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -541,19 +541,19 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { char *query = 0; //clear out old `guilds` entry - _RunQuery(query, MakeAnyLenString(&query, + QueryWithLogging(query, MakeAnyLenString(&query, "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id), "clearing old guild record"); //clear out old `guild_ranks` entries - _RunQuery(query, MakeAnyLenString(&query, + QueryWithLogging(query, MakeAnyLenString(&query, "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), "clearing old guild_ranks records"); //clear out people belonging to this guild. - _RunQuery(query, MakeAnyLenString(&query, + QueryWithLogging(query, MakeAnyLenString(&query, "DELETE FROM guild_members WHERE guild_id=%lu", (unsigned long)guild_id), "clearing chars in guild"); // Delete the guild bank - _RunQuery(query, MakeAnyLenString(&query, + QueryWithLogging(query, MakeAnyLenString(&query, "DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id), "deleting guild bank"); _log(GUILDS__DB, "Deleted guild %d from the database.", guild_id); @@ -806,14 +806,14 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { bool BaseGuildManager::DBSetGuildRank(uint32 charid, uint8 rank) { char *query = 0; - return(_RunQuery(query, MakeAnyLenString(&query, + return(QueryWithLogging(query, MakeAnyLenString(&query, "UPDATE guild_members SET rank=%d WHERE char_id=%d", rank, charid), "setting a guild member's rank")); } bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) { char *query = 0; - return(_RunQuery(query, MakeAnyLenString(&query, + return(QueryWithLogging(query, MakeAnyLenString(&query, "UPDATE guild_members SET banker=%d WHERE char_id=%d", is_banker?1:0, charid), "setting a guild member's banker flag")); } @@ -855,7 +855,7 @@ bool BaseGuildManager::DBSetAltFlag(uint32 charid, bool is_alt) { char *query = 0; - return(_RunQuery(query, MakeAnyLenString(&query, + return(QueryWithLogging(query, MakeAnyLenString(&query, "UPDATE guild_members SET alt=%d WHERE char_id=%d", is_alt?1:0, charid), "setting a guild member's alt flag")); } @@ -895,7 +895,7 @@ bool BaseGuildManager::GetAltFlag(uint32 CharID) bool BaseGuildManager::DBSetTributeFlag(uint32 charid, bool enabled) { char *query = 0; - return(_RunQuery(query, MakeAnyLenString(&query, + return(QueryWithLogging(query, MakeAnyLenString(&query, "UPDATE guild_members SET tribute_enable=%d WHERE char_id=%d", enabled?1:0, charid), "setting a guild member's tribute flag")); } @@ -930,7 +930,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { return(true); } -bool BaseGuildManager::_RunQuery(char *&query, int len, const char *errmsg) { +bool BaseGuildManager::QueryWithLogging(char *&query, int len, const char *errmsg) { if(m_db == nullptr) return(false); diff --git a/common/guild_base.h b/common/guild_base.h index f27afb3d0..1e856ede9 100644 --- a/common/guild_base.h +++ b/common/guild_base.h @@ -108,7 +108,7 @@ protected: bool DBSetAltFlag(uint32 charid, bool is_alt); bool DBSetTributeFlag(uint32 charid, bool enabled); bool DBSetPublicNote(uint32 charid, const char *note); - bool _RunQuery(char *&query, int len, const char *errmsg); + bool QueryWithLogging(char *&query, int len, const char *errmsg); // void DBSetPublicNote(uint32 guild_id,char* charname, char* note); bool LocalDeleteGuild(uint32 guild_id); From 8a44271b2f9a5427608d45dee290324f13671b92 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:22:05 -0700 Subject: [PATCH 006/217] QueryWithLogging converted to QueryDatabase --- common/guild_base.cpp | 10 ++++------ common/guild_base.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 3edbaf69c..d9f72d595 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -930,19 +930,17 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { return(true); } -bool BaseGuildManager::QueryWithLogging(char *&query, int len, const char *errmsg) { +bool BaseGuildManager::QueryWithLogging(std::string query, int len, const char *errmsg) { if(m_db == nullptr) return(false); - char errbuf[MYSQL_ERRMSG_SIZE]; + auto results = m_db->QueryDatabase(query); - if (!m_db->RunQuery(query, len, errbuf)) + if (!results.Success()) { - _log(GUILDS__ERROR, "Error %s: '%s': %s", errmsg, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error %s: '%s': %s", errmsg, query.c_str(), results.ErrorMessage().c_str()); return(false); } - safe_delete_array(query); return(true); } diff --git a/common/guild_base.h b/common/guild_base.h index 1e856ede9..787e1d0c9 100644 --- a/common/guild_base.h +++ b/common/guild_base.h @@ -108,7 +108,7 @@ protected: bool DBSetAltFlag(uint32 charid, bool is_alt); bool DBSetTributeFlag(uint32 charid, bool enabled); bool DBSetPublicNote(uint32 charid, const char *note); - bool QueryWithLogging(char *&query, int len, const char *errmsg); + bool QueryWithLogging(std::string query, int len, const char *errmsg); // void DBSetPublicNote(uint32 guild_id,char* charname, char* note); bool LocalDeleteGuild(uint32 guild_id); From 94110dbe52b9a0ed00e6a780ac10784f35ca3928 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:24:21 -0700 Subject: [PATCH 007/217] removed len from QueryWithLogging --- common/guild_base.cpp | 2 +- common/guild_base.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index d9f72d595..2e67eb88d 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -930,7 +930,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { return(true); } -bool BaseGuildManager::QueryWithLogging(std::string query, int len, const char *errmsg) { +bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { if(m_db == nullptr) return(false); diff --git a/common/guild_base.h b/common/guild_base.h index 787e1d0c9..652db0bc8 100644 --- a/common/guild_base.h +++ b/common/guild_base.h @@ -108,7 +108,7 @@ protected: bool DBSetAltFlag(uint32 charid, bool is_alt); bool DBSetTributeFlag(uint32 charid, bool enabled); bool DBSetPublicNote(uint32 charid, const char *note); - bool QueryWithLogging(std::string query, int len, const char *errmsg); + bool QueryWithLogging(std::string query, const char *errmsg); // void DBSetPublicNote(uint32 guild_id,char* charname, char* note); bool LocalDeleteGuild(uint32 guild_id); From 3856f7f1e54e3fada4638636abad660fe6fa1072 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:27:00 -0700 Subject: [PATCH 008/217] DBDeleteGuild converted to QueryDatabase --- common/guild_base.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 2e67eb88d..c40cc4fea 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -538,23 +538,21 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { return(false); } - char *query = 0; - //clear out old `guilds` entry - QueryWithLogging(query, MakeAnyLenString(&query, - "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id), "clearing old guild record"); + std::string query = StringFormat("DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id); + QueryWithLogging(query, "clearing old guild record"); //clear out old `guild_ranks` entries - QueryWithLogging(query, MakeAnyLenString(&query, - "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id), "clearing old guild_ranks records"); + query = StringFormat("DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id); + QueryWithLogging(query, "clearing old guild_ranks records"); //clear out people belonging to this guild. - QueryWithLogging(query, MakeAnyLenString(&query, - "DELETE FROM guild_members WHERE guild_id=%lu", (unsigned long)guild_id), "clearing chars in guild"); + query = StringFormat("DELETE FROM guild_members WHERE guild_id=%lu", (unsigned long)guild_id); + QueryWithLogging(query, "clearing chars in guild"); // Delete the guild bank - QueryWithLogging(query, MakeAnyLenString(&query, - "DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id), "deleting guild bank"); + query = StringFormat("DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id); + QueryWithLogging(query, "deleting guild bank"); _log(GUILDS__DB, "Deleted guild %d from the database.", guild_id); @@ -930,7 +928,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { return(true); } -bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { +bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { if(m_db == nullptr) return(false); From 1734641d12af824aa5bcccc83efe5c4e75f9641d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:30:26 -0700 Subject: [PATCH 009/217] DBRenameGuild converted to QueryDatabase --- common/guild_base.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index c40cc4fea..94a8d8794 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -562,41 +562,37 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { if(m_db == nullptr) { _log(GUILDS__DB, "Requested to rename guild %d when we have no database object.", guild_id); - return(false); + return false; } std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) - return(false); + return false; GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //escape our strings. uint32 len = strlen(name); char *esc = new char[len*2+1]; m_db->DoEscapeString(esc, name, len); //insert the new `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "UPDATE guilds SET name='%s' WHERE id=%d", - esc, guild_id), errbuf)) + std::string query = StringFormat("UPDATE guilds SET name='%s' WHERE id=%d", esc, guild_id); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error renaming guild %d '%s': %s", guild_id, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), results.Success()); safe_delete_array(esc); - return(false); + return false; } - safe_delete_array(query); safe_delete_array(esc); _log(GUILDS__DB, "Renamed guild %s (%d) to %s in database.", info->name.c_str(), guild_id, name); info->name = name; //update our local record. - return(true); + return true; } bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { From 9eec8f37f5720fa905910ef8100829228abd3ef8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:31:56 -0700 Subject: [PATCH 010/217] DBSetGuildRank converted to non len QueryWithLogging --- common/guild_base.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 94a8d8794..654c3d003 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -799,10 +799,8 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { } bool BaseGuildManager::DBSetGuildRank(uint32 charid, uint8 rank) { - char *query = 0; - return(QueryWithLogging(query, MakeAnyLenString(&query, - "UPDATE guild_members SET rank=%d WHERE char_id=%d", - rank, charid), "setting a guild member's rank")); + std::string query = StringFormat("UPDATE guild_members SET rank=%d WHERE char_id=%d", rank, charid); + return(QueryWithLogging(query, "setting a guild member's rank")); } bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) { From 941f1cc3956b4503b8bfee46101091d4efbc7872 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:32:56 -0700 Subject: [PATCH 011/217] DBSetBankerFlag converted to non len QueryWithLogging --- common/guild_base.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 654c3d003..35a440f63 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -804,10 +804,9 @@ bool BaseGuildManager::DBSetGuildRank(uint32 charid, uint8 rank) { } bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) { - char *query = 0; - return(QueryWithLogging(query, MakeAnyLenString(&query, - "UPDATE guild_members SET banker=%d WHERE char_id=%d", - is_banker?1:0, charid), "setting a guild member's banker flag")); + std::string query = StringFormat("UPDATE guild_members SET banker=%d WHERE char_id=%d", + is_banker? 1: 0, charid); + return(QueryWithLogging(query, "setting a guild member's banker flag")); } bool BaseGuildManager::GetBankerFlag(uint32 CharID) From 34a56f75cfbad6989515115f740d561cf06d2636 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:34:30 -0700 Subject: [PATCH 012/217] DBSetAltFlag converted to non len QueryWithLogging --- common/guild_base.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 35a440f63..550200db3 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -844,11 +844,10 @@ bool BaseGuildManager::GetBankerFlag(uint32 CharID) bool BaseGuildManager::DBSetAltFlag(uint32 charid, bool is_alt) { - char *query = 0; + std::string query = StringFormat("UPDATE guild_members SET alt=%d WHERE char_id=%d", + is_alt ? 1: 0, charid); - return(QueryWithLogging(query, MakeAnyLenString(&query, - "UPDATE guild_members SET alt=%d WHERE char_id=%d", - is_alt?1:0, charid), "setting a guild member's alt flag")); + return(QueryWithLogging(query, "setting a guild member's alt flag")); } bool BaseGuildManager::GetAltFlag(uint32 CharID) From 80cc6e4ef37dd683464c5dbcb1515a2f7ad96834 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:35:37 -0700 Subject: [PATCH 013/217] DBSetTributeFlag converted to non len QueryWithLogging --- common/guild_base.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 550200db3..6de774d87 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -884,10 +884,9 @@ bool BaseGuildManager::GetAltFlag(uint32 CharID) } bool BaseGuildManager::DBSetTributeFlag(uint32 charid, bool enabled) { - char *query = 0; - return(QueryWithLogging(query, MakeAnyLenString(&query, - "UPDATE guild_members SET tribute_enable=%d WHERE char_id=%d", - enabled?1:0, charid), "setting a guild member's tribute flag")); + std::string query = StringFormat("UPDATE guild_members SET tribute_enable=%d WHERE char_id=%d", + enabled ? 1: 0, charid); + return(QueryWithLogging(query, "setting a guild member's tribute flag")); } bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { From 9e5fdc50d9f18e71a33d21a67c58c346f5be2b95 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:43:45 -0700 Subject: [PATCH 014/217] DBSetGuildLeader converted to QueryDatabase --- common/guild_base.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 6de774d87..7c5b14ae5 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -598,41 +598,37 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { if(m_db == nullptr) { _log(GUILDS__DB, "Requested to set the leader for guild %d when we have no database object.", guild_id); - return(false); + return false; } std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) - return(false); + return false; GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //insert the new `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "UPDATE guilds SET leader='%d' WHERE id=%d", - leader, guild_id), errbuf)) + std::string query = StringFormat("UPDATE guilds SET leader='%d' WHERE id=%d",leader, guild_id); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query, errbuf); - safe_delete_array(query); - return(false); + _log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); //set the old leader to officer if(!DBSetGuildRank(info->leader_char_id, GUILD_OFFICER)) - return(false); + return false; //set the new leader to leader if(!DBSetGuildRank(leader, GUILD_LEADER)) - return(false); + return false; _log(GUILDS__DB, "Set guild leader for guild %d to %d in the database", guild_id, leader); info->leader_char_id = leader; //update our local record. - return(true); + return true; } bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) { From dd06ecf99b67d722616a75164164af85dc2d43c4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:46:03 -0700 Subject: [PATCH 015/217] DBSetGuildMOTD converted to QueryDatabase --- common/guild_base.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 7c5b14ae5..45b77e0e6 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -643,9 +643,6 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c return(false); GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //escape our strings. uint32 len = strlen(motd); uint32 len2 = strlen(setter); @@ -655,17 +652,16 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c m_db->DoEscapeString(esc_set, setter, len2); //insert the new `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "UPDATE guilds SET motd='%s',motd_setter='%s' WHERE id=%d", - esc, esc_set, guild_id), errbuf)) + std::string query = StringFormat("UPDATE guilds SET motd='%s',motd_setter='%s' WHERE id=%d", esc, esc_set, guild_id); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str()); safe_delete_array(esc); safe_delete_array(esc_set); - return(false); + return false; } - safe_delete_array(query); safe_delete_array(esc); safe_delete_array(esc_set); @@ -674,7 +670,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c info->motd = motd; //update our local record. info->motd_setter = setter; //update our local record. - return(true); + return true; } bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL) From a701541fceb7df5b7aa5874257a440fac5070352 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:48:01 -0700 Subject: [PATCH 016/217] DBSetGuildURL converted to QueryDatabase --- common/guild_base.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 45b77e0e6..9be8b797e 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -676,42 +676,35 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL) { if(m_db == nullptr) - return(false); - - std::map::const_iterator res; - - res = m_guilds.find(GuildID); + return false; + auto res = m_guilds.find(GuildID); if(res == m_guilds.end()) - return(false); + return false; GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //escape our strings. uint32 len = strlen(URL); - char *esc = new char[len*2+1]; - m_db->DoEscapeString(esc, URL, len); - if (!m_db->RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET url='%s' WHERE id=%d", esc, GuildID), errbuf)) + std::string query = StringFormat("UPDATE guilds SET url='%s' WHERE id=%d", esc, GuildID); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error setting URL for guild %d '%s': %s", GuildID, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error setting URL for guild %d '%s': %s", GuildID, query.c_str(), results.ErrorMessage().c_str()); safe_delete_array(esc); return(false); } - safe_delete_array(query); safe_delete_array(esc); _log(GUILDS__DB, "Set URL for guild %d in the database", GuildID); info->url = URL; //update our local record. - return(true); + return true; } bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) From 553d12412b717064eaebbdefce1a3d36fd784b16 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:50:10 -0700 Subject: [PATCH 017/217] DBSetGuildChannel converted to QueryDatabase --- common/guild_base.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 9be8b797e..d87c1714f 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -712,33 +712,27 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) if(m_db == nullptr) return(false); - std::map::const_iterator res; - - res = m_guilds.find(GuildID); + auto res = m_guilds.find(GuildID); if(res == m_guilds.end()) return(false); GuildInfo *info = res->second; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //escape our strings. uint32 len = strlen(Channel); - char *esc = new char[len*2+1]; - m_db->DoEscapeString(esc, Channel, len); - if (!m_db->RunQuery(query, MakeAnyLenString(&query, "UPDATE guilds SET channel='%s' WHERE id=%d", esc, GuildID), errbuf)) + std::string query = StringFormat("UPDATE guilds SET channel='%s' WHERE id=%d", esc, GuildID); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { - _log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), results.ErrorMessage().c_str()); safe_delete_array(esc); return(false); } - safe_delete_array(query); safe_delete_array(esc); _log(GUILDS__DB, "Set Channel for guild %d in the database", GuildID); From c7e2d3b355b1aa238787e1f51cc7410942591cd6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 11:57:18 -0700 Subject: [PATCH 018/217] DBSetGuild converted to QueryDatabase --- common/guild_base.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index d87c1714f..35f2f32f4 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -748,33 +748,28 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { return(false); } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + std::string query; if(guild_id != GUILD_NONE) { - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)", - charid, guild_id, rank), errbuf)) - { - _log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query, errbuf); - safe_delete_array(query); - return(false); + query = StringFormat("REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)", charid, guild_id, rank); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) { + _log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query.c_str(), results.ErrorMessage().c_str()); + return false; } + } else { - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM guild_members WHERE char_id=%d", - charid), errbuf)) + query = StringFormat("DELETE FROM guild_members WHERE char_id=%d", charid); + auto results = m_db->QueryDatabase(query); + if (!results.Success()) { - _log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query, errbuf); - safe_delete_array(query); - return(false); + _log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query.c_str(), results.ErrorMessage().c_str()); + return false; } - } - safe_delete_array(query); - + } _log(GUILDS__DB, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank); - - return(true); + return true; } bool BaseGuildManager::DBSetGuildRank(uint32 charid, uint8 rank) { From 364f133ffdce6dc94e53cda0c1fc28163d688657 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:01:39 -0700 Subject: [PATCH 019/217] GetBankerFlag converted to QueryDatabase --- common/guild_base.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 35f2f32f4..cb0e55ec6 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -785,34 +785,24 @@ bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) { bool BaseGuildManager::GetBankerFlag(uint32 CharID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(!m_db) return false; - if(!m_db->RunQuery(query, MakeAnyLenString(&query, "select `banker` from `guild_members` where char_id=%i LIMIT 1", CharID), errbuf, &result)) + std::string query = StringFormat("select `banker` from `guild_members` where char_id=%i LIMIT 1", CharID); + auto results = m_db->QueryDatabase(query); + if(!results.Success()) { - _log(GUILDS__ERROR, "Error retrieving banker flag '%s': %s", query, errbuf); - - safe_delete_array(query); - + _log(GUILDS__ERROR, "Error retrieving banker flag '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - if(mysql_num_rows(result) != 1) + if(results.RowCount() != 1) return false; - row = mysql_fetch_row(result); + auto row = results.begin(); bool IsBanker = atoi(row[0]); - mysql_free_result(result); - return IsBanker; } From df705e34add7f12c89bb0e3b0eaf5fd95a9880d8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:04:38 -0700 Subject: [PATCH 020/217] GetAltFlag converted to QueryDatabase --- common/guild_base.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index cb0e55ec6..3ece39699 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -816,34 +816,24 @@ bool BaseGuildManager::DBSetAltFlag(uint32 charid, bool is_alt) bool BaseGuildManager::GetAltFlag(uint32 CharID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(!m_db) + if(!m_db) return false; - if(!m_db->RunQuery(query, MakeAnyLenString(&query, "select `alt` from `guild_members` where char_id=%i LIMIT 1", CharID), errbuf, &result)) + std::string query = StringFormat("SELECT `alt` FROM `guild_members` WHERE char_id=%i LIMIT 1", CharID); + auto results = m_db->QueryDatabase(query); + if(!results.Success()) { - _log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query, errbuf); - - safe_delete_array(query); - + _log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - if(mysql_num_rows(result) != 1) + if(results.RowCount() != 1) return false; - row = mysql_fetch_row(result); + auto row = results.begin(); bool IsAlt = atoi(row[0]); - mysql_free_result(result); - return IsAlt; } From f292cbc3e7d82dbbe5f42b89e1ae2ee3b803a444 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:07:43 -0700 Subject: [PATCH 021/217] DBSetPublicNote converted to QueryDatabase --- common/guild_base.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 3ece39699..f27332716 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -847,30 +847,25 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { if(m_db == nullptr) return(false); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - //escape our strings. uint32 len = strlen(note); char *esc = new char[len*2+1]; m_db->DoEscapeString(esc, note, len); //insert the new `guilds` entry - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - "UPDATE guild_members SET public_note='%s' WHERE char_id=%d", - esc, charid), errbuf)) - { - _log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query, errbuf); - safe_delete_array(query); - safe_delete_array(esc); - return(false); - } - safe_delete_array(query); + std::string query = StringFormat("UPDATE guild_members SET public_note='%s' WHERE char_id=%d", esc, charid); safe_delete_array(esc); + auto results = m_db->QueryDatabase(query); + + if (!results.Success()) + { + _log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), results.ErrorMessage().c_str()); + return false; + } _log(GUILDS__DB, "Set public not for char %d", charid); - return(true); + return true; } bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { From b2ca66267ee0debdd80533752ae3385e9989b9b1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:13:27 -0700 Subject: [PATCH 022/217] DoesAccountContainAGuildLeader converted to QueryDatabase --- common/guild_base.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index f27332716..7521735d5 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -1261,25 +1261,17 @@ BaseGuildManager::GuildInfo::GuildInfo() { uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - - if (!m_db->RunQuery(query, - MakeAnyLenString(&query, - "select guild_id from guild_members where char_id in (select id from character_ where account_id = %i) and rank = 2", - AccountID), errbuf, &result)) + std::string query = StringFormat("SELECT guild_id FROM guild_members WHERE char_id IN " + "(SELECT id FROM character_ WHERE account_id = %i) AND rank = 2", + AccountID); + auto results = m_db->QueryDatabase(query); + if (!results.Success()) { - _log(GUILDS__ERROR, "Error executing query '%s': %s", query, errbuf); - safe_delete_array(query); + _log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return 0; } - safe_delete_array(query); - uint32 Rows = mysql_num_rows(result); - mysql_free_result(result); - - return Rows; + return results.RowCount(); } From 449d5f9358b3171114becb8fc826792f9757c912 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:13:56 -0700 Subject: [PATCH 023/217] Removed large commented out section --- common/guild_base.cpp | 225 ------------------------------------------ 1 file changed, 225 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 7521735d5..b14ce2fd6 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -1275,230 +1275,5 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID) } -/* - -bool Database::LoadGuilds(GuildRanks_Struct* guilds) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - // int i; - MYSQL_RES *result; - MYSQL_ROW row; - - for (int a = 0; a < 512; a++) { - guilds[a].leader = 0; - guilds[a].databaseID = 0; - memset(guilds[a].name, 0, sizeof(guilds[a].name)); - for (int i = 0; i <= GUILD_MAX_RANK; i++) { - snprintf(guilds[a].rank[i].rankname, 100, "Guild Rank %i", i); - if (i == 0) { - guilds[a].rank[i].heargu = 1; - guilds[a].rank[i].speakgu = 1; - guilds[a].rank[i].invite = 1; - guilds[a].rank[i].remove = 1; - guilds[a].rank[i].promote = 1; - guilds[a].rank[i].demote = 1; - guilds[a].rank[i].motd = 1; - guilds[a].rank[i].warpeace = 1; - } - else { - guilds[a].rank[i].heargu = 0; - guilds[a].rank[i].speakgu = 0; - guilds[a].rank[i].invite = 0; - guilds[a].rank[i].remove = 0; - guilds[a].rank[i].promote = 0; - guilds[a].rank[i].demote = 0; - guilds[a].rank[i].motd = 0; - guilds[a].rank[i].warpeace = 0; - } - } - Sleep(0); - } - - - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title from guilds"), errbuf, &result)) { - - safe_delete_array(query); - uint32 guildeqid = 0xFFFFFFFF; - while ((row = mysql_fetch_row(result))) { - guildeqid = atoi(row[1]); - if (guildeqid < 512) { - guilds[guildeqid].leader = atoi(row[3]); - guilds[guildeqid].databaseID = atoi(row[0]); - guilds[guildeqid].minstatus = atoi(row[4]); - strcpy(guilds[guildeqid].name, row[2]); - for (int i = 0; i <= GUILD_MAX_RANK; i++) { - strcpy(guilds[guildeqid].rank[i].rankname, row[5 + (i*2)]); - if (i == 0) { - guilds[guildeqid].rank[i].heargu = 1; - guilds[guildeqid].rank[i].speakgu = 1; - guilds[guildeqid].rank[i].invite = 1; - guilds[guildeqid].rank[i].remove = 1; - guilds[guildeqid].rank[i].promote = 1; - guilds[guildeqid].rank[i].demote = 1; - guilds[guildeqid].rank[i].motd = 1; - guilds[guildeqid].rank[i].warpeace = 1; - } - else if (strlen(row[4 + (i*2)]) >= 8) { - guilds[guildeqid].rank[i].heargu = (row[4 + (i*2)][GUILD_HEAR] == '1'); - guilds[guildeqid].rank[i].speakgu = (row[4 + (i*2)][GUILD_SPEAK] == '1'); - guilds[guildeqid].rank[i].invite = (row[4 + (i*2)][GUILD_INVITE] == '1'); - guilds[guildeqid].rank[i].remove = (row[4 + (i*2)][GUILD_REMOVE] == '1'); - guilds[guildeqid].rank[i].promote = (row[4 + (i*2)][GUILD_PROMOTE] == '1'); - guilds[guildeqid].rank[i].demote = (row[4 + (i*2)][GUILD_DEMOTE] == '1'); - guilds[guildeqid].rank[i].motd = (row[4 + (i*2)][GUILD_MOTD] == '1'); - guilds[guildeqid].rank[i].warpeace = (row[4 + (i*2)][GUILD_WARPEACE] == '1'); - } - else { - - guilds[guildeqid].rank[i].heargu = 1; - guilds[guildeqid].rank[i].speakgu = 1; - guilds[guildeqid].rank[i].invite = 0; - - guilds[guildeqid].rank[i].remove = 0; - guilds[guildeqid].rank[i].promote = 0; - guilds[guildeqid].rank[i].demote = 0; - guilds[guildeqid].rank[i].motd = 0; - guilds[guildeqid].rank[i].warpeace = 0; - } - - if (guilds[guildeqid].rank[i].rankname[0] == 0) - snprintf(guilds[guildeqid].rank[i].rankname, 100, "Guild Rank %i", i); - } - } - Sleep(0); - } - mysql_free_result(result); - return true; - } - else - { - cerr << "Error in LoadGuilds query '" << query << "' " << errbuf << endl; - safe_delete_array(query); - return false; - } - - return false; -} - - -void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - char* notebuf = new char[(strlen(note)*2)+3]; - DoEscapeString(notebuf, note, strlen(note)) ; - if (!RunQuery(query, MakeAnyLenString(&query, "update character_ set publicnote='%s' where name='%s' and guild=%i", notebuf,charname,guild_id), errbuf)) { - cerr << "Error running SetPublicNote query: " << errbuf << endl; - } - safe_delete_array(query); - safe_delete_array(notebuf); -} - - - -bool Database::GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title from guilds where eqid=%i;", guildeqid), errbuf, &result)) - { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - gr->leader = atoi(row[3]); - gr->databaseID = atoi(row[0]); - gr->minstatus = atoi(row[4]); - strcpy(gr->name, row[2]); - for (int i = 0; i <= GUILD_MAX_RANK; i++) { - strcpy(gr->rank[i].rankname, row[5 + (i*2)]); - if (i == 0) { - gr->rank[i].heargu = 1; - gr->rank[i].speakgu = 1; - gr->rank[i].invite = 1; - gr->rank[i].remove = 1; - gr->rank[i].promote = 1; - gr->rank[i].demote = 1; - gr->rank[i].motd = 1; - gr->rank[i].warpeace = 1; - } - else if (strlen(row[4 + (i*2)]) >= 8) { - gr->rank[i].heargu = (row[4 + (i*2)][GUILD_HEAR] == '1'); - gr->rank[i].speakgu = (row[4 + (i*2)][GUILD_SPEAK] == '1'); - gr->rank[i].invite = (row[4 + (i*2)][GUILD_INVITE] == '1'); - gr->rank[i].remove = (row[4 + (i*2)][GUILD_REMOVE] == '1'); - gr->rank[i].promote = (row[4 + (i*2)][GUILD_PROMOTE] == '1'); - gr->rank[i].demote = (row[4 + (i*2)][GUILD_DEMOTE] == '1'); - gr->rank[i].motd = (row[4 + (i*2)][GUILD_MOTD] == '1'); - gr->rank[i].warpeace = (row[4 + (i*2)][GUILD_WARPEACE] == '1'); - } - else { - gr->rank[i].heargu = 1; - gr->rank[i].speakgu = 1; - gr->rank[i].invite = 0; - gr->rank[i].remove = 0; - gr->rank[i].promote = 0; - gr->rank[i].demote = 0; - gr->rank[i].motd = 0; - gr->rank[i].warpeace = 0; - } - - if (gr->rank[i].rankname[0] == 0) - snprintf(gr->rank[i].rankname, 100, "Guild Rank %i", i); - } - } - else { - gr->leader = 0; - gr->databaseID = 0; - gr->minstatus = 0; - memset(gr->name, 0, sizeof(gr->name)); - for (int i = 0; i <= GUILD_MAX_RANK; i++) { - snprintf(gr->rank[i].rankname, 100, "Guild Rank %i", i); - if (i == 0) { - gr->rank[i].heargu = 1; - gr->rank[i].speakgu = 1; - gr->rank[i].invite = 1; - gr->rank[i].remove = 1; - gr->rank[i].promote = 1; - gr->rank[i].demote = 1; - gr->rank[i].motd = 1; - gr->rank[i].warpeace = 1; - } - else { - gr->rank[i].heargu = 0; - gr->rank[i].speakgu = 0; - gr->rank[i].invite = 0; - gr->rank[i].remove = 0; - gr->rank[i].promote = 0; - gr->rank[i].demote = 0; - gr->rank[i].motd = 0; - - gr->rank[i].warpeace = 0; - } - } - } - mysql_free_result(result); - return true; - } - else { - cerr << "Error in GetGuildRank query '" << query << "' " << errbuf << endl; - safe_delete_array(query); - return false; - } - - return false; -} - - - - - - - -*/ - - - - From 76f727b7ff1ce68560ffa35be8fe8cb39b27d6d9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:21:05 -0700 Subject: [PATCH 024/217] ProcessGuildMember converted to use MySQLRequestRow --- common/guild_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index b14ce2fd6..023330e6b 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -897,7 +897,7 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { " g.banker,g.public_note,g.alt " \ " FROM character_ AS c LEFT JOIN guild_members AS g ON c.id=g.char_id " #endif -static void ProcessGuildMember(MYSQL_ROW &row, CharGuildInfo &into) { +static void ProcessGuildMember(MySQLRequestRow row, CharGuildInfo &into) { //fields from `characer_` into.char_id = atoi(row[0]); into.char_name = row[1]; From ea0c8f86fee102ec8135cbc3ed979b2bb909b13e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:21:57 -0700 Subject: [PATCH 025/217] GetEntireGuild converted to QueryDatabase --- common/guild_base.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 023330e6b..55efab95e 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -930,31 +930,23 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vectorRunQuery(query, MakeAnyLenString(&query, - GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id - ), errbuf, &result)) { - _log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); + std::string query = StringFormat(GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id); + auto results = m_db->QueryDatabase(query); + if (!results.Success()) { + _log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) { + for (auto row = results.begin(); row != results.end(); ++row) { CharGuildInfo *ci = new CharGuildInfo; ProcessGuildMember(row, *ci); members.push_back(ci); } - mysql_free_result(result); _log(GUILDS__DB, "Retreived entire guild member list for guild %d from the database", guild_id); - return(true); + return true; } bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) { From 845ed720b3c93cc7c15fe740619cc7d64ec98646 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:27:08 -0700 Subject: [PATCH 026/217] GetCharInfo converted to QueryDatabase --- common/guild_base.cpp | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 55efab95e..a14cdb3f8 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -955,38 +955,28 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) { return(false); } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - //escape our strings. uint32 nl = strlen(char_name); char *esc = new char[nl*2+1]; m_db->DoEscapeString(esc, char_name, nl); //load up the rank info for each guild. - if (!m_db->RunQuery(query, MakeAnyLenString(&query, - GuildMemberBaseQuery " WHERE c.name='%s'", esc - ), errbuf, &result)) { - _log(GUILDS__ERROR, "Error loading guild member '%s': %s", query, errbuf); - safe_delete_array(query); - safe_delete_array(esc); - return(false); + std::string query = StringFormat(GuildMemberBaseQuery " WHERE c.name='%s'", esc); + safe_delete_array(esc); + auto results = m_db->QueryDatabase(query); + if (!results.Success()) { + _log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - safe_delete_array(esc); - bool ret = true; - if ((row = mysql_fetch_row(result))) { - ProcessGuildMember(row, into); - _log(GUILDS__DB, "Retreived guild member info for char %s from the database", char_name); - } else { - ret = true; - } - mysql_free_result(result); + if (results.RowCount() == 0) + return false; - return(ret); + auto row = results.begin(); + ProcessGuildMember(row, into); + _log(GUILDS__DB, "Retreived guild member info for char %s from the database", char_name); + + return true; } From 327fa3823287fd8df4e6b142d20752b8c0d04897 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 17 Aug 2014 12:30:53 -0700 Subject: [PATCH 027/217] GetCharInfo converted to QueryDatabase --- common/guild_base.cpp | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index a14cdb3f8..717cb49c3 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -984,38 +984,30 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) { bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) { if(m_db == nullptr) { _log(GUILDS__DB, "Requested char info on %d when we have no database object.", char_id); - return(false); + return false; } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - //load up the rank info for each guild. - if (!m_db->RunQuery(query, MakeAnyLenString(&query, + std::string query; #ifdef BOTS - GuildMemberBaseQuery " WHERE c.id=%d AND c.mobtype = 'C'", char_id + query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.mobtype = 'C'", char_id); #else - GuildMemberBaseQuery " WHERE c.id=%d", char_id + query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d", char_id); #endif - ), errbuf, &result)) { - _log(GUILDS__ERROR, "Error loading guild member '%s': %s", query, errbuf); - safe_delete_array(query); - return(false); + auto results = m_db->QueryDatabase(query); + if (!results.Success()) { + _log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - safe_delete_array(query); - bool ret = true; - if ((row = mysql_fetch_row(result))) { - ProcessGuildMember(row, into); - _log(GUILDS__DB, "Retreived guild member info for char %d", char_id); - } else { - ret = true; - } - mysql_free_result(result); + if (results.RowCount() == 0) + return false; - return(ret); + auto row = results.begin(); + ProcessGuildMember(row, into); + _log(GUILDS__DB, "Retreived guild member info for char %d", char_id); + + return true; } From fd8dc1214c0f0c46362cba3fd403b1138a202fcb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 12:28:21 -0700 Subject: [PATCH 028/217] Load converted to QueryDatabase --- common/ptimer.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 8e9f03dcf..bfca79452 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -127,41 +127,31 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_star } bool PersistentTimer::Load(Database *db) { - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - char *query = 0; - uint32 qlen = 0; - uint32 qcount = 0; - - qlen = MakeAnyLenString(&query, "SELECT start,duration,enable " - " FROM timers WHERE char_id=%lu AND type=%u", (unsigned long)_char_id, _type); #ifdef DEBUG_PTIMERS printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type); #endif - - if (!db->RunQuery(query, qlen, errbuf, &result)) { - safe_delete_array(query); + std::string query = StringFormat("SELECT start, duration, enable " + "FROM timers WHERE char_id=%lu AND type=%u", + (unsigned long)_char_id, _type); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - bool res = false; - qcount = mysql_num_rows(result); - if(qcount == 1 && (row = mysql_fetch_row(result)) ) { - start_time = strtoul(row[0], nullptr, 10); - timer_time = strtoul(row[1], nullptr, 10); - enabled = (row[2][0] == '1'); + if (results.RowCount() != 1) + return false; - res = true; - } - mysql_free_result(result); + auto row = results.begin(); - return(res); + start_time = strtoul(row[0], nullptr, 10); + timer_time = strtoul(row[1], nullptr, 10); + enabled = (row[2][0] == '1'); + + return true; } bool PersistentTimer::Store(Database *db) { From e360ba520931a2e44428b427459cf615c9630267 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 12:35:16 -0700 Subject: [PATCH 029/217] Store converted to QueryDatabase --- common/ptimer.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index bfca79452..c099832ed 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -156,32 +156,26 @@ bool PersistentTimer::Load(Database *db) { bool PersistentTimer::Store(Database *db) { if(Expired(db, false)) //dont need to store expired timers. - return(true); - - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 qlen = 0; - - qlen = MakeAnyLenString(&query, "REPLACE INTO timers " - " (char_id,type,start,duration,enable) " - " VALUES(%lu,%u,%lu,%lu,%d)", - (unsigned long)_char_id, _type, (unsigned long)start_time, (unsigned long)timer_time, enabled?1:0); + return true; + std::string query = StringFormat("REPLACE INTO timers " + " (char_id, type, start, duration, enable) " + " VALUES (%lu, %u, %lu, %lu, %d)", + (unsigned long)_char_id, _type, (unsigned long)start_time, + (unsigned long)timer_time, enabled ? 1: 0); #ifdef DEBUG_PTIMERS - printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query); + printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query.c_str()); #endif - - if (!db->RunQuery(query, qlen, errbuf)) { - safe_delete_array(query); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - return(true); + return true; } bool PersistentTimer::Clear(Database *db) { From cbed61db7e61e57b912edcbd4000e05b4d528755 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 12:37:33 -0700 Subject: [PATCH 030/217] Clear converted to QueryDatabase --- common/ptimer.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index c099832ed..d8231c4ca 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -179,28 +179,23 @@ bool PersistentTimer::Store(Database *db) { } bool PersistentTimer::Clear(Database *db) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 qlen = 0; - - qlen = MakeAnyLenString(&query, "DELETE FROM timers " - " WHERE char_id=%lu AND type=%u ", - (unsigned long)_char_id, _type); + std::string query = StringFormat("DELETE FROM timers " + "WHERE char_id = %lu AND type = %u ", + (unsigned long)_char_id, _type); #ifdef DEBUG_PTIMERS - printf("Clearing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query); + printf("Clearing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query.c_str()); #endif - if (!db->RunQuery(query, qlen, errbuf)) { - safe_delete_array(query); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - return(true); + return true; } From 3cde8d9af86125a768675463f7627c964d19006a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 12:54:20 -0700 Subject: [PATCH 031/217] Load converted to QueryDatabase --- common/ptimer.cpp | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index d8231c4ca..699dba729 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -279,61 +279,47 @@ PTimerList::~PTimerList() { bool PTimerList::Load(Database *db) { - std::map::iterator s; - s = _list.begin(); - while(s != _list.end()) { - if(s->second != nullptr) - delete s->second; - ++s; - } + + for (auto timerIterator = _list.begin(); timerIterator != _list.end(); ++timerIterator) + if(timerIterator->second != nullptr) + delete timerIterator->second; _list.clear(); - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - char *query = 0; - uint32 qlen = 0; - uint32 qcount = 0; - - qlen = MakeAnyLenString(&query, "SELECT type,start,duration,enable " - " FROM timers WHERE char_id=%lu", (unsigned long)_char_id); - #ifdef DEBUG_PTIMERS printf("Loading all timers for char %lu\n", (unsigned long)_char_id); #endif - - if (!db->RunQuery(query, qlen, errbuf, &result)) { - safe_delete_array(query); + std::string query = StringFormat("SELECT type, start, duration, enable " + "FROM timers WHERE char_id = %lu", + (unsigned long)_char_id); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); pTimerType type; uint32 start_time, timer_time; bool enabled; PersistentTimer *cur; - qcount = mysql_num_rows(result); - while((row = mysql_fetch_row(result)) ) { + + for (auto row = results.begin(); row != results.end(); ++row) { type = atoi(row[0]); start_time = strtoul(row[1], nullptr, 10); timer_time = strtoul(row[2], nullptr, 10); enabled = (row[3][0] == '1'); //if it expired allready, dont bother. - cur = new PersistentTimer(_char_id, type, start_time, timer_time, enabled); if(!cur->Expired(nullptr)) _list[type] = cur; else delete cur; } - mysql_free_result(result); - return(true); + return true; } bool PTimerList::Store(Database *db) { From f052c6004a92ca39d13b5d2cec1e63fe08c66ab7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:12:52 -0700 Subject: [PATCH 032/217] Clear converted to QueryDatabase --- common/ptimer.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 699dba729..4f6996715 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -346,27 +346,19 @@ bool PTimerList::Store(Database *db) { bool PTimerList::Clear(Database *db) { _list.clear(); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 qlen = 0; - - qlen = MakeAnyLenString(&query, "DELETE FROM timers " - " WHERE char_id=%lu ", (unsigned long)_char_id); - + std::string query = StringFormat("DELETE FROM timers WHERE char_id=%lu ", (unsigned long)_char_id); #ifdef DEBUG_PTIMERS - printf("Storing all timers for char %lu: '%s'\n", (unsigned long)_char_id, query); + printf("Storing all timers for char %lu: '%s'\n", (unsigned long)_char_id, query.c_str()); #endif - - if (!db->RunQuery(query, qlen, errbuf)) { - safe_delete_array(query); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - return(true); + return true; } void PTimerList::Start(pTimerType type, uint32 duration) { From 1253fa2a25dd8b21e3b8427fb96ba3ea43e25a72 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:14:46 -0700 Subject: [PATCH 033/217] ClearOffline converted to QueryDatabase --- common/ptimer.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 4f6996715..1e1aa7349 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -436,26 +436,19 @@ void PTimerList::ToVector(std::vector< std::pair } bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 qlen = 0; - qlen = MakeAnyLenString(&query, "DELETE FROM timers WHERE char_id=%lu AND type=%u ",(unsigned long)char_id, type); + std::string query = StringFormat("DELETE FROM timers WHERE char_id=%lu AND type=%u ",(unsigned long)char_id, type); #ifdef DEBUG_PTIMERS - printf("Clearing timer (offline): char %lu of type %u: '%s'\n", (unsigned long)char_id, type, query); + printf("Clearing timer (offline): char %lu of type %u: '%s'\n", (unsigned long)char_id, type, query.c_str()); #endif - - if (!db->RunQuery(query, qlen, errbuf)) { - safe_delete_array(query); + auto results = db->QueryDatabase(query); + if (!results.Success()) { #if EQDEBUG > 5 - LogFile->write(EQEMuLog::Error, "Error in PTimerList::ClearOffline, error: %s", errbuf); + LogFile->write(EQEMuLog::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str()); #endif - return(false); + return false; } - safe_delete_array(query); - - return(true); - + return true; } From 11c327e1d7fbd5c539efc8654303852cce8e9331 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:30:55 -0700 Subject: [PATCH 034/217] ExportSpells converted to QueryDatabase --- client_files/export/main.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index d89976b88..9ff190636 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -32,7 +32,7 @@ void ExportBaseData(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientExport); set_exception_handler(); - + LogFile->write(EQEMuLog::Status, "Client Files Export Utility"); if(!EQEmuConfig::LoadConfig()) { LogFile->write(EQEMuLog::Error, "Unable to load configuration file."); @@ -52,11 +52,11 @@ int main(int argc, char **argv) { "database connection"); return 1; } - + ExportSpells(&database); ExportSkillCaps(&database); ExportBaseData(&database); - + return 0; } @@ -69,29 +69,27 @@ void ExportSpells(SharedDatabase *db) { return; } - char errbuf[MYSQL_ERRMSG_SIZE]; - const char *query = "SELECT * FROM spells_new ORDER BY id"; - MYSQL_RES *result; - MYSQL_ROW row; - if(db->RunQuery(query, strlen(query), errbuf, &result)) { - while(row = mysql_fetch_row(result)) { + const std::string query = "SELECT * FROM spells_new ORDER BY id"; + auto results = db->QueryDatabase(query); + + if(results.Success()) { + for (auto row = results.begin(); row != results.end(); ++row) { std::string line; - unsigned int fields = mysql_num_fields(result); + unsigned int fields = results.ColumnCount(); for(unsigned int i = 0; i < fields; ++i) { if(i != 0) { line.push_back('^'); } - + line += row[i]; } - + fprintf(f, "%s\n", line.c_str()); } - mysql_free_result(result); } else { - LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query, errbuf); + LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); } - + fclose(f); } From b98f8c6262be2b40385a87b51dffc3b1650dfd6e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:42:25 -0700 Subject: [PATCH 035/217] SkillUsable converted to QueryDatabase --- client_files/export/main.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 9ff190636..9c00acebe 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -94,25 +94,25 @@ void ExportSpells(SharedDatabase *db) { } bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = nullptr; - MYSQL_RES *result; - MYSQL_ROW row; - bool res = false; - if(db->RunQuery(query, MakeAnyLenString(&query, "SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d", - class_id, skill_id), errbuf, &result)) { - if(row = mysql_fetch_row(result)) { - if(row[0] && atoi(row[0]) > 0) { - res = true; - } - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in skill_usable query '%s' %s", query, errbuf); - } - safe_delete_array(query); - return res; + bool res = false; + + std::string query = StringFormat("SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d", + class_id, skill_id); + auto results = db->QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in skill_usable query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); + return false; + } + + if (results.RowCount() == 0) + return false; + + auto row = results.begin(); + if(row[0] && atoi(row[0]) > 0) + return true; + + return false; } int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) { From 24732eff885e5607fdc5014cafde53391cb5eead Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:46:05 -0700 Subject: [PATCH 036/217] GetSkill converted to QueryDatabase --- client_files/export/main.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 9c00acebe..ea6863745 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -116,23 +116,20 @@ bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) { } int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = nullptr; - MYSQL_RES *result; - MYSQL_ROW row; - int res = 0; - if(db->RunQuery(query, MakeAnyLenString(&query, "SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d", - class_id, skill_id, level), errbuf, &result)) { - if(row = mysql_fetch_row(result)) { - res = atoi(row[0]); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in get_skill query '%s' %s", query, errbuf); - } - safe_delete_array(query); - return res; + std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d", + class_id, skill_id, level); + auto results = db->QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in get_skill query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; + } + + if (results.RowCount() == 0) + return 0; + + auto row = results.begin(); + return atoi(row[0]); } void ExportSkillCaps(SharedDatabase *db) { From 446da590d8dbff14ddc2a43601070a92c0f6605e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 13:50:16 -0700 Subject: [PATCH 037/217] ExportBaseData converted to QueryDatabase --- client_files/export/main.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index ea6863745..aca5ddc56 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -170,27 +170,23 @@ void ExportBaseData(SharedDatabase *db) { return; } - char errbuf[MYSQL_ERRMSG_SIZE]; - const char *query = "SELECT * FROM base_data ORDER BY level, class"; - MYSQL_RES *result; - MYSQL_ROW row; - if(db->RunQuery(query, strlen(query), errbuf, &result)) { - while(row = mysql_fetch_row(result)) { + const std::string query = "SELECT * FROM base_data ORDER BY level, class"; + auto results = db->QueryDatabase(query); + if(results.Success()) { + for (auto row = results.begin();row != results.end();++row) { std::string line; - unsigned int fields = mysql_num_fields(result); - for(unsigned int i = 0; i < fields; ++i) { - if(i != 0) { + unsigned int fields = results.ColumnCount(); + for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) { + if(rowIndex != 0) line.push_back('^'); - } - line += row[i]; + line += row[rowIndex]; } fprintf(f, "%s\n", line.c_str()); } - mysql_free_result(result); } else { - LogFile->write(EQEMuLog::Error, "Error in ExportBaseData query '%s' %s", query, errbuf); + LogFile->write(EQEMuLog::Error, "Error in ExportBaseData query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); } fclose(f); From b7bcd13cbd9ffb25fedcf572cf16ba126a320489 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:02:16 -0700 Subject: [PATCH 038/217] GetSpellColumns converted to QueryDatabase --- client_files/import/main.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 0bbbaa3fd..93a07e7c2 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -31,7 +31,7 @@ void ImportBaseData(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientImport); set_exception_handler(); - + LogFile->write(EQEMuLog::Status, "Client Files Import Utility"); if(!EQEmuConfig::LoadConfig()) { LogFile->write(EQEMuLog::Error, "Unable to load configuration file."); @@ -55,26 +55,20 @@ int main(int argc, char **argv) { ImportSpells(&database); ImportSkillCaps(&database); ImportBaseData(&database); - + return 0; } int GetSpellColumns(SharedDatabase *db) { - char errbuf[MYSQL_ERRMSG_SIZE]; - const char *query = "DESCRIBE spells_new"; - MYSQL_RES *result; - MYSQL_ROW row; - int res = 0; - if(db->RunQuery(query, (uint32)strlen(query), errbuf, &result)) { - while(row = mysql_fetch_row(result)) { - ++res; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query, errbuf); - } - return res; + const std::string query = "DESCRIBE spells_new"; + auto results = db->QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; + } + + return results.RowCount(); } void ImportSpells(SharedDatabase *db) { @@ -104,7 +98,7 @@ void ImportSpells(SharedDatabase *db) { auto split = SplitString(escaped, '^'); int line_columns = (int)split.size(); std::string sql; - + if(line_columns >= columns) { sql = "INSERT INTO spells_new VALUES("; for(int i = 0; i < columns; ++i) { @@ -170,12 +164,12 @@ void ImportSkillCaps(SharedDatabase *db) { char buffer[2048]; while(fgets(buffer, 2048, f)) { auto split = SplitString(buffer, '^'); - + if(split.size() < 4) { continue; } - + int class_id, skill_id, level, cap; class_id = atoi(split[0].c_str()); skill_id = atoi(split[1].c_str()); From 503a2c0d04149413fab18fb04fad06b93ed7d383 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:03:53 -0700 Subject: [PATCH 039/217] ImportSpells converted to QueryDatabase --- client_files/import/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 93a07e7c2..3547b4062 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -79,8 +79,8 @@ void ImportSpells(SharedDatabase *db) { return; } - std::string delete_sql = "DELETE FROM spells_new"; - db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length()); + std::string query = "DELETE FROM spells_new"; + db->QueryDatabase(query); int columns = GetSpellColumns(db); int spells_imported = 0; @@ -97,8 +97,8 @@ void ImportSpells(SharedDatabase *db) { std::string escaped = ::EscapeString(buffer); auto split = SplitString(escaped, '^'); int line_columns = (int)split.size(); - std::string sql; + std::string sql; if(line_columns >= columns) { sql = "INSERT INTO spells_new VALUES("; for(int i = 0; i < columns; ++i) { @@ -134,7 +134,7 @@ void ImportSpells(SharedDatabase *db) { sql += ");"; } - db->RunQuery(sql.c_str(), (uint32)sql.length()); + db->QueryDatabase(sql); spells_imported++; if(spells_imported % 1000 == 0) { From ad987c55315def4235daab04a09022010df35c1b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:05:06 -0700 Subject: [PATCH 040/217] ImportSkillCaps converted to QueryDatabase --- client_files/import/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 3547b4062..5f786ee00 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -159,7 +159,7 @@ void ImportSkillCaps(SharedDatabase *db) { } std::string delete_sql = "DELETE FROM skill_caps"; - db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length()); + db->QueryDatabase(delete_sql); char buffer[2048]; while(fgets(buffer, 2048, f)) { @@ -179,7 +179,7 @@ void ImportSkillCaps(SharedDatabase *db) { std::string sql = StringFormat("INSERT INTO skill_caps(class, skillID, level, cap) VALUES(%d, %d, %d, %d)", class_id, skill_id, level, cap); - db->RunQuery(sql.c_str(), (uint32)sql.length()); + db->QueryDatabase(sql); } fclose(f); From 230296e777098f249d5822970b8b3e19d2dc3417 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:05:59 -0700 Subject: [PATCH 041/217] ImportBaseData converted to QueryDatabase --- client_files/import/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 5f786ee00..321e3a17b 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -195,7 +195,7 @@ void ImportBaseData(SharedDatabase *db) { } std::string delete_sql = "DELETE FROM base_data"; - db->RunQuery(delete_sql.c_str(), (uint32)delete_sql.length()); + db->QueryDatabase(delete_sql); char buffer[2048]; while(fgets(buffer, 2048, f)) { @@ -224,7 +224,7 @@ void ImportBaseData(SharedDatabase *db) { "mana_fac, end_fac) VALUES(%d, %d, %f, %f, %f, %f, %f, %f, %f, %f)", level, class_id, hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac); - db->RunQuery(sql.c_str(), (uint32)sql.length()); + db->QueryDatabase(sql); } fclose(f); From 0353dcb28cec46050d334fb1944f99c81648529a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:18:21 -0700 Subject: [PATCH 042/217] LoadRules converted to QueryDatabase --- common/rulesys.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 1f4ee8edf..634d23598 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -266,10 +266,6 @@ void RuleManager::SaveRules(Database *db, const char *ruleset) { bool RuleManager::LoadRules(Database *db, const char *ruleset) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; int rsid = GetRulesetID(db, ruleset); if(rsid < 0) { @@ -282,24 +278,19 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) { m_activeRuleset = rsid; m_activeName = ruleset; - if (db->RunQuery(query, MakeAnyLenString(&query, - "SELECT rule_name, rule_value" - " FROM rule_values" - " WHERE ruleset_id=%d", rsid), errbuf, &result)) + std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id=%d", rsid); + auto results = db->QueryDatabase(query); + if (!results.Success()) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - if(!SetRule(row[0], row[1], nullptr, false)) - _log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]); - } - mysql_free_result(result); - } else { - safe_delete_array(query); - LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query, errbuf); - return(false); + LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - return(true); + for(auto row = results.begin(); row != results.end(); ++row) + if(!SetRule(row[0], row[1], nullptr, false)) + _log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]); + + return true; } void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) { From 6450b08fd6f7d9e5f49992f01f850196c32e1db3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:21:12 -0700 Subject: [PATCH 043/217] _SaveRules converted to QueryDatabase --- common/rulesys.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 634d23598..aafdcce56 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -308,16 +308,14 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) { break; } - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - if (!db->RunQuery(query, MakeAnyLenString(&query, - "REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) " - " VALUES(%d, '%s', '%s')", - m_activeRuleset, _GetRuleName(type, index), vstr),errbuf)) - { - _log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query,errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("REPLACE INTO rule_values " + "(ruleset_id, rule_name, rule_value) " + " VALUES(%d, '%s', '%s')", + m_activeRuleset, _GetRuleName(type, index), vstr); + auto results = db->QueryDatabase(query); + if (!results.Success()) + _log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query.c_str(), results.ErrorMessage().c_str()); + } From 85ebb32176fdac38b398dc954b18d0f90dbb5f6c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:24:58 -0700 Subject: [PATCH 044/217] GetRulesetID converted to QueryDatabase --- common/rulesys.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index aafdcce56..fa524e8ba 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -320,33 +320,25 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) { int RuleManager::GetRulesetID(Database *db, const char *rulesetname) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; uint32 len = strlen(rulesetname); char* rst = new char[2*len+1]; db->DoEscapeString(rst, rulesetname, len); - int res = -1; + std::string query = StringFormat("SELECT ruleset_id FROM rule_sets WHERE name='%s'", rst); + safe_delete_array(rst); + auto results = db->QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str()); + return -1; + } - if (db->RunQuery(query, MakeAnyLenString(&query, - "SELECT ruleset_id" - " FROM rule_sets" - " WHERE name='%s'", rst), errbuf, &result)) - { - if((row = mysql_fetch_row(result))) { - res = atoi(row[0]); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query, errbuf); - } - safe_delete_array(query); - safe_delete_array(rst); + if (results.RowCount() == 0) + return -1; - return(res); + auto row = results.begin(); + + return atoi(row[0]); } int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) { From a75b53f9b0c5dbbacec5f94dbb1eae0f8d28b9db Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:30:13 -0700 Subject: [PATCH 045/217] _FindOrCreateRuleset converted to QueryDatabase --- common/rulesys.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index fa524e8ba..3076d1a46 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -342,32 +342,25 @@ int RuleManager::GetRulesetID(Database *db, const char *rulesetname) { } int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) { - int res; - res = GetRulesetID(db, ruleset); + int res = GetRulesetID(db, ruleset); if(res >= 0) - return(res); //found and existing one... + return res; //found and existing one... uint32 len = strlen(ruleset); char* rst = new char[2*len+1]; db->DoEscapeString(rst, ruleset, len); - uint32 new_id; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - if (!db->RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO rule_sets (ruleset_id, name) " - " VALUES(0, '%s')", - rst),errbuf,nullptr,nullptr,&new_id)) + std::string query = StringFormat("INSERT INTO rule_sets (ruleset_id, name) VALUES(0, '%s')", rst); + safe_delete_array(rst); + auto results = db->QueryDatabase(query); + if (!results.Success()) { - _log(RULES__ERROR, "Fauled to create rule set in the database: %s: %s", query,errbuf); - res = -1; - } else { - res = new_id; + _log(RULES__ERROR, "Fauled to create rule set in the database: %s: %s", query.c_str(), results.ErrorMessage().c_str()); + return -1; } - safe_delete_array(query); - return(res); + return results.LastInsertedID(); } std::string RuleManager::GetRulesetName(Database *db, int id) { From b439881f37bd3bede8cec2d5a0378b311fa0e44d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:33:27 -0700 Subject: [PATCH 046/217] GetRulesetName converted to QueryDatabase --- common/rulesys.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 3076d1a46..93c519a45 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -364,28 +364,21 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) { } std::string RuleManager::GetRulesetName(Database *db, int id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - std::string res; - - if (db->RunQuery(query, MakeAnyLenString(&query, - "SELECT name" - " FROM rule_sets" - " WHERE ruleset_id=%d", id), errbuf, &result)) + std::string query = StringFormat("SELECT name FROM rule_sets WHERE ruleset_id=%d", id); + auto results = db->QueryDatabase(query); + if (!results.Success()) { - if((row = mysql_fetch_row(result))) { - res = row[0]; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query, errbuf); + LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str()); + return ""; } - safe_delete_array(query); - return(res); + if (results.RowCount() == 0) + return ""; + + auto row = results.begin(); + + return row[0]; } bool RuleManager::ListRulesets(Database *db, std::map &into) { From 84e95d9a2807fa25c2fc1a971059f38ccf8b0d1d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:36:58 -0700 Subject: [PATCH 047/217] ListRulesets converted to QueryDatabase --- common/rulesys.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 93c519a45..f23d482b3 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -382,29 +382,22 @@ std::string RuleManager::GetRulesetName(Database *db, int id) { } bool RuleManager::ListRulesets(Database *db, std::map &into) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; //start out with the default set which is always present. into[0] = "default"; - if (db->RunQuery(query, MakeAnyLenString(&query, - "SELECT ruleset_id,name" - " FROM rule_sets"), errbuf, &result)) + std::string query = "SELECT ruleset_id, name FROM rule_sets"; + auto results = db->QueryDatabase(query); + if (results.Success()) { - while((row = mysql_fetch_row(result))) { - into[ atoi(row[0]) ] = row[1]; - } - mysql_free_result(result); - safe_delete_array(query); - } else { - LogFile->write(EQEMuLog::Error, "Error in ListRulesets query %s: %s", query, errbuf); - safe_delete_array(query); - return(false); + LogFile->write(EQEMuLog::Error, "Error in ListRulesets query %s: %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - return(true); + + for (auto row = results.begin(); row != results.end(); ++row) + into[ atoi(row[0]) ] = row[1]; + + return true; } int32 RuleManager::GetIntRule(RuleManager::IntType t) const From 529408fca0a7f8a998aedd303ad4400ccf3dca45 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:45:54 -0700 Subject: [PATCH 048/217] LoadDatabase converted to QueryDatabase --- queryserv/lfguild.cpp | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index 37f80bf28..d99bfe992 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -34,37 +34,27 @@ GuildLookingForPlayers::GuildLookingForPlayers(char *Name, char *Comments, uint3 bool LFGuildManager::LoadDatabase() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!database.RunQuery(query,MakeAnyLenString(&query, "SELECT `type`,`name`,`comment`, `fromlevel`, `tolevel`, `classes`, `aacount`, `timezone`, `timeposted` FROM `lfguild`"),errbuf,&result)){ - - _log(QUERYSERV__ERROR, "Failed to load LFGuild info from database. %s %s", query, errbuf); - safe_delete_array(query); - + std::string query = "SELECT `type`,`name`,`comment`, " + "`fromlevel`, `tolevel`, `classes`, " + "`aacount`, `timezone`, `timeposted` FROM `lfguild`"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + _log(QUERYSERV__ERROR, "Failed to load LFGuild info from database. %s %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - while((row = mysql_fetch_row(result))) { - + for (auto row = results.begin(); row != results.end(); ++row) { uint32 type = atoul(row[0]); if(type == 0) { PlayerLookingForGuild p(row[1], row[2], atoul(row[3]), atoul(row[5]), atoul(row[6]), atoul(row[7]), atoul(row[8])); Players.push_back(p); + continue; } - else - { - GuildLookingForPlayers g(row[1], row[2], atoul(row[3]), atoul(row[4]), atoul(row[5]), atoul(row[6]), atoul(row[7]), atoul(row[8])); - Guilds.push_back(g); - } - } - mysql_free_result(result); + GuildLookingForPlayers g(row[1], row[2], atoul(row[3]), atoul(row[4]), atoul(row[5]), atoul(row[6]), atoul(row[7]), atoul(row[8])); + Guilds.push_back(g); + } return true; } From b234c67622bcb9b7b955301beaf22bd4fc2fbd4e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:52:38 -0700 Subject: [PATCH 049/217] TogglePlayer converted to QueryDatabase --- queryserv/lfguild.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index d99bfe992..b174ac700 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -232,37 +232,31 @@ void LFGuildManager::SendGuildMatches(uint32 FromZoneID, uint32 FromInstanceID, void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char *From, uint32 Class, uint32 Level, uint32 AAPoints, char *Comments, uint32 Toggle, uint32 TimeZone) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - std::list::iterator it; - - for(it = Players.begin(); it != Players.end(); ++it) - { - if(!strcasecmp((*it).Name.c_str(), From)) - { + for(auto it = Players.begin(); it != Players.end(); ++it) + if(!strcasecmp((*it).Name.c_str(), From)) { Players.erase(it); - break; } - } - if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `lfguild` WHERE `type` = 0 AND `name` = '%s'", From), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error removing player from LFGuild table, query was %s, %s", query, errbuf); - - safe_delete_array(query); + std::string query = StringFormat("DELETE FROM `lfguild` WHERE `type` = 0 AND `name` = '%s'", From); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error removing player from LFGuild table, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); uint32 Now = time(nullptr); - if(Toggle == 1) - { + if(Toggle == 1) { PlayerLookingForGuild p(From, Comments, Level, Class, AAPoints, TimeZone, Now); Players.push_back(p); - if(!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `lfguild` (`type`, `name`, `comment`, `fromlevel`, `tolevel`, `classes`, `aacount`, `timezone`, `timeposted`) VALUES(0, '%s', '%s', %u, 0, %u, %u, %u, %u)", From, Comments, Level, Class, AAPoints, TimeZone, Now), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error inserting player into LFGuild table, query was %s, %s", query, errbuf); - - safe_delete_array(query); + query = StringFormat("INSERT INTO `lfguild` " + "(`type`, `name`, `comment`, `fromlevel`, `tolevel`, " + "`classes`, `aacount`, `timezone`, `timeposted`) " + "VALUES (0, '%s', '%s', %u, 0, %u, %u, %u, %u)", + From, Comments, Level, Class, AAPoints, TimeZone, Now); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error inserting player into LFGuild table, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); } ServerPacket *pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(From) + strlen(Comments) + 30); @@ -279,7 +273,6 @@ void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char worldserver->SendPacket(pack); safe_delete(pack); - } void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char *From, char* GuildName, char *Comments, uint32 FromLevel, uint32 ToLevel, uint32 Classes, uint32 AACount, uint32 Toggle, uint32 TimeZone) From dd044ca45319fa81378d090319fe00a605036950 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 14:56:55 -0700 Subject: [PATCH 050/217] ToggleGuild converted to QueryDatabase --- queryserv/lfguild.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index b174ac700..c4c33cb58 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -277,24 +277,17 @@ void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char *From, char* GuildName, char *Comments, uint32 FromLevel, uint32 ToLevel, uint32 Classes, uint32 AACount, uint32 Toggle, uint32 TimeZone) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - std::list::iterator it; - - for(it = Guilds.begin(); it != Guilds.end(); ++it) - { + for(auto it = Guilds.begin(); it != Guilds.end(); ++it) if(!strcasecmp((*it).Name.c_str(), GuildName)) { Guilds.erase(it); break; } - } - if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `lfguild` WHERE `type` = 1 AND `name` = '%s'", GuildName), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error removing guild from LFGuild table, query was %s, %s", query, errbuf); - - safe_delete_array(query); + std::string query = StringFormat("DELETE FROM `lfguild` WHERE `type` = 1 AND `name` = '%s'", GuildName); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error removing guild from LFGuild table, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); uint32 Now = time(nullptr); @@ -302,12 +295,19 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char { GuildLookingForPlayers g(GuildName, Comments, FromLevel, ToLevel, Classes, AACount, TimeZone, Now); Guilds.push_back(g); - if(!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `lfguild` (`type`, `name`, `comment`, `fromlevel`, `tolevel`, `classes`, `aacount`, `timezone`, `timeposted`) VALUES(1, '%s', '%s', %u, %u, %u, %u, %u, %u)", GuildName, Comments, FromLevel, ToLevel, Classes, AACount, TimeZone, Now), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error inserting guild into LFGuild table, query was %s, %s", query, errbuf); - safe_delete_array(query); + query = StringFormat("INSERT INTO `lfguild` " + "(`type`, `name`, `comment`, `fromlevel`, `tolevel`, " + "`classes`, `aacount`, `timezone`, `timeposted`) " + "VALUES (1, '%s', '%s', %u, %u, %u, %u, %u, %u)", + GuildName, Comments, FromLevel, ToLevel, + Classes, AACount, TimeZone, Now); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error inserting guild into LFGuild table, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); } + ServerPacket *pack = new ServerPacket(ServerOP_LFGuildUpdate, strlen(GuildName) + strlen(Comments) + 30); pack->WriteString(GuildName); From 37b45be6d8500d024be01008719a7e4869e435dc Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 15:34:41 -0700 Subject: [PATCH 051/217] LoadAdventureTemplate converted to QueryDatabase --- world/AdventureManager.cpp | 105 +++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 58 deletions(-) diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 4ce2fbc53..4aac0c91c 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -639,67 +639,56 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int id) bool AdventureManager::LoadAdventureTemplates() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, zone, zone_version, " + std::string query = "SELECT id, zone, zone_version, " "is_hard, min_level, max_level, type, type_data, type_count, assa_x, " "assa_y, assa_z, assa_h, text, duration, zone_in_time, win_points, lose_points, " - "theme, zone_in_zone_id, zone_in_x, zone_in_y, zone_in_object_id, dest_x, dest_y," - " dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, " - "graveyard_radius FROM adventure_template"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - uint8 x = 0; - AdventureTemplate *t = new AdventureTemplate; - t->id = atoi(row[x++]); - strcpy(t->zone, row[x++]); - t->zone_version = atoi(row[x++]); - t->is_hard = atoi(row[x++]); - t->min_level = atoi(row[x++]); - t->max_level = atoi(row[x++]); - t->type = atoi(row[x++]); - t->type_data = atoi(row[x++]); - t->type_count = atoi(row[x++]); - t->assa_x = atof(row[x++]); - t->assa_y = atof(row[x++]); - t->assa_z = atof(row[x++]); - t->assa_h = atof(row[x++]); - strn0cpy(t->text, row[x++], sizeof(t->text)); - t->duration = atoi(row[x++]); - t->zone_in_time = atoi(row[x++]); - t->win_points = atoi(row[x++]); - t->lose_points = atoi(row[x++]); - t->theme = atoi(row[x++]); - t->zone_in_zone_id = atoi(row[x++]); - t->zone_in_x = atof(row[x++]); - t->zone_in_y = atof(row[x++]); - t->zone_in_object_id = atoi(row[x++]); - t->dest_x = atof(row[x++]); - t->dest_y = atof(row[x++]); - t->dest_z = atof(row[x++]); - t->dest_h = atof(row[x++]); - t->graveyard_zone_id = atoi(row[x++]); - t->graveyard_x = atof(row[x++]); - t->graveyard_y = atof(row[x++]); - t->graveyard_z = atof(row[x++]); - t->graveyard_radius = atof(row[x++]); - adventure_templates[t->id] = t; - } - mysql_free_result(result); - safe_delete_array(query); - return true; - } - else - { - LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query, errbuf); - safe_delete_array(query); + "theme, zone_in_zone_id, zone_in_x, zone_in_y, zone_in_object_id, dest_x, dest_y, " + "dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, " + "graveyard_radius FROM adventure_template"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return false; - } - return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureTemplate *aTemplate = new AdventureTemplate; + aTemplate->id = atoi(row[0]); + strcpy(aTemplate->zone, row[1]); + aTemplate->zone_version = atoi(row[2]); + aTemplate->is_hard = atoi(row[3]); + aTemplate->min_level = atoi(row[4]); + aTemplate->max_level = atoi(row[5]); + aTemplate->type = atoi(row[6]); + aTemplate->type_data = atoi(row[7]); + aTemplate->type_count = atoi(row[8]); + aTemplate->assa_x = atof(row[9]); + aTemplate->assa_y = atof(row[10]); + aTemplate->assa_z = atof(row[11]); + aTemplate->assa_h = atof(row[12]); + strn0cpy(aTemplate->text, row[13], sizeof(aTemplate->text)); + aTemplate->duration = atoi(row[14]); + aTemplate->zone_in_time = atoi(row[15]); + aTemplate->win_points = atoi(row[16]); + aTemplate->lose_points = atoi(row[17]); + aTemplate->theme = atoi(row[18]); + aTemplate->zone_in_zone_id = atoi(row[19]); + aTemplate->zone_in_x = atof(row[20]); + aTemplate->zone_in_y = atof(row[21]); + aTemplate->zone_in_object_id = atoi(row[22]); + aTemplate->dest_x = atof(row[23]); + aTemplate->dest_y = atof(row[24]); + aTemplate->dest_z = atof(row[25]); + aTemplate->dest_h = atof(row[26]); + aTemplate->graveyard_zone_id = atoi(row[27]); + aTemplate->graveyard_x = atof(row[28]); + aTemplate->graveyard_y = atof(row[29]); + aTemplate->graveyard_z = atof(row[30]); + aTemplate->graveyard_radius = atof(row[31]); + adventure_templates[aTemplate->id] = aTemplate; + } + + return true; } bool AdventureManager::LoadAdventureEntries() From 41182de4f298023e417077f6fd7a83d05848f03a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 15:13:28 -0700 Subject: [PATCH 052/217] MoveCorpsesToGraveyard converted to QueryDatabase --- world/Adventure.cpp | 58 ++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/world/Adventure.cpp b/world/Adventure.cpp index 83fd8fa2f..162c4563b 100644 --- a/world/Adventure.cpp +++ b/world/Adventure.cpp @@ -374,49 +374,35 @@ void Adventure::MoveCorpsesToGraveyard() std::list dbid_list; std::list charid_list; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID()), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - dbid_list.push_back(atoi(row[0])); - charid_list.push_back(atoi(row[1])); - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query, errbuf); - safe_delete_array(query); - } + std::string query = StringFormat("SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID()); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); - std::list::iterator iter = dbid_list.begin(); - while(iter != dbid_list.end()) + for(auto row = results.begin(); row != results.end(); ++row) { + dbid_list.push_back(atoi(row[0])); + charid_list.push_back(atoi(row[1])); + } + + for (auto iter = dbid_list.begin(); iter != dbid_list.end(); ++iter) { float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); float y = GetTemplate()->graveyard_y + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius); float z = GetTemplate()->graveyard_z; - if(database.RunQuery(query,MakeAnyLenString(&query, "UPDATE player_corpses SET zoneid=%d, instanceid=0, x=%f, y=%f, z=%f WHERE instanceid=%d", - GetTemplate()->graveyard_zone_id, x, y, z, GetInstanceID()), errbuf)) - { - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query, errbuf); - safe_delete_array(query); - } - ++iter; + + query = StringFormat("UPDATE player_corpses " + "SET zoneid = %d, instanceid = 0, " + "x = %f, y = %f, z = %f WHERE instanceid = %d", + GetTemplate()->graveyard_zone_id, + x, y, z, GetInstanceID()); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); } - iter = dbid_list.begin(); - std::list::iterator c_iter = charid_list.begin(); - while(iter != dbid_list.end()) + auto c_iter = charid_list.begin(); + for (auto iter = dbid_list.begin(); iter != dbid_list.end(); ++iter, ++c_iter) { ServerPacket* pack = new ServerPacket(ServerOP_DepopAllPlayersCorpses, sizeof(ServerDepopAllPlayersCorpses_Struct)); ServerDepopAllPlayersCorpses_Struct *dpc = (ServerDepopAllPlayersCorpses_Struct*)pack->pBuffer; @@ -433,8 +419,6 @@ void Adventure::MoveCorpsesToGraveyard() zoneserver_list.SendPacket(spc->zone_id, 0, pack); delete pack; - ++iter; - ++c_iter; } } From fcb022b8aee64cc9a5e4eb6ef30f5c15b80906bb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 15:01:29 -0700 Subject: [PATCH 053/217] ExpireEntries converted to QueryDatabase --- queryserv/lfguild.cpp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index c4c33cb58..a98c23ddc 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -326,36 +326,30 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char void LFGuildManager::ExpireEntries() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - std::list::iterator it; - std::list::iterator it2; - - for(it = Players.begin(); it != Players.end(); ++it) + for(auto it = Players.begin(); it != Players.end(); ++it) { - if((*it).TimePosted + 604800 <= (uint32)time(nullptr)) - { - if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str()), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query, errbuf); + if((*it).TimePosted + 604800 > (uint32)time(nullptr)) + continue; - safe_delete_array(query); + std::string query = StringFormat("DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str()); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); - it = Players.erase(it); - } - } + it = Players.erase(it); + } - for(it2 = Guilds.begin(); it2 != Guilds.end(); ++it2) + for(auto it2 = Guilds.begin(); it2 != Guilds.end(); ++it2) { - if((*it2).TimePosted + 2592000 <= time(nullptr)) - { - if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str()), errbuf, 0, 0)) - _log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query, errbuf); + if((*it2).TimePosted + 2592000 > time(nullptr)) + continue; - safe_delete_array(query); + std::string query = StringFormat("DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str()); + auto results = database.QueryDatabase(query); + if(!results.Success()) + _log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query.c_str(), results.ErrorMessage().c_str()); - it2 = Guilds.erase(it2); - } + it2 = Guilds.erase(it2); } } From 8b05eff17907a5364123e5301b7e6c6f7a8cdef0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 15:39:03 -0700 Subject: [PATCH 054/217] LoadAdventureEntries converted to QueryDatabase --- world/AdventureManager.cpp | 72 ++++++++++++++------------------------ 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 4aac0c91c..97264ca7c 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -693,54 +693,36 @@ bool AdventureManager::LoadAdventureTemplates() bool AdventureManager::LoadAdventureEntries() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, template_id FROM adventure_template_entry"), errbuf, &result)) + std::string query = "SELECT id, template_id FROM adventure_template_entry"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { - while((row = mysql_fetch_row(result))) - { - int id = atoi(row[0]); - int template_id = atoi(row[1]); - AdventureTemplate* tid = nullptr; - - std::map::iterator t_iter = adventure_templates.find(template_id); - if(t_iter == adventure_templates.end()) - { - continue; - } - else - { - tid = adventure_templates[template_id]; - } - - std::list temp; - std::map >::iterator iter = adventure_entries.find(id); - if(iter == adventure_entries.end()) - { - temp.push_back(tid); - adventure_entries[id] = temp; - } - else - { - temp = adventure_entries[id]; - temp.push_back(tid); - adventure_entries[id] = temp; - } - } - mysql_free_result(result); - safe_delete_array(query); - return true; - } - else - { - LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query, errbuf); - safe_delete_array(query); + LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return false; } - return false; + + for (auto row = results.begin(); row != results.end(); ++row) + { + int id = atoi(row[0]); + int template_id = atoi(row[1]); + AdventureTemplate* tid = nullptr; + + auto t_iter = adventure_templates.find(template_id); + if(t_iter == adventure_templates.end()) + continue; + + tid = adventure_templates[template_id]; + + std::list temp; + auto iter = adventure_entries.find(id); + if(iter == adventure_entries.end()) + temp = adventure_entries[id]; + + temp.push_back(tid); + adventure_entries[id] = temp; + } + + return true; } void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id) From 042613d23456b257c5e68e4b95d8f29e312a3aab Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 15:44:55 -0700 Subject: [PATCH 055/217] LoadLeaderboardInfo converted to QueryDatabase --- world/AdventureManager.cpp | 128 +++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 69 deletions(-) diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 97264ca7c..5768bb9b2 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -1067,79 +1067,69 @@ void AdventureManager::LoadLeaderboardInfo() leaderboard_info_percentage_ruj.clear(); leaderboard_info_wins_tak.clear(); leaderboard_info_percentage_tak.clear(); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(database.RunQuery(query,MakeAnyLenString(&query,"select ch.name, ch.id, adv_stats.* from adventure_stats " - "AS adv_stats ""left join character_ AS ch on adv_stats.player_id = ch.id;"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - if(row[0]) - { - LeaderboardInfo lbi; - lbi.name = row[0]; - lbi.wins = atoi(row[3]); - lbi.guk_wins = atoi(row[3]); - lbi.wins += atoi(row[4]); - lbi.mir_wins = atoi(row[4]); - lbi.wins += atoi(row[5]); - lbi.mmc_wins = atoi(row[5]); - lbi.wins += atoi(row[6]); - lbi.ruj_wins = atoi(row[6]); - lbi.wins += atoi(row[7]); - lbi.tak_wins = atoi(row[7]); - lbi.losses = atoi(row[8]); - lbi.guk_losses = atoi(row[8]); - lbi.losses += atoi(row[9]); - lbi.mir_losses = atoi(row[9]); - lbi.losses += atoi(row[10]); - lbi.mmc_losses = atoi(row[10]); - lbi.losses += atoi(row[11]); - lbi.ruj_losses = atoi(row[11]); - lbi.losses += atoi(row[12]); - lbi.tak_losses = atoi(row[12]); - - leaderboard_info_wins.push_back(lbi); - leaderboard_info_percentage.push_back(lbi); - leaderboard_info_wins_guk.push_back(lbi); - leaderboard_info_percentage_guk.push_back(lbi); - leaderboard_info_wins_mir.push_back(lbi); - leaderboard_info_percentage_mir.push_back(lbi); - leaderboard_info_wins_mmc.push_back(lbi); - leaderboard_info_percentage_mmc.push_back(lbi); - leaderboard_info_wins_ruj.push_back(lbi); - leaderboard_info_percentage_ruj.push_back(lbi); - leaderboard_info_wins_tak.push_back(lbi); - leaderboard_info_percentage_tak.push_back(lbi); - - leaderboard_sorted_wins = false; - leaderboard_sorted_percentage = false; - leaderboard_sorted_wins_guk = false; - leaderboard_sorted_percentage_guk = false; - leaderboard_sorted_wins_mir = false; - leaderboard_sorted_percentage_mir = false; - leaderboard_sorted_wins_mmc = false; - leaderboard_sorted_percentage_mmc = false; - leaderboard_sorted_wins_ruj = false; - leaderboard_sorted_percentage_ruj = false; - leaderboard_sorted_wins_tak = false; - leaderboard_sorted_percentage_tak = false; - } - } - mysql_free_result(result); - safe_delete_array(query); + std::string query = "SELECT ch.name, ch.id, adv_stats.* FROM adventure_stats " + "AS adv_stats LEFT JOIN character_ AS ch ON adv_stats.player_id = ch.id;"; + auto results = database.QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return; } - else - { - LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query, errbuf); - safe_delete_array(query); - return; + + for (auto row = results.begin(); row != results.end(); ++row) + { + if(!row[0]) + continue; + + LeaderboardInfo lbi; + lbi.name = row[0]; + lbi.wins = atoi(row[3]); + lbi.guk_wins = atoi(row[3]); + lbi.wins += atoi(row[4]); + lbi.mir_wins = atoi(row[4]); + lbi.wins += atoi(row[5]); + lbi.mmc_wins = atoi(row[5]); + lbi.wins += atoi(row[6]); + lbi.ruj_wins = atoi(row[6]); + lbi.wins += atoi(row[7]); + lbi.tak_wins = atoi(row[7]); + lbi.losses = atoi(row[8]); + lbi.guk_losses = atoi(row[8]); + lbi.losses += atoi(row[9]); + lbi.mir_losses = atoi(row[9]); + lbi.losses += atoi(row[10]); + lbi.mmc_losses = atoi(row[10]); + lbi.losses += atoi(row[11]); + lbi.ruj_losses = atoi(row[11]); + lbi.losses += atoi(row[12]); + lbi.tak_losses = atoi(row[12]); + + leaderboard_info_wins.push_back(lbi); + leaderboard_info_percentage.push_back(lbi); + leaderboard_info_wins_guk.push_back(lbi); + leaderboard_info_percentage_guk.push_back(lbi); + leaderboard_info_wins_mir.push_back(lbi); + leaderboard_info_percentage_mir.push_back(lbi); + leaderboard_info_wins_mmc.push_back(lbi); + leaderboard_info_percentage_mmc.push_back(lbi); + leaderboard_info_wins_ruj.push_back(lbi); + leaderboard_info_percentage_ruj.push_back(lbi); + leaderboard_info_wins_tak.push_back(lbi); + leaderboard_info_percentage_tak.push_back(lbi); + + leaderboard_sorted_wins = false; + leaderboard_sorted_percentage = false; + leaderboard_sorted_wins_guk = false; + leaderboard_sorted_percentage_guk = false; + leaderboard_sorted_wins_mir = false; + leaderboard_sorted_percentage_mir = false; + leaderboard_sorted_wins_mmc = false; + leaderboard_sorted_percentage_mmc = false; + leaderboard_sorted_wins_ruj = false; + leaderboard_sorted_percentage_ruj = false; + leaderboard_sorted_wins_tak = false; + leaderboard_sorted_percentage_tak = false; } - return; }; void AdventureManager::DoLeaderboardRequest(const char* player, uint8 type) From a2280d1fe5297f79012c4907aee2bb1eccbe5019 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:10:39 -0700 Subject: [PATCH 056/217] CountBugs converted to QueryDatabase --- world/EQW.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/world/EQW.cpp b/world/EQW.cpp index 02196e49c..2fa36ec49 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -384,21 +384,16 @@ bool EQW::SetPublicNote(uint32 charid, const char *note) { } int EQW::CountBugs() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT count(*) FROM bugs where status = 0"), errbuf, &result)) { - safe_delete_array(query); - if((row = mysql_fetch_row(result))) { - int count = atoi(row[0]); - mysql_free_result(result); - return count; - } - mysql_free_result(result); - } - safe_delete_array(query); - return 0; + std::string query = "SELECT count(*) FROM bugs where status = 0"; + auto results = database.QueryDatabase(query); + if (!results.Success()) + return 0; + + if (results.RowCount() == 0) + return 0; + + auto row = results.begin(); + return atoi(row[0]); } std::vector EQW::ListBugs(uint32 offset) { From 34f051ab9a5c3b2bd64100900a42ff8fa985f861 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:13:11 -0700 Subject: [PATCH 057/217] ListBugs converted to QueryDatabase --- world/EQW.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/world/EQW.cpp b/world/EQW.cpp index 2fa36ec49..b15189730 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -398,18 +398,15 @@ int EQW::CountBugs() { std::vector EQW::ListBugs(uint32 offset) { std::vector res; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset), errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - res.push_back(row[0]); - } - mysql_free_result(result); - } - safe_delete_array(query); + std::string query = StringFormat("SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset); + auto results = database.QueryDatabase(query); + + if (!results.Success()) + return res; + + for (auto row = results.begin();row != results.end(); ++row) + res.push_back(row[0]); + return res; } From 9270c45a5ef028ec812472ff1677b3b8698a96f7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:15:47 -0700 Subject: [PATCH 058/217] GetBugDetails converted to QueryDatabase --- world/EQW.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/world/EQW.cpp b/world/EQW.cpp index b15189730..d8ba3cff9 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -412,25 +412,22 @@ std::vector EQW::ListBugs(uint32 offset) { std::map EQW::GetBugDetails(Const_char *id) { std::map res; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if(database.RunQuery(query, MakeAnyLenString(&query, "select name, zone, x, y, z, target, bug from bugs where id = %s", id), errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - res["name"] = row[0]; - res["zone"] = row[1]; - res["x"] = row[2]; - res["y"] = row[3]; - res["z"] = row[4]; - res["target"] = row[5]; - res["bug"] = row[6]; - res["id"] = id; - } - mysql_free_result(result); - } - safe_delete_array(query); + std::string query = StringFormat("SELECT name, zone, x, y, z, target, bug FROM bugs WHERE id = %s", id); + auto results = database.QueryDatabase(query); + + if (!results.Success()) + return res; + + for(auto row = results.begin(); row != results.end(); ++row) { + res["name"] = row[0]; + res["zone"] = row[1]; + res["x"] = row[2]; + res["y"] = row[3]; + res["z"] = row[4]; + res["target"] = row[5]; + res["bug"] = row[6]; + res["id"] = id; + } return res; } From 7b33ef67f248205a0eaa6fa1ae2c4619806a86b3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:17:07 -0700 Subject: [PATCH 059/217] ResolveBug converted to QueryDatabase --- world/EQW.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/world/EQW.cpp b/world/EQW.cpp index d8ba3cff9..070383dc3 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -433,12 +433,8 @@ std::map EQW::GetBugDetails(Const_char *id) { void EQW::ResolveBug(const char *id) { std::vector res; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE bugs SET status=1 WHERE id=%s", id), errbuf)) { - safe_delete_array(query); - } - safe_delete_array(query); + std::string query = StringFormat("UPDATE bugs SET status=1 WHERE id=%s", id); + database.QueryDatabase(query); } void EQW::SendMessage(uint32 type, const char *msg) { From 52344bfe24376e61205baf6c4c50dc5d6acb0ece Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:34:27 -0700 Subject: [PATCH 060/217] GetNPCSpells converted to QueryDatabase --- zone/MobAI.cpp | 233 ++++++++++++++++++++++++------------------------- 1 file changed, 115 insertions(+), 118 deletions(-) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index bf32a980c..4efef2751 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -1181,7 +1181,7 @@ void Mob::AI_Process() { if (GetSpecialAbility(SPECATK_FLURRY)) { int flurry_chance = GetSpecialAbilityParam(SPECATK_FLURRY, 0); - flurry_chance = flurry_chance > 0 ? flurry_chance : RuleI(Combat, NPCFlurryChance); + flurry_chance = flurry_chance > 0 ? flurry_chance : RuleI(Combat, NPCFlurryChance); if (MakeRandomInt(0, 99) < flurry_chance) { ExtraAttackOptions opts; @@ -1215,16 +1215,16 @@ void Mob::AI_Process() { if (IsPet() || (IsNPC() && CastToNPC()->GetSwarmOwner())) { Mob *owner = nullptr; - + if (IsPet()) owner = GetOwner(); - else + else owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); - + if (owner) { int16 flurry_chance = owner->aabonuses.PetFlurry + owner->spellbonuses.PetFlurry + owner->itembonuses.PetFlurry; - + if (flurry_chance && (MakeRandomInt(0, 99) < flurry_chance)) Flurry(nullptr); } @@ -1604,7 +1604,7 @@ void NPC::AI_DoMovement() { roambox_movingto_x -= movex * 2; if (roambox_movingto_y > roambox_max_y || roambox_movingto_y < roambox_min_y) roambox_movingto_y -= movey * 2; - //New coord is still invalid, ignore distance and just pick a new random coord. + //New coord is still invalid, ignore distance and just pick a new random coord. //If we're here we may have a roambox where one side is shorter than the specified distance. Commons, Wkarana, etc. if (roambox_movingto_x > roambox_max_x || roambox_movingto_x < roambox_min_x) roambox_movingto_x = MakeRandomFloat(roambox_min_x+1,roambox_max_x-1); @@ -2406,7 +2406,7 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { } //If any casting variables are defined in the current list, ignore those in the parent list. - if (spell_list->fail_recast || spell_list->engaged_no_sp_recast_min || spell_list->engaged_no_sp_recast_max + if (spell_list->fail_recast || spell_list->engaged_no_sp_recast_min || spell_list->engaged_no_sp_recast_max || spell_list->engaged_beneficial_self_chance || spell_list->engaged_beneficial_other_chance || spell_list->engaged_detrimental_chance || spell_list->pursue_no_sp_recast_min || spell_list->pursue_no_sp_recast_max || spell_list->pursue_detrimental_chance || spell_list->idle_no_sp_recast_min || spell_list->idle_no_sp_recast_max || spell_list->idle_beneficial_chance) { @@ -2457,7 +2457,7 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { AISpellVar.idle_no_sp_recast_min = (_idle_no_sp_recast_min) ? _idle_no_sp_recast_min : RuleI(Spells, AI_IdleNoSpellMinRecast); AISpellVar.idle_no_sp_recast_max = (_idle_no_sp_recast_max) ? _idle_no_sp_recast_max : RuleI(Spells, AI_IdleNoSpellMaxRecast); AISpellVar.idle_beneficial_chance = (_idle_beneficial_chance) ? _idle_beneficial_chance : RuleI(Spells, AI_IdleBeneficialChance); - + if (AIspells.size() == 0) AIautocastspell_timer->Disable(); else @@ -2469,12 +2469,12 @@ bool NPC::AI_AddNPCSpellsEffects(uint32 iDBSpellsEffectsID) { npc_spells_effects_id = iDBSpellsEffectsID; AIspellsEffects.clear(); - - if (iDBSpellsEffectsID == 0) + + if (iDBSpellsEffectsID == 0) return false; - + DBnpcspellseffects_Struct* spell_effects_list = database.GetNPCSpellsEffects(iDBSpellsEffectsID); - + if (!spell_effects_list) { return false; } @@ -2502,9 +2502,9 @@ bool NPC::AI_AddNPCSpellsEffects(uint32 iDBSpellsEffectsID) { if (parentlist) { for (i=0; inumentries; i++) { if (GetLevel() >= parentlist->entries[i].minlevel && GetLevel() <= parentlist->entries[i].maxlevel && parentlist->entries[i].spelleffectid > 0) { - if (!IsSpellEffectInList(spell_effects_list, parentlist->entries[i].spelleffectid, parentlist->entries[i].base, + if (!IsSpellEffectInList(spell_effects_list, parentlist->entries[i].spelleffectid, parentlist->entries[i].base, parentlist->entries[i].limit, parentlist->entries[i].max)) - { + { AddSpellEffectToNPCList(parentlist->entries[i].spelleffectid, parentlist->entries[i].base, parentlist->entries[i].limit, parentlist->entries[i].max); @@ -2528,10 +2528,10 @@ void NPC::ApplyAISpellEffects(StatBonuses* newbon) { if (!AI_HasSpellsEffects()) return; - + for(int i=0; i < AIspellsEffects.size(); i++) { - ApplySpellsBonuses(0, 0, newbon, 0, false, 0,-1, + ApplySpellsBonuses(0, 0, newbon, 0, false, 0,-1, true, AIspellsEffects[i].spelleffectid, AIspellsEffects[i].base, AIspellsEffects[i].limit,AIspellsEffects[i].max); } @@ -2541,10 +2541,10 @@ void NPC::ApplyAISpellEffects(StatBonuses* newbon) // adds a spell to the list, taking into account priority and resorting list as needed. void NPC::AddSpellEffectToNPCList(uint16 iSpellEffectID, int32 base, int32 limit, int32 max) { - + if(!iSpellEffectID) return; - + HasAISpellEffects = true; AISpellsEffects_Struct t; @@ -2627,7 +2627,7 @@ void NPC::AISpellsList(Client *c) DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { if (iDBSpellsID == 0) - return 0; + return nullptr; if (!npc_spells_cache) { npc_spells_maxid = GetMaxNPCSpellsID(); @@ -2640,112 +2640,109 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { } if (iDBSpellsID > npc_spells_maxid) - return 0; + return nullptr; if (npc_spells_cache[iDBSpellsID]) { // it's in the cache, easy =) return npc_spells_cache[iDBSpellsID]; } else if (!npc_spells_loadtried[iDBSpellsID]) { // no reason to ask the DB again if we have failed once already npc_spells_loadtried[iDBSpellsID] = true; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, parent_list, attack_proc, proc_chance, range_proc, rproc_chance, defensive_proc, dproc_chance, fail_recast, engaged_no_sp_recast_min, engaged_no_sp_recast_max, engaged_b_self_chance, engaged_b_other_chance, engaged_d_chance, pursue_no_sp_recast_min, pursue_no_sp_recast_max, pursue_d_chance, idle_no_sp_recast_min, idle_no_sp_recast_max, idle_b_chance from npc_spells where id=%d", iDBSpellsID), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 tmpparent_list = atoi(row[1]); - uint16 tmpattack_proc = atoi(row[2]); - uint8 tmpproc_chance = atoi(row[3]); - uint16 tmprange_proc = atoi(row[4]); - int16 tmprproc_chance = atoi(row[5]); - uint16 tmpdefensive_proc = atoi(row[6]); - int16 tmpdproc_chance = atoi(row[7]); - uint32 tmppfail_recast = atoi(row[8]); - uint32 tmpengaged_no_sp_recast_min = atoi(row[9]); - uint32 tmpengaged_no_sp_recast_max = atoi(row[10]); - uint8 tmpengaged_b_self_chance = atoi(row[11]); - uint8 tmpengaged_b_other_chance = atoi(row[12]); - uint8 tmpengaged_d_chance = atoi(row[13]); - uint32 tmppursue_no_sp_recast_min = atoi(row[14]); - uint32 tmppursue_no_sp_recast_max = atoi(row[15]); - uint8 tmppursue_d_chance = atoi(row[16]); - uint32 tmpidle_no_sp_recast_min = atoi(row[17]); - uint32 tmpidle_no_sp_recast_max = atoi(row[18]); - uint8 tmpidle_b_chance = atoi(row[19]); - mysql_free_result(result); - if (RunQuery(query, MakeAnyLenString(&query, "SELECT spellid, type, minlevel, maxlevel, manacost, recast_delay, priority, resist_adjust from npc_spells_entries where npc_spells_id=%d ORDER BY minlevel", iDBSpellsID), errbuf, &result)) { - safe_delete_array(query); - uint32 tmpSize = sizeof(DBnpcspells_Struct) + (sizeof(DBnpcspells_entries_Struct) * mysql_num_rows(result)); - npc_spells_cache[iDBSpellsID] = (DBnpcspells_Struct*) new uchar[tmpSize]; - memset(npc_spells_cache[iDBSpellsID], 0, tmpSize); - npc_spells_cache[iDBSpellsID]->parent_list = tmpparent_list; - npc_spells_cache[iDBSpellsID]->attack_proc = tmpattack_proc; - npc_spells_cache[iDBSpellsID]->proc_chance = tmpproc_chance; - npc_spells_cache[iDBSpellsID]->range_proc = tmprange_proc; - npc_spells_cache[iDBSpellsID]->rproc_chance = tmpdproc_chance; - npc_spells_cache[iDBSpellsID]->defensive_proc = tmpdefensive_proc; - npc_spells_cache[iDBSpellsID]->dproc_chance = tmpdproc_chance; - npc_spells_cache[iDBSpellsID]->fail_recast = tmppfail_recast; - npc_spells_cache[iDBSpellsID]->engaged_no_sp_recast_min = tmpengaged_no_sp_recast_min; - npc_spells_cache[iDBSpellsID]->engaged_no_sp_recast_max = tmpengaged_no_sp_recast_max; - npc_spells_cache[iDBSpellsID]->engaged_beneficial_self_chance = tmpengaged_b_self_chance; - npc_spells_cache[iDBSpellsID]->engaged_beneficial_other_chance = tmpengaged_b_other_chance; - npc_spells_cache[iDBSpellsID]->engaged_detrimental_chance = tmpengaged_d_chance; - npc_spells_cache[iDBSpellsID]->pursue_no_sp_recast_min = tmppursue_no_sp_recast_min; - npc_spells_cache[iDBSpellsID]->pursue_no_sp_recast_max = tmppursue_no_sp_recast_max; - npc_spells_cache[iDBSpellsID]->pursue_detrimental_chance = tmppursue_d_chance; - npc_spells_cache[iDBSpellsID]->idle_no_sp_recast_min = tmpidle_no_sp_recast_min; - npc_spells_cache[iDBSpellsID]->idle_no_sp_recast_max = tmpidle_no_sp_recast_max; - npc_spells_cache[iDBSpellsID]->idle_beneficial_chance = tmpidle_b_chance; - npc_spells_cache[iDBSpellsID]->numentries = mysql_num_rows(result); - int j = 0; - while ((row = mysql_fetch_row(result))) { - int spell_id = atoi(row[0]); - npc_spells_cache[iDBSpellsID]->entries[j].spellid = spell_id; - npc_spells_cache[iDBSpellsID]->entries[j].type = atoi(row[1]); - npc_spells_cache[iDBSpellsID]->entries[j].minlevel = atoi(row[2]); - npc_spells_cache[iDBSpellsID]->entries[j].maxlevel = atoi(row[3]); - npc_spells_cache[iDBSpellsID]->entries[j].manacost = atoi(row[4]); - npc_spells_cache[iDBSpellsID]->entries[j].recast_delay = atoi(row[5]); - npc_spells_cache[iDBSpellsID]->entries[j].priority = atoi(row[6]); - if(row[7]) - { - npc_spells_cache[iDBSpellsID]->entries[j].resist_adjust = atoi(row[7]); - } - else - { - if(IsValidSpell(spell_id)) - { - npc_spells_cache[iDBSpellsID]->entries[j].resist_adjust = spells[spell_id].ResistDiff; - } - } - j++; - } - mysql_free_result(result); - return npc_spells_cache[iDBSpellsID]; - } - else { - std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); - return 0; - } - } - else { - mysql_free_result(result); - } - } - else { - std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); - return 0; - } + std::string query = StringFormat("SELECT id, parent_list, attack_proc, proc_chance, " + "range_proc, rproc_chance, defensive_proc, dproc_chance, " + "fail_recast, engaged_no_sp_recast_min, engaged_no_sp_recast_max, " + "engaged_b_self_chance, engaged_b_other_chance, engaged_d_chance, " + "pursue_no_sp_recast_min, pursue_no_sp_recast_max, " + "pursue_d_chance, idle_no_sp_recast_min, idle_no_sp_recast_max, " + "idle_b_chance FROM npc_spells WHERE id=%d", iDBSpellsID); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << results.ErrorMessage() << std::endl; + return nullptr; + } - return 0; - } - return 0; + if (results.RowCount() != 1) + return nullptr; + + auto row = results.begin(); + uint32 tmpparent_list = atoi(row[1]); + uint16 tmpattack_proc = atoi(row[2]); + uint8 tmpproc_chance = atoi(row[3]); + uint16 tmprange_proc = atoi(row[4]); + int16 tmprproc_chance = atoi(row[5]); + uint16 tmpdefensive_proc = atoi(row[6]); + int16 tmpdproc_chance = atoi(row[7]); + uint32 tmppfail_recast = atoi(row[8]); + uint32 tmpengaged_no_sp_recast_min = atoi(row[9]); + uint32 tmpengaged_no_sp_recast_max = atoi(row[10]); + uint8 tmpengaged_b_self_chance = atoi(row[11]); + uint8 tmpengaged_b_other_chance = atoi(row[12]); + uint8 tmpengaged_d_chance = atoi(row[13]); + uint32 tmppursue_no_sp_recast_min = atoi(row[14]); + uint32 tmppursue_no_sp_recast_max = atoi(row[15]); + uint8 tmppursue_d_chance = atoi(row[16]); + uint32 tmpidle_no_sp_recast_min = atoi(row[17]); + uint32 tmpidle_no_sp_recast_max = atoi(row[18]); + uint8 tmpidle_b_chance = atoi(row[19]); + + query = StringFormat("SELECT spellid, type, minlevel, maxlevel, " + "manacost, recast_delay, priority, resist_adjust " + "FROM npc_spells_entries " + "WHERE npc_spells_id=%d ORDER BY minlevel", iDBSpellsID); + results = QueryDatabase(query); + + if (!results.Success()) + { + std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << results.ErrorMessage() << std::endl; + return nullptr; + } + + uint32 tmpSize = sizeof(DBnpcspells_Struct) + (sizeof(DBnpcspells_entries_Struct) * results.RowCount()); + npc_spells_cache[iDBSpellsID] = (DBnpcspells_Struct*) new uchar[tmpSize]; + memset(npc_spells_cache[iDBSpellsID], 0, tmpSize); + npc_spells_cache[iDBSpellsID]->parent_list = tmpparent_list; + npc_spells_cache[iDBSpellsID]->attack_proc = tmpattack_proc; + npc_spells_cache[iDBSpellsID]->proc_chance = tmpproc_chance; + npc_spells_cache[iDBSpellsID]->range_proc = tmprange_proc; + npc_spells_cache[iDBSpellsID]->rproc_chance = tmpdproc_chance; + npc_spells_cache[iDBSpellsID]->defensive_proc = tmpdefensive_proc; + npc_spells_cache[iDBSpellsID]->dproc_chance = tmpdproc_chance; + npc_spells_cache[iDBSpellsID]->fail_recast = tmppfail_recast; + npc_spells_cache[iDBSpellsID]->engaged_no_sp_recast_min = tmpengaged_no_sp_recast_min; + npc_spells_cache[iDBSpellsID]->engaged_no_sp_recast_max = tmpengaged_no_sp_recast_max; + npc_spells_cache[iDBSpellsID]->engaged_beneficial_self_chance = tmpengaged_b_self_chance; + npc_spells_cache[iDBSpellsID]->engaged_beneficial_other_chance = tmpengaged_b_other_chance; + npc_spells_cache[iDBSpellsID]->engaged_detrimental_chance = tmpengaged_d_chance; + npc_spells_cache[iDBSpellsID]->pursue_no_sp_recast_min = tmppursue_no_sp_recast_min; + npc_spells_cache[iDBSpellsID]->pursue_no_sp_recast_max = tmppursue_no_sp_recast_max; + npc_spells_cache[iDBSpellsID]->pursue_detrimental_chance = tmppursue_d_chance; + npc_spells_cache[iDBSpellsID]->idle_no_sp_recast_min = tmpidle_no_sp_recast_min; + npc_spells_cache[iDBSpellsID]->idle_no_sp_recast_max = tmpidle_no_sp_recast_max; + npc_spells_cache[iDBSpellsID]->idle_beneficial_chance = tmpidle_b_chance; + npc_spells_cache[iDBSpellsID]->numentries = results.RowCount(); + + int entryIndex = 0; + for (row = results.begin(); row != results.end(); ++row, ++entryIndex) + { + int spell_id = atoi(row[0]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].spellid = spell_id; + npc_spells_cache[iDBSpellsID]->entries[entryIndex].type = atoi(row[1]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].minlevel = atoi(row[2]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].maxlevel = atoi(row[3]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].manacost = atoi(row[4]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].recast_delay = atoi(row[5]); + npc_spells_cache[iDBSpellsID]->entries[entryIndex].priority = atoi(row[6]); + + if(row[7]) + npc_spells_cache[iDBSpellsID]->entries[entryIndex].resist_adjust = atoi(row[7]); + else if(IsValidSpell(spell_id)) + npc_spells_cache[iDBSpellsID]->entries[entryIndex].resist_adjust = spells[spell_id].ResistDiff; + } + + return npc_spells_cache[iDBSpellsID]; + } + + return nullptr; } uint32 ZoneDatabase::GetMaxNPCSpellsID() { @@ -2805,7 +2802,7 @@ DBnpcspellseffects_Struct* ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEff if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, parent_list from npc_spells_effects where id=%d", iDBSpellsEffectsID), errbuf, &result)) { safe_delete_array(query); if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); + row = mysql_fetch_row(result); uint32 tmpparent_list = atoi(row[1]); mysql_free_result(result); if (RunQuery(query, MakeAnyLenString(&query, "SELECT spell_effect_id, minlevel, maxlevel,se_base, se_limit, se_max from npc_spells_effects_entries where npc_spells_effects_id=%d ORDER BY minlevel", iDBSpellsEffectsID), errbuf, &result)) { From 65cc3a4b0a5c9fb1afee99eb60bc4b9962a35517 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:40:45 -0700 Subject: [PATCH 061/217] GetMaxNPCSpellsID converted to QueryDatabase --- zone/MobAI.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index 4efef2751..6fbcb78d3 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -2746,30 +2746,23 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) { } uint32 ZoneDatabase::GetMaxNPCSpellsID() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT max(id) from npc_spells"), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 ret = 0; - if (row[0]) - ret = atoi(row[0]); - mysql_free_result(result); - return ret; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in GetMaxNPCSpellsID query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = "SELECT max(id) from npc_spells"; + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in GetMaxNPCSpellsID query '" << query << "' " << results.ErrorMessage() << std::endl; return 0; } - return 0; + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + + if (!row[0]) + return 0; + + return atoi(row[0]); } DBnpcspellseffects_Struct* ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEffectsID) { From 580f32c190316ea2613c8ace2b4acb48b744ca40 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 16:57:22 -0700 Subject: [PATCH 062/217] GetNPCSpellsEffects converted to QueryDatabase --- zone/MobAI.cpp | 103 +++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 55 deletions(-) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index 6fbcb78d3..b0a13b7a7 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -2767,7 +2767,7 @@ uint32 ZoneDatabase::GetMaxNPCSpellsID() { DBnpcspellseffects_Struct* ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEffectsID) { if (iDBSpellsEffectsID == 0) - return 0; + return nullptr; if (!npc_spellseffects_cache) { npc_spellseffects_maxid = GetMaxNPCSpellsEffectsID(); @@ -2780,63 +2780,56 @@ DBnpcspellseffects_Struct* ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEff } if (iDBSpellsEffectsID > npc_spellseffects_maxid) - return 0; - if (npc_spellseffects_cache[iDBSpellsEffectsID]) { // it's in the cache, easy =) + return nullptr; + + if (npc_spellseffects_cache[iDBSpellsEffectsID]) // it's in the cache, easy =) return npc_spellseffects_cache[iDBSpellsEffectsID]; - } - else if (!npc_spellseffects_loadtried[iDBSpellsEffectsID]) { // no reason to ask the DB again if we have failed once already - npc_spellseffects_loadtried[iDBSpellsEffectsID] = true; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + if (npc_spellseffects_loadtried[iDBSpellsEffectsID]) + return nullptr; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, parent_list from npc_spells_effects where id=%d", iDBSpellsEffectsID), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 tmpparent_list = atoi(row[1]); - mysql_free_result(result); - if (RunQuery(query, MakeAnyLenString(&query, "SELECT spell_effect_id, minlevel, maxlevel,se_base, se_limit, se_max from npc_spells_effects_entries where npc_spells_effects_id=%d ORDER BY minlevel", iDBSpellsEffectsID), errbuf, &result)) { - safe_delete_array(query); - uint32 tmpSize = sizeof(DBnpcspellseffects_Struct) + (sizeof(DBnpcspellseffects_entries_Struct) * mysql_num_rows(result)); - npc_spellseffects_cache[iDBSpellsEffectsID] = (DBnpcspellseffects_Struct*) new uchar[tmpSize]; - memset(npc_spellseffects_cache[iDBSpellsEffectsID], 0, tmpSize); - npc_spellseffects_cache[iDBSpellsEffectsID]->parent_list = tmpparent_list; - npc_spellseffects_cache[iDBSpellsEffectsID]->numentries = mysql_num_rows(result); - int j = 0; - while ((row = mysql_fetch_row(result))) { - int spell_effect_id = atoi(row[0]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].spelleffectid = spell_effect_id; - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].minlevel = atoi(row[1]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].maxlevel = atoi(row[2]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].base = atoi(row[3]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].limit = atoi(row[4]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[j].max = atoi(row[5]); - j++; - } - mysql_free_result(result); - return npc_spellseffects_cache[iDBSpellsEffectsID]; - } - else { - std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); - return 0; - } - } - else { - mysql_free_result(result); - } - } - else { - std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); - return 0; - } - return 0; - } - return 0; + npc_spellseffects_loadtried[iDBSpellsEffectsID] = true; + + std::string query = StringFormat("SELECT id, parent_list FROM npc_spells_effects WHERE id=%d", iDBSpellsEffectsID); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in AddNPCSpells query1 '" << query << "' " << results.ErrorMessage() << std::endl; + return nullptr; + } + + if (results.RowCount() != 1) + return nullptr; + + auto row = results.begin(); + uint32 tmpparent_list = atoi(row[1]); + + query = StringFormat("SELECT spell_effect_id, minlevel, " + "maxlevel,se_base, se_limit, se_max " + "FROM npc_spells_effects_entries " + "WHERE npc_spells_effects_id = %d ORDER BY minlevel", iDBSpellsEffectsID); + results = QueryDatabase(query); + if (!results.Success()) + return nullptr; + + uint32 tmpSize = sizeof(DBnpcspellseffects_Struct) + (sizeof(DBnpcspellseffects_entries_Struct) * results.RowCount()); + npc_spellseffects_cache[iDBSpellsEffectsID] = (DBnpcspellseffects_Struct*) new uchar[tmpSize]; + memset(npc_spellseffects_cache[iDBSpellsEffectsID], 0, tmpSize); + npc_spellseffects_cache[iDBSpellsEffectsID]->parent_list = tmpparent_list; + npc_spellseffects_cache[iDBSpellsEffectsID]->numentries = results.RowCount(); + + int entryIndex = 0; + for (row = results.begin(); row != results.end(); ++row, ++entryIndex) + { + int spell_effect_id = atoi(row[0]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].spelleffectid = spell_effect_id; + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].minlevel = atoi(row[1]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].maxlevel = atoi(row[2]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].base = atoi(row[3]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].limit = atoi(row[4]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].max = atoi(row[5]); + } + + return npc_spellseffects_cache[iDBSpellsEffectsID]; } uint32 ZoneDatabase::GetMaxNPCSpellsEffectsID() { From d73449104a73a449183089cfe530ed6f2800501e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:00:37 -0700 Subject: [PATCH 063/217] GetMaxNPCSpellsEffectsID converted to QueryDatabase --- zone/MobAI.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index b0a13b7a7..021d6f76b 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -2833,29 +2833,21 @@ DBnpcspellseffects_Struct* ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEff } uint32 ZoneDatabase::GetMaxNPCSpellsEffectsID() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT max(id) from npc_spells_effects"), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 ret = 0; - if (row[0]) - ret = atoi(row[0]); - mysql_free_result(result); - return ret; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in GetMaxNPCSpellsEffectsID query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = "SELECT max(id) FROM npc_spells_effects"; + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in GetMaxNPCSpellsEffectsID query '" << query << "' " << results.ErrorMessage() << std::endl; return 0; } - return 0; + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + if (!row[0]) + return 0; + + return atoi(row[0]); } From 3720d9e50f0972ac163c220bfeda7e89fb5ea037 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:21:27 -0700 Subject: [PATCH 064/217] AddObject converted to QueryDatabase --- zone/Object.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/zone/Object.cpp b/zone/Object.cpp index 44459bab0..3af12e133 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -560,9 +560,6 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object) // Add new Zone Object (theoretically only called for items dropped to ground) uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - uint32 database_id = 0; uint32 item_id = 0; int16 charges = 0; @@ -577,26 +574,24 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob char* object_name = new char[len]; DoEscapeString(object_name, object.object_name, strlen(object.object_name)); - // Construct query - uint32 len_query = MakeAnyLenString(&query, - "insert into object (zoneid, xpos, ypos, zpos, heading, itemid, charges, objectname, " - "type, icon) values (%i, %f, %f, %f, %f, %i, %i, '%s', %i, %i)", - object.zone_id, object.x, object.y, object.z, object.heading, - item_id, charges, object_name, type, icon); - - // Save new record for object - if (!RunQuery(query, len_query, errbuf, nullptr, nullptr, &database_id)) { - LogFile->write(EQEMuLog::Error, "Unable to insert object: %s", errbuf); - } - else { - // Save container contents, if container - if (inst && inst->IsType(ItemClassContainer)) { - SaveWorldContainer(object.zone_id, database_id, inst); - } + // Save new record for object + std::string query = StringFormat("INSERT INTO object " + "(zoneid, xpos, ypos, zpos, heading, " + "itemid, charges, objectname, type, icon) " + "values (%i, %f, %f, %f, %f, %i, %i, '%s', %i, %i)", + object.zone_id, object.x, object.y, object.z, object.heading, + item_id, charges, object_name, type, icon); + safe_delete_array(object_name); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Unable to insert object: %s", results.ErrorMessage().c_str()); + return 0; } - safe_delete_array(object_name); - safe_delete_array(query); + // Save container contents, if container + if (inst && inst->IsType(ItemClassContainer)) + SaveWorldContainer(object.zone_id, database_id, inst); + return database_id; } From 4d83397506ceb5af020e88caf5e1a436b121968f Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:29:19 -0700 Subject: [PATCH 065/217] UpdateObject converted to QueryDatabase --- zone/Object.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/zone/Object.cpp b/zone/Object.cpp index 3af12e133..8d70906da 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -598,9 +598,6 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob // Update information about existing object in database void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - uint32 item_id = 0; int16 charges = 0; @@ -614,27 +611,25 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec char* object_name = new char[len]; DoEscapeString(object_name, object.object_name, strlen(object.object_name)); - // Construct query - uint32 len_query = MakeAnyLenString(&query, - "update object set zoneid=%i, xpos=%f, ypos=%f, zpos=%f, heading=%f, " - "itemid=%i, charges=%i, objectname='%s', type=%i, icon=%i where id=%i", - object.zone_id, object.x, object.y, object.z, object.heading, - item_id, charges, object_name, type, icon, id); - // Save new record for object - if (!RunQuery(query, len_query, errbuf)) { - LogFile->write(EQEMuLog::Error, "Unable to update object: %s", errbuf); - } - else { - // Save container contents, if container - if (inst && inst->IsType(ItemClassContainer)) { - SaveWorldContainer(object.zone_id, id, inst); - } + std::string query = StringFormat("UPDATE object SET " + "zoneid = %i, xpos = %f, ypos = %f, zpos = %f, heading = %f, " + "itemid = %i, charges = %i, objectname = '%s', type = %i, icon = %i " + "WHERE id = %i", + object.zone_id, object.x, object.y, object.z, object.heading, + item_id, charges, object_name, type, icon, id); + safe_delete_array(object_name); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Unable to update object: %s", results.ErrorMessage().c_str()); + return; } - safe_delete_array(object_name); - safe_delete_array(query); + // Save container contents, if container + if (inst && inst->IsType(ItemClassContainer)) + SaveWorldContainer(object.zone_id, id, inst); } + Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs){ char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; From 6ca5fb19f410a7e03f1db59aa7f81e17c3c26b26 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:35:47 -0700 Subject: [PATCH 066/217] LoadGroundSpawns converted to QueryDatabase --- zone/Object.cpp | 53 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/zone/Object.cpp b/zone/Object.cpp index 8d70906da..415de7537 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -630,37 +630,36 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec SaveWorldContainer(object.zone_id, id, inst); } -Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; +Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs) { - if (RunQuery(query, MakeAnyLenString(&query, "SELECT max_x,max_y,max_z,min_x,min_y,heading,name,item,max_allowed,respawn_timer from ground_spawns where zoneid=%i and (version=%u OR version=-1) limit 50", zone_id, version), errbuf, &result)) - { - safe_delete_array(query); - int i=0; - while( (row=mysql_fetch_row(result) ) ) { - gs->spawn[i].max_x=atof(row[0]); - gs->spawn[i].max_y=atof(row[1]); - gs->spawn[i].max_z=atof(row[2]); - gs->spawn[i].min_x=atof(row[3]); - gs->spawn[i].min_y=atof(row[4]); - gs->spawn[i].heading=atof(row[5]); - strcpy(gs->spawn[i].name,row[6]); - gs->spawn[i].item=atoi(row[7]); - gs->spawn[i].max_allowed=atoi(row[8]); - gs->spawn[i].respawntimer=atoi(row[9]); - i++; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in LoadGroundSpawns query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT max_x, max_y, max_z, " + "min_x, min_y, heading, name, " + "item, max_allowed, respawn_timer " + "FROM ground_spawns " + "WHERE zoneid = %i AND (version = %u OR version = -1) " + "LIMIT 50", zone_id, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in LoadGroundSpawns query '" << query << "' " << results.ErrorMessage() << std::endl; + return gs; } + + int spawnIndex=0; + for (auto row = results.begin(); row != results.end(); ++row, ++spawnIndex) { + gs->spawn[spawnIndex].max_x=atof(row[0]); + gs->spawn[spawnIndex].max_y=atof(row[1]); + gs->spawn[spawnIndex].max_z=atof(row[2]); + gs->spawn[spawnIndex].min_x=atof(row[3]); + gs->spawn[spawnIndex].min_y=atof(row[4]); + gs->spawn[spawnIndex].heading=atof(row[5]); + strcpy(gs->spawn[spawnIndex].name,row[6]); + gs->spawn[spawnIndex].item=atoi(row[7]); + gs->spawn[spawnIndex].max_allowed=atoi(row[8]); + gs->spawn[spawnIndex].respawntimer=atoi(row[9]); + } return gs; } + void ZoneDatabase::DeleteObject(uint32 id) { char errbuf[MYSQL_ERRMSG_SIZE]; From d8856a7bae7013a3ed1181a47263b486fa974ae3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:37:57 -0700 Subject: [PATCH 067/217] DeleteObject converted to QueryDatabase --- zone/Object.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/zone/Object.cpp b/zone/Object.cpp index 415de7537..ea746c090 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -662,23 +662,12 @@ Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Gro void ZoneDatabase::DeleteObject(uint32 id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - // Construct query - uint32 len_query = MakeAnyLenString(&query, - "delete from object where id=%i", id); - - // Save new record for object - if (!RunQuery(query, len_query, errbuf)) { - LogFile->write(EQEMuLog::Error, "Unable to delete object: %s", errbuf); + // delete record of object + std::string query = StringFormat("DELETE FROM object WHERE id = %i", id); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Unable to delete object: %s", results.ErrorMessage().c_str()); } - //else { - // Delete contained items, if any - // DeleteWorldContainer(id); - //} - - safe_delete_array(query); } uint32 Object::GetDBID() From 5234eb6fc8aeccf666f61bcf62c6b7712673f138 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:50:03 -0700 Subject: [PATCH 068/217] LoadNPCByNPCID converted to QueryDatabase --- zone/QGlobals.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 73faa8b2c..b14713c81 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -51,7 +51,7 @@ void QGlobalCache::Combine(std::list &cacheA, std::list cacheB void QGlobalCache::GetQGlobals(std::list &globals, NPC *n, Client *c, Zone *z) { globals.clear(); - + QGlobalCache *npc_c = nullptr; QGlobalCache *char_c = nullptr; QGlobalCache *zone_c = nullptr; @@ -139,21 +139,15 @@ void QGlobalCache::PurgeExpiredGlobals() void QGlobalCache::LoadByNPCID(uint32 npcID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " + "FROM quest_globals WHERE npcid = %d", npcID); + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; + + for (auto row = results.begin(); row != results.end(); ++row) + AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); - if (database.RunQuery(query, MakeAnyLenString(&query, "select name, charid, npcid, zoneid, value, expdate" - " from quest_globals where npcid = %d", npcID), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]?atoi(row[5]):0xFFFFFFFF)); - } - mysql_free_result(result); - } - safe_delete_array(query); } void QGlobalCache::LoadByCharID(uint32 charID) From c6b2b1da4e353323c8d6cceb2391c345a5d1e20c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:53:05 -0700 Subject: [PATCH 069/217] LoadByCharID converted to QueryDatabase --- zone/QGlobals.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index b14713c81..9146340a3 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -152,21 +152,15 @@ void QGlobalCache::LoadByNPCID(uint32 npcID) void QGlobalCache::LoadByCharID(uint32 charID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " + "FROM quest_globals WHERE charid = %d && npcid = 0", charID); + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; + + for (auto row = results.begin(); row != results.end(); ++row) + AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); - if (database.RunQuery(query, MakeAnyLenString(&query, "select name, charid, npcid, zoneid, value, expdate from" - " quest_globals where charid = %d && npcid = 0", charID), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]?atoi(row[5]):0xFFFFFFFF)); - } - mysql_free_result(result); - } - safe_delete_array(query); } void QGlobalCache::LoadByZoneID(uint32 zoneID) From 810553de2af02a4c47ba32ff21a19db62e11d051 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:55:35 -0700 Subject: [PATCH 070/217] LoadByZoneID converted to QueryDatabase --- zone/QGlobals.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 9146340a3..24fd4119c 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -165,22 +165,16 @@ void QGlobalCache::LoadByCharID(uint32 charID) void QGlobalCache::LoadByZoneID(uint32 zoneID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " + "FROM quest_globals WHERE zoneid = %d && npcid = 0 && charid = 0", zoneID); + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; - if (database.RunQuery(query, MakeAnyLenString(&query, "select name, charid, npcid, zoneid, value, expdate from quest_globals" - " where zoneid = %d && npcid = 0 && charid = 0", zoneID), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]?atoi(row[5]):0xFFFFFFFF)); - } - mysql_free_result(result); - } - safe_delete_array(query); + for (auto row = results.begin(); row != results.end(); ++row) + AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); } + void QGlobalCache::LoadByGlobalContext() { char errbuf[MYSQL_ERRMSG_SIZE]; From f7781e6d1dee3986424cd322335a73f178b9a451 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Mon, 18 Aug 2014 17:35:58 -0400 Subject: [PATCH 071/217] Renames spells_new fields. field191 => viral_targets field192 => viral_timer --- utils/sql/git/required/2014_08_18_spells_new_update.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 utils/sql/git/required/2014_08_18_spells_new_update.sql diff --git a/utils/sql/git/required/2014_08_18_spells_new_update.sql b/utils/sql/git/required/2014_08_18_spells_new_update.sql new file mode 100644 index 000000000..bda3a55a4 --- /dev/null +++ b/utils/sql/git/required/2014_08_18_spells_new_update.sql @@ -0,0 +1,2 @@ +ALTER TABLE `spells_new` CHANGE `field191` `viral_targets` INT(11) NOT NULL DEFAULT '0'; +ALTER TABLE `spells_new` CHANGE `field192` `viral_timer` INT(11) NOT NULL DEFAULT '0'; \ No newline at end of file From 8d909ea8e279faa5abd652a3f049daac0a2e3ebb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 17:58:51 -0700 Subject: [PATCH 072/217] LoadByGlobalContext converted to QueryDatabase --- zone/QGlobals.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 24fd4119c..7bd09d8f7 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -177,19 +177,12 @@ void QGlobalCache::LoadByZoneID(uint32 zoneID) void QGlobalCache::LoadByGlobalContext() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = "SELECT name, charid, npcid, zoneid, value, expdate " + "FROM quest_globals WHERE zoneid = 0 && npcid = 0 && charid = 0"; + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; - if (database.RunQuery(query, MakeAnyLenString(&query, "select name, charid, npcid, zoneid, value, expdate from quest_globals" - " where zoneid = 0 && npcid = 0 && charid = 0"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]?atoi(row[5]):0xFFFFFFFF)); - } - mysql_free_result(result); - } - safe_delete_array(query); + for (auto row = results.begin(); row != results.end(); ++row) + AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); } From 7692793289f8bd3bc03aa8696edbe81d16e74f73 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:10:28 -0700 Subject: [PATCH 073/217] Consolidated LoadBy code into new LoadBy method --- zone/QGlobals.cpp | 29 +++++++++-------------------- zone/QGlobals.h | 1 + 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 7bd09d8f7..d21bebf2d 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -141,48 +141,37 @@ void QGlobalCache::LoadByNPCID(uint32 npcID) { std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " "FROM quest_globals WHERE npcid = %d", npcID); - auto results = database.QueryDatabase(query); - if (!results.Success()) - return; - - for (auto row = results.begin(); row != results.end(); ++row) - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); - + LoadBy(query); } void QGlobalCache::LoadByCharID(uint32 charID) { std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " "FROM quest_globals WHERE charid = %d && npcid = 0", charID); - auto results = database.QueryDatabase(query); - if (!results.Success()) - return; - - for (auto row = results.begin(); row != results.end(); ++row) - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); - + LoadBy(query); } void QGlobalCache::LoadByZoneID(uint32 zoneID) { std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate " "FROM quest_globals WHERE zoneid = %d && npcid = 0 && charid = 0", zoneID); - auto results = database.QueryDatabase(query); - if (!results.Success()) - return; - - for (auto row = results.begin(); row != results.end(); ++row) - AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); + LoadBy(query); } void QGlobalCache::LoadByGlobalContext() { std::string query = "SELECT name, charid, npcid, zoneid, value, expdate " "FROM quest_globals WHERE zoneid = 0 && npcid = 0 && charid = 0"; + LoadBy(query); + } + +void QGlobalCache::LoadBy(const std::string query) +{ auto results = database.QueryDatabase(query); if (!results.Success()) return; for (auto row = results.begin(); row != results.end(); ++row) AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF)); + } diff --git a/zone/QGlobals.h b/zone/QGlobals.h index 73a795186..b879cba97 100644 --- a/zone/QGlobals.h +++ b/zone/QGlobals.h @@ -42,6 +42,7 @@ public: void LoadByZoneID(uint32 zoneID); //zone void LoadByGlobalContext(); //zone protected: + void LoadBy(const std::string query); std::list qGlobalBucket; }; From b672475166f41fc70fb98a990e9b26e3724837bb Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:23:22 -0700 Subject: [PATCH 074/217] LoadSettings converted to QueryDatabase --- world/EQLConfig.cpp | 57 ++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 90955a620..4d2ea009c 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -33,46 +33,35 @@ EQLConfig::EQLConfig(const char *launcher_name) } void EQLConfig::LoadSettings() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - LauncherZone tmp; + LauncherZone tmp; char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - if (database.RunQuery(query, MakeAnyLenString(&query, - "SELECT dynamics FROM launcher WHERE name='%s'", - namebuf) - , errbuf, &result)) - { - while ((row = mysql_fetch_row(result))) { - m_dynamics = atoi(row[0]); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("SELECT dynamics FROM launcher WHERE name = '%s'", namebuf); + auto results = database.QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); + else { + auto row = results.begin(); + m_dynamics = atoi(row[0]); + } + + query = StringFormat("SELECT zone, port FROM launcher_zones WHERE launcher = '%s'", namebuf); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); + return; + } + + LauncherZone zs; + for (auto row = results.begin(); row != results.end(); ++row) { + zs.name = row[0]; + zs.port = atoi(row[1]); + m_zones[zs.name] = zs; + } - if (database.RunQuery(query, MakeAnyLenString(&query, - "SELECT zone,port FROM launcher_zones WHERE launcher='%s'", - namebuf) - , errbuf, &result)) - { - LauncherZone zs; - while ((row = mysql_fetch_row(result))) { - zs.name = row[0]; - zs.port = atoi(row[1]); - m_zones[zs.name] = zs; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf); - } - safe_delete_array(query); } EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) { From 352d46d2eee75298542d0eb81fec7f1c6baaa8f5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:25:26 -0700 Subject: [PATCH 075/217] CreateLauncher converted to QueryDatabase --- world/EQLConfig.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 4d2ea009c..87606ce5f 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -65,23 +65,19 @@ void EQLConfig::LoadSettings() { } EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; char namebuf[128]; database.DoEscapeString(namebuf, name, strlen(name)&0x3F); //limit len to 64 namebuf[127] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO launcher (name,dynamics) VALUES('%s', %d)", - namebuf, dynamic_count), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("INSERT INTO launcher (name, dynamics) VALUES('%s', %d)", namebuf, dynamic_count); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", results.ErrorMessage().c_str()); return nullptr; } - safe_delete_array(query); - return(new EQLConfig(name)); + return new EQLConfig(name); } void EQLConfig::GetZones(std::vector &result) { From b5a46735df3a0297187a318c144111a6837eb3a6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:28:54 -0700 Subject: [PATCH 076/217] DeleteLauncher converted to QueryDatabase --- world/EQLConfig.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 87606ce5f..95b176e07 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -111,30 +111,23 @@ void EQLConfig::DeleteLauncher() { launcher_list.Remove(m_name.c_str()); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher WHERE name='%s'", - namebuf), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("DELETE FROM launcher WHERE name = '%s'", namebuf); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1st query: %s", results.ErrorMessage().c_str()); return; } - safe_delete_array(query); - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher_zones WHERE launcher='%s'", - namebuf), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf); - safe_delete_array(query); + query = StringFormat("DELETE FROM launcher_zones WHERE launcher = '%s'", namebuf); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2nd query: %s", results.ErrorMessage().c_str()); return; } - safe_delete_array(query); } bool EQLConfig::IsConnected() const { From e4320f98f8679f06bc6733fa52186e489a8d6116 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:31:20 -0700 Subject: [PATCH 077/217] BootStaticZone converted to QueryDatabase --- world/EQLConfig.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 95b176e07..216d61e7d 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -159,12 +159,9 @@ void EQLConfig::StartZone(Const_char *zone_ref) { bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { //make sure the short name is valid. if(database.GetZoneID(short_name) == 0) - return(false); + return false; //database update - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; @@ -172,14 +169,13 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)", - namebuf, zonebuf, port), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("INSERT INTO launcher_zones (launcher, zone, port) " + "VALUES('%s', '%s', %d)", namebuf, zonebuf, port); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); //update our internal state. LauncherZone lz; @@ -193,7 +189,7 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { ll->BootZone(short_name, port); } - return(true); + return true; } bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { From 0af394fb96b11d4b4f04a13904a472af70f36e5c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:34:15 -0700 Subject: [PATCH 078/217] ChangeStaticZone converted to QueryDatabase --- world/EQLConfig.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 216d61e7d..bf15dc587 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -195,7 +195,7 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { //make sure the short name is valid. if(database.GetZoneID(short_name) == 0) - return(false); + return false; //check internal state std::map::iterator res; @@ -203,14 +203,9 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { if(res == m_zones.end()) { //not found. LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name); - return(false); + return false; } - - //database update - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; @@ -218,15 +213,13 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'", - port, namebuf, zonebuf), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("UPDATE launcher_zones SET port=%d WHERE " + "launcher = '%s' AND zone = '%s'",port, namebuf, zonebuf); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - //update internal state res->second.port = port; @@ -237,7 +230,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { ll->RestartZone(short_name); } - return(true); + return true; } bool EQLConfig::DeleteStaticZone(Const_char *short_name) { From ab70427b7d1bb307ecc1187f8b1fd3c6be5d5f05 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:36:08 -0700 Subject: [PATCH 079/217] DeleteStaticZone converted to QueryDatabase --- world/EQLConfig.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index bf15dc587..4597ff5a1 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -240,13 +240,9 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) { if(res == m_zones.end()) { //not found. LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name); - return(false); + return false; } - //database update - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; @@ -254,14 +250,13 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) { database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'", - namebuf, zonebuf), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("DELETE FROM launcher_zones WHERE " + "launcher = '%s' AND zone = '%s'", namebuf, zonebuf); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); //internal update. m_zones.erase(res); From c4f1f57f748b5ddd6ebd1b85af8cad41a49cb451 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:38:51 -0700 Subject: [PATCH 080/217] SetDynamicCount converted to QueryDatabase --- world/EQLConfig.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 4597ff5a1..6c5ddaf39 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -271,21 +271,17 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) { } bool EQLConfig::SetDynamicCount(int count) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "UPDATE launcher SET dynamics=%d WHERE name='%s'", - count, namebuf), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", errbuf); - safe_delete_array(query); + std::string query = StringFormat("UPDATE launcher SET dynamics=%d WHERE name='%s'", count, namebuf); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); //update in-memory version. m_dynamics = count; @@ -296,7 +292,7 @@ bool EQLConfig::SetDynamicCount(int count) { ll->BootDynamics(count); } - return(false); + return false; } int EQLConfig::GetDynamicCount() const { From e2d85337d0877d836965f9a53de46fbd12d6cce5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 18:54:40 -0700 Subject: [PATCH 081/217] Process converted to QueryDatabase --- world/zoneserver.cpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 73a4a6c67..9c40ce516 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -446,31 +446,34 @@ bool ZoneServer::Process() { zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); } else if (cle->Online() == CLE_Status_Zoning) { - if (!scm->noreply) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - //MYSQL_ROW row; Trumpcard - commenting. Currently unused. + if (!scm->noreply) + { time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); char *telldate=asctime(timeinfo); - if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT name from character_ where name='%s'",scm->deliverto), errbuf, &result)) { - safe_delete(query); - if (result!=0) { - if (database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO tellque (Date,Receiver,Sender,Message) values('%s','%s','%s','%s')",telldate,scm->deliverto,scm->from,scm->message), errbuf, &result)) - zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to); - else - zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); - safe_delete(query); - } - else - zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); - mysql_free_result(result); - } - else - safe_delete(query); + + std::string query = StringFormat("SELECT name FROM character_ WHERE name = '%s'",scm->deliverto); + auto results = database.QueryDatabase(query); + if (!results.Success()) + break; + + if (results.RowCount() == 0) { + zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); + break; + } + + query = StringFormat("INSERT INTO tellque " + "(Date, Receiver, Sender, Message) " + "VALUES('%s', '%s', '%s', '%s')", + telldate, scm->deliverto, scm->from, scm->message); + results = database.QueryDatabase(query); + if (results.Success()) + zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to); + else + zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); + } // zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to); } From 43326c1804f53bba6edf4861aa6b4914b5ed92a4 Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 18 Aug 2014 22:13:15 -0400 Subject: [PATCH 082/217] Fix for perl scripts passing non-client objects to API handler for MovePC and MovePCInstance. [Fixes #127] --- changelog.txt | 3 +++ zone/doors.cpp | 3 +-- zone/perl_client.cpp | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 556069f21..b63e8a5dc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/18/2014 == +Uleat: Fix for https://github.com/EQEmu/Server/issues/127 -- also activated a remarked action in doors.cpp to eliminate a memory leak. + == 08/16/2014 == KLS: (addmoreice) Trying out some unstable DB changes. Do backup your database before trying them as master will be considered unstable for a few days at least. Uleat (Noudness): Fixed a floating-point comparison error that led to the notorious 'client bounce' (this is not related to the diff --git a/zone/doors.cpp b/zone/doors.cpp index ab0b54c8f..a453191a1 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -253,8 +253,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) strcpy(tmpmsg, "Door is locked by an unknown guild"); } sender->Message(4, tmpmsg); - // safe_delete(outapp); - // /\ possible missing line..all other 'fail' returns seem to have it + safe_delete(outapp); return; } // a key is required or the door is locked but can be picked or both diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 816956d86..ecb2c4d18 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1259,7 +1259,22 @@ XS(XS_Client_MovePC) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->MovePC(zoneID, x, y, z, heading); + if (THIS->IsClient()) { + THIS->MovePC(zoneID, x, y, z, heading); + } + else { + if (THIS->IsBot()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Bot reference"); + else if (THIS->IsMerc()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Merc reference"); + else if (THIS->IsNPC()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type NPC reference"); + else + _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process an Unknown type reference"); + + Perl_croak(aTHX_ "THIS is not of type Client"); + } + } XSRETURN_EMPTY; } @@ -1288,7 +1303,21 @@ XS(XS_Client_MovePCInstance) if(THIS == nullptr) Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); - THIS->MovePC(zoneID, instanceID, x, y, z, heading); + if (THIS->IsClient()) { + THIS->MovePC(zoneID, instanceID, x, y, z, heading); + } + else { + if (THIS->IsBot()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); + else if (THIS->IsMerc()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); + else if (THIS->IsNPC()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); + else + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); + + Perl_croak(aTHX_ "THIS is not of type Client"); + } } XSRETURN_EMPTY; } From 9cdf0a7a8362774ee60c00ea8366629662b88f19 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 19:09:06 -0700 Subject: [PATCH 083/217] GetZoneForage converted to QueryDatabase --- zone/forage.cpp | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/zone/forage.cpp b/zone/forage.cpp index 4f8d17c0c..b4d35993a 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -85,12 +85,7 @@ CREATE TABLE fishing ( // This allows EqEmu to have zone specific foraging - BoB uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - uint8 index = 0; uint32 item[FORAGE_ITEM_LIMIT]; uint32 chance[FORAGE_ITEM_LIMIT]; uint32 ret; @@ -100,31 +95,32 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { } uint32 chancepool = 0; - - if (RunQuery(query, MakeAnyLenString(&query, "SELECT itemid,chance FROM forage WHERE zoneid= '%i' and level <= '%i' LIMIT %i", ZoneID, skill, FORAGE_ITEM_LIMIT), errbuf, &result)) - { - safe_delete_array(query); - while ((row = mysql_fetch_row(result)) && (index < FORAGE_ITEM_LIMIT)) { - item[index] = atoi(row[0]); - chance[index] = atoi(row[1])+chancepool; -LogFile->write(EQEMuLog::Error, "Possible Forage: %d with a %d chance", item[index], chance[index]); - chancepool = chance[index]; - index++; - } - - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in Forage query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT itemid, chance FROM " + "forage WHERE zoneid = '%i' and level <= '%i' " + "LIMIT %i", ZoneID, skill, FORAGE_ITEM_LIMIT); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Forage query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return 0; } + uint8 index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + if (index >= FORAGE_ITEM_LIMIT) + break; + + item[index] = atoi(row[0]); + chance[index] = atoi(row[1]) + chancepool; + LogFile->write(EQEMuLog::Error, "Possible Forage: %d with a %d chance", item[index], chance[index]); + chancepool = chance[index]; + } + + if(chancepool == 0 || index < 1) - return(0); + return 0; if(index == 1) { - return(item[0]); + return item[0]; } ret = 0; From 65e865a5505f281f6103469eccc8e067fe8418ac Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 19:18:51 -0700 Subject: [PATCH 084/217] GetZoneFishing converted to QueryDatabase --- zone/forage.cpp | 74 +++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/zone/forage.cpp b/zone/forage.cpp index b4d35993a..19e52d96d 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -139,12 +139,6 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - uint8 index = 0; uint32 item[50]; uint32 chance[50]; uint32 npc_ids[50]; @@ -157,44 +151,44 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, chance[c]=0; } - if (RunQuery(query, MakeAnyLenString(&query, "SELECT itemid,chance,npc_id,npc_chance FROM fishing WHERE (zoneid= '%i' || zoneid = 0) and skill_level <= '%i'",ZoneID, skill ), errbuf, &result)) - { - safe_delete_array(query); - while ((row = mysql_fetch_row(result))&&(index<50)) { - item[index] = atoi(row[0]); - chance[index] = atoi(row[1])+chancepool; - chancepool = chance[index]; - - npc_ids[index] = atoi(row[2]); - npc_chances[index] = atoi(row[3]); - index++; - } - - mysql_free_result(result); - } - else { - std::cerr << "Error in Fishing query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT itemid, chance, npc_id, npc_chance " + "FROM fishing WHERE (zoneid = '%i' || zoneid = 0) AND skill_level <= '%i'", + ZoneID, skill); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in Fishing query '" << query << "' " << results.ErrorMessage() << std::endl; return 0; - } + } + + uint8 index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + if (index >= 50) + break; + + item[index] = atoi(row[0]); + chance[index] = atoi(row[1])+chancepool; + chancepool = chance[index]; + + npc_ids[index] = atoi(row[2]); + npc_chances[index] = atoi(row[3]); + } npc_id = 0; npc_chance = 0; - if (index>0) { - uint32 random = MakeRandomInt(1, chancepool); - for (int i = 0; i < index; i++) - { - if (random <= chance[i]) - { - ret = item[i]; - npc_id = npc_ids[i]; - npc_chance = npc_chances[i]; - break; - } - } - } else { - ret = 0; - } + if (index <= 0) + return 0; + + uint32 random = MakeRandomInt(1, chancepool); + for (int i = 0; i < index; i++) + { + if (random > chance[i]) + continue; + + ret = item[i]; + npc_id = npc_ids[i]; + npc_chance = npc_chances[i]; + break; + } return ret; } From 9814a6e5a202526ee8d8a2deaca1a75fafd88c72 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 20:55:28 -0700 Subject: [PATCH 085/217] BuildHorseType converted to QueryDatabase --- zone/horse.cpp | 101 ++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 60 deletions(-) diff --git a/zone/horse.cpp b/zone/horse.cpp index 04c826df0..cbeb708b0 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -67,70 +67,51 @@ const NPCType *Horse::GetHorseType(uint16 spell_id) { const NPCType *Horse::BuildHorseType(uint16 spell_id) { - const char* FileName = spells[spell_id].teleport_zone; + const char* fileName = spells[spell_id].teleport_zone; - char mount_color = 0; - - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (database.RunQuery(query,MakeAnyLenString(&query, "SELECT race,gender,texture,mountspeed FROM horses WHERE filename='%s'", FileName), errbuf, &result)) { - - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - - row = mysql_fetch_row(result); - - NPCType* npc_type = new NPCType; - memset(npc_type, 0, sizeof(NPCType)); - strcpy(npc_type->name,"Unclaimed_Mount"); //this should never get used - - strcpy(npc_type->special_abilities, "19,1^20,1^24,1"); - npc_type->cur_hp = 1; - npc_type->max_hp = 1; - npc_type->race = atoi(row[0]); - npc_type->gender = atoi(row[1]); // Drogmor's are female horses. Yuck. - npc_type->class_ = 1; - npc_type->deity= 1; - npc_type->level = 1; - npc_type->npc_id = 0; - npc_type->loottable_id = 0; - npc_type->texture = atoi(row[2]); - npc_type->helmtexture = atoi(row[2]); - npc_type->runspeed = atof(row[3]); - - mount_color = atoi(row[2]); - - npc_type->light = 0; - npc_type->STR = 75; - npc_type->STA = 75; - npc_type->DEX = 75; - npc_type->AGI = 75; - npc_type->INT = 75; - npc_type->WIS = 75; - npc_type->CHA = 75; - - horses_auto_delete.Insert(npc_type); - - mysql_free_result(result); - return(npc_type); - } - else { - LogFile->write(EQEMuLog::Error, "No Database entry for mount: %s, check the horses table", FileName); - //Message(13, "Unable to find data for mount %s", FileName); - safe_delete_array(query); - } - mysql_free_result(result); - return nullptr; - } - else { - LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT race, gender, texture, mountspeed FROM horses WHERE filename = '%s'", fileName); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return nullptr; } + if (results.RowCount() != 1) { + LogFile->write(EQEMuLog::Error, "No Database entry for mount: %s, check the horses table", fileName); + return nullptr; + } + + auto row = results.begin(); + + NPCType* npc_type = new NPCType; + memset(npc_type, 0, sizeof(NPCType)); + strcpy(npc_type->name,"Unclaimed_Mount"); //this should never get used + + strcpy(npc_type->special_abilities, "19,1^20,1^24,1"); + npc_type->cur_hp = 1; + npc_type->max_hp = 1; + npc_type->race = atoi(row[0]); + npc_type->gender = atoi(row[1]); // Drogmor's are female horses. Yuck. + npc_type->class_ = 1; + npc_type->deity= 1; + npc_type->level = 1; + npc_type->npc_id = 0; + npc_type->loottable_id = 0; + npc_type->texture = atoi(row[2]); // mount color + npc_type->helmtexture = atoi(row[2]); // mount color + npc_type->runspeed = atof(row[3]); + + npc_type->light = 0; + npc_type->STR = 75; + npc_type->STA = 75; + npc_type->DEX = 75; + npc_type->AGI = 75; + npc_type->INT = 75; + npc_type->WIS = 75; + npc_type->CHA = 75; + horses_auto_delete.Insert(npc_type); + + return npc_type; } void Client::SummonHorse(uint16 spell_id) { From e907ab4f3e2b210e7011dfbe02587e2a2a4052f4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:01:27 -0700 Subject: [PATCH 086/217] LoadMercTypes converted to QueryDatabase --- zone/merc.cpp | 129 ++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 67 deletions(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index ff4581489..8c34d2e05 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2773,7 +2773,7 @@ int16 Merc::GetFocusEffect(focusType type, uint16 spell_id) { int32 Merc::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) { - + if (spells[spell_id].targettype == ST_Self) return value; @@ -2784,9 +2784,9 @@ int32 Merc::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) { int chance = RuleI(Spells, BaseCritChance); chance += itembonuses.CriticalSpellChance + spellbonuses.CriticalSpellChance + aabonuses.CriticalSpellChance; - + if (chance > 0){ - + int32 ratio = RuleI(Spells, BaseCritRatio); //Critical modifier is applied from spell effects only. Keep at 100 for live like criticals. if (MakeRandomInt(1,100) <= chance){ @@ -2801,29 +2801,29 @@ int32 Merc::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) { } ratio += RuleI(Spells, WizCritRatio); //Default is zero - + if (Critical){ - value = value_BaseEffect*ratio/100; + value = value_BaseEffect*ratio/100; - value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100; + value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100; value += int(value_BaseEffect*GetFocusEffect(focusFcDamagePctCrit, spell_id)/100)*ratio/100; if (target) { - value += int(value_BaseEffect*target->GetVulnerability(this, spell_id, 0)/100)*ratio/100; - value -= target->GetFcDamageAmtIncoming(this, spell_id); + value += int(value_BaseEffect*target->GetVulnerability(this, spell_id, 0)/100)*ratio/100; + value -= target->GetFcDamageAmtIncoming(this, spell_id); } - value -= GetFocusEffect(focusFcDamageAmtCrit, spell_id)*ratio/100; + value -= GetFocusEffect(focusFcDamageAmtCrit, spell_id)*ratio/100; - value -= GetFocusEffect(focusFcDamageAmt, spell_id); + value -= GetFocusEffect(focusFcDamageAmt, spell_id); if(itembonuses.SpellDmg && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5) value -= GetExtraSpellAmt(spell_id, itembonuses.SpellDmg, value)*ratio/100; - value = (value * GetSpellScale() / 100); - + value = (value * GetSpellScale() / 100); + entity_list.MessageClose_StringID(this, false, 100, MT_SpellCrits, OTHER_CRIT_BLAST, GetName(), itoa(-value)); @@ -2832,30 +2832,30 @@ int32 Merc::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) { } value = value_BaseEffect; - - value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100; - + + value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100; + value += value_BaseEffect*GetFocusEffect(focusFcDamagePctCrit, spell_id)/100; if (target) { value += value_BaseEffect*target->GetVulnerability(this, spell_id, 0)/100; - value -= target->GetFcDamageAmtIncoming(this, spell_id); + value -= target->GetFcDamageAmtIncoming(this, spell_id); } - value -= GetFocusEffect(focusFcDamageAmtCrit, spell_id); + value -= GetFocusEffect(focusFcDamageAmtCrit, spell_id); + + value -= GetFocusEffect(focusFcDamageAmt, spell_id); - value -= GetFocusEffect(focusFcDamageAmt, spell_id); - if(itembonuses.SpellDmg && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5) - value -= GetExtraSpellAmt(spell_id, itembonuses.SpellDmg, value); + value -= GetExtraSpellAmt(spell_id, itembonuses.SpellDmg, value); + + value = (value * GetSpellScale() / 100); - value = (value * GetSpellScale() / 100); - return value; } int32 Merc::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) { - + if (target == nullptr) target = this; @@ -2863,37 +2863,37 @@ int32 Merc::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) { int16 chance = 0; int8 modifier = 1; bool Critical = false; - - value_BaseEffect = value + (value*GetFocusEffect(focusFcBaseEffects, spell_id)/100); - + + value_BaseEffect = value + (value*GetFocusEffect(focusFcBaseEffects, spell_id)/100); + value = value_BaseEffect; - value += int(value_BaseEffect*GetFocusEffect(focusImprovedHeal, spell_id)/100); - + value += int(value_BaseEffect*GetFocusEffect(focusImprovedHeal, spell_id)/100); + // Instant Heals if(spells[spell_id].buffduration < 1) { - chance += itembonuses.CriticalHealChance + spellbonuses.CriticalHealChance + aabonuses.CriticalHealChance; + chance += itembonuses.CriticalHealChance + spellbonuses.CriticalHealChance + aabonuses.CriticalHealChance; + + chance += target->GetFocusIncoming(focusFcHealPctCritIncoming, SE_FcHealPctCritIncoming, this, spell_id); - chance += target->GetFocusIncoming(focusFcHealPctCritIncoming, SE_FcHealPctCritIncoming, this, spell_id); - if (spellbonuses.CriticalHealDecay) - chance += GetDecayEffectValue(spell_id, SE_CriticalHealDecay); - + chance += GetDecayEffectValue(spell_id, SE_CriticalHealDecay); + if(chance && (MakeRandomInt(0,99) < chance)) { Critical = true; modifier = 2; //At present time no critical heal amount modifier SPA exists. } - + value *= modifier; - value += GetFocusEffect(focusFcHealAmtCrit, spell_id) * modifier; - value += GetFocusEffect(focusFcHealAmt, spell_id); - value += target->GetFocusIncoming(focusFcHealAmtIncoming, SE_FcHealAmtIncoming, this, spell_id); - + value += GetFocusEffect(focusFcHealAmtCrit, spell_id) * modifier; + value += GetFocusEffect(focusFcHealAmt, spell_id); + value += target->GetFocusIncoming(focusFcHealAmtIncoming, SE_FcHealAmtIncoming, this, spell_id); + if(itembonuses.HealAmt && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5) value += GetExtraSpellAmt(spell_id, itembonuses.HealAmt, value) * modifier; - value += value*target->GetHealRate(spell_id, this)/100; + value += value*target->GetHealRate(spell_id, this)/100; if (Critical) entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s performs an exceptional heal! (%d)", GetName(), value); @@ -2903,14 +2903,14 @@ int32 Merc::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) { //Heal over time spells. [Heal Rate and Additional Healing effects do not increase this value] else { - - chance = itembonuses.CriticalHealOverTime + spellbonuses.CriticalHealOverTime + aabonuses.CriticalHealOverTime; - chance += target->GetFocusIncoming(focusFcHealPctCritIncoming, SE_FcHealPctCritIncoming, this, spell_id); - + chance = itembonuses.CriticalHealOverTime + spellbonuses.CriticalHealOverTime + aabonuses.CriticalHealOverTime; + + chance += target->GetFocusIncoming(focusFcHealPctCritIncoming, SE_FcHealPctCritIncoming, this, spell_id); + if (spellbonuses.CriticalRegenDecay) chance += GetDecayEffectValue(spell_id, SE_CriticalRegenDecay); - + if(chance && (MakeRandomInt(0,99) < chance)) return (value * 2); } @@ -5851,35 +5851,30 @@ void Client::SendMercAssignPacket(uint32 entityID, uint32 unk01, uint32 unk02) { FastQueuePacket(&outapp); } -void NPC::LoadMercTypes(){ - std::string errorMessage; - char* Query = 0; - char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; - MYSQL_RES* DatasetResult; - MYSQL_ROW DataRow; +void NPC::LoadMercTypes() { - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT DISTINCT MTyp.dbstring, MTyp.clientversion FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, merc_types MTyp, merc_templates MTem WHERE MME.merchant_id = %i AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id AND MMTE.merc_template_id = MTem.merc_template_id AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID()), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } - else { - while(DataRow = mysql_fetch_row(DatasetResult)) { - MercType tempMercType; + std::string query = StringFormat("SELECT DISTINCT MTyp.dbstring, MTyp.clientversion " + "FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, " + "merc_types MTyp, merc_templates MTem " + "WHERE MME.merchant_id = %i " + "AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id " + "AND MMTE.merc_template_id = MTem.merc_template_id " + "AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()"); + return; + } - tempMercType.Type = atoi(DataRow[0]); - tempMercType.ClientVersion = atoi(DataRow[1]); + for (auto row = results.begin(); row != results.end(); ++row) { + MercType tempMercType; - mercTypeList.push_back(tempMercType); - } + tempMercType.Type = atoi(row[0]); + tempMercType.ClientVersion = atoi(row[1]); - mysql_free_result(DatasetResult); + mercTypeList.push_back(tempMercType); } - safe_delete_array(Query); - Query = 0; - - if(!errorMessage.empty()) { - LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()"); - } } void NPC::LoadMercs(){ From 49d231f5ddb583964667332e7d4b147a9f89ceba Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:05:38 -0700 Subject: [PATCH 087/217] LoadMercs converted to QueryDatabase --- zone/merc.cpp | 52 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/zone/merc.cpp b/zone/merc.cpp index 8c34d2e05..16550908f 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -5879,38 +5879,36 @@ void NPC::LoadMercTypes() { void NPC::LoadMercs(){ - std::string errorMessage; - char* Query = 0; - char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; - MYSQL_RES* DatasetResult; - MYSQL_ROW DataRow; + std::string query = StringFormat("SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring AS merc_type_id, " + "MTem.dbstring AS merc_subtype_id, 0 AS CostFormula, " + "CASE WHEN MTem.clientversion > MTyp.clientversion " + "THEN MTem.clientversion " + "ELSE MTyp.clientversion END AS clientversion, MTem.merc_npc_type_id " + "FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, " + "merc_types MTyp, merc_templates MTem " + "WHERE MME.merchant_id = %i AND " + "MME.merc_merchant_template_id = MMTE.merc_merchant_template_id " + "AND MMTE.merc_template_id = MTem.merc_template_id " + "AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()"); + return; + } - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring AS merc_type_id, MTem.dbstring AS merc_subtype_id, 0 AS CostFormula, CASE WHEN MTem.clientversion > MTyp.clientversion then MTem.clientversion ELSE MTyp.clientversion END AS clientversion, MTem.merc_npc_type_id FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, merc_types MTyp, merc_templates MTem WHERE MME.merchant_id = %i AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id AND MMTE.merc_template_id = MTem.merc_template_id AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID()), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } - else { - while(DataRow = mysql_fetch_row(DatasetResult)) { - MercData tempMerc; + for (auto row = results.begin(); row != results.end(); ++row) { + MercData tempMerc; - tempMerc.MercTemplateID = atoi(DataRow[0]); - tempMerc.MercType = atoi(DataRow[1]); - tempMerc.MercSubType = atoi(DataRow[2]); - tempMerc.CostFormula = atoi(DataRow[3]); - tempMerc.ClientVersion = atoi(DataRow[4]); - tempMerc.NPCID = atoi(DataRow[5]); + tempMerc.MercTemplateID = atoi(row[0]); + tempMerc.MercType = atoi(row[1]); + tempMerc.MercSubType = atoi(row[2]); + tempMerc.CostFormula = atoi(row[3]); + tempMerc.ClientVersion = atoi(row[4]); + tempMerc.NPCID = atoi(row[5]); - mercDataList.push_back(tempMerc); - } - - mysql_free_result(DatasetResult); + mercDataList.push_back(tempMerc); } - safe_delete_array(Query); - Query = 0; - - if(!errorMessage.empty()) { - LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()"); - } } int NPC::GetNumMercTypes(uint32 clientVersion) From c6091c4f27464c4fd61d10b58873ba992f4aa64a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:13:20 -0700 Subject: [PATCH 088/217] DelGlobal converted to QueryDatabase --- zone/mob.cpp | 102 +++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 56 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index a6baabd1a..e260005d0 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -311,7 +311,7 @@ Mob::Mob(const char* in_name, shielder[m].shielder_id = 0; shielder[m].shielder_bonus = 0; } - + destructibleobject = false; wandertype=0; pausetype=0; @@ -893,7 +893,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) ns->spawn.invis = (invisible || hidden) ? 1 : 0; // TODO: load this before spawning players ns->spawn.NPC = IsClient() ? 0 : 1; ns->spawn.IsMercenary = (IsMerc() || no_target_hotkey) ? 1 : 0; - + ns->spawn.petOwnerId = ownerid; ns->spawn.haircolor = haircolor; @@ -2392,7 +2392,7 @@ bool Mob::HateSummon() { { if(summon_level == 1) { entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!' ", GetCleanName(), target->GetCleanName() ); - + if (target->IsClient()) { target->CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), x_pos, y_pos, z_pos, target->GetHeading(), 0, SummonPC); } @@ -2404,12 +2404,12 @@ bool Mob::HateSummon() { target->CastToBot()->SetPreSummonX(target->GetX()); target->CastToBot()->SetPreSummonY(target->GetY()); target->CastToBot()->SetPreSummonZ(target->GetZ()); - + } #endif //BOTS target->GMMove(x_pos, y_pos, z_pos, target->GetHeading()); } - + return true; } else if(summon_level == 2) { entity_list.MessageClose(this, true, 500, MT_Say, "%s says,'You will not evade me, %s!'", GetCleanName(), target->GetCleanName()); @@ -3040,7 +3040,7 @@ void Mob::TriggerDefensiveProcs(const ItemInst* weapon, Mob *on, uint16 hand, in case (-1): skillinuse = SkillBlock; break; - + case (-2): skillinuse = SkillParry; break; @@ -3273,7 +3273,7 @@ void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsP if (!spellbonuses.TriggerOnValueAmount) return; - + if (spellbonuses.TriggerOnValueAmount){ int buff_count = GetMaxTotalSlots(); @@ -3294,15 +3294,15 @@ void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsP if (IsHP){ if ((base2 >= 500 && base2 <= 520) && GetHPRatio() < (base2 - 500)*5) use_spell = true; - + else if (base2 = 1004 && GetHPRatio() < 80) use_spell = true; } else if (IsMana){ - if ( (base2 = 521 && GetManaRatio() < 20) || (base2 = 523 && GetManaRatio() < 40)) + if ( (base2 = 521 && GetManaRatio() < 20) || (base2 = 523 && GetManaRatio() < 40)) use_spell = true; - + else if (base2 = 38311 && GetManaRatio() < 10) use_spell = true; } @@ -3322,7 +3322,7 @@ void Mob::TryTriggerOnValueAmount(bool IsHP, bool IsMana, bool IsEndur, bool IsP if (use_spell){ SpellFinished(spells[spell_id].base[i], this, 10, 0, -1, spells[spell_id].ResistDiff); - + if(!TryFadeEffect(e)) BuffFadeBySlot(e); } @@ -3382,7 +3382,7 @@ int32 Mob::GetVulnerability(Mob* caster, uint32 spell_id, uint32 ticsremaining) if (!caster) return 0; - + int32 value = 0; //Apply innate vulnerabilities @@ -3395,7 +3395,7 @@ int32 Mob::GetVulnerability(Mob* caster, uint32 spell_id, uint32 ticsremaining) //Apply spell derived vulnerabilities if (spellbonuses.FocusEffects[focusSpellVulnerability]){ - + int32 tmp_focus = 0; int tmp_buffslot = -1; @@ -3456,15 +3456,15 @@ int16 Mob::GetSkillDmgTaken(const SkillUseTypes skill_used) } int16 Mob::GetHealRate(uint16 spell_id, Mob* caster) { - + int16 heal_rate = 0; - heal_rate += itembonuses.HealRate + spellbonuses.HealRate + aabonuses.HealRate; - heal_rate += GetFocusIncoming(focusFcHealPctIncoming, SE_FcHealPctIncoming, caster, spell_id); + heal_rate += itembonuses.HealRate + spellbonuses.HealRate + aabonuses.HealRate; + heal_rate += GetFocusIncoming(focusFcHealPctIncoming, SE_FcHealPctIncoming, caster, spell_id); if(heal_rate < -99) heal_rate = -99; - + return heal_rate; } @@ -3474,7 +3474,7 @@ bool Mob::TryFadeEffect(int slot) { for(int i = 0; i < EFFECT_COUNT; i++) { - if (spells[buffs[slot].spellid].effectid[i] == SE_CastOnFadeEffectAlways || + if (spells[buffs[slot].spellid].effectid[i] == SE_CastOnFadeEffectAlways || spells[buffs[slot].spellid].effectid[i] == SE_CastOnRuneFadeEffect) { uint16 spell_id = spells[buffs[slot].spellid].base[i]; @@ -3532,7 +3532,7 @@ void Mob::TrySympatheticProc(Mob *target, uint32 spell_id) else SpellFinished(focus_trigger, target, 10, 0, -1, spells[focus_trigger].ResistDiff); } - + CheckNumHitsRemaining(NUMHIT_MatchingSpells, 0, focus_spell); } } @@ -3928,36 +3928,26 @@ void Mob::TarGlobal(const char *varname, const char *value, const char *duration } void Mob::DelGlobal(const char *varname) { - // delglobal(varname) - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + int qgZoneid=zone->GetZoneID(); int qgCharid=0; int qgNpcid=0; if (this->IsNPC()) - { qgNpcid = this->GetNPCTypeID(); - } if (this->IsClient()) - { qgCharid = this->CastToClient()->CharacterID(); - } else - { qgCharid = -qgNpcid; // make char id negative npc id as a fudge - } - if (!database.RunQuery(query, - MakeAnyLenString(&query, - "DELETE FROM quest_globals WHERE name='%s'" - " && (npcid=0 || npcid=%i) && (charid=0 || charid=%i) && (zoneid=%i || zoneid=0)", - varname,qgNpcid,qgCharid,qgZoneid),errbuf)) - { - //_log(QUESTS, "DelGlobal error deleting %s : %s", varname, errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("DELETE FROM quest_globals " + "WHERE name='%s' && (npcid=0 || npcid=%i) " + "&& (charid=0 || charid=%i) " + "&& (zoneid=%i || zoneid=0)", + varname, qgNpcid, qgCharid, qgZoneid); + + database.QueryDatabase(query); if(zone) { @@ -4362,7 +4352,7 @@ int16 Mob::GetSkillDmgAmt(uint16 skill) } void Mob::MeleeLifeTap(int32 damage) { - + int16 lifetap_amt = 0; lifetap_amt = spellbonuses.MeleeLifetap + itembonuses.MeleeLifetap + aabonuses.MeleeLifetap + spellbonuses.Vampirism + itembonuses.Vampirism + aabonuses.Vampirism; @@ -4371,7 +4361,7 @@ void Mob::MeleeLifeTap(int32 damage) { lifetap_amt = damage * lifetap_amt / 100; mlog(COMBAT__DAMAGE, "Melee lifetap healing for %d damage.", damage); - + if (lifetap_amt > 0) HealDamage(lifetap_amt); //Heal self for modified damage amount. else @@ -4383,9 +4373,9 @@ bool Mob::TryReflectSpell(uint32 spell_id) { if (!spells[spell_id].reflectable) return false; - + int chance = itembonuses.reflect_chance + spellbonuses.reflect_chance + aabonuses.reflect_chance; - + if(chance && MakeRandomInt(0, 99) < chance) return true; @@ -4403,12 +4393,12 @@ void Mob::SpellProjectileEffect() } Mob* target = entity_list.GetMobID(projectile_target_id[i]); - + float dist = 0; - - if (target) + + if (target) dist = target->CalculateDistance(projectile_x[i], projectile_y[i], projectile_z[i]); - + int increment_end = 0; increment_end = (dist / 10) - 1; //This pretty accurately determines end time for speed for 1.5 and timer of 250 ms @@ -4681,7 +4671,7 @@ void Mob::SlowMitigation(Mob* caster) else if ((GetSlowMitigation() >= 74) && (GetSlowMitigation() < 101)) caster->Message_StringID(MT_SpellFailure, SLOW_SLIGHTLY_SUCCESSFUL); - else if (GetSlowMitigation() > 100) + else if (GetSlowMitigation() > 100) caster->Message_StringID(MT_SpellFailure, SPELL_OPPOSITE_EFFECT); } } @@ -4758,10 +4748,10 @@ bool Mob::PassLimitToSkill(uint16 spell_id, uint16 skill) { } uint16 Mob::GetWeaponSpeedbyHand(uint16 hand) { - + uint16 weapon_speed = 0; switch (hand) { - + case 13: weapon_speed = attack_timer.GetDuration(); break; @@ -4784,7 +4774,7 @@ int8 Mob::GetDecayEffectValue(uint16 spell_id, uint16 spelleffect) { if (!IsValidSpell(spell_id)) return false; - int spell_level = spells[spell_id].classes[(GetClass()%16) - 1]; + int spell_level = spells[spell_id].classes[(GetClass()%16) - 1]; int effect_value = 0; int lvlModifier = 100; @@ -4793,16 +4783,16 @@ int8 Mob::GetDecayEffectValue(uint16 spell_id, uint16 spelleffect) { if (IsValidSpell(buffs[slot].spellid)){ for (int i = 0; i < EFFECT_COUNT; i++){ if(spells[buffs[slot].spellid].effectid[i] == spelleffect) { - - int critchance = spells[buffs[slot].spellid].base[i]; + + int critchance = spells[buffs[slot].spellid].base[i]; int decay = spells[buffs[slot].spellid].base2[i]; - int lvldiff = spell_level - spells[buffs[slot].spellid].max[i]; - + int lvldiff = spell_level - spells[buffs[slot].spellid].max[i]; + if(lvldiff > 0 && decay > 0) { - lvlModifier -= decay*lvldiff; + lvlModifier -= decay*lvldiff; if (lvlModifier > 0){ - critchance = (critchance*lvlModifier)/100; + critchance = (critchance*lvlModifier)/100; effect_value += critchance; } } @@ -4813,7 +4803,7 @@ int8 Mob::GetDecayEffectValue(uint16 spell_id, uint16 spelleffect) { } } } - + return effect_value; } From 4e71330508435b77bd654e8c941dd51679e98579 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:16:11 -0700 Subject: [PATCH 089/217] InsertQuestGlobal converted to QueryDatabase --- zone/mob.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/zone/mob.cpp b/zone/mob.cpp index e260005d0..51238c93f 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3970,33 +3970,22 @@ void Mob::DelGlobal(const char *varname) { // Inserts global variable into quest_globals table void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varname, const char *varvalue, int duration) { - char *query = 0; - char errbuf[MYSQL_ERRMSG_SIZE]; - // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" std::stringstream duration_ss; if (duration == INT_MAX) - { duration_ss << "NULL"; - } else - { duration_ss << "unix_timestamp(now()) + " << duration; - } //NOTE: this should be escaping the contents of arglist //npcwise a malicious script can arbitrarily alter the DB uint32 last_id = 0; - if (!database.RunQuery(query, MakeAnyLenString(&query, - "REPLACE INTO quest_globals (charid, npcid, zoneid, name, value, expdate)" - "VALUES (%i, %i, %i, '%s', '%s', %s)", - charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str() - ), errbuf)) - { - //_log(QUESTS, "SelGlobal error inserting %s : %s", varname, errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("REPLACE INTO quest_globals " + "(charid, npcid, zoneid, name, value, expdate)" + "VALUES (%i, %i, %i, '%s', '%s', %s)", + charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str()); + database.QueryDatabase(query); if(zone) { @@ -4022,14 +4011,12 @@ void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varna qgu->npc_id = npcid; qgu->char_id = charid; qgu->zone_id = zoneid; + if(duration == INT_MAX) - { qgu->expdate = 0xFFFFFFFF; - } else - { qgu->expdate = Timer::GetTimeSeconds() + duration; - } + strcpy((char*)qgu->name, varname); strcpy((char*)qgu->value, varvalue); qgu->id = last_id; From e618fe87bdab084c3d5431ecedd6b6279e61c0b4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:20:55 -0700 Subject: [PATCH 090/217] DeletePetitionFromDB converted to QueryDatabase --- zone/petitions.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 51910a052..282d57ca7 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -216,18 +216,12 @@ void PetitionList::UpdatePetition(Petition* pet) { } void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 affected_rows = 0; - uint8 checkedout = 0; - if (wpet->CheckedOut()) checkedout = 0; - else checkedout = 1; - if (!RunQuery(query, MakeAnyLenString(&query, "DELETE from petitions where petid = %i", wpet->GetID()), errbuf, 0, &affected_rows)) { - LogFile->write(EQEMuLog::Error, "Error in DeletePetitionFromDB query '%s': %s", query, errbuf); - } - safe_delete_array(query); - return; + std::string query = StringFormat("DELETE FROM petitions WHERE petid = %i", wpet->GetID()); + auto results = QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in DeletePetitionFromDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + } void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) { From 6364d2c31d63b54384206566417e3f5ad0233a98 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:36:11 -0700 Subject: [PATCH 091/217] UpdatePetitionToDB converted to QueryDatabase --- zone/petitions.cpp | 56 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 282d57ca7..c9b7599cd 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -225,46 +225,50 @@ void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) { } void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 affected_rows = 0; - uint8 checkedout = 0; - if (wpet->CheckedOut()) checkedout = 1; - else checkedout = 0; - if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE petitions set gmtext = '%s', lastgm = '%s', urgency = %i, checkouts = %i, unavailables = %i, ischeckedout = %i where petid = %i", wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(), wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetID()), errbuf, 0, &affected_rows)) { - LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query, errbuf); - } - safe_delete_array(query); - return; + + std::string query = StringFormat("UPDATE petitions SET gmtext = '%s', lastgm = '%s', urgency = %i, " + "checkouts = %i, unavailables = %i, ischeckedout = %i " + "WHERE petid = %i", + wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(), + wpet->GetCheckouts(), wpet->GetUnavails(), + wpet->CheckedOut() ? 1: 0, wpet->GetID()); + auto results = QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + } - - void ZoneDatabase::InsertPetitionToDB(Petition* wpet) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 affected_rows = 0; - uint8 checkedout = 0; - if (wpet->CheckedOut()) - checkedout = 1; - else - checkedout = 0; uint32 len = strlen(wpet->GetPetitionText()); char* petitiontext = new char[2*len+1]; memset(petitiontext, 0, 2*len+1); DoEscapeString(petitiontext, wpet->GetPetitionText(), len); - if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO petitions (petid, charname, accountname, lastgm, petitiontext, zone, urgency, charclass, charrace, charlevel, checkouts, unavailables, ischeckedout, senttime, gmtext) values (%i,'%s','%s','%s','%s',%i,%i,%i,%i,%i,%i,%i,%i,%i, '%s')", wpet->GetID(), wpet->GetCharName(), wpet->GetAccountName(), wpet->GetLastGM(), petitiontext, wpet->GetZone(), wpet->GetUrgency(), wpet->GetCharClass(), wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetSentTime(), wpet->GetGMText()), errbuf, 0, &affected_rows)) { - LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query, errbuf); + + std::string query = StringFormat("INSERT INTO petitions " + "(petid, charname, accountname, lastgm, " + "petitiontext, zone, urgency, charclass, " + "charrace, charlevel, checkouts, unavailables, " + "ischeckedout, senttime, gmtext) " + "VALUES (%i, '%s', '%s', '%s', '%s', " + "%i, %i, %i, %i, %i, " + "%i, %i, %i, %i, '%s')", + wpet->GetID(), wpet->GetCharName(), wpet->GetAccountName(), wpet->GetLastGM(), + petitiontext, wpet->GetZone(), wpet->GetUrgency(), wpet->GetCharClass(), + wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(), wpet->GetUnavails(), + wpet->CheckedOut()? 1: 0, wpet->GetSentTime(), wpet->GetGMText()); + safe_delete_array(petitiontext); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(petitiontext); - safe_delete_array(query); #if EQDEBUG >= 5 LogFile->write(EQEMuLog::Debug, "New petition created"); #endif - return; + } void ZoneDatabase::RefreshPetitionsFromDB() From 748748dda95a2c43b50da4bc08efc818b9621f8f Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:46:46 -0700 Subject: [PATCH 092/217] RefreshPetitionsFromDB converted to QueryDatabase --- zone/petitions.cpp | 65 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/zone/petitions.cpp b/zone/petitions.cpp index c9b7599cd..8eb3ca896 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -273,41 +273,40 @@ void ZoneDatabase::InsertPetitionToDB(Petition* wpet) void ZoneDatabase::RefreshPetitionsFromDB() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; Petition* newpet; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT petid, charname, accountname, lastgm, petitiontext, zone, urgency, charclass, charrace, charlevel, checkouts, unavailables, ischeckedout, senttime, gmtext from petitions order by petid"), errbuf, &result)) - { - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) { - newpet = new Petition(atoi(row[0])); - newpet->SetCName(row[1]); - newpet->SetAName(row[2]); - newpet->SetLastGM(row[3]); - newpet->SetPetitionText(row[4]); - newpet->SetZone(atoi(row[5])); - newpet->SetUrgency(atoi(row[6])); - newpet->SetClass(atoi(row[7])); - newpet->SetRace(atoi(row[8])); - newpet->SetLevel(atoi(row[9])); - newpet->SetCheckouts(atoi(row[10])); - newpet->SetUnavails(atoi(row[11])); - newpet->SetSentTime2(atol(row[13])); - newpet->SetGMText(row[14]); - std::cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << std::endl; - if (atoi(row[12]) == 1) newpet->SetCheckedOut(true); - else newpet->SetCheckedOut(false); - petition_list.AddPetition(newpet); - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in RefreshPetitionsFromDB query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = "SELECT petid, charname, accountname, lastgm, petitiontext, " + "zone, urgency, charclass, charrace, charlevel, checkouts, " + "unavailables, ischeckedout, senttime, gmtext " + "FROM petitions ORDER BY petid"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in RefreshPetitionsFromDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return; } - return; + for (auto row = results.begin(); row != results.end(); ++row) { + newpet = new Petition(atoi(row[0])); + newpet->SetCName(row[1]); + newpet->SetAName(row[2]); + newpet->SetLastGM(row[3]); + newpet->SetPetitionText(row[4]); + newpet->SetZone(atoi(row[5])); + newpet->SetUrgency(atoi(row[6])); + newpet->SetClass(atoi(row[7])); + newpet->SetRace(atoi(row[8])); + newpet->SetLevel(atoi(row[9])); + newpet->SetCheckouts(atoi(row[10])); + newpet->SetUnavails(atoi(row[11])); + newpet->SetSentTime2(atol(row[13])); + newpet->SetGMText(row[14]); + + std::cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << std::endl; + + if (atoi(row[12]) == 1) + newpet->SetCheckedOut(true); + else + newpet->SetCheckedOut(false); + petition_list.AddPetition(newpet); + } + } From 8b89beb02ebe992615fc2eca2646c365c0db3f07 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 21:57:29 -0700 Subject: [PATCH 093/217] MakePoweredPet converted to QueryDatabase --- zone/pets.cpp | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/zone/pets.cpp b/zone/pets.cpp index c7b4b1eac..a3887e6f2 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -362,31 +362,34 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, // handle monster summoning pet appearance if(record.monsterflag) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result = nullptr; - MYSQL_ROW row = nullptr; - uint32 monsterid; + + uint32 monsterid = 0; // get a random npc id from the spawngroups assigned to this zone - if (database.RunQuery(query, MakeAnyLenString(&query, - "SELECT npcID FROM (spawnentry INNER JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID) " - "INNER JOIN npc_types ON npc_types.id = spawnentry.npcID " - "WHERE spawn2.zone = '%s' AND npc_types.bodytype NOT IN (11, 33, 66, 67) " - "AND npc_types.race NOT IN (0,1,2,3,4,5,6,7,8,9,10,11,12,44,55,67,71,72,73,77,78,81,90,92,93,94,106,112,114,127,128,130,139,141,183,236,237,238,239,254,266,329,330,378,379,380,381,382,383,404,522) " - "ORDER BY RAND() LIMIT 1", zone->GetShortName()), errbuf, &result)) - { - row = mysql_fetch_row(result); - if (row) - monsterid = atoi(row[0]); - else - monsterid = 567; // since we don't have any monsters, just make it look like an earth pet for now - } - else { // if the database query failed - LogFile->write(EQEMuLog::Error, "Error querying database for monster summoning pet in zone %s (%s)", zone->GetShortName(), errbuf); - monsterid = 567; + auto query = StringFormat("SELECT npcID " + "FROM (spawnentry INNER JOIN spawn2 ON spawn2.spawngroupID = spawnentry.spawngroupID) " + "INNER JOIN npc_types ON npc_types.id = spawnentry.npcID " + "WHERE spawn2.zone = '%s' AND npc_types.bodytype NOT IN (11, 33, 66, 67) " + "AND npc_types.race NOT IN (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 44, " + "55, 67, 71, 72, 73, 77, 78, 81, 90, 92, 93, 94, 106, 112, 114, 127, 128, " + "130, 139, 141, 183, 236, 237, 238, 239, 254, 266, 329, 330, 378, 379, " + "380, 381, 382, 383, 404, 522) " + "ORDER BY RAND() LIMIT 1", zone->GetShortName()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + // if the database query failed + LogFile->write(EQEMuLog::Error, "Error querying database for monster summoning pet in zone %s (%s)", zone->GetShortName(), results.ErrorMessage().c_str()); } + if (results.RowCount() != 0) { + auto row = results.begin(); + monsterid = atoi(row[0]); + } + + // since we don't have any monsters, just make it look like an earth pet for now + if (monsterid == 0) + monsterid = 567; + // give the summoned pet the attributes of the monster we found const NPCType* monster = database.GetNPCType(monsterid); if(monster) { @@ -396,12 +399,9 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, npc_type->gender = monster->gender; npc_type->luclinface = monster->luclinface; npc_type->helmtexture = monster->helmtexture; - } - else { + } else LogFile->write(EQEMuLog::Error, "Error loading NPC data for monster summoning pet (NPC ID %d)", monsterid); - } - safe_delete_array(query); } //this takes ownership of the npc_type data From 977b28cb9cf487081a87c1b6ef012be86af491f5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 22:02:35 -0700 Subject: [PATCH 094/217] GetPoweredPetEntry converted to QueryDatabase --- zone/pets.cpp | 61 +++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/zone/pets.cpp b/zone/pets.cpp index a3887e6f2..b70de8e0d 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -450,46 +450,35 @@ bool ZoneDatabase::GetPetEntry(const char *pet_type, PetRecord *into) { } bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 querylen = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query; - if (petpower <= 0) { - querylen = MakeAnyLenString(&query, - "SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset FROM pets " - "WHERE type='%s' AND petpower<=0", pet_type); - } - else { - querylen = MakeAnyLenString(&query, - "SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset FROM pets " - "WHERE type='%s' AND petpower<=%d ORDER BY petpower DESC LIMIT 1", pet_type, petpower); - } + if (petpower <= 0) + query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset " + "FROM pets WHERE type='%s' AND petpower<=0", pet_type); + else + query = StringFormat("SELECT npcID, temp, petpower, petcontrol, petnaming, monsterflag, equipmentset " + "FROM pets WHERE type='%s' AND petpower<=%d ORDER BY petpower DESC LIMIT 1", + pet_type, petpower); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; + } - if (RunQuery(query, querylen, errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); + if (results.RowCount() != 1) + return false; - into->npc_type = atoi(row[0]); - into->temporary = atoi(row[1]); - into->petpower = atoi(row[2]); - into->petcontrol = atoi(row[3]); - into->petnaming = atoi(row[4]); - into->monsterflag = atoi(row[5]); - into->equipmentset = atoi(row[6]); + auto row = results.begin(); - mysql_free_result(result); - return(true); - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query, errbuf); - safe_delete_array(query); - } - return(false); + into->npc_type = atoi(row[0]); + into->temporary = atoi(row[1]); + into->petpower = atoi(row[2]); + into->petcontrol = atoi(row[3]); + into->petnaming = atoi(row[4]); + into->monsterflag = atoi(row[5]); + into->equipmentset = atoi(row[6]); + + return true; } Mob* Mob::GetPet() { From c613f362a71361dfb44f34c046f19e4334007a78 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 18 Aug 2014 22:12:01 -0700 Subject: [PATCH 095/217] GetBasePetItems converted to QueryDatabase --- zone/pets.cpp | 88 ++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/zone/pets.cpp b/zone/pets.cpp index b70de8e0d..24a814f61 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -646,11 +646,6 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { // A slot will only get an item put in it if it is empty. That way // an equipmentset can overload a slot for the set(s) it includes. - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 querylen = 0; - MYSQL_RES *result; - MYSQL_ROW row; int depth = 0; int32 curset = equipmentset; int32 nextset = -1; @@ -662,56 +657,43 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { // query pets_equipmentset_entries with the set_id and loop over // all of the result rows. Check if we have something in the slot // already. If no, add the item id to the equipment array. - while (curset >= 0 && depth < 5) { - if (RunQuery(query, - MakeAnyLenString(&query, "SELECT nested_set FROM pets_equipmentset WHERE set_id='%s'", curset), - errbuf, &result)) - { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - nextset = atoi(row[0]); - mysql_free_result(result); - - if (RunQuery(query, - MakeAnyLenString(&query, "SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset), - errbuf, &result)) - { - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) - { - slot = atoi(row[0]); - if (slot >= EmuConstants::EQUIPMENT_SIZE) - continue; - if (items[slot] == 0) - items[slot] = atoi(row[1]); - } - - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query, errbuf); - safe_delete_array(query); - } - curset = nextset; - depth++; - } - else - { - // invalid set reference, it doesn't exist - LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset); - mysql_free_result(result); - return false; - } - } - else - { - LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT nested_set FROM pets_equipmentset WHERE set_id = '%s'", curset); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } - } // end while + } + + if (results.RowCount() != 1) { + // invalid set reference, it doesn't exist + LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset); + return false; + } + + auto row = results.begin(); + nextset = atoi(row[0]); + + query = StringFormat("SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset); + results = QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + else { + for (row = results.begin(); row != results.end(); ++row) + { + slot = atoi(row[0]); + + if (slot >= EmuConstants::EQUIPMENT_SIZE) + continue; + + if (items[slot] == 0) + items[slot] = atoi(row[1]); + } + } + + curset = nextset; + depth++; + } return true; } From a5020a68f05894eba0f9bc74e139e5655b118fb9 Mon Sep 17 00:00:00 2001 From: akkadius Date: Tue, 19 Aug 2014 10:55:29 -0500 Subject: [PATCH 096/217] Implemented a Stop_Return feature (Accidental item handin prevention) that will be symmetrically used with plugin::return_items that I am currently running live testing on EZ before releasing to EQEmu. This does not hurt to have this in the source. Fixed crash where 'attacker' validation is not being checked Removed petition console spam that does not follow traditional logging and is useless Made fix with SympatheticProcChances where it was checking for TempItem->Focus.Effect instead of TempItemAug->Focus.Effect --- changelog.txt | 6 +++++- zone/attack.cpp | 4 ++-- zone/client.cpp | 9 +++++++++ zone/exp.cpp | 9 +++++++++ zone/inventory.cpp | 10 ++++++++++ zone/petitions.cpp | 1 - zone/spell_effects.cpp | 2 +- zone/tasks.cpp | 1 + zone/trading.cpp | 10 ++++++++++ 9 files changed, 47 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index b63e8a5dc..2102ef251 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,10 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- -== 08/18/2014 == +== 08/19/2014 == +Akkadius: Implemented a Stop_Return feature (Accidental item handin prevention) that will be symmetrically used with plugin::return_items that I am currently running live testing on EZ before releasing to EQEmu. This does not hurt to have this in the source. +Akkadius: Fixed crash where 'attacker' validation is not being checked +Akkadius: Removed petition console spam that does not follow traditional logging and is useless +Akkadius: Made fix with SympatheticProcChances where it was checking for TempItem->Focus.Effect instead of TempItemAug->Focus.Effect== 08/18/2014 == Uleat: Fix for https://github.com/EQEmu/Server/issues/127 -- also activated a remarked action in doors.cpp to eliminate a memory leak. == 08/16/2014 == diff --git a/zone/attack.cpp b/zone/attack.cpp index 3195b4234..234149eff 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3569,12 +3569,12 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons TryTriggerOnValueAmount(true); //fade mez if we are mezzed - if (IsMezzed()) { + if (IsMezzed() && attacker) { mlog(COMBAT__HITS, "Breaking mez due to attack."); entity_list.MessageClose_StringID(this, true, 100, MT_WornOff, HAS_BEEN_AWAKENED, GetCleanName(), attacker->GetCleanName()); BuffFadeByEffect(SE_Mez); - } + } //check stun chances if bashing if (damage > 0 && ((skill_used == SkillBash || skill_used == SkillKick) && attacker)) { diff --git a/zone/client.cpp b/zone/client.cpp index aa93478ba..0ac0671ef 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2237,6 +2237,15 @@ void Client::AddMoneyToPP(uint64 copper, bool updateclient){ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient){ + /* Set a timestamp in an entity variable for plugin check_handin.pl in return_items + This will stopgap players from items being returned if global_npc.pl has a catch all return_items + */ + struct timeval read_time; + char buffer[50]; + gettimeofday(&read_time, 0); + sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + this->SetEntityVariable("Stop_Return", buffer); + int32 new_value = m_pp.platinum + platinum; if(new_value >= 0 && new_value > m_pp.platinum) m_pp.platinum += platinum; diff --git a/zone/exp.cpp b/zone/exp.cpp index 5e8eb49f8..6553789d6 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -48,6 +48,15 @@ static uint32 MaxBankedRaidLeadershipPoints(int Level) void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { + /* Set a timestamp in an entity variable for plugin check_handin.pl in return_items + This will stopgap players from items being returned if global_npc.pl has a catch all return_items + */ + struct timeval read_time; + char buffer[50]; + gettimeofday(&read_time, 0); + sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + this->SetEntityVariable("Stop_Return", buffer); + uint32 add_exp = in_add_exp; if(!resexp && (XPRate != 0)) diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 9a815c6ca..76f0d9f87 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -200,6 +200,16 @@ bool Client::CheckLoreConflict(const Item_Struct* item) { } bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned, uint16 to_slot) { + + /* Set a timestamp in an entity variable for plugin check_handin.pl in return_items + This will stopgap players from items being returned if global_npc.pl has a catch all return_items + */ + struct timeval read_time; + char buffer[50]; + gettimeofday(&read_time, 0); + sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + this->SetEntityVariable("Recieved_Item", buffer); + // TODO: update calling methods and script apis to handle a failure return const Item_Struct* item = database.GetItem(item_id); diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 51910a052..040a1dfcf 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -298,7 +298,6 @@ void ZoneDatabase::RefreshPetitionsFromDB() newpet->SetUnavails(atoi(row[11])); newpet->SetSentTime2(atol(row[13])); newpet->SetGMText(row[14]); - std::cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << std::endl; if (atoi(row[12]) == 1) newpet->SetCheckedOut(true); else newpet->SetCheckedOut(false); petition_list.AddPetition(newpet); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 8a45cf391..869e38619 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -5093,7 +5093,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { if (IsValidSpell(proc_spellid)){ - ProcChance = GetSympatheticProcChances(spell_id, spells[TempItem->Focus.Effect].base[0], TempItemAug->ProcRate); + ProcChance = GetSympatheticProcChances(spell_id, spells[TempItemAug->Focus.Effect].base[0], TempItemAug->ProcRate); if(MakeRandomFloat(0, 1) <= ProcChance) SympatheticProcList.push_back(proc_spellid); diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 221085d4e..ddcabb3f4 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -33,6 +33,7 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) #include "masterentity.h" #include "../common/features.h" #include "QuestParserCollection.h" +#include "mob.h" TaskManager::TaskManager() { diff --git a/zone/trading.cpp b/zone/trading.cpp index 8c564c130..1ace776a7 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -623,6 +623,16 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if(UpdateTasksOnDeliver(items, Cash, tradingWith->GetNPCTypeID())) { if(!tradingWith->IsMoving()) tradingWith->FaceTarget(this); + + /* Set a timestamp in an entity variable for plugin check_handin.pl in return_items + This will stopgap players from items being returned if global_npc.pl has a catch all return_items + */ + struct timeval read_time; + char buffer[50]; + gettimeofday(&read_time, 0); + sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + this->SetEntityVariable("Stop_Return", buffer); + } } From 236d2273190205fde57fc1044bc8ef79b074b095 Mon Sep 17 00:00:00 2001 From: akkadius Date: Tue, 19 Aug 2014 10:58:22 -0500 Subject: [PATCH 097/217] Log merge fix --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index 2102ef251..26fb72c5a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,9 @@ Akkadius: Implemented a Stop_Return feature (Accidental item handin prevention) Akkadius: Fixed crash where 'attacker' validation is not being checked Akkadius: Removed petition console spam that does not follow traditional logging and is useless Akkadius: Made fix with SympatheticProcChances where it was checking for TempItem->Focus.Effect instead of TempItemAug->Focus.Effect== 08/18/2014 == + +== 08/18/2014 == + Uleat: Fix for https://github.com/EQEmu/Server/issues/127 -- also activated a remarked action in doors.cpp to eliminate a memory leak. == 08/16/2014 == From f22b26f80fccfba761b1f9b0b2fe87f39f0731d7 Mon Sep 17 00:00:00 2001 From: af4t Date: Tue, 19 Aug 2014 17:07:27 -0400 Subject: [PATCH 098/217] Squashed commit of the following: commit 5d074ea99837e1b0e5bca57f2484f01e623025f8 Author: Michael Cook Date: Thu Jun 5 02:57:56 2014 -0400 Update LS default entry in example config commit e9c4613368029c219637f8a6d1b7846b48dc85cf Merge: 3690f93 dd73b82 Author: KimLS Date: Wed Jun 4 18:32:48 2014 -0700 Merge branch 'master' into water_map_v2 commit 3690f933020cbb24ae12b32a18ad2ca836edcfb0 Author: KimLS Date: Sat May 31 16:32:15 2014 -0700 Fix for fear failing, removed #fear command because it was blank anyway, added a cmake command to change the default map/water/path directory commit dd73b82ec21faaec0895fc9c9e6647cfcc4d8fec Author: KimLS Date: Tue May 27 16:16:06 2014 -0700 Fix for a problem with global player quests and hasquestsub commit 8a5405060fa732c6199d1307c4c8aca2081ff498 Author: KimLS Date: Fri May 23 17:39:16 2014 -0700 Fix for string.h missing in water map commit 83270d09836506b7fe097e07c0633b30d67b4ecf Author: KimLS Date: Fri May 23 16:10:23 2014 -0700 Merge from master stuff commit fd4343702f7dab3f6553ced17af24276b19f4ffa Merge: 0483e8b 5af47c5 Author: KimLS Date: Fri May 23 16:09:46 2014 -0700 Merge branch 'master' into water_map_v2 commit 0483e8bd1ba99d16ad2e9eb67e865606589fd09a Author: KimLS Date: Fri May 23 16:08:02 2014 -0700 Removed the logging now that the issue is resolved commit 39cbdbd5c2e12f304330fd566779e3020eb511fd Author: KimLS Date: Fri May 23 15:54:26 2014 -0700 Debug logs for map, also can actually turn perl off on zone commit 3a2ccd75210066a165809c91704222fff35ee533 Author: KimLS Date: Wed May 21 17:30:54 2014 -0700 Added loading of v2 regular maps, also #bestz will report water info even if a reg map failed to load. commit 8c9227180449454bc712edbcc50ff23371c80acd Author: KimLS Date: Tue May 20 00:14:26 2014 -0700 Initial v2 water map format. --- zone/perl_client.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index ecb2c4d18..476c47599 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1263,12 +1263,14 @@ XS(XS_Client_MovePC) THIS->MovePC(zoneID, x, y, z, heading); } else { - if (THIS->IsBot()) - _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Bot reference"); - else if (THIS->IsMerc()) + if (THIS->IsMerc()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Merc reference"); else if (THIS->IsNPC()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type NPC reference"); + #ifdef BOTS + else if (THIS->IsBot()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process a type Bot reference"); + #endif else _log(CLIENT__ERROR, "Perl(XS_Client_MovePC) attempted to process an Unknown type reference"); @@ -1307,12 +1309,14 @@ XS(XS_Client_MovePCInstance) THIS->MovePC(zoneID, instanceID, x, y, z, heading); } else { - if (THIS->IsBot()) - _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); - else if (THIS->IsMerc()) + if (THIS->IsMerc()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); else if (THIS->IsNPC()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); + #ifdef BOTS + else if (THIS->IsBot()) + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); + #endif else _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); From d87c95c1f8f846193acd51a61c7aab939aa946f5 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 19 Aug 2014 20:00:55 -0400 Subject: [PATCH 099/217] Properly set '-std=c++0x' as a CXX_FLAGS This fixes an issue with clang compiling C files. (Note: this does not mean clang is supported yet) Ideally, this should check the compiler for -std=c++11 support, then check -std=c++0x if the previous failed, then error if that fails as well. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4f3e101f..1d0b6a632 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,7 +259,7 @@ OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON) #C++11 stuff IF(NOT MSVC) - ADD_DEFINITIONS(-std=c++0x) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") ENDIF(NOT MSVC) #Various definitions From 68115505f87bfde07bf6c1683e30e1bad391e158 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 11:58:12 -0700 Subject: [PATCH 100/217] LoadAAEffects2 converted to QueryDatabase --- zone/AA.cpp | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index de3704fcd..cc1f7cf2a 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1466,32 +1466,30 @@ void Zone::LoadAAs() { bool ZoneDatabase::LoadAAEffects2() { aa_effects.clear(); //start fresh - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT aaid, slot, effectid, base1, base2 FROM aa_effects ORDER BY aaid ASC, slot ASC"), errbuf, &result)) { - int count = 0; - while((row = mysql_fetch_row(result))!= nullptr) { - int aaid = atoi(row[0]); - int slot = atoi(row[1]); - int effectid = atoi(row[2]); - int base1 = atoi(row[3]); - int base2 = atoi(row[4]); - aa_effects[aaid][slot].skill_id = effectid; - aa_effects[aaid][slot].base1 = base1; - aa_effects[aaid][slot].base2 = base2; - aa_effects[aaid][slot].slot = slot; //not really needed, but we'll populate it just in case - count++; - } - mysql_free_result(result); - if (count < 1) //no results - LogFile->write(EQEMuLog::Error, "Error loading AA Effects, none found in the database."); - } else { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query, errbuf); + const std::string query = "SELECT aaid, slot, effectid, base1, base2 FROM aa_effects ORDER BY aaid ASC, slot ASC"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); + + if (results.RowCount()) { //no results + LogFile->write(EQEMuLog::Error, "Error loading AA Effects, none found in the database."); + return false; + } + + for(auto row = results.begin(); row != results.end(); ++row) { + int aaid = atoi(row[0]); + int slot = atoi(row[1]); + int effectid = atoi(row[2]); + int base1 = atoi(row[3]); + int base2 = atoi(row[4]); + aa_effects[aaid][slot].skill_id = effectid; + aa_effects[aaid][slot].base1 = base1; + aa_effects[aaid][slot].base2 = base2; + aa_effects[aaid][slot].slot = slot; //not really needed, but we'll populate it just in case + } + return true; } void Client::ResetAA(){ From 4214cf47c28cddc53234845c9ec712b1305d215b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:05:57 -0700 Subject: [PATCH 101/217] LoadAAEffects converted to QueryDatabase --- zone/AA.cpp | 64 +++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index cc1f7cf2a..789441d01 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1631,45 +1631,37 @@ void Client::InspectBuffs(Client* Inspector, int Rank) //this really need to be renamed to LoadAAActions() bool ZoneDatabase::LoadAAEffects() { - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - memset(AA_Actions, 0, sizeof(AA_Actions)); //I hope the compiler is smart about this size... - const char *query = "SELECT aaid,rank,reuse_time,spell_id,target,nonspell_action,nonspell_mana,nonspell_duration," - "redux_aa,redux_rate,redux_aa2,redux_rate2 FROM aa_actions"; - - if(RunQuery(query, static_cast(strlen(query)), errbuf, &result)) { - //safe_delete_array(query); - int r; - while ((row = mysql_fetch_row(result))) { - r = 0; - int aaid = atoi(row[r++]); - int rank = atoi(row[r++]); - if(aaid < 0 || aaid >= aaHighestID || rank < 0 || rank >= MAX_AA_ACTION_RANKS) - continue; - AA_DBAction *caction = &AA_Actions[aaid][rank]; - - caction->reuse_time = atoi(row[r++]); - caction->spell_id = atoi(row[r++]); - caction->target = (aaTargetType) atoi(row[r++]); - caction->action = (aaNonspellAction) atoi(row[r++]); - caction->mana_cost = atoi(row[r++]); - caction->duration = atoi(row[r++]); - caction->redux_aa = (aaID) atoi(row[r++]); - caction->redux_rate = atoi(row[r++]); - caction->redux_aa2 = (aaID) atoi(row[r++]); - caction->redux_rate2 = atoi(row[r++]); - - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in LoadAAEffects query '%s': %s", query, errbuf);; - //safe_delete_array(query); + const std::string query = "SELECT aaid, rank, reuse_time, spell_id, target, " + "nonspell_action, nonspell_mana, nonspell_duration, " + "redux_aa, redux_rate, redux_aa2, redux_rate2 FROM aa_actions"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadAAEffects query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + + int aaid = atoi(row[0]); + int rank = atoi(row[1]); + if(aaid < 0 || aaid >= aaHighestID || rank < 0 || rank >= MAX_AA_ACTION_RANKS) + continue; + AA_DBAction *caction = &AA_Actions[aaid][rank]; + + caction->reuse_time = atoi(row[2]); + caction->spell_id = atoi(row[3]); + caction->target = (aaTargetType) atoi(row[4]); + caction->action = (aaNonspellAction) atoi(row[5]); + caction->mana_cost = atoi(row[6]); + caction->duration = atoi(row[7]); + caction->redux_aa = (aaID) atoi(row[8]); + caction->redux_rate = atoi(row[9]); + caction->redux_aa2 = (aaID) atoi(row[10]); + caction->redux_rate2 = atoi(row[11]); + + } return true; } From e33e8b713e239ca299db2e7de0745db5731a7df9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:09:59 -0700 Subject: [PATCH 102/217] GetTotalAALevels converted to QueryDatabase --- zone/AA.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 789441d01..6b5d9fbc0 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1673,23 +1673,20 @@ bool ZoneDatabase::LoadAAEffects() { //AndMetal: this may now be obsolete since we have Zone::GetTotalAALevels() uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int total=0; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT count(slot) from aa_effects where aaid=%i", skill_id), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - total=atoi(row[0]); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in GetTotalAALevels '%s: %s", query, errbuf); - safe_delete_array(query); - } - return total; + + std::string query = StringFormat("SELECT count(slot) FROM aa_effects WHERE aaid = %i", skill_id); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetTotalAALevels '%s: %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; + } + + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + + return atoi(row[0]); } //this will allow us to count the number of effects for an AA by pulling the info from memory instead of the database. hopefully this will same some CPU cycles From 3bc582885b82cdf9c8709f66390339971a5bae9e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:21:46 -0700 Subject: [PATCH 103/217] LoadAAs converted to QueryDatabase --- zone/AA.cpp | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 6b5d9fbc0..3d8cb69dc 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1779,41 +1779,36 @@ uint32 ZoneDatabase::GetSizeAA(){ void ZoneDatabase::LoadAAs(SendAA_Struct **load){ if(!load) return; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT skill_id from altadv_vars order by skill_id"), errbuf, &result)) { - int skill=0,ndx=0; - while((row = mysql_fetch_row(result))!=nullptr) { - skill=atoi(row[0]); - load[ndx] = GetAASkillVars(skill); - load[ndx]->seq = ndx+1; - ndx++; + + std::string query = "SELECT skill_id FROM altadv_vars ORDER BY skill_id"; + auto results = QueryDatabase(query); + if (results.Success()) { + int skill = 0, index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + skill = atoi(row[0]); + load[index] = GetAASkillVars(skill); + load[index]->seq = index+1; } - mysql_free_result(result); } else { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query, errbuf); + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); } - safe_delete_array(query); AARequiredLevelAndCost.clear(); + query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id"; + results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return; + } - if (RunQuery(query, MakeAnyLenString(&query, "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id"), errbuf, &result)) - { - AALevelCost_Struct aalcs; - while((row = mysql_fetch_row(result))!=nullptr) - { - aalcs.Level = atoi(row[1]); - aalcs.Cost = atoi(row[2]); - AARequiredLevelAndCost[atoi(row[0])] = aalcs; - } - mysql_free_result(result); - } - else - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query, errbuf); + AALevelCost_Struct aalcs; + for (auto row = results.begin(); row != results.end(); ++row) + { + aalcs.Level = atoi(row[1]); + aalcs.Cost = atoi(row[2]); + AARequiredLevelAndCost[atoi(row[0])] = aalcs; + } - safe_delete_array(query); } SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id) From 110d22e77534bc471168f3f43de26d7f647e3c3d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:37:02 -0700 Subject: [PATCH 104/217] GetAASkillVars converted to QueryDatabase --- zone/AA.cpp | 193 ++++++++++++++++++++++------------------------------ 1 file changed, 81 insertions(+), 112 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 3d8cb69dc..83f27adeb 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1813,125 +1813,94 @@ void ZoneDatabase::LoadAAs(SendAA_Struct **load){ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - SendAA_Struct* sendaa = nullptr; - uchar* buffer; - if (RunQuery(query, MakeAnyLenString(&query, "SET @row = 0"), errbuf)) { //initialize "row" variable in database for next query - safe_delete_array(query); - MYSQL_RES *result; //we don't really need these unless we get to this point, so why bother? - MYSQL_ROW row; + std::string query = "SET @row = 0"; //initialize "row" variable in database for next query + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return nullptr; + } - if (RunQuery(query, MakeAnyLenString(&query, - "SELECT " - "a.cost, " - "a.max_level, " - "a.hotkey_sid, " - "a.hotkey_sid2, " - "a.title_sid, " - "a.desc_sid, " - "a.type, " - "COALESCE(" //so we can return 0 if it's null - "(" //this is our derived table that has the row # that we can SELECT from, because the client is stupid - "SELECT " - "p.prereq_index_num " - "FROM " - "(" - "SELECT " - "a2.skill_id, " - "@row := @row + 1 AS prereq_index_num " - "FROM " - "altadv_vars a2" - ") AS p " - "WHERE " - "p.skill_id = a.prereq_skill" - "), " - "0) AS prereq_skill_index, " - "a.prereq_minpoints, " - "a.spell_type, " - "a.spell_refresh, " - "a.classes, " - "a.berserker, " - "a.spellid, " - "a.class_type, " - "a.name, " - "a.cost_inc, " - "a.aa_expansion, " - "a.special_category, " - "a.sof_type, " - "a.sof_cost_inc, " - "a.sof_max_level, " - "a.sof_next_skill, " - "a.clientver, " // Client Version 0 = None, 1 = All, 2 = Titanium/6.2, 4 = SoF 5 = SOD 6 = UF - "a.account_time_required, " - "a.sof_current_level," - "a.sof_next_id, " - "a.level_inc " - " FROM altadv_vars a WHERE skill_id=%i", skill_id), errbuf, &result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - int total_abilities = GetTotalAALevels(skill_id); //eventually we'll want to use zone->GetTotalAALevels(skill_id) since it should save queries to the DB - int totalsize = total_abilities * sizeof(AA_Ability) + sizeof(SendAA_Struct); + query = StringFormat("SELECT a.cost, a.max_level, a.hotkey_sid, a.hotkey_sid2, a.title_sid, a.desc_sid, a.type, " + "COALESCE (" //So we can return 0 if it's null. + "(" // this is our derived table that has the row # + // that we can SELECT from, because the client is stupid. + "SELECT p.prereq_index_num " + "FROM (SELECT a2.skill_id, @row := @row + 1 AS prereq_index_num " + "FROM altadv_vars a2) AS p " + "WHERE p.skill_id = a.prereq_skill), 0) " + "AS prereq_skill_index, a.prereq_minpoints, a.spell_type, a.spell_refresh, a.classes, " + "a.berserker, a.spellid, a.class_type, a.name, a.cost_inc, a.aa_expansion, a.special_category, " + "a.sof_type, a.sof_cost_inc, a.sof_max_level, a.sof_next_skill, " + "a.clientver, " // Client Version 0 = None, 1 = All, 2 = Titanium/6.2, 4 = SoF 5 = SOD 6 = UF + "a.account_time_required, a.sof_current_level, a.sof_next_id, a.level_inc " + "FROM altadv_vars a WHERE skill_id=%i", skill_id); + results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return nullptr; + } - buffer = new uchar[totalsize]; - memset(buffer,0,totalsize); - sendaa = (SendAA_Struct*)buffer; + if (results.RowCount() != 1) + return nullptr; - row = mysql_fetch_row(result); + int total_abilities = GetTotalAALevels(skill_id); //eventually we'll want to use zone->GetTotalAALevels(skill_id) since it should save queries to the DB + int totalsize = total_abilities * sizeof(AA_Ability) + sizeof(SendAA_Struct); - //ATOI IS NOT UNSIGNED LONG-SAFE!!! + SendAA_Struct* sendaa = nullptr; + uchar* buffer; - sendaa->cost = atoul(row[0]); - sendaa->cost2 = sendaa->cost; - sendaa->max_level = atoul(row[1]); - sendaa->hotkey_sid = atoul(row[2]); - sendaa->id = skill_id; - sendaa->hotkey_sid2 = atoul(row[3]); - sendaa->title_sid = atoul(row[4]); - sendaa->desc_sid = atoul(row[5]); - sendaa->type = atoul(row[6]); - sendaa->prereq_skill = atoul(row[7]); - sendaa->prereq_minpoints = atoul(row[8]); - sendaa->spell_type = atoul(row[9]); - sendaa->spell_refresh = atoul(row[10]); - sendaa->classes = static_cast(atoul(row[11])); - sendaa->berserker = static_cast(atoul(row[12])); - sendaa->last_id = 0xFFFFFFFF; - sendaa->current_level=1; - sendaa->spellid = atoul(row[13]); - sendaa->class_type = atoul(row[14]); - strcpy(sendaa->name,row[15]); + buffer = new uchar[totalsize]; + memset(buffer,0,totalsize); + sendaa = (SendAA_Struct*)buffer; - sendaa->total_abilities=total_abilities; - if(sendaa->max_level > 1) - sendaa->next_id=skill_id+1; - else - sendaa->next_id=0xFFFFFFFF; + auto row = results.begin(); + + //ATOI IS NOT UNSIGNED LONG-SAFE!!! + + sendaa->cost = atoul(row[0]); + sendaa->cost2 = sendaa->cost; + sendaa->max_level = atoul(row[1]); + sendaa->hotkey_sid = atoul(row[2]); + sendaa->id = skill_id; + sendaa->hotkey_sid2 = atoul(row[3]); + sendaa->title_sid = atoul(row[4]); + sendaa->desc_sid = atoul(row[5]); + sendaa->type = atoul(row[6]); + sendaa->prereq_skill = atoul(row[7]); + sendaa->prereq_minpoints = atoul(row[8]); + sendaa->spell_type = atoul(row[9]); + sendaa->spell_refresh = atoul(row[10]); + sendaa->classes = static_cast(atoul(row[11])); + sendaa->berserker = static_cast(atoul(row[12])); + sendaa->last_id = 0xFFFFFFFF; + sendaa->current_level=1; + sendaa->spellid = atoul(row[13]); + sendaa->class_type = atoul(row[14]); + strcpy(sendaa->name,row[15]); + + sendaa->total_abilities=total_abilities; + if(sendaa->max_level > 1) + sendaa->next_id=skill_id+1; + else + sendaa->next_id=0xFFFFFFFF; + + sendaa->cost_inc = atoi(row[16]); + + // Begin SoF Specific/Adjusted AA Fields + sendaa->aa_expansion = atoul(row[17]); + sendaa->special_category = atoul(row[18]); + sendaa->sof_type = atoul(row[19]); + sendaa->sof_cost_inc = atoi(row[20]); + sendaa->sof_max_level = atoul(row[21]); + sendaa->sof_next_skill = atoul(row[22]); + sendaa->clientver = atoul(row[23]); + sendaa->account_time_required = atoul(row[24]); + + //Internal use only - not sent to client + sendaa->sof_current_level = atoul(row[25]); + sendaa->sof_next_id = atoul(row[26]); + sendaa->level_inc = static_cast(atoul(row[27])); - sendaa->cost_inc = atoi(row[16]); - // Begin SoF Specific/Adjusted AA Fields - sendaa->aa_expansion = atoul(row[17]); - sendaa->special_category = atoul(row[18]); - sendaa->sof_type = atoul(row[19]); - sendaa->sof_cost_inc = atoi(row[20]); - sendaa->sof_max_level = atoul(row[21]); - sendaa->sof_next_skill = atoul(row[22]); - sendaa->clientver = atoul(row[23]); - sendaa->account_time_required = atoul(row[24]); - //Internal use only - not sent to client - sendaa->sof_current_level = atoul(row[25]); - sendaa->sof_next_id = atoul(row[26]); - sendaa->level_inc = static_cast(atoul(row[27])); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query, errbuf); - safe_delete_array(query); - } - } else { - LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query, errbuf); - safe_delete_array(query); - } return sendaa; } From 64cd589ca34401032623d025ed450a810804c70a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:41:37 -0700 Subject: [PATCH 105/217] FillAAEffects converted to QueryDatabase --- zone/AA.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 83f27adeb..b96990f48 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1714,24 +1714,20 @@ void ZoneDatabase::FillAAEffects(SendAA_Struct* aa_struct){ if(!aa_struct) return; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT effectid, base1, base2, slot from aa_effects where aaid=%i order by slot asc", aa_struct->id), errbuf, &result)) { - int ndx=0; - while((row = mysql_fetch_row(result))!=nullptr) { - aa_struct->abilities[ndx].skill_id=atoi(row[0]); - aa_struct->abilities[ndx].base1=atoi(row[1]); - aa_struct->abilities[ndx].base2=atoi(row[2]); - aa_struct->abilities[ndx].slot=atoi(row[3]); - ndx++; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in Client::FillAAEffects query: '%s': %s", query, errbuf); + std::string query = StringFormat("SELECT effectid, base1, base2, slot from aa_effects where aaid=%i order by slot asc", aa_struct->id); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Client::FillAAEffects query: '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + int index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + aa_struct->abilities[index].skill_id=atoi(row[0]); + aa_struct->abilities[index].base1=atoi(row[1]); + aa_struct->abilities[index].base2=atoi(row[2]); + aa_struct->abilities[index].slot=atoi(row[3]); } - safe_delete_array(query); } uint32 ZoneDatabase::CountAAs(){ From 9867fdd4d2e16c15966c82773f0d4fcec39188e5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:45:41 -0700 Subject: [PATCH 106/217] CountAAs converted to QueryDatabase --- zone/AA.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index b96990f48..5c02e8909 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1731,20 +1731,20 @@ void ZoneDatabase::FillAAEffects(SendAA_Struct* aa_struct){ } uint32 ZoneDatabase::CountAAs(){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int count=0; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT count(title_sid) from altadv_vars"), errbuf, &result)) { - if((row = mysql_fetch_row(result))!=nullptr) - count = atoi(row[0]); - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query, errbuf); + + const std::string query = "SELECT count(title_sid) FROM altadv_vars"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; } - safe_delete_array(query); - return count; + + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + + return atoi(row[0]);; } uint32 ZoneDatabase::CountAAEffects(){ From 1c87a6069a6c59cf267dc06e10b361973de597c5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:48:10 -0700 Subject: [PATCH 107/217] CountAAEffects converted to QueryDatabase --- zone/AA.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/zone/AA.cpp b/zone/AA.cpp index 5c02e8909..b3cc24222 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -1747,22 +1747,21 @@ uint32 ZoneDatabase::CountAAs(){ return atoi(row[0]);; } -uint32 ZoneDatabase::CountAAEffects(){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int count=0; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT count(id) from aa_effects"), errbuf, &result)) { - if((row = mysql_fetch_row(result))!=nullptr){ - count = atoi(row[0]); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query, errbuf); +uint32 ZoneDatabase::CountAAEffects() { + + const std::string query = "SELECT count(id) FROM aa_effects"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; } - safe_delete_array(query); - return count; + + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + + return atoi(row[0]); } uint32 ZoneDatabase::GetSizeAA(){ From 21ba9953f8ae9dedf7d035df9110e9b4e745acc6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:52:41 -0700 Subject: [PATCH 108/217] SetZoneFlag converted to QueryDatabase --- zone/zoning.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/zone/zoning.cpp b/zone/zoning.cpp index f69598ce5..565ebf8d2 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -723,16 +723,11 @@ void Client::SetZoneFlag(uint32 zone_id) { zone_flags.insert(zone_id); - //update the DB - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - // Retrieve all waypoints for this grid - if(!database.RunQuery(query,MakeAnyLenString(&query, - "INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", - CharacterID(),zone_id),errbuf)) { - LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), errbuf); - } + std::string query = StringFormat("INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", CharacterID(), zone_id); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); } void Client::ClearZoneFlag(uint32 zone_id) { From bc90ab795bd571369a74fc651bfd40080b0a31a9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 12:55:53 -0700 Subject: [PATCH 109/217] ClearZoneFlag converted to QueryDatabase --- zone/zoning.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 565ebf8d2..de1f73193 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -736,16 +736,12 @@ void Client::ClearZoneFlag(uint32 zone_id) { zone_flags.erase(zone_id); - //update the DB - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - // Retrieve all waypoints for this grid - if(!database.RunQuery(query,MakeAnyLenString(&query, - "DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", - CharacterID(),zone_id),errbuf)) { - LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), errbuf); - } + std::string query = StringFormat("DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", CharacterID(), zone_id); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); + } void Client::LoadZoneFlags() { From cf4145dad470ac146cfb3649d4682444c671f211 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 13:02:27 -0700 Subject: [PATCH 110/217] LoadZoneFlags converted to QueryDatabase --- zone/zoning.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/zone/zoning.cpp b/zone/zoning.cpp index de1f73193..ae10ecf59 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -745,26 +745,17 @@ void Client::ClearZoneFlag(uint32 zone_id) { } void Client::LoadZoneFlags() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; // Retrieve all waypoints for this grid - if(database.RunQuery(query,MakeAnyLenString(&query, - "SELECT zoneID from zone_flags WHERE charID=%d", - CharacterID()),errbuf,&result)) - { - while((row = mysql_fetch_row(result))) { - zone_flags.insert(atoi(row[0])); - } - mysql_free_result(result); - } - else // DB query error! - { - LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str()); + return; + } + + for(auto row = results.begin(); row != results.end(); ++row) + zone_flags.insert(atoi(row[0])); } bool Client::HasZoneFlag(uint32 zone_id) const { From 536773db440709f82831fff9b436b984ad305ff3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 13:20:51 -0700 Subject: [PATCH 111/217] LoadTraps converted to QueryDatabase --- zone/trap.cpp | 65 ++++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/zone/trap.cpp b/zone/trap.cpp index 2ab431c24..f870cebf7 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -262,45 +262,36 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) { //todo: rewrite this to not need direct access to trap members. bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - // int char_num = 0; - unsigned long* lengths; - - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id,x,y,z,effect,effectvalue,effectvalue2,skill,maxzdiff,radius,chance,message,respawn_time,respawn_var,level FROM traps WHERE zone='%s' AND version=%u", zonename, version), errbuf, &result)) { - safe_delete_array(query); - while ((row = mysql_fetch_row(result))) - { - lengths = mysql_fetch_lengths(result); - Trap* trap = new Trap(); - trap->trap_id = atoi(row[0]); - trap->x = atof(row[1]); - trap->y = atof(row[2]); - trap->z = atof(row[3]); - trap->effect = atoi(row[4]); - trap->effectvalue = atoi(row[5]); - trap->effectvalue2 = atoi(row[6]); - trap->skill = atoi(row[7]); - trap->maxzdiff = atof(row[8]); - trap->radius = atof(row[9]); - trap->chance = atoi(row[10]); - trap->message = row[11]; - trap->respawn_time = atoi(row[12]); - trap->respawn_var = atoi(row[13]); - trap->level = atoi(row[14]); - entity_list.AddTrap(trap); - trap->CreateHiddenTrigger(); - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, " + "maxzdiff, radius, chance, message, respawn_time, respawn_var, level " + "FROM traps WHERE zone='%s' AND version=%u", zonename, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + Trap* trap = new Trap(); + trap->trap_id = atoi(row[0]); + trap->x = atof(row[1]); + trap->y = atof(row[2]); + trap->z = atof(row[3]); + trap->effect = atoi(row[4]); + trap->effectvalue = atoi(row[5]); + trap->effectvalue2 = atoi(row[6]); + trap->skill = atoi(row[7]); + trap->maxzdiff = atof(row[8]); + trap->radius = atof(row[9]); + trap->chance = atoi(row[10]); + trap->message = row[11]; + trap->respawn_time = atoi(row[12]); + trap->respawn_var = atoi(row[13]); + trap->level = atoi(row[14]); + entity_list.AddTrap(trap); + trap->CreateHiddenTrigger(); + } return true; } From 774227323781992c9bd7fa0d4c8723c82f395b31 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 13:31:47 -0700 Subject: [PATCH 112/217] LoadTributes converted to QueryDatabase --- zone/tribute.cpp | 92 ++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 63166cc41..5190aaa4f 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -378,68 +378,60 @@ void Client::SendGuildTributes() { } bool ZoneDatabase::LoadTributes() { - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - TributeData t; - memset(&t.tiers, 0, sizeof(t.tiers)); - t.tier_count = 0; + TributeData tributeData; + memset(&tributeData.tiers, 0, sizeof(tributeData.tiers)); + tributeData.tier_count = 0; tribute_list.clear(); - const char *query = "SELECT id,name,descr,unknown,isguild FROM tributes"; - if (RunQuery(query, strlen(query), errbuf, &result)) { - int r; - while ((row = mysql_fetch_row(result))) { - r = 0; - uint32 id = atoul(row[r++]); - t.name = row[r++]; - t.description = row[r++]; - t.unknown = strtoul(row[r++], nullptr, 10); - t.is_guild = atol(row[r++])==0?false:true; - - tribute_list[id] = t; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadTributes first query '%s': %s", query, errbuf); + const std::string query = "SELECT id, name, descr, unknown, isguild FROM tributes"; + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadTributes first query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; } + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 id = atoul(row[0]); + tributeData.name = row[1]; + tributeData.description = row[2]; + tributeData.unknown = strtoul(row[3], nullptr, 10); + tributeData.is_guild = atol(row[4]) == 0? false: true; - const char *query2 = "SELECT tribute_id,level,cost,item_id FROM tribute_levels ORDER BY tribute_id,level"; - if (RunQuery(query2, strlen(query2), errbuf, &result)) { - int r; - while ((row = mysql_fetch_row(result))) { - r = 0; - uint32 id = atoul(row[r++]); + tribute_list[id] = tributeData; + } - if(tribute_list.count(id) != 1) { - LogFile->write(EQEMuLog::Error, "Error in LoadTributes: unknown tribute %lu in tribute_levels", (unsigned long)id); - continue; - } - - TributeData &cur = tribute_list[id]; - - if(cur.tier_count >= MAX_TRIBUTE_TIERS) { - LogFile->write(EQEMuLog::Error, "Error in LoadTributes: on tribute %lu: more tiers defined than permitted", (unsigned long)id); - continue; - } - - TributeLevel_Struct &s = cur.tiers[cur.tier_count]; - - s.level = atoul(row[r++]); - s.cost = atoul(row[r++]); - s.tribute_item_id = atoul(row[r++]); - cur.tier_count++; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadTributes level query '%s': %s", query, errbuf); + const std::string query2 = "SELECT tribute_id, level, cost, item_id FROM tribute_levels ORDER BY tribute_id, level"; + results = QueryDatabase(query2); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadTributes level query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; } + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 id = atoul(row[0]); + + if(tribute_list.count(id) != 1) { + LogFile->write(EQEMuLog::Error, "Error in LoadTributes: unknown tribute %lu in tribute_levels", (unsigned long)id); + continue; + } + + TributeData &cur = tribute_list[id]; + + if(cur.tier_count >= MAX_TRIBUTE_TIERS) { + LogFile->write(EQEMuLog::Error, "Error in LoadTributes: on tribute %lu: more tiers defined than permitted", (unsigned long)id); + continue; + } + + TributeLevel_Struct &s = cur.tiers[cur.tier_count]; + + s.level = atoul(row[1]); + s.cost = atoul(row[2]); + s.tribute_item_id = atoul(row[3]); + cur.tier_count++; + } + return true; } From 5fec840f0696282b169968b41fbc55d484cf05ee Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 13:58:36 -0700 Subject: [PATCH 113/217] AssignWaypoints converted to QueryDatabase --- zone/waypoints.cpp | 135 +++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 77 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index eb22f13a8..d0da194e8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -869,97 +869,78 @@ void NPC::AssignWaypoints(int32 grid) { return; } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - bool GridErr = false, WPErr = false; Waypoints.clear(); + roamer = false; // Retrieve the wander and pause types for this grid - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `type`,`type2` FROM `grid` WHERE `id`=%i AND `zoneid`=%i",grid,zone->GetZoneID()),errbuf, &result)) - { - if((row = mysql_fetch_row(result))) - { - if(row[0] != 0) - wandertype = atoi(row[0]); - else - wandertype = 0; - if(row[1] != 0) - pausetype = atoi(row[1]); - else - pausetype = 0; - } - else // No grid record found in this zone for the given ID - GridErr = true; - mysql_free_result(result); + std::string query = StringFormat("SELECT `type`, `type2` FROM `grid` WHERE `id` = %i AND `zoneid` = %i", grid, zone->GetZoneID()); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign grid %u to mob %s: %s", grid, name, results.ErrorMessage().c_str()); + return; } - else // DB query error! - { - GridErr = true; - LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign grid %u to mob %s: %s", grid, name, errbuf); - } - safe_delete_array(query); - if(!GridErr) - { - this->CastToNPC()->SetGrid(grid); // Assign grid number + if (results.RowCount() == 0) + return; - // Retrieve all waypoints for this grid - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `x`,`y`,`z`,`pause`,`heading` FROM grid_entries WHERE `gridid`=%i AND `zoneid`=%i ORDER BY `number`",grid,zone->GetZoneID()),errbuf,&result)) - { - roamer = true; - max_wp = -1; // Initialize it; will increment it for each waypoint successfully added to the list + auto row = results.begin(); - while((row = mysql_fetch_row(result))) - { - if(row[0] != 0 && row[1] != 0 && row[2] != 0 && row[3] != 0) - { - wplist newwp; - newwp.index = ++max_wp; - newwp.x = atof(row[0]); - newwp.y = atof(row[1]); - newwp.z = atof(row[2]); + wandertype = atoi(row[0]); + pausetype = atoi(row[1]); - if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) ) - { - if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(newwp.x, newwp.y, newwp.z))) - { - Map::Vertex dest(newwp.x, newwp.y, newwp.z); - float newz = zone->zonemap->FindBestZ(dest, nullptr); + this->CastToNPC()->SetGrid(grid); // Assign grid number - if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaLoading)) - newwp.z = newz + 1; - } - } + // Retrieve all waypoints for this grid + query = StringFormat("SELECT `x`,`y`,`z`,`pause`,`heading` " + "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %i " + "ORDER BY `number`", grid, zone->GetZoneID()); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign waypoints from grid %u to mob %s: %s", grid, name, results.ErrorMessage().c_str()); + return; + } + + roamer = true; + max_wp = 0; // Initialize it; will increment it for each waypoint successfully added to the list + + for (auto row = results.begin(); row != results.end(); ++row, ++max_wp) + { + wplist newwp; + newwp.index = max_wp; + newwp.x = atof(row[0]); + newwp.y = atof(row[1]); + newwp.z = atof(row[2]); + + if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) ) + { + if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || + (zone->HasWaterMap() && !zone->watermap->InWater(newwp.x, newwp.y, newwp.z))) + { + Map::Vertex dest(newwp.x, newwp.y, newwp.z); + + float newz = zone->zonemap->FindBestZ(dest, nullptr); + + if( (newz > -2000) && ABS(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaLoading)) + newwp.z = newz + 1; + } + } + + newwp.pause = atoi(row[3]); + newwp.heading = atof(row[4]); + Waypoints.push_back(newwp); + } - newwp.pause = atoi(row[3]); - newwp.heading = atof(row[4]); - Waypoints.push_back(newwp); - } - } - mysql_free_result(result); - } - else // DB query error! - { - WPErr = true; - LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign waypoints from grid %u to mob %s: %s", grid, name, errbuf); - } - safe_delete_array(query); - } // end if (!GridErr) if(Waypoints.size() < 2) { roamer = false; - } else if(!GridErr && !WPErr) { - UpdateWaypoint(0); - SetWaypointPause(); - if (wandertype == 1 || wandertype == 2 || wandertype == 5) - CalculateNewWaypoint(); - } else { - roamer = false; } + + UpdateWaypoint(0); + SetWaypointPause(); + + if (wandertype == 1 || wandertype == 2 || wandertype == 5) + CalculateNewWaypoint(); + } void Mob::SendTo(float new_x, float new_y, float new_z) { From b6547293839be356c004051e1fe7e6fb95470722 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:03:00 -0700 Subject: [PATCH 114/217] GetGridType2 converted to QueryDatabase --- zone/waypoints.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index d0da194e8..44f8d061f 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1030,24 +1030,21 @@ int ZoneDatabase::GetHighestGrid(uint32 zoneid) { } uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) { - char *query = 0; - char errbuff[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - int type2 = 0; - if (RunQuery(query, MakeAnyLenString(&query,"SELECT type2 from grid where id = %i and zoneid = %i",grid,zoneid),errbuff,&result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - type2 = atoi( row[0] ); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in GetGridType2 query '%s': %s", query, errbuff); - safe_delete_array(query); - } - return(type2); + int type2 = 0; + std::string query = StringFormat("SELECT type2 FROM grid WHERE id = %i AND zoneid = %i", grid, zoneid); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetGridType2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; + } + + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + + return atoi(row[0]); } bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) { From 5f2db0d1cbef149585eb01d95c4e3df95d0aef90 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:08:43 -0700 Subject: [PATCH 115/217] GetWaypoints converted to QueryDatabase --- zone/waypoints.cpp | 48 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 44f8d061f..c3a1331fb 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1048,31 +1048,29 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) { } bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) { - char *query = 0; - char errbuff[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query,"SELECT x, y, z, pause, heading from grid_entries where gridid = %i and number = %i and zoneid = %i",grid,num,zoneid),errbuff,&result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - if ( wp ) { - wp->x = atof( row[0] ); - wp->y = atof( row[1] ); - wp->z = atof( row[2] ); - wp->pause = atoi( row[3] ); - wp->heading = atof( row[4] ); - } - mysql_free_result(result); - return true; - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query, errbuff); - safe_delete_array(query); - } - return false; + + std::string query = StringFormat("SELECT x, y, z, pause, heading FROM grid_entries " + "WHERE gridid = %i AND number = %i AND zoneid = %i", grid, num, zoneid); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; + } + + if (results.RowCount() != 1) + return false; + + auto row = results.begin(); + + if (wp) { + wp->x = atof( row[0] ); + wp->y = atof( row[1] ); + wp->z = atof( row[2] ); + wp->pause = atoi( row[3] ); + wp->heading = atof( row[4] ); + } + + return true; } void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) From cab0beb77f21b502b0e441c3b38e6d1eaff5a210 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:32:04 -0700 Subject: [PATCH 116/217] AssignGrid converted to QueryDatabase --- zone/waypoints.cpp | 155 ++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 93 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index c3a1331fb..46304b31e 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1049,6 +1049,9 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) { bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) { + if (wp == nullptr) + return false; + std::string query = StringFormat("SELECT x, y, z, pause, heading FROM grid_entries " "WHERE gridid = %i AND number = %i AND zoneid = %i", grid, num, zoneid); auto results = QueryDatabase(query); @@ -1062,122 +1065,88 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* auto row = results.begin(); - if (wp) { - wp->x = atof( row[0] ); - wp->y = atof( row[1] ); - wp->z = atof( row[2] ); - wp->pause = atoi( row[3] ); - wp->heading = atof( row[4] ); - } + wp->x = atof(row[0]); + wp->y = atof(row[1]); + wp->z = atof(row[2]); + wp->pause = atoi(row[3]); + wp->heading = atof(row[4]); return true; } void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) { - char *query = 0; - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; int matches = 0, fuzzy = 0, spawn2id = 0; - uint32 affected_rows; float dbx = 0, dby = 0; // looks like most of the stuff in spawn2 is straight integers // so let's try that first - if(!RunQuery( - query, - MakeAnyLenString( - &query, - "SELECT id,x,y FROM spawn2 WHERE zone='%s' AND x=%i AND y=%i", - zone->GetShortName(), (int)x, (int)y - ), - errbuf, - &result - )) { - LogFile->write(EQEMuLog::Error, "Error querying spawn2 '%s': '%s'", query, errbuf); - return; + std::string query = StringFormat("SELECT id, x, y FROM spawn2 WHERE zone = '%s' AND x = %i AND y = %i", + zone->GetShortName(), (int)x, (int)y); + auto results = QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error querying spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(query); // how much it's allowed to be off by #define _GASSIGN_TOLERANCE 1.0 - if(!(matches = mysql_num_rows(result))) // try a fuzzy match if that didn't find it + if(results.RowCount() == 0) // try a fuzzy match if that didn't find it { - mysql_free_result(result); - if(!RunQuery( - query, - MakeAnyLenString( - &query, - "SELECT id,x,y FROM spawn2 WHERE zone='%s' AND " - "ABS( ABS(x) - ABS(%f) ) < %f AND " - "ABS( ABS(y) - ABS(%f) ) < %f", - zone->GetShortName(), x, _GASSIGN_TOLERANCE, y, _GASSIGN_TOLERANCE - ), - errbuf, - &result - )) { - LogFile->write(EQEMuLog::Error, "Error querying fuzzy spawn2 '%s': '%s'", query, errbuf); + query = StringFormat("SELECT id,x,y FROM spawn2 WHERE zone='%s' AND " + "ABS( ABS(x) - ABS(%f) ) < %f AND " + "ABS( ABS(y) - ABS(%f) ) < %f", + zone->GetShortName(), x, _GASSIGN_TOLERANCE, y, _GASSIGN_TOLERANCE); + results = QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error querying fuzzy spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); return; } - safe_delete_array(query); + fuzzy = 1; - if(!(matches = mysql_num_rows(result))) - mysql_free_result(result); + matches = results.RowCount(); } - if(matches) + + if (matches == 0) { + client->Message(0, "ERROR: Unable to assign grid - can't find it in spawn2"); + return; + } + + if(matches == 1) { - if(matches > 1) - { - client->Message(0, "ERROR: Unable to assign grid - multiple spawn2 rows match"); - mysql_free_result(result); - } - else - { - row = mysql_fetch_row(result); - spawn2id = atoi(row[0]); - dbx = atof(row[1]); - dby = atof(row[2]); - if(!RunQuery( - query, - MakeAnyLenString( - &query, - "UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id - ), - errbuf, - &result, - &affected_rows - )) { - LogFile->write(EQEMuLog::Error, "Error updating spawn2 '%s': '%s'", query, errbuf); - return; - } - if(affected_rows == 1) - { - if(client) client->LogSQL(query); - if(fuzzy) - { - float difference; - difference = sqrtf(pow(fabs(x-dbx),2) + pow(fabs(y-dby),2)); - client->Message(0, - "Grid assign: spawn2 id = %d updated - fuzzy match: deviation %f", - spawn2id, difference - ); - } - else - { - client->Message(0, "Grid assign: spawn2 id = %d updated - exact match", spawn2id); - } - } - else - { - client->Message(0, "ERROR: found spawn2 id %d but the update query failed", spawn2id); - } - } + client->Message(0, "ERROR: Unable to assign grid - multiple spawn2 rows match"); + return; } - else + + auto row = results.begin(); + + spawn2id = atoi(row[0]); + dbx = atof(row[1]); + dby = atof(row[2]); + + query = StringFormat("UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id); + results = QueryDatabase(query); + if (!results.Success()) { - client->Message(0, "ERROR: Unable to assign grid - can't find it in spawn2"); - } + LogFile->write(EQEMuLog::Error, "Error updating spawn2 '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + if (results.RowsAffected() != 1) { + client->Message(0, "ERROR: found spawn2 id %d but the update query failed", spawn2id); + return; + } + + if(client) + client->LogSQL(query.c_str()); + + if(!fuzzy) { + client->Message(0, "Grid assign: spawn2 id = %d updated - exact match", spawn2id); + return; + } + + float difference = sqrtf(pow(fabs(x - dbx) , 2) + pow(fabs(y - dby), 2)); + client->Message(0, "Grid assign: spawn2 id = %d updated - fuzzy match: deviation %f", spawn2id, difference); } /****************** From 334e29a6d66ce6815fbe19b336f335cb547a09ab Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:40:47 -0700 Subject: [PATCH 117/217] ModifyGrid converted to QueryDatabase --- zone/waypoints.cpp | 56 ++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 46304b31e..571cb5e13 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1156,41 +1156,43 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid) * type,type2: The type and type2 values for the grid being created (ignored if grid is being deleted) * zoneid: The ID number of the zone the grid is being created/deleted in */ +void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type, uint8 type2, uint16 zoneid) { -void ZoneDatabase::ModifyGrid(Client *c, bool remove, uint32 id, uint8 type, uint8 type2, uint16 zoneid) { - char *query = 0; - char errbuf[MYSQL_ERRMSG_SIZE]; if (!remove) { - if(!RunQuery(query, MakeAnyLenString(&query,"INSERT INTO grid(id,zoneid,type,type2) VALUES(%i,%i,%i,%i)",id,zoneid,type,type2), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error creating grid entry '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); + std::string query = StringFormat("INSERT INTO grid(id, zoneid, type, type2) " + "VALUES (%i, %i, %i, %i)", id, zoneid, type, type2); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error creating grid entry '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + if(client) + client->LogSQL(query.c_str()); + + return; } - else - { - if(!RunQuery(query, MakeAnyLenString(&query,"DELETE FROM grid where id=%i",id), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error deleting grid '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); - query = 0; - if(!RunQuery(query, MakeAnyLenString(&query,"DELETE FROM grid_entries WHERE zoneid=%i AND gridid=%i",zoneid,id), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error deleting grid entries '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); - } -} /*** END ZoneDatabase::ModifyGrid() ***/ + + std::string query = StringFormat("DELETE FROM grid where id=%i", id); + auto results = QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "Error deleting grid '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + else if(client) + client->LogSQL(query.c_str()); + + query = StringFormat("DELETE FROM grid_entries WHERE zoneid = %i AND gridid = %i", zoneid, id); + results = QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error deleting grid entries '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + else if(client) + client->LogSQL(query.c_str()); + +} /************************************** * AddWP - Adds a new waypoint to a specific grid for a specific zone. */ - void ZoneDatabase::AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading) { char *query = 0; From 06b0bd6da45c1d4f0a05d0c7fba19535585640b5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:44:32 -0700 Subject: [PATCH 118/217] AddWP converted to QueryDatabase --- zone/waypoints.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 571cb5e13..a4a4ba40a 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1193,18 +1193,20 @@ void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type /************************************** * AddWP - Adds a new waypoint to a specific grid for a specific zone. */ -void ZoneDatabase::AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading) +void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading) { - char *query = 0; - char errbuf[MYSQL_ERRMSG_SIZE]; - - if(!RunQuery(query,MakeAnyLenString(&query,"INSERT INTO grid_entries (gridid,zoneid,`number`,x,y,z,pause,heading) values (%i,%i,%i,%f,%f,%f,%i,%f)",gridid,zoneid,wpnum,xpos,ypos,zpos,pause,heading), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error adding waypoint '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); + std::string query = StringFormat("INSERT INTO grid_entries (gridid, zoneid, `number`, x, y, z, pause, heading) " + "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", + gridid, zoneid, wpnum, xpos, ypos, zpos, pause, heading); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error adding waypoint '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(query); -} /*** END ZoneDatabase::AddWP() ***/ + + if(client) + client->LogSQL(query.c_str()); +} /********** From c466317082eaa945c4c4eb2e891a861b186b48c0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 14:48:57 -0700 Subject: [PATCH 119/217] DeleteWaypoint converted to QueryDatabase --- zone/waypoints.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index a4a4ba40a..81d5c4ed4 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1219,19 +1219,20 @@ void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, float xpos * wp_num: The number of the waypoint being deleted * zoneid: The ID number of the zone that contains the waypoint being deleted */ - -void ZoneDatabase::DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid) +void ZoneDatabase::DeleteWaypoint(Client *client, uint32 grid_num, uint32 wp_num, uint16 zoneid) { - char *query=0; - char errbuf[MYSQL_ERRMSG_SIZE]; - - if(!RunQuery(query, MakeAnyLenString(&query,"DELETE FROM grid_entries where gridid=%i and zoneid=%i and `number`=%i",grid_num,zoneid,wp_num), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error deleting waypoint '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); + std::string query = StringFormat("DELETE FROM grid_entries WHERE " + "gridid = %i AND zoneid = %i AND `number` = %i", + grid_num, zoneid, wp_num); + auto results = QueryDatabase(query); + if(!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error deleting waypoint '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(query); -} /*** END ZoneDatabase::DeleteWaypoint() ***/ + + if(client) + client->LogSQL(query.c_str()); +} /****************** From 8b69de46e9309ac019b459a01bdd8c8523aa2e69 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:06:53 -0700 Subject: [PATCH 120/217] AddWPForSpawn converted to QueryDatabase --- zone/waypoints.cpp | 121 ++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 68 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 81d5c4ed4..111d091e4 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1242,92 +1242,77 @@ void ZoneDatabase::DeleteWaypoint(Client *client, uint32 grid_num, uint32 wp_num * Returns 0 if the function didn't have to create a new grid. If the function had to create a new grid for the spawn, then the ID of * the created grid is returned. */ +uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading) { -uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float ypos, float zpos, uint32 pause, int type1, int type2, uint16 zoneid, float heading) { - char *query = 0; - uint32 grid_num, // The grid number the spawn is assigned to (if spawn has no grid, will be the grid number we end up creating) - next_wp_num; // The waypoint number we should be assigning to the new waypoint - bool CreatedNewGrid; // Did we create a new grid in this function? - MYSQL_RES *result; - MYSQL_ROW row; - char errbuf[MYSQL_ERRMSG_SIZE]; + uint32 grid_num; // The grid number the spawn is assigned to (if spawn has no grid, will be the grid number we end up creating) + uint32 next_wp_num; // The waypoint number we should be assigning to the new waypoint + bool createdNewGrid; // Did we create a new grid in this function? // See what grid number our spawn is assigned - if(RunQuery(query, MakeAnyLenString(&query,"SELECT pathgrid FROM spawn2 WHERE id=%i",spawn2id),errbuf,&result)) - { - safe_delete_array(query); - if(mysql_num_rows(result) > 0) - { - row = mysql_fetch_row(result); - grid_num = atoi(row[0]); - } - else // This spawn ID was not found in the `spawn2` table - return 0; - - mysql_free_result(result); - } - else { // Query error - LogFile->write(EQEMuLog::Error, "Error setting pathgrid '%s': '%s'", query, errbuf); + std::string query = StringFormat("SELECT pathgrid FROM spawn2 WHERE id = %i", spawn2id); + auto results = QueryDatabase(query); + if (!results.Success()) { + // Query error + LogFile->write(EQEMuLog::Error, "Error setting pathgrid '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); return 0; } - if (grid_num == 0) // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn - { - CreatedNewGrid = true; - if((grid_num = GetFreeGrid(zoneid)) == 0) // There are no grids for the current zone -- create Grid #1 - grid_num = 1; + if (results.RowCount() == 0) + return 0; - if(!RunQuery(query, MakeAnyLenString(&query,"insert into grid set id='%i',zoneid= %i, type='%i', type2='%i'",grid_num,zoneid,type1,type2), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error adding grid '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); + auto row = results.begin(); + grid_num = atoi(row[0]); - query = 0; - if(!RunQuery(query, MakeAnyLenString(&query,"update spawn2 set pathgrid='%i' where id='%i'",grid_num,spawn2id), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error updating spawn2 pathing '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); + if (grid_num == 0) + { // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn + createdNewGrid = true; + grid_num = GetFreeGrid(zoneid); + if(grid_num == 0) // There are no grids for the current zone -- create Grid #1 + grid_num = 1; + + query = StringFormat("INSERT INTO grid SET id = '%i', zoneid = %i, type ='%i', type2 = '%i'", + grid_num, zoneid, type1, type2); + results = QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error adding grid '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + else if(client) + client->LogSQL(query.c_str()); + + query = StringFormat("UPDATE spawn2 SET pathgrid = '%i' WHERE id = '%i'", grid_num, spawn2id); + results = QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error updating spawn2 pathing '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + else if(client) + client->LogSQL(query.c_str()); } else // NPC had a grid assigned to it - CreatedNewGrid = false; - + createdNewGrid = false; // Find out what the next waypoint is for this grid - query = 0; - if(RunQuery(query, MakeAnyLenString(&query,"SELECT max(`number`) FROM grid_entries WHERE zoneid='%i' AND gridid='%i'",zoneid,grid_num),errbuf,&result)) - { - safe_delete_array(query); - row = mysql_fetch_row(result); - if(row[0] != 0) - next_wp_num = atoi(row[0]) + 1; - else // No waypoints in this grid yet - next_wp_num = 1; + query = StringFormat("SELECT max(`number`) FROM grid_entries WHERE zoneid = '%i' AND gridid = '%i'", zoneid, grid_num); - mysql_free_result(result); - } - else { // Query error - LogFile->write(EQEMuLog::Error, "Error getting next waypoint id '%s': '%s'", query, errbuf); + if(!results.Success()) { // Query error + LogFile->write(EQEMuLog::Error, "Error getting next waypoint id '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); return 0; } - query = 0; - if(!RunQuery(query, MakeAnyLenString(&query,"INSERT INTO grid_entries(gridid,zoneid,`number`,x,y,z,pause,heading) VALUES (%i,%i,%i,%f,%f,%f,%i,%f)",grid_num,zoneid,next_wp_num,xpos,ypos,zpos,pause,heading), errbuf)) { - LogFile->write(EQEMuLog::Error, "Error adding grid entry '%s': '%s'", query, errbuf); - } else { - if(c) c->LogSQL(query); - } - safe_delete_array(query); + row = results.begin(); + if(row[0] != 0) + next_wp_num = atoi(row[0]) + 1; + else // No waypoints in this grid yet + next_wp_num = 1; - if(CreatedNewGrid) - return grid_num; - - return 0; -} /*** END ZoneDatabase::AddWPForSpawn() ***/ + query = StringFormat("INSERT INTO grid_entries(gridid, zoneid, `number`, x, y, z, pause, heading) " + "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", + grid_num, zoneid, next_wp_num, xpos, ypos, zpos, pause, heading); + results = QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Error adding grid entry '%s': '%s'", query.c_str(), results.ErrorMessage().c_str()); + else if(client) + client->LogSQL(query.c_str()); + return createdNewGrid? grid_num: 0; +} uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { char *query = 0; From 2f30488cd55af2cad3716b8d955a3d706d831331 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:11:12 -0700 Subject: [PATCH 121/217] GetFreeGrid converted to QueryDatabase --- zone/waypoints.cpp | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 111d091e4..a67943b5c 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1315,28 +1315,22 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, float xpos, } uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { - char *query = 0; - char errbuf[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query,"SELECT max(id) from grid where zoneid = %i",zoneid),errbuf,&result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - uint32 tmp=0; - if (row[0]) - tmp = atoi(row[0]); - mysql_free_result(result); - tmp++; - return tmp; - } - mysql_free_result(result); + + std::string query = StringFormat("SELECT max(id) FROM grid WHERE zoneid = %i", zoneid); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetFreeGrid query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; } - else { - LogFile->write(EQEMuLog::Error, "Error in GetFreeGrid query '%s': %s", query, errbuf); - safe_delete_array(query); - } - return 0; + + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + uint32 freeGridID = 1; + freeGridID = atoi(row[0]) + 1; + + return freeGridID; } int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { From fe718a81f3ed6bbff96ed8082a0918bd789d0ee0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:14:36 -0700 Subject: [PATCH 122/217] GetHighestWaypoint converted to QueryDatabase --- zone/waypoints.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index a67943b5c..2119ea384 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1334,26 +1334,20 @@ uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { } int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { - char *query = 0; - char errbuff[MYSQL_ERRMSG_SIZE]; - MYSQL_RES *result; - MYSQL_ROW row; - int res = 0; - if (RunQuery(query, MakeAnyLenString(&query, - "SELECT COALESCE(MAX(number), 0) FROM grid_entries WHERE zoneid = %i AND gridid = %i", - zoneid, gridid),errbuff,&result)) { - safe_delete_array(query); - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - res = atoi( row[0] ); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in GetHighestWaypoint query '%s': %s", query, errbuff); - safe_delete_array(query); + + std::string query = StringFormat("SELECT COALESCE(MAX(number), 0) FROM grid_entries " + "WHERE zoneid = %i AND gridid = %i", zoneid, gridid); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in GetHighestWaypoint query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return 0; } - return(res); + if (results.RowCount() != 1) + return 0; + + auto row = results.begin(); + return atoi(row[0]); } void NPC::SaveGuardSpotCharm() From 5946af88a60b0571f7bf1b6b3d8a010c45d03b16 Mon Sep 17 00:00:00 2001 From: Uleat Date: Wed, 20 Aug 2014 18:30:19 -0400 Subject: [PATCH 123/217] Reworked Trade::AddEntity() to allow client-directed movement of stacked items (as close to 'stacking' as I can get it - see changelog.txt) --- changelog.txt | 9 ++++-- zone/common.h | 2 +- zone/inventory.cpp | 2 +- zone/trading.cpp | 68 +++++++++++++++++++++++++++------------------- 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/changelog.txt b/changelog.txt index 26fb72c5a..bf2ea97f0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,13 +1,18 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/20/2014 == +Uleat: Rework of Trade::AddEntity() - function used to move items into the trade window. Now accepts argument for 'stack_size' and updates client properly. +Note: I tested trade with Titanium:{SoF,SoD,UF,RoF} in both directions and no client generated an OP_MoveItem event for attempting to place a stackable +onto a partial stack already in the trade window. The only way to achieve stacking is to click on the receiving client. If there is a partial stack remaining +on the cursor after the OP_MoveItem event, and there is room available, the client will generate subsequent events to move the remaining count. + == 08/19/2014 == Akkadius: Implemented a Stop_Return feature (Accidental item handin prevention) that will be symmetrically used with plugin::return_items that I am currently running live testing on EZ before releasing to EQEmu. This does not hurt to have this in the source. Akkadius: Fixed crash where 'attacker' validation is not being checked Akkadius: Removed petition console spam that does not follow traditional logging and is useless -Akkadius: Made fix with SympatheticProcChances where it was checking for TempItem->Focus.Effect instead of TempItemAug->Focus.Effect== 08/18/2014 == +Akkadius: Made fix with SympatheticProcChances where it was checking for TempItem->Focus.Effect instead of TempItemAug->Focus.Effect == 08/18/2014 == - Uleat: Fix for https://github.com/EQEmu/Server/issues/127 -- also activated a remarked action in doors.cpp to eliminate a memory leak. == 08/16/2014 == diff --git a/zone/common.h b/zone/common.h index 19cd51ce1..10ce05420 100644 --- a/zone/common.h +++ b/zone/common.h @@ -526,7 +526,7 @@ public: Mob* With(); // Add item from cursor slot to trade bucket (automatically does bag data too) - void AddEntity(uint16 from_slot_id, uint16 trade_slot_id); + void AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_size); // Audit trade void LogTrade(); diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 76f0d9f87..7a36aa5e9 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -1540,7 +1540,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // Also sends trade information to other client of trade session if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit - trade->AddEntity(src_slot_id, dst_slot_id); + trade->AddEntity(src_slot_id, dst_slot_id, move_in->number_in_stack); return true; } else { diff --git a/zone/trading.cpp b/zone/trading.cpp index 1ace776a7..7dbc93bad 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -71,8 +71,9 @@ void Trade::Start(uint32 mob_id, bool initiate_with) } // Add item from a given slot to trade bucket (automatically does bag data too) -void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id) -{ +void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_size) { + // TODO: review for inventory saves + if (!owner || !owner->IsClient()) { // This should never happen LogFile->write(EQEMuLog::Debug, "Programming error: NPC's should not call Trade::AddEntity()"); @@ -87,45 +88,56 @@ void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id) // Item always goes into trade bucket from cursor Client* client = owner->CastToClient(); - const ItemInst* inst = client->GetInv().GetItem(MainCursor); + ItemInst* inst = client->GetInv().GetItem(MainCursor); + if (!inst) { client->Message(13, "Error: Could not find item on your cursor!"); return; } - _log(TRADING__HOLDER, "%s added item '%s' to trade slot %i", owner->GetName(), inst->GetItem()->Name, trade_slot_id); - ItemInst* inst2 = client->GetInv().GetItem(trade_slot_id); - int new_charges = 0; - if (!inst2 || !inst2->GetItem()) { - // Send all item data to other client - SendItemData(inst, trade_slot_id); - // Move item on cursor to the trade slots - client->PutItemInInventory(trade_slot_id, *inst); - } - else - { - if (client->GetInv().GetItem(MainCursor)->GetID() != client->GetInv().GetItem(trade_slot_id)->GetID()) { + + // it looks like the original code attempted to allow stacking... + // (it just didn't handle partial stack move actions -U) + if (stack_size > 0) { + if (!inst->IsStackable() || !inst2 || !inst2->GetItem() || (inst->GetID() != inst2->GetID()) || (stack_size > inst->GetCharges())) { client->Kick(); return; } - new_charges = (inst2->GetCharges()+inst->GetCharges()); - if (new_charges < inst2->GetItem()->StackSize) - { - inst2->SetCharges(new_charges); - new_charges = 0; - } - else - { - new_charges = inst->GetCharges()-(inst2->GetItem()->StackSize-inst2->GetCharges()); //Leftover charges = charges - difference + + uint32 _stack_size = 0; + + if ((stack_size + inst2->GetCharges()) > inst2->GetItem()->StackSize) { + _stack_size = (stack_size + inst2->GetCharges()) - inst->GetItem()->StackSize; inst2->SetCharges(inst2->GetItem()->StackSize); } + else { + _stack_size = inst->GetCharges() - stack_size; + inst2->SetCharges(stack_size + inst2->GetCharges()); + } + + _log(TRADING__HOLDER, "%s added partial item '%s' stack (qty: %i) to trade slot %i", owner->GetName(), inst->GetItem()->Name, stack_size, trade_slot_id); + + if (_stack_size > 0) + inst->SetCharges(_stack_size); + else + client->DeleteItemInInventory(from_slot_id); + SendItemData(inst2, trade_slot_id); } - if (new_charges > 0) - client->GetInv().GetItem(from_slot_id)->SetCharges(new_charges); - else - client->DeleteItemInInventory(from_slot_id);//, (ItemInst&)trade_inst); + else { + if (inst2 && inst2->GetID()) { + client->Kick(); + return; + } + + SendItemData(inst, trade_slot_id); + + _log(TRADING__HOLDER, "%s added item '%s' to trade slot %i", owner->GetName(), inst->GetItem()->Name, trade_slot_id); + + client->PutItemInInventory(trade_slot_id, *inst); + client->DeleteItemInInventory(from_slot_id); + } } // Retrieve mob the owner is trading with From f0abaad84f69617230c20e955703be59406defbd Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:32:14 -0700 Subject: [PATCH 124/217] LoadZoneObjects converted to QueryDatabase --- zone/zone.cpp | 225 ++++++++++++++++++++++++-------------------------- 1 file changed, 106 insertions(+), 119 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 4124ba7d3..456383ce3 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -156,140 +156,127 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { //this really loads the objects into entity_list bool Zone::LoadZoneObjects() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = nullptr; - MYSQL_RES *result; - MYSQL_ROW row; - uint32 len_query = MakeAnyLenString(&query, "SELECT " - "id,zoneid,xpos,ypos,zpos,heading,itemid,charges,objectname,type,icon," - "unknown08,unknown10,unknown20,unknown24,unknown76" - " from object where zoneid=%i and (version=%u or version=-1)", zoneid, instanceversion); + std::string query = StringFormat("SELECT id, zoneid, xpos, ypos, zpos, heading, " + "itemid, charges, objectname, type, icon, unknown08, " + "unknown10, unknown20, unknown24, unknown76 fROM object " + "WHERE zoneid = %i AND (version = %u OR version = -1)", + zoneid, instanceversion); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error Loading Objects from DB: %s",results.ErrorMessage().c_str()); + return false; + } - if (database.RunQuery(query, len_query, errbuf, &result)) { - safe_delete_array(query); - LogFile->write(EQEMuLog::Status, "Loading Objects from DB..."); - while ((row = mysql_fetch_row(result))) { - if (atoi(row[9]) == 0) - { - // Type == 0 - Static Object - const char* shortname = database.GetZoneName(atoi(row[1]), false); // zoneid -> zone_shortname + LogFile->write(EQEMuLog::Status, "Loading Objects from DB..."); + for (auto row = results.begin(); row != results.end(); ++row) { + if (atoi(row[9]) == 0) + { + // Type == 0 - Static Object + const char* shortname = database.GetZoneName(atoi(row[1]), false); // zoneid -> zone_shortname - if (shortname) - { - Door d; - memset(&d, 0, sizeof(d)); + if (!shortname) + continue; - strn0cpy(d.zone_name, shortname, sizeof(d.zone_name)); - d.db_id = 1000000000 + atoi(row[0]); // Out of range of normal use for doors.id - d.door_id = -1; // Client doesn't care if these are all the same door_id - d.pos_x = atof(row[2]); // xpos - d.pos_y = atof(row[3]); // ypos - d.pos_z = atof(row[4]); // zpos - d.heading = atof(row[5]); // heading + Door d; + memset(&d, 0, sizeof(d)); - strn0cpy(d.door_name, row[8], sizeof(d.door_name)); // objectname - // Strip trailing "_ACTORDEF" if present. Client won't accept it for doors. - int len = strlen(d.door_name); - if ((len > 9) && (memcmp(&d.door_name[len - 9], "_ACTORDEF", 10) == 0)) - { - d.door_name[len - 9] = '\0'; - } + strn0cpy(d.zone_name, shortname, sizeof(d.zone_name)); + d.db_id = 1000000000 + atoi(row[0]); // Out of range of normal use for doors.id + d.door_id = -1; // Client doesn't care if these are all the same door_id + d.pos_x = atof(row[2]); // xpos + d.pos_y = atof(row[3]); // ypos + d.pos_z = atof(row[4]); // zpos + d.heading = atof(row[5]); // heading - memcpy(d.dest_zone, "NONE", 5); + strn0cpy(d.door_name, row[8], sizeof(d.door_name)); // objectname + // Strip trailing "_ACTORDEF" if present. Client won't accept it for doors. + int len = strlen(d.door_name); + if ((len > 9) && (memcmp(&d.door_name[len - 9], "_ACTORDEF", 10) == 0)) + d.door_name[len - 9] = '\0'; - if ((d.size = atoi(row[11])) == 0) // unknown08 = optional size percentage - { - d.size = 100; - } + memcpy(d.dest_zone, "NONE", 5); - switch (d.opentype = atoi(row[12])) // unknown10 = optional request_nonsolid (0 or 1 or experimental number) - { - case 0: - d.opentype = 31; - break; - case 1: - d.opentype = 9; - break; - } + if ((d.size = atoi(row[11])) == 0) // unknown08 = optional size percentage + d.size = 100; - d.incline = atoi(row[13]); // unknown20 = optional model incline value - d.client_version_mask = 0xFFFFFFFF; //We should load the mask from the zone. + switch (d.opentype = atoi(row[12])) // unknown10 = optional request_nonsolid (0 or 1 or experimental number) + { + case 0: + d.opentype = 31; + break; + case 1: + d.opentype = 9; + break; + } - Doors* door = new Doors(&d); - entity_list.AddDoor(door); - } + d.incline = atoi(row[13]); // unknown20 = optional model incline value + d.client_version_mask = 0xFFFFFFFF; //We should load the mask from the zone. - continue; - } - Object_Struct data = {0}; - uint32 id = 0; - uint32 icon = 0; - uint32 type = 0; - uint32 itemid = 0; - uint32 idx = 0; - int16 charges = 0; + Doors* door = new Doors(&d); + entity_list.AddDoor(door); + } - id = (uint32)atoi(row[0]); - data.zone_id = atoi(row[1]); - data.x = atof(row[2]); - data.y = atof(row[3]); - data.z = atof(row[4]); - data.heading = atof(row[5]); - itemid = (uint32)atoi(row[6]); - charges = (int16)atoi(row[7]); - strcpy(data.object_name, row[8]); - type = (uint8)atoi(row[9]); - icon = (uint32)atoi(row[10]); - data.object_type = type; - data.linked_list_addr[0] = 0; - data.linked_list_addr[1] = 0; - data.unknown008 = (uint32)atoi(row[11]); - data.unknown010 = (uint32)atoi(row[12]); - data.unknown020 = (uint32)atoi(row[13]); - data.unknown024 = (uint32)atoi(row[14]); - data.unknown076 = (uint32)atoi(row[15]); - data.unknown084 = 0; + Object_Struct data = {0}; + uint32 id = 0; + uint32 icon = 0; + uint32 type = 0; + uint32 itemid = 0; + uint32 idx = 0; + int16 charges = 0; - ItemInst* inst = nullptr; - //FatherNitwit: this dosent seem to work... - //tradeskill containers do not have an itemid of 0... at least what I am seeing - if (itemid == 0) { - // Generic tradeskill container - inst = new ItemInst(ItemInstWorldContainer); - } - else { - // Groundspawn object - inst = database.CreateItem(itemid); - } + id = (uint32)atoi(row[0]); + data.zone_id = atoi(row[1]); + data.x = atof(row[2]); + data.y = atof(row[3]); + data.z = atof(row[4]); + data.heading = atof(row[5]); + itemid = (uint32)atoi(row[6]); + charges = (int16)atoi(row[7]); + strcpy(data.object_name, row[8]); + type = (uint8)atoi(row[9]); + icon = (uint32)atoi(row[10]); + data.object_type = type; + data.linked_list_addr[0] = 0; + data.linked_list_addr[1] = 0; + data.unknown008 = (uint32)atoi(row[11]); + data.unknown010 = (uint32)atoi(row[12]); + data.unknown020 = (uint32)atoi(row[13]); + data.unknown024 = (uint32)atoi(row[14]); + data.unknown076 = (uint32)atoi(row[15]); + data.unknown084 = 0; - //Father Nitwit's fix... not perfect... - if(inst == nullptr && type != OT_DROPPEDITEM) { - inst = new ItemInst(ItemInstWorldContainer); - } + ItemInst* inst = nullptr; + //FatherNitwit: this dosent seem to work... + //tradeskill containers do not have an itemid of 0... at least what I am seeing + if (itemid == 0) { + // Generic tradeskill container + inst = new ItemInst(ItemInstWorldContainer); + } + else { + // Groundspawn object + inst = database.CreateItem(itemid); + } - // Load child objects if container - if (inst && inst->IsType(ItemClassContainer)) { - database.LoadWorldContainer(id, inst); - } + //Father Nitwit's fix... not perfect... + if(inst == nullptr && type != OT_DROPPEDITEM) { + inst = new ItemInst(ItemInstWorldContainer); + } - Object* object = new Object(id, type, icon, data, inst); - entity_list.AddObject(object, false); - if(type == OT_DROPPEDITEM && itemid != 0) - { - entity_list.RemoveObject(object->GetID()); - } + // Load child objects if container + if (inst && inst->IsType(ItemClassContainer)) { + database.LoadWorldContainer(id, inst); + } - safe_delete(inst); - } - mysql_free_result(result); - } - else { - safe_delete_array(query); - LogFile->write(EQEMuLog::Error, "Error Loading Objects from DB: %s",errbuf); - return(false); - } - return(true); + Object* object = new Object(id, type, icon, data, inst); + entity_list.AddObject(object, false); + if(type == OT_DROPPEDITEM && itemid != 0) + entity_list.RemoveObject(object->GetID()); + + safe_delete(inst); + } + + return true; } //this also just loads into entity_list, not really into zone @@ -789,7 +776,7 @@ void Zone::Shutdown(bool quite) if (!quite) LogFile->write(EQEMuLog::Normal, "Zone shutdown: going to sleep"); ZoneLoaded = false; - + zone->ResetAuth(); safe_delete(zone); dbasync->CommitWrites(); @@ -1381,7 +1368,7 @@ bool Zone::Process() { return true; } -void Zone::ChangeWeather() +void Zone::ChangeWeather() { if(!HasWeather()) { From 01382e87a032ae63e34de5986790c2cb665e241a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:36:46 -0700 Subject: [PATCH 125/217] LoadNewMerchantData converted to QueryDatabase --- zone/zone.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 456383ce3..a929873b3 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -451,29 +451,29 @@ void Zone::LoadTempMerchantData_result(MYSQL_RES* result) { //there should prolly be a temp counterpart of this... void Zone::LoadNewMerchantData(uint32 merchantid){ - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::list merlist; - if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT item, slot, faction_required, level_required, alt_currency_cost, classes_required FROM merchantlist WHERE merchantid=%d", merchantid), errbuf, &result)) { - while((row = mysql_fetch_row(result))) { - MerchantList ml; - ml.id = merchantid; - ml.item = atoul(row[0]); - ml.slot = atoul(row[1]); - ml.faction_required = atoul(row[2]); - ml.level_required = atoul(row[3]); - ml.alt_currency_cost = atoul(row[3]); - ml.classes_required = atoul(row[4]); - merlist.push_back(ml); - } - merchanttable[merchantid] = merlist; - mysql_free_result(result); - } - else - LogFile->write(EQEMuLog::Error, "Error in LoadNewMerchantData query '%s' %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT item, slot, faction_required, level_required, alt_currency_cost, " + "classes_required FROM merchantlist WHERE merchantid=%d", merchantid); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadNewMerchantData query '%s' %s", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + for(auto row = results.begin(); row != results.end(); ++row) { + MerchantList ml; + ml.id = merchantid; + ml.item = atoul(row[0]); + ml.slot = atoul(row[1]); + ml.faction_required = atoul(row[2]); + ml.level_required = atoul(row[3]); + ml.alt_currency_cost = atoul(row[3]); + ml.classes_required = atoul(row[4]); + merlist.push_back(ml); + } + + merchanttable[merchantid] = merlist; } void Zone::LoadMerchantData_result(MYSQL_RES* result) { From 7a3c05a41f87a5cf16433486260b9a2a817d6420 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:53:02 -0700 Subject: [PATCH 126/217] LoadMercTemplates converted to QueryDatabase --- zone/zone.cpp | 106 ++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 56 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index a929873b3..99443f57b 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -541,75 +541,69 @@ void Zone::GetMerchantDataForZoneLoad(){ void Zone::LoadMercTemplates(){ - std::string errorMessage; - char* Query = 0; - char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; - MYSQL_RES* DatasetResult; - MYSQL_ROW DataRow; std::list merc_stances; merc_templates.clear(); - - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` FROM `merc_stance_entries` order by `class_id`, `proficiency_id`, `stance_id`"), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } + std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` FROM " + "`merc_stance_entries` ORDER BY `class_id`, `proficiency_id`, `stance_id`"; + auto results = database.QueryDatabase(query); + if (!results.Success()) + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadMercTemplates()"); else { - while(DataRow = mysql_fetch_row(DatasetResult)) { + for (auto row = results.begin(); row != results.end(); ++row) { MercStanceInfo tempMercStanceInfo; - tempMercStanceInfo.ClassID = atoi(DataRow[0]); - tempMercStanceInfo.ProficiencyID = atoi(DataRow[1]); - tempMercStanceInfo.StanceID = atoi(DataRow[2]); - tempMercStanceInfo.IsDefault = atoi(DataRow[3]); + tempMercStanceInfo.ClassID = atoi(row[0]); + tempMercStanceInfo.ProficiencyID = atoi(row[1]); + tempMercStanceInfo.StanceID = atoi(row[2]); + tempMercStanceInfo.IsDefault = atoi(row[3]); merc_stances.push_back(tempMercStanceInfo); } - - mysql_free_result(DatasetResult); } - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring AS merc_type_id, MTem.dbstring AS merc_subtype_id, MTyp.race_id, MS.class_id, MTyp.proficiency_id, MS.tier_id, 0 AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;"), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } - else { - while(DataRow = mysql_fetch_row(DatasetResult)) { - int stanceIndex = 0; - MercTemplate tempMercTemplate; - - tempMercTemplate.MercTemplateID = atoi(DataRow[0]); - tempMercTemplate.MercType = atoi(DataRow[1]); - tempMercTemplate.MercSubType = atoi(DataRow[2]); - tempMercTemplate.RaceID = atoi(DataRow[3]); - tempMercTemplate.ClassID = atoi(DataRow[4]); - tempMercTemplate.ProficiencyID = atoi(DataRow[5]); - tempMercTemplate.TierID = atoi(DataRow[6]); - tempMercTemplate.CostFormula = atoi(DataRow[7]); - tempMercTemplate.ClientVersion = atoi(DataRow[8]); - tempMercTemplate.MercNPCID = atoi(DataRow[9]); - - for(int i = 0; i < MaxMercStanceID; i++) { - tempMercTemplate.Stances[i] = 0; - } - - for (std::list::iterator mercStanceListItr = merc_stances.begin(); mercStanceListItr != merc_stances.end(); ++mercStanceListItr) { - if(mercStanceListItr->ClassID == tempMercTemplate.ClassID && mercStanceListItr->ProficiencyID == tempMercTemplate.ProficiencyID) { - zone->merc_stance_list[tempMercTemplate.MercTemplateID].push_back((*mercStanceListItr)); - tempMercTemplate.Stances[stanceIndex] = mercStanceListItr->StanceID; - stanceIndex++; - } - } - - merc_templates[tempMercTemplate.MercTemplateID] = tempMercTemplate; - } - - mysql_free_result(DatasetResult); + query = "SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring " + "AS merc_type_id, MTem.dbstring " + "AS merc_subtype_id, MTyp.race_id, MS.class_id, MTyp.proficiency_id, MS.tier_id, 0 " + "AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id " + "FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS " + "WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id " + "ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;"; + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadMercTemplates()"); + return; } - safe_delete_array(Query); - Query = 0; + for (auto row = results.begin(); row != results.end(); ++row) { + + MercTemplate tempMercTemplate; + + tempMercTemplate.MercTemplateID = atoi(row[0]); + tempMercTemplate.MercType = atoi(row[1]); + tempMercTemplate.MercSubType = atoi(row[2]); + tempMercTemplate.RaceID = atoi(row[3]); + tempMercTemplate.ClassID = atoi(row[4]); + tempMercTemplate.ProficiencyID = atoi(row[5]); + tempMercTemplate.TierID = atoi(row[6]); + tempMercTemplate.CostFormula = atoi(row[7]); + tempMercTemplate.ClientVersion = atoi(row[8]); + tempMercTemplate.MercNPCID = atoi(row[9]); + + for(int i = 0; i < MaxMercStanceID; i++) + tempMercTemplate.Stances[i] = 0; + + int stanceIndex = 0; + for (std::list::iterator mercStanceListItr = merc_stances.begin(); mercStanceListItr != merc_stances.end(); ++mercStanceListItr, ++stanceIndex) { + if(mercStanceListItr->ClassID != tempMercTemplate.ClassID || mercStanceListItr->ProficiencyID != tempMercTemplate.ProficiencyID) + continue; + + zone->merc_stance_list[tempMercTemplate.MercTemplateID].push_back((*mercStanceListItr)); + tempMercTemplate.Stances[stanceIndex] = mercStanceListItr->StanceID; + } + + merc_templates[tempMercTemplate.MercTemplateID] = tempMercTemplate; + } - if(!errorMessage.empty()) { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadMercTemplates()"); - } } From 5da5e9b5decbd5d2bb0b94d5c648fdebe00a14f2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 15:57:04 -0700 Subject: [PATCH 127/217] LoadLevelEXPMods converted to QueryDatabase --- zone/zone.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 99443f57b..da044beee 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -606,36 +606,26 @@ void Zone::LoadMercTemplates(){ } - void Zone::LoadLevelEXPMods(){ - std::string errorMessage; - char* Query = 0; - char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; - MYSQL_RES* DatasetResult; - MYSQL_ROW DataRow; + level_exp_mod.clear(); + const std::string query = "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadEXPLevelMods()"); + return; + } - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods"), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } - else { - while(DataRow = mysql_fetch_row(DatasetResult)) { - uint32 index = atoi(DataRow[0]); - float exp_mod = atof(DataRow[1]); - float aa_exp_mod = atof(DataRow[2]); - level_exp_mod[index].ExpMod = exp_mod; - level_exp_mod[index].AAExpMod = aa_exp_mod; - } - mysql_free_result(DatasetResult); - } + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 index = atoi(row[0]); + float exp_mod = atof(row[1]); + float aa_exp_mod = atof(row[2]); + level_exp_mod[index].ExpMod = exp_mod; + level_exp_mod[index].AAExpMod = aa_exp_mod; + } - safe_delete_array(Query); - Query = 0; - - if(!errorMessage.empty()) { - LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadEXPLevelMods()"); - } } + void Zone::LoadMercSpells(){ std::string errorMessage; From 826f7d0efd0ff4d0ffe0e3c01be56d493b3a0bd8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:00:36 -0700 Subject: [PATCH 128/217] LoadMercSpells converted to QueryDatabase --- zone/zone.cpp | 60 ++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index da044beee..f50b2a095 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -628,46 +628,38 @@ void Zone::LoadLevelEXPMods(){ void Zone::LoadMercSpells(){ - std::string errorMessage; - char* Query = 0; - char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; - MYSQL_RES* DatasetResult; - MYSQL_ROW DataRow; merc_spells_list.clear(); + const std::string query = "SELECT msl.class_id, msl.proficiency_id, msle.spell_id, msle.spell_type, " + "msle.stance_id, msle.minlevel, msle.maxlevel, msle.slot, msle.procChance " + "FROM merc_spell_lists msl, merc_spell_list_entries msle " + "WHERE msle.merc_spell_list_id = msl.merc_spell_list_id " + "ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadMercSpells()"); + return; + } - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT msl.class_id, msl.proficiency_id, msle.spell_id, msle.spell_type, msle.stance_id, msle.minlevel, msle.maxlevel, msle.slot, msle.procChance FROM merc_spell_lists msl, merc_spell_list_entries msle WHERE msle.merc_spell_list_id = msl.merc_spell_list_id ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;"), TempErrorMessageBuffer, &DatasetResult)) { - errorMessage = std::string(TempErrorMessageBuffer); - } - else { - while(DataRow = mysql_fetch_row(DatasetResult)) { - uint32 classid; - MercSpellEntry tempMercSpellEntry; + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 classid; + MercSpellEntry tempMercSpellEntry; - classid = atoi(DataRow[0]); - tempMercSpellEntry.proficiencyid = atoi(DataRow[1]); - tempMercSpellEntry.spellid = atoi(DataRow[2]); - tempMercSpellEntry.type = atoi(DataRow[3]); - tempMercSpellEntry.stance = atoi(DataRow[4]); - tempMercSpellEntry.minlevel = atoi(DataRow[5]); - tempMercSpellEntry.maxlevel = atoi(DataRow[6]); - tempMercSpellEntry.slot = atoi(DataRow[7]); - tempMercSpellEntry.proc_chance = atoi(DataRow[8]); + classid = atoi(row[0]); + tempMercSpellEntry.proficiencyid = atoi(row[1]); + tempMercSpellEntry.spellid = atoi(row[2]); + tempMercSpellEntry.type = atoi(row[3]); + tempMercSpellEntry.stance = atoi(row[4]); + tempMercSpellEntry.minlevel = atoi(row[5]); + tempMercSpellEntry.maxlevel = atoi(row[6]); + tempMercSpellEntry.slot = atoi(row[7]); + tempMercSpellEntry.proc_chance = atoi(row[8]); - merc_spells_list[classid].push_back(tempMercSpellEntry); - } + merc_spells_list[classid].push_back(tempMercSpellEntry); + } - mysql_free_result(DatasetResult); + if(MERC_DEBUG > 0) + LogFile->write(EQEMuLog::Debug, "Mercenary Debug: Loaded %i merc spells.", merc_spells_list[1].size() + merc_spells_list[2].size() + merc_spells_list[9].size() + merc_spells_list[12].size()); - if(MERC_DEBUG > 0) - LogFile->write(EQEMuLog::Debug, "Mercenary Debug: Loaded %i merc spells.", merc_spells_list[1].size() + merc_spells_list[2].size() + merc_spells_list[9].size() + merc_spells_list[12].size()); - } - - safe_delete_array(Query); - Query = 0; - - if(!errorMessage.empty()) { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadMercSpells()"); - } } void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) { From 971c3f633fe7bb0ee1b8d66b5655095bbe3b16ff Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:05:09 -0700 Subject: [PATCH 129/217] GetDecayTimes converted to QueryDatabase --- zone/zone.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index f50b2a095..32f1b44c8 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1845,32 +1845,26 @@ bool Zone::RemoveSpawnGroup(uint32 in_id) { // Added By Hogie bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - int i = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT varname, value FROM variables WHERE varname like 'decaytime%%' ORDER BY varname"), errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - Seperator sep(row[0]); - npcCorpseDecayTimes[i].minlvl = atoi(sep.arg[1]); - npcCorpseDecayTimes[i].maxlvl = atoi(sep.arg[2]); - if (atoi(row[1]) > 7200) - npcCorpseDecayTimes[i].seconds = 720; - else - npcCorpseDecayTimes[i].seconds = atoi(row[1]); - i++; - } - mysql_free_result(result); - } - else { - safe_delete_array(query); - return false; - } + const std::string query = "SELECT varname, value FROM variables WHERE varname LIKE 'decaytime%%' ORDER BY varname"; + auto results = QueryDatabase(query); + if (!results.Success()) + return false; + + int index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) { + Seperator sep(row[0]); + npcCorpseDecayTimes[index].minlvl = atoi(sep.arg[1]); + npcCorpseDecayTimes[index].maxlvl = atoi(sep.arg[2]); + + if (atoi(row[1]) > 7200) + npcCorpseDecayTimes[index].seconds = 720; + else + npcCorpseDecayTimes[index].seconds = atoi(row[1]); + } + return true; -}// Added By Hogie -- End +} void Zone::weatherSend() { From 12a59853b5bfbf1a2578e4ef74cfee37ddd168e3 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:08:20 -0700 Subject: [PATCH 130/217] LoadLDoNTraps converted to QueryDatabase --- zone/zone.cpp | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 32f1b44c8..6c079105f 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2035,34 +2035,23 @@ void Zone::SetInstanceTimer(uint32 new_duration) void Zone::LoadLDoNTraps() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, type, spell_id, " - "skill, locked FROM ldon_trap_templates"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - uint8 x = 0; - LDoNTrapTemplate *lt = new LDoNTrapTemplate; - lt->id = atoi(row[x++]); - lt->type = (LDoNChestTypes)atoi(row[x++]); - lt->spell_id = atoi(row[x++]); - lt->skill = atoi(row[x++]); - lt->locked = atoi(row[x++]); - ldon_trap_list[lt->id] = lt; - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTraps: %s (%s)", query, errbuf); - safe_delete_array(query); + const std::string query = "SELECT id, type, spell_id, skill, locked FROM ldon_trap_templates"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTraps: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return; - } + } + + for (auto row = results.begin();row != results.end(); ++row) { + LDoNTrapTemplate *lt = new LDoNTrapTemplate; + lt->id = atoi(row[0]); + lt->type = (LDoNChestTypes)atoi(row[1]); + lt->spell_id = atoi(row[2]); + lt->skill = atoi(row[3]); + lt->locked = atoi(row[4]); + ldon_trap_list[lt->id] = lt; + } + } void Zone::LoadLDoNTrapEntries() From 5e858678e925e9ca8450df54da61b3a791cc682c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:15:55 -0700 Subject: [PATCH 131/217] LoadLDoNTrapEntries converted QueryDatabase --- zone/zone.cpp | 76 ++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 47 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 6c079105f..322b0dc75 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2056,54 +2056,36 @@ void Zone::LoadLDoNTraps() void Zone::LoadLDoNTrapEntries() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, trap_id FROM ldon_trap_entries"),errbuf,&result)) { - while((row = mysql_fetch_row(result))) - { - uint32 id = atoi(row[0]); - uint32 trap_id = atoi(row[1]); - - LDoNTrapTemplate *tt = nullptr; - std::map::iterator it; - it = ldon_trap_list.find(trap_id); - if(it == ldon_trap_list.end()) - { - continue; - } - else - { - tt = ldon_trap_list[trap_id]; - } - - std::list temp; - std::map >::iterator iter; - - iter = ldon_trap_entry_list.find(id); - if(iter == ldon_trap_entry_list.end()) - { - temp.push_back(tt); - ldon_trap_entry_list[id] = temp; - } - else - { - temp = ldon_trap_entry_list[id]; - temp.push_back(tt); - ldon_trap_entry_list[id] = temp; - } - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTrapEntries: %s (%s)", query, errbuf); - safe_delete_array(query); + const std::string query = "SELECT id, trap_id FROM ldon_trap_entries"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTrapEntries: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) + { + uint32 id = atoi(row[0]); + uint32 trap_id = atoi(row[1]); + + LDoNTrapTemplate *trapTemplate = nullptr; + auto it = ldon_trap_list.find(trap_id); + + if(it == ldon_trap_list.end()) + continue; + + trapTemplate = ldon_trap_list[trap_id]; + + std::list temp; + auto iter = ldon_trap_entry_list.find(id); + + if(iter != ldon_trap_entry_list.end()) + temp = ldon_trap_entry_list[id]; + + temp.push_back(trapTemplate); + ldon_trap_entry_list[id] = temp; + } + } void Zone::LoadVeteranRewards() From 2eb270376f86bb02965e9a8383294117e56bd792 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:20:46 -0700 Subject: [PATCH 132/217] LoadVeteranRewards converted to QueryDatabase --- zone/zone.cpp | 83 ++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 322b0dc75..b234149bd 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2091,56 +2091,51 @@ void Zone::LoadLDoNTrapEntries() void Zone::LoadVeteranRewards() { VeteranRewards.clear(); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - InternalVeteranReward current_reward; - uint8 idx = 0; + InternalVeteranReward current_reward; current_reward.claim_id = 0; + const std::string query = "SELECT claim_id, name, item_id, charges " + "FROM veteran_reward_templates " + "WHERE reward_slot < 8 and claim_id > 0 " + "ORDER by claim_id, reward_slot"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadVeteranRewards: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); + return; + } - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT claim_id, name, item_id, charges FROM" - " veteran_reward_templates WHERE reward_slot < 8 and claim_id > 0 ORDER by claim_id, reward_slot"), - errbuf,&result)) - { - while((row = mysql_fetch_row(result))) - { - uint32 claim = atoi(row[0]); - if(claim != current_reward.claim_id) - { - if(current_reward.claim_id != 0) - { - current_reward.claim_count = idx; - current_reward.number_available = 1; - VeteranRewards.push_back(current_reward); - } - idx = 0; - memset(¤t_reward, 0, sizeof(InternalVeteranReward)); - current_reward.claim_id = claim; - } + int index = 0; + for (auto row = results.begin(); row != results.end(); ++row, ++index) + { + uint32 claim = atoi(row[0]); - strcpy(current_reward.items[idx].item_name, row[1]); - current_reward.items[idx].item_id = atoi(row[2]); - current_reward.items[idx].charges = atoi(row[3]); - idx++; - } + if(claim != current_reward.claim_id) + { + if(current_reward.claim_id != 0) + { + current_reward.claim_count = index; + current_reward.number_available = 1; + VeteranRewards.push_back(current_reward); + } + + index = 0; + memset(¤t_reward, 0, sizeof(InternalVeteranReward)); + current_reward.claim_id = claim; + } + + strcpy(current_reward.items[index].item_name, row[1]); + current_reward.items[index].item_id = atoi(row[2]); + current_reward.items[index].charges = atoi(row[3]); + } + + if(current_reward.claim_id != 0) + { + current_reward.claim_count = index; + current_reward.number_available = 1; + VeteranRewards.push_back(current_reward); + } - if(current_reward.claim_id != 0) - { - current_reward.claim_count = idx; - current_reward.number_available = 1; - VeteranRewards.push_back(current_reward); - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadVeteranRewards: %s (%s)", query, errbuf); - safe_delete_array(query); - } } void Zone::LoadAlternateCurrencies() From 2bc58a97bc249a1aeb92351227db1a51adbf8ad1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:24:05 -0700 Subject: [PATCH 133/217] LoadAlternateCurrencies converted to QueryDatabase --- zone/zone.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index b234149bd..cd215bc2a 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2141,30 +2141,23 @@ void Zone::LoadVeteranRewards() void Zone::LoadAlternateCurrencies() { AlternateCurrencies.clear(); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + AltCurrencyDefinition_Struct current_currency; - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, item_id from alternate_currency"), - errbuf,&result)) - { - while((row = mysql_fetch_row(result))) - { - current_currency.id = atoi(row[0]); - current_currency.item_id = atoi(row[1]); - AlternateCurrencies.push_back(current_currency); - } + const std::string query = "SELECT id, item_id FROM alternate_currency"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAlternateCurrencies: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + for (auto row = results.begin(); row != results.end(); ++row) + { + current_currency.id = atoi(row[0]); + current_currency.item_id = atoi(row[1]); + AlternateCurrencies.push_back(current_currency); + } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAlternateCurrencies: %s (%s)", query, errbuf); - safe_delete_array(query); - } } void Zone::UpdateQGlobal(uint32 qid, QGlobal newGlobal) From cee4a3f4753ec1a83592feb47079192722fb362d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:27:12 -0700 Subject: [PATCH 134/217] LoadAdventureFlavor converted to QueryDatabase --- zone/zone.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index cd215bc2a..1f214ddb1 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2192,28 +2192,18 @@ void Zone::DeleteQGlobal(std::string name, uint32 npcID, uint32 charID, uint32 z void Zone::LoadAdventureFlavor() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, text FROM adventure_template_entry_flavor"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - uint32 id = atoi(row[0]); - std::string in_str = row[1]; - adventure_entry_list_flavor[id] = in_str; - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAdventureFlavor: %s (%s)", query, errbuf); - safe_delete_array(query); + const std::string query = "SELECT id, text FROM adventure_template_entry_flavor"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAdventureFlavor: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); return; } + + for (auto row = results.begin(); row != results.end(); ++row) { + uint32 id = atoi(row[0]); + adventure_entry_list_flavor[id] = row[1]; + } + } void Zone::DoAdventureCountIncrease() From 029314ec7f5c276e5b8413ee0df19c84197ba57c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:31:05 -0700 Subject: [PATCH 135/217] LoadNPCEmotes converted to QueryDatabase --- zone/zone.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 1f214ddb1..77ee95e02 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2265,31 +2265,25 @@ void Zone::DoAdventureActions() void Zone::LoadNPCEmotes(LinkedList* NPCEmoteList) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - NPCEmoteList->Clear(); - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT emoteid, event_, type, text FROM npc_emotes"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - NPC_Emote_Struct* nes = new NPC_Emote_Struct; - nes->emoteid = atoi(row[0]); - nes->event_ = atoi(row[1]); - nes->type = atoi(row[2]); - strn0cpy(nes->text, row[3], sizeof(nes->text)); - NPCEmoteList->Insert(nes); - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadNPCEmotes: %s (%s)", query, errbuf); - safe_delete_array(query); - } + NPCEmoteList->Clear(); + const std::string query = "SELECT emoteid, event_, type, text FROM npc_emotes"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadNPCEmotes: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + for (auto row = results.begin(); row != results.end(); ++row) + { + NPC_Emote_Struct* nes = new NPC_Emote_Struct; + nes->emoteid = atoi(row[0]); + nes->event_ = atoi(row[1]); + nes->type = atoi(row[2]); + strn0cpy(nes->text, row[3], sizeof(nes->text)); + NPCEmoteList->Insert(nes); + } + } void Zone::ReloadWorld(uint32 Option){ From 19e04a18758190ffa2726f970f957068dc9bf4be Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:34:35 -0700 Subject: [PATCH 136/217] LoadTickItems converted to QueryDatabase --- zone/zone.cpp | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 77ee95e02..21f366bc8 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2296,35 +2296,30 @@ void Zone::ReloadWorld(uint32 Option){ void Zone::LoadTickItems() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; tick_items.clear(); - if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick"), errbuf, &result)) - { - while((row = mysql_fetch_row(result))) - { - if(atoi(row[0]) >= 1) - { - item_tick_struct ti_tmp; - ti_tmp.itemid = atoi(row[0]); - ti_tmp.chance = atoi(row[1]); - ti_tmp.level = atoi(row[2]); - ti_tmp.bagslot = (int16)atoi(row[4]); - ti_tmp.qglobal = std::string(row[3]); - tick_items[atoi(row[0])] = ti_tmp; - } - } - mysql_free_result(result); - safe_delete_array(query); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in Zone::LoadTickItems: %s (%s)", query, errbuf); - safe_delete_array(query); - } + const std::string query = "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick"; + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in Zone::LoadTickItems: %s (%s)", query.c_str(), results.ErrorMessage().c_str()); + return; + } + + + for (auto row = results.begin(); row != results.end(); ++row) { + if(atoi(row[0]) == 0) + continue; + + item_tick_struct ti_tmp; + ti_tmp.itemid = atoi(row[0]); + ti_tmp.chance = atoi(row[1]); + ti_tmp.level = atoi(row[2]); + ti_tmp.bagslot = (int16)atoi(row[4]); + ti_tmp.qglobal = std::string(row[3]); + tick_items[atoi(row[0])] = ti_tmp; + + } + } uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) { From 5a6373c429d0ed3772932606a5d5594aadfa3e25 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 20 Aug 2014 16:39:07 -0700 Subject: [PATCH 137/217] UpdateHotzone converted to QueryDatabase --- zone/zone.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index 21f366bc8..b04f06da4 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2339,24 +2339,15 @@ uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) { void Zone::UpdateHotzone() { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - bool updh; + std::string query = StringFormat("SELECT hotzone FROM zone WHERE short_name = '%s'", GetShortName()); + auto results = database.QueryDatabase(query); + if (!results.Success()) + return; - if(database.RunQuery(query, MakeAnyLenString(&query,"SELECT hotzone FROM zone WHERE short_name = '%s'", GetShortName()), errbuf, &result) ) - { - if( (row = mysql_fetch_row(result)) ) - { - updh = atoi(row[0]) == 0 ? false:true; - //Hotzone status has changed - if(is_hotzone != updh) - { - is_hotzone = updh; - } - } - mysql_free_result(result); - } - safe_delete_array(query); + if (results.RowCount() == 0) + return; + + auto row = results.begin(); + + is_hotzone = atoi(row[0]) == 0 ? false: true; } From 8b19c76e89edc65721d2546bd97837f50effa0c8 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Wed, 20 Aug 2014 23:41:47 -0400 Subject: [PATCH 138/217] Adds new column to 'merchantlist' table. Adds 'probability' after 'classes_required', valid values are 0 to 100. --- common/eq_packet_structs.h | 1 + .../2014_08_20_merchantlist_probability.sql | 1 + zone/client_process.cpp | 9 ++-- zone/entity.cpp | 1 + zone/lua_npc.cpp | 13 ++++- zone/lua_npc.h | 2 + zone/npc.h | 3 ++ zone/perl_npc.cpp | 50 +++++++++++++++++++ zone/zone.cpp | 6 ++- zone/zonedump.h | 1 + 10 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 utils/sql/git/required/2014_08_20_merchantlist_probability.sql diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index aab82e4f7..d2fbcbb76 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -3468,6 +3468,7 @@ struct MerchantList { int8 level_required; uint16 alt_currency_cost; uint32 classes_required; + uint8 probability; }; struct TempMerchantList { diff --git a/utils/sql/git/required/2014_08_20_merchantlist_probability.sql b/utils/sql/git/required/2014_08_20_merchantlist_probability.sql new file mode 100644 index 000000000..9ceedbb30 --- /dev/null +++ b/utils/sql/git/required/2014_08_20_merchantlist_probability.sql @@ -0,0 +1 @@ +ALTER TABLE `merchantlist` ADD `probability` INT(3) NOT NULL DEFAULT '100' AFTER `classes_required`; \ No newline at end of file diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 6045881e1..acdf67be8 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -983,17 +983,18 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { uint8 handychance = 0; for (itr = merlist.begin(); itr != merlist.end() && i < numItemSlots; ++itr) { MerchantList ml = *itr; - if(GetLevel() < ml.level_required) { + if (merch->CastToNPC()->GetMerchantProbability() > ml.probability) + continue; + + if(GetLevel() < ml.level_required) continue; - } if (!(ml.classes_required & (1 << (GetClass() - 1)))) continue; int32 fac = merch ? merch->GetPrimaryFaction() : 0; - if(fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) { + if(fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) continue; - } handychance = MakeRandomInt(0, merlist.size() + tmp_merlist.size() - 1 ); diff --git a/zone/entity.cpp b/zone/entity.cpp index 5ff19847f..d904dbdfe 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -622,6 +622,7 @@ void EntityList::AddCorpse(Corpse *corpse, uint32 in_id) void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) { npc->SetID(GetFreeID()); + npc->SetMerchantProbability((uint8) MakeRandomInt(0, 99)); parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0); uint16 emoteid = npc->GetEmoteID(); diff --git a/zone/lua_npc.cpp b/zone/lua_npc.cpp index 41524af15..dabc1c46f 100644 --- a/zone/lua_npc.cpp +++ b/zone/lua_npc.cpp @@ -442,6 +442,15 @@ void Lua_NPC::MerchantCloseShop() { self->MerchantCloseShop(); } +void Lua_NPC::SetMerchantProbability(uint8 amt) { + Lua_Safe_Call_Void(); + self->SetMerchantProbability(amt); +} + +uint8 Lua_NPC::GetMerchantProbability() { + Lua_Safe_Call_Int(); + return self->GetMerchantProbability(); +} luabind::scope lua_register_npc() { return luabind::class_("NPC") @@ -532,7 +541,9 @@ luabind::scope lua_register_npc() { .def("GetSpawnKillCount", (int(Lua_NPC::*)(void))&Lua_NPC::GetSpawnKillCount) .def("GetScore", (int(Lua_NPC::*)(void))&Lua_NPC::GetScore) .def("MerchantOpenShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantOpenShop) - .def("MerchantCloseShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantCloseShop); + .def("MerchantCloseShop", (void(Lua_NPC::*)(void))&Lua_NPC::MerchantCloseShop) + .def("SetMerchantProbability", (void(Lua_NPC::*)(void))&Lua_NPC::SetMerchantProbability) + .def("GetMerchantProbability", (uint8(Lua_NPC::*)(void))&Lua_NPC::GetMerchantProbability); } #endif diff --git a/zone/lua_npc.h b/zone/lua_npc.h index 8c34ed17d..7db7f7e4b 100644 --- a/zone/lua_npc.h +++ b/zone/lua_npc.h @@ -114,6 +114,8 @@ public: int GetScore(); void MerchantOpenShop(); void MerchantCloseShop(); + void SetMerchantProbability(uint8 amt); + uint8 GetMerchantProbability(); }; #endif diff --git a/zone/npc.h b/zone/npc.h index 5c8fd43bb..34fcfcd0a 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -390,6 +390,8 @@ public: uint32 GetSpawnKillCount(); int GetScore(); + void SetMerchantProbability(uint8 amt) { probability = amt; } + uint8 GetMerchantProbability() { return probability; } void mod_prespawn(Spawn2 *sp); int mod_npc_damage(int damage, SkillUseTypes skillinuse, int hand, const Item_Struct* weapon, Mob* other); void mod_npc_killed_merit(Mob* c); @@ -504,6 +506,7 @@ protected: std::list mercDataList; bool raid_target; + uint8 probability; private: uint32 loottable_id; diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index 891709113..dcc66b886 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -2145,6 +2145,54 @@ XS(XS_NPC_GetScore) XSRETURN(1); } +XS(XS_NPC_SetMerchantProbability); +XS(XS_NPC_SetMerchantProbability) { + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: NPC::SetMerchantProbability(THIS, Probability)"); + { + NPC *THIS; + uint8 Probability = (uint8)SvIV(ST(1)); + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(NPC *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->SetMerchantProbability(Probability); + } + XSRETURN_EMPTY; +} + +XS(XS_NPC_GetMerchantProbability); +XS(XS_NPC_GetMerchantProbability) { + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NPC::GetMerchantProbability(THIS)"); + { + NPC *THIS; + uint8 RETVAL; + dXSTARG; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(NPC *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if(THIS == NULL) + Perl_croak(aTHX_ "THIS is NULL, avoiding crash."); + + RETVAL = THIS->GetMerchantProbability(); + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + #ifdef __cplusplus extern "C" #endif @@ -2243,6 +2291,8 @@ XS(boot_NPC) newXSproto(strcpy(buf, "GetAccuracyRating"), XS_NPC_GetAccuracyRating, file, "$"); newXSproto(strcpy(buf, "GetSpawnKillCount"), XS_NPC_GetSpawnKillCount, file, "$"); newXSproto(strcpy(buf, "GetScore"), XS_NPC_GetScore, file, "$"); + newXSproto(strcpy(buf, "SetMerchantProbability"), XS_NPC_SetMerchantProbability, file, "$$"); + newXSproto(strcpy(buf, "GetMerchantProbability"), XS_NPC_GetMerchantProbability, file, "$"); XSRETURN_YES; } diff --git a/zone/zone.cpp b/zone/zone.cpp index 4124ba7d3..d0d8efb2f 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -469,7 +469,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid){ MYSQL_RES *result; MYSQL_ROW row; std::list merlist; - if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT item, slot, faction_required, level_required, alt_currency_cost, classes_required FROM merchantlist WHERE merchantid=%d", merchantid), errbuf, &result)) { + if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT item, slot, faction_required, level_required, alt_currency_cost, classes_required, probability FROM merchantlist WHERE merchantid=%d", merchantid), errbuf, &result)) { while((row = mysql_fetch_row(result))) { MerchantList ml; ml.id = merchantid; @@ -479,6 +479,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid){ ml.level_required = atoul(row[3]); ml.alt_currency_cost = atoul(row[3]); ml.classes_required = atoul(row[4]); + ml.probability = atoul(row[5]); merlist.push_back(ml); } merchanttable[merchantid] = merlist; @@ -526,6 +527,7 @@ void Zone::LoadMerchantData_result(MYSQL_RES* result) { ml.level_required = atoul(row[4]); ml.alt_currency_cost = atoul(row[5]); ml.classes_required = atoul(row[6]); + ml.probability = atoul(row[7]); cur->second.push_back(ml); } } @@ -539,7 +541,7 @@ void Zone::GetMerchantDataForZoneLoad(){ workpt.b1() = DBA_b1_Zone_MerchantLists; DBAsyncWork* dbaw = new DBAsyncWork(&database, &MTdbafq, workpt, DBAsync::Read); dbaw->AddQuery(1, &query, MakeAnyLenString(&query, - "select ml.merchantid,ml.slot,ml.item,ml.faction_required,ml.level_required,ml.alt_currency_cost,ml.classes_required " + "select ml.merchantid,ml.slot,ml.item,ml.faction_required,ml.level_required,ml.alt_currency_cost,ml.classes_required,ml.probability " "from merchantlist ml, npc_types nt, spawnentry se, spawn2 s2 " "where nt.merchant_id=ml.merchantid and nt.id=se.npcid " "and se.spawngroupid=s2.spawngroupid and s2.zone='%s' and s2.version=%u " diff --git a/zone/zonedump.h b/zone/zonedump.h index 98841630a..052f7446d 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -126,6 +126,7 @@ struct NPCType float healscale; bool no_target_hotkey; bool raid_target; + uint8 probability; }; /* From a4a8a1aba5a8c58e3023025e304d2b78f0e4937f Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 17:54:49 -0400 Subject: [PATCH 139/217] Clean up some compiler warnings with Stop_Return --- zone/client.cpp | 4 ++-- zone/exp.cpp | 2 +- zone/trading.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 0ac0671ef..2f2b4d370 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -2243,7 +2243,7 @@ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 plat struct timeval read_time; char buffer[50]; gettimeofday(&read_time, 0); - sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec); this->SetEntityVariable("Stop_Return", buffer); int32 new_value = m_pp.platinum + platinum; @@ -8277,4 +8277,4 @@ void Client::ExpeditionSay(const char *str, int ExpID) { mysql_free_result(result); -} \ No newline at end of file +} diff --git a/zone/exp.cpp b/zone/exp.cpp index 6553789d6..75d95bf25 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -54,7 +54,7 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { struct timeval read_time; char buffer[50]; gettimeofday(&read_time, 0); - sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec); this->SetEntityVariable("Stop_Return", buffer); uint32 add_exp = in_add_exp; diff --git a/zone/trading.cpp b/zone/trading.cpp index 7dbc93bad..9a504d2cb 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -642,7 +642,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) struct timeval read_time; char buffer[50]; gettimeofday(&read_time, 0); - sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec); this->SetEntityVariable("Stop_Return", buffer); } From 663dbf9fc27df55044227a784dd6708aa52a1619 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 17:56:32 -0400 Subject: [PATCH 140/217] Fix incorrect array size on A/B/C/DStackers --- zone/common.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/common.h b/zone/common.h index 10ce05420..3cc1af1cf 100644 --- a/zone/common.h +++ b/zone/common.h @@ -368,10 +368,10 @@ struct StatBonuses { bool NegateIfCombat; // Bool Drop buff if cast or melee int8 Screech; // -1 = Will be blocked if another Screech is +(1) int16 AlterNPCLevel; // amount of lvls +/- - int16 AStacker[1]; // For buff stack blocking 0=Exists 1=Effect_value - int16 BStacker[1]; // For buff stack blocking 0=Exists 1=Effect_value - int16 CStacker[1]; // For buff stack blocking 0=Exists 1=Effect_value - int16 DStacker[1]; // For buff stack blocking 0=Exists 1=Effect_value + int16 AStacker[2]; // For buff stack blocking 0=Exists 1=Effect_value + int16 BStacker[2]; // For buff stack blocking 0=Exists 1=Effect_value + int16 CStacker[2]; // For buff stack blocking 0=Exists 1=Effect_value + int16 DStacker[2]; // For buff stack blocking 0=Exists 1=Effect_value bool BerserkSPA; // berserk effect int16 Metabolism; // Food/drink consumption rates. bool Sanctuary; // Sanctuary effect, lowers place on hate list until cast on others. From 69944d907dcc68f94f29f11daac3b7576d069b89 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 17:59:52 -0400 Subject: [PATCH 141/217] Fix compiler warning in zone/inventory.cpp --- zone/inventory.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 7a36aa5e9..c626fad43 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -200,16 +200,15 @@ bool Client::CheckLoreConflict(const Item_Struct* item) { } bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned, uint16 to_slot) { - /* Set a timestamp in an entity variable for plugin check_handin.pl in return_items This will stopgap players from items being returned if global_npc.pl has a catch all return_items */ struct timeval read_time; char buffer[50]; gettimeofday(&read_time, 0); - sprintf(buffer, "%i.%i \n", read_time.tv_sec, read_time.tv_usec); + sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec); this->SetEntityVariable("Recieved_Item", buffer); - + // TODO: update calling methods and script apis to handle a failure return const Item_Struct* item = database.GetItem(item_id); From 16f112a28139975a5467577ac4055aa0a6bff810 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 18:10:40 -0400 Subject: [PATCH 142/217] Fix some if checks in Mob::CalcFocusEffect() --- zone/spell_effects.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 869e38619..2092aeb2f 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -4761,24 +4761,24 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo case SE_LimitSpellClass: if(focus_spell.base[i] < 0) { //Exclude - if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellClass)); + if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellClass)) return(0); - } + } else { LimitInclude[12] = true; - if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellClass)); //Include + if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellClass)) //Include LimitInclude[13] = true; } break; case SE_LimitSpellSubclass: if(focus_spell.base[i] < 0) { //Exclude - if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellSubclass)); + if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellSubclass)) return(0); - } + } else { LimitInclude[14] = true; - if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellSubclass)); //Include + if (CheckSpellCategory(spell_id, focus_spell.base[i], SE_LimitSpellSubclass)) //Include LimitInclude[15] = true; } break; @@ -6470,4 +6470,4 @@ void Mob::CalcSpellPowerDistanceMod(uint16 spell_id, float range, Mob* caster) SetSpellPowerDistanceMod(static_cast(mod)); } -} \ No newline at end of file +} From 0ad4ffe33f0799856cb729a86288945723ce155d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 19:02:29 -0400 Subject: [PATCH 143/217] Fix error in EQRawApplicationPacket::EQRawApplicationPacket() --- common/EQPacket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/EQPacket.cpp b/common/EQPacket.cpp index 5372a0f9d..36e8c83af 100644 --- a/common/EQPacket.cpp +++ b/common/EQPacket.cpp @@ -476,7 +476,7 @@ EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const u const unsigned char *packet_start = (buf + 3); const int32 packet_length = len - 3; safe_delete_array(pBuffer); - if(len >= 0) + if(packet_length >= 0) { size = packet_length; pBuffer = new unsigned char[size]; From 2e80e56af1255822ac5741d8354e2a4e003d8e8d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Thu, 21 Aug 2014 19:17:40 -0400 Subject: [PATCH 144/217] Fix dangling else statements --- ucs/clientlist.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index c2b887ff0..aa019a2cc 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -1329,7 +1329,7 @@ void Client::SendChannelMessage(std::string Message) } } - if(RequiredChannel) + if(RequiredChannel) { if(RuleB(Chat, EnableAntiSpam)) { if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || @@ -1384,7 +1384,7 @@ void Client::SendChannelMessage(std::string Message) else GeneralChannelMessage("Channel " + ChannelName + " is moderated and you have not been granted a voice."); } - + } } void Client::SendChannelMessageByNumber(std::string Message) { @@ -1883,11 +1883,12 @@ void Client::ChannelModerate(std::string CommandString) { RequiredChannel->SetModerated(!RequiredChannel->IsModerated()); - if(!RequiredChannel->IsClientInChannel(this)) - if(RequiredChannel->IsModerated()) + if (!RequiredChannel->IsClientInChannel(this)) { + if (RequiredChannel->IsModerated()) GeneralChannelMessage("Channel " + ChannelName + " is now moderated."); else GeneralChannelMessage("Channel " + ChannelName + " is no longer moderated."); + } } From 6457c00548d5382a1b9b7a1d8d17a5024535df2b Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 16:44:02 -0700 Subject: [PATCH 145/217] Renaming files --- common/CMakeLists.txt | 18 +++++++++--------- common/{BasePacket.cpp => base_packet.cpp} | 0 common/{Condition.cpp => condition.cpp} | 0 common/{CRC16.cpp => crc16.cpp} | 0 ...CPConnection.cpp => emu_tcp_connection.cpp} | 0 .../{EmuTCPServer.cpp => emu_tcp_server.cpp} | 0 common/{EQDB.cpp => eqdb.cpp} | 0 common/{EQDBRes.cpp => eqdb_res.cpp} | 0 common/{perl_EQDB.cpp => perl_eqdb.cpp} | 0 common/{perl_EQDBRes.cpp => perl_eqdb_res.cpp} | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename common/{BasePacket.cpp => base_packet.cpp} (100%) rename common/{Condition.cpp => condition.cpp} (100%) rename common/{CRC16.cpp => crc16.cpp} (100%) rename common/{EmuTCPConnection.cpp => emu_tcp_connection.cpp} (100%) rename common/{EmuTCPServer.cpp => emu_tcp_server.cpp} (100%) rename common/{EQDB.cpp => eqdb.cpp} (100%) rename common/{EQDBRes.cpp => eqdb_res.cpp} (100%) rename common/{perl_EQDB.cpp => perl_eqdb.cpp} (100%) rename common/{perl_EQDBRes.cpp => perl_eqdb_res.cpp} (100%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 9b84ecb05..36356afe9 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,22 +1,22 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(common_sources - BasePacket.cpp + base_packet.cpp classes.cpp - Condition.cpp + condition.cpp crash.cpp - CRC16.cpp + crc16.cpp crc32.cpp database.cpp dbasync.cpp dbcore.cpp debug.cpp emu_opcodes.cpp - EmuTCPConnection.cpp - EmuTCPServer.cpp + emu_tcp_connection.cpp + emu_tcp_server.cpp eq_dictionary.cpp - EQDB.cpp - EQDBRes.cpp + eqdb.cpp + eqdb_res.cpp eqemu_exception.cpp EQEmuConfig.cpp EQEMuError.cpp @@ -47,8 +47,8 @@ SET(common_sources packet_dump.cpp packet_dump_file.cpp packet_functions.cpp - perl_EQDB.cpp - perl_EQDBRes.cpp + perl_eqdb.cpp + perl_eqdb_res.cpp ProcLauncher.cpp ptimer.cpp races.cpp diff --git a/common/BasePacket.cpp b/common/base_packet.cpp similarity index 100% rename from common/BasePacket.cpp rename to common/base_packet.cpp diff --git a/common/Condition.cpp b/common/condition.cpp similarity index 100% rename from common/Condition.cpp rename to common/condition.cpp diff --git a/common/CRC16.cpp b/common/crc16.cpp similarity index 100% rename from common/CRC16.cpp rename to common/crc16.cpp diff --git a/common/EmuTCPConnection.cpp b/common/emu_tcp_connection.cpp similarity index 100% rename from common/EmuTCPConnection.cpp rename to common/emu_tcp_connection.cpp diff --git a/common/EmuTCPServer.cpp b/common/emu_tcp_server.cpp similarity index 100% rename from common/EmuTCPServer.cpp rename to common/emu_tcp_server.cpp diff --git a/common/EQDB.cpp b/common/eqdb.cpp similarity index 100% rename from common/EQDB.cpp rename to common/eqdb.cpp diff --git a/common/EQDBRes.cpp b/common/eqdb_res.cpp similarity index 100% rename from common/EQDBRes.cpp rename to common/eqdb_res.cpp diff --git a/common/perl_EQDB.cpp b/common/perl_eqdb.cpp similarity index 100% rename from common/perl_EQDB.cpp rename to common/perl_eqdb.cpp diff --git a/common/perl_EQDBRes.cpp b/common/perl_eqdb_res.cpp similarity index 100% rename from common/perl_EQDBRes.cpp rename to common/perl_eqdb_res.cpp From 405884f47dd66678f08d361c87359be44166f510 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 16:59:32 -0700 Subject: [PATCH 146/217] More file renames. --- common/CMakeLists.txt | 49 +++++++++---------- common/{EQPacket.cpp => eq_packet.cpp} | 0 common/{EQStream.cpp => eq_stream.cpp} | 0 ...StreamFactory.cpp => eq_stream_factor.cpp} | 0 ...{EQStreamIdent.cpp => eq_stream_ident.cpp} | 0 ...{EQStreamProxy.cpp => eq_stream_proxy.cpp} | 0 common/{EQEmuConfig.cpp => eqemu_config.cpp} | 0 common/{EQEMuError.cpp => eqemu_error.cpp} | 0 common/{Item.cpp => item.cpp} | 0 .../{MiscFunctions.cpp => misc_functions.cpp} | 0 common/{Mutex.cpp => mutex.cpp} | 0 ...estResult.cpp => mysql_request_result.cpp} | 0 ...QLRequestRow.cpp => mysql_request_row.cpp} | 0 common/patches/{Client62.cpp => client62.cpp} | 0 common/patches/{RoF.cpp => rof.cpp} | 0 common/patches/{SoD.cpp => sod.cpp} | 0 common/patches/{SoF.cpp => sof.cpp} | 0 common/patches/{Titanium.cpp => titanium.cpp} | 0 .../patches/{Underfoot.cpp => underfoot.cpp} | 0 .../{ProcLauncher.cpp => proc_launcher.cpp} | 0 common/{StringUtil.cpp => string_util.cpp} | 0 ...StructStrategy.cpp => struct_strategy.cpp} | 0 .../{TCPConnection.cpp => tcp_connection.cpp} | 0 common/{TCPServer.cpp => tcp_server.cpp} | 0 common/{XMLParser.cpp => xml_parser.cpp} | 0 25 files changed, 24 insertions(+), 25 deletions(-) rename common/{EQPacket.cpp => eq_packet.cpp} (100%) rename common/{EQStream.cpp => eq_stream.cpp} (100%) rename common/{EQStreamFactory.cpp => eq_stream_factor.cpp} (100%) rename common/{EQStreamIdent.cpp => eq_stream_ident.cpp} (100%) rename common/{EQStreamProxy.cpp => eq_stream_proxy.cpp} (100%) rename common/{EQEmuConfig.cpp => eqemu_config.cpp} (100%) rename common/{EQEMuError.cpp => eqemu_error.cpp} (100%) rename common/{Item.cpp => item.cpp} (100%) rename common/{MiscFunctions.cpp => misc_functions.cpp} (100%) rename common/{Mutex.cpp => mutex.cpp} (100%) rename common/{MySQLRequestResult.cpp => mysql_request_result.cpp} (100%) rename common/{MySQLRequestRow.cpp => mysql_request_row.cpp} (100%) rename common/patches/{Client62.cpp => client62.cpp} (100%) rename common/patches/{RoF.cpp => rof.cpp} (100%) rename common/patches/{SoD.cpp => sod.cpp} (100%) rename common/patches/{SoF.cpp => sof.cpp} (100%) rename common/patches/{Titanium.cpp => titanium.cpp} (100%) rename common/patches/{Underfoot.cpp => underfoot.cpp} (100%) rename common/{ProcLauncher.cpp => proc_launcher.cpp} (100%) rename common/{StringUtil.cpp => string_util.cpp} (100%) rename common/{StructStrategy.cpp => struct_strategy.cpp} (100%) rename common/{TCPConnection.cpp => tcp_connection.cpp} (100%) rename common/{TCPServer.cpp => tcp_server.cpp} (100%) rename common/{XMLParser.cpp => xml_parser.cpp} (100%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 36356afe9..fb4416868 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -18,30 +18,30 @@ SET(common_sources eqdb.cpp eqdb_res.cpp eqemu_exception.cpp - EQEmuConfig.cpp - EQEMuError.cpp - EQPacket.cpp - EQStream.cpp - EQStreamFactory.cpp - EQStreamIdent.cpp - EQStreamProxy.cpp + eqemu_config.cpp + eqemu_error.cpp + eq_packet.cpp + eq_stream.cpp + eq_stream_factory.cpp + eq_stream_ident.cpp + eq_stream_proxy.cpp eqtime.cpp extprofile.cpp faction.cpp guild_base.cpp guilds.cpp ipc_mutex.cpp - Item.cpp + item.cpp logsys.cpp logsys_eqemu.cpp md5.cpp memory_mapped_file.cpp misc.cpp - MiscFunctions.cpp + misc_functions.cpp moremath.cpp - Mutex.cpp - MySQLRequestResult.cpp - MySQLRequestRow.cpp + mutex.cpp + mysql_request_result.cpp + mysql_request_row.cpp opcode_map.cpp opcodemgr.cpp packet_dump.cpp @@ -49,7 +49,7 @@ SET(common_sources packet_functions.cpp perl_eqdb.cpp perl_eqdb_res.cpp - ProcLauncher.cpp + proc_launcher.cpp ptimer.cpp races.cpp rdtsc.cpp @@ -57,24 +57,23 @@ SET(common_sources serverinfo.cpp shareddb.cpp spdat.cpp - StringUtil.cpp - StructStrategy.cpp - TCPConnection.cpp - TCPServer.cpp + string_util.cpp + struct_strategy.cpp + tcp_connection.cpp + tcp_server.cpp timeoutmgr.cpp timer.cpp unix.cpp worldconn.cpp - XMLParser.cpp + xml_parser.cpp platform.cpp - patches/Client62.cpp + patches/client62.cpp patches/patches.cpp - patches/SoD.cpp - patches/SoF.cpp - patches/RoF.cpp - #patches/RoF2.cpp - patches/Titanium.cpp - patches/Underfoot.cpp + patches/sod.cpp + patches/sof.cpp + patches/rof.cpp + patches/titanium.cpp + patches/underfoot.cpp SocketLib/Base64.cpp SocketLib/File.cpp SocketLib/HttpdCookies.cpp diff --git a/common/EQPacket.cpp b/common/eq_packet.cpp similarity index 100% rename from common/EQPacket.cpp rename to common/eq_packet.cpp diff --git a/common/EQStream.cpp b/common/eq_stream.cpp similarity index 100% rename from common/EQStream.cpp rename to common/eq_stream.cpp diff --git a/common/EQStreamFactory.cpp b/common/eq_stream_factor.cpp similarity index 100% rename from common/EQStreamFactory.cpp rename to common/eq_stream_factor.cpp diff --git a/common/EQStreamIdent.cpp b/common/eq_stream_ident.cpp similarity index 100% rename from common/EQStreamIdent.cpp rename to common/eq_stream_ident.cpp diff --git a/common/EQStreamProxy.cpp b/common/eq_stream_proxy.cpp similarity index 100% rename from common/EQStreamProxy.cpp rename to common/eq_stream_proxy.cpp diff --git a/common/EQEmuConfig.cpp b/common/eqemu_config.cpp similarity index 100% rename from common/EQEmuConfig.cpp rename to common/eqemu_config.cpp diff --git a/common/EQEMuError.cpp b/common/eqemu_error.cpp similarity index 100% rename from common/EQEMuError.cpp rename to common/eqemu_error.cpp diff --git a/common/Item.cpp b/common/item.cpp similarity index 100% rename from common/Item.cpp rename to common/item.cpp diff --git a/common/MiscFunctions.cpp b/common/misc_functions.cpp similarity index 100% rename from common/MiscFunctions.cpp rename to common/misc_functions.cpp diff --git a/common/Mutex.cpp b/common/mutex.cpp similarity index 100% rename from common/Mutex.cpp rename to common/mutex.cpp diff --git a/common/MySQLRequestResult.cpp b/common/mysql_request_result.cpp similarity index 100% rename from common/MySQLRequestResult.cpp rename to common/mysql_request_result.cpp diff --git a/common/MySQLRequestRow.cpp b/common/mysql_request_row.cpp similarity index 100% rename from common/MySQLRequestRow.cpp rename to common/mysql_request_row.cpp diff --git a/common/patches/Client62.cpp b/common/patches/client62.cpp similarity index 100% rename from common/patches/Client62.cpp rename to common/patches/client62.cpp diff --git a/common/patches/RoF.cpp b/common/patches/rof.cpp similarity index 100% rename from common/patches/RoF.cpp rename to common/patches/rof.cpp diff --git a/common/patches/SoD.cpp b/common/patches/sod.cpp similarity index 100% rename from common/patches/SoD.cpp rename to common/patches/sod.cpp diff --git a/common/patches/SoF.cpp b/common/patches/sof.cpp similarity index 100% rename from common/patches/SoF.cpp rename to common/patches/sof.cpp diff --git a/common/patches/Titanium.cpp b/common/patches/titanium.cpp similarity index 100% rename from common/patches/Titanium.cpp rename to common/patches/titanium.cpp diff --git a/common/patches/Underfoot.cpp b/common/patches/underfoot.cpp similarity index 100% rename from common/patches/Underfoot.cpp rename to common/patches/underfoot.cpp diff --git a/common/ProcLauncher.cpp b/common/proc_launcher.cpp similarity index 100% rename from common/ProcLauncher.cpp rename to common/proc_launcher.cpp diff --git a/common/StringUtil.cpp b/common/string_util.cpp similarity index 100% rename from common/StringUtil.cpp rename to common/string_util.cpp diff --git a/common/StructStrategy.cpp b/common/struct_strategy.cpp similarity index 100% rename from common/StructStrategy.cpp rename to common/struct_strategy.cpp diff --git a/common/TCPConnection.cpp b/common/tcp_connection.cpp similarity index 100% rename from common/TCPConnection.cpp rename to common/tcp_connection.cpp diff --git a/common/TCPServer.cpp b/common/tcp_server.cpp similarity index 100% rename from common/TCPServer.cpp rename to common/tcp_server.cpp diff --git a/common/XMLParser.cpp b/common/xml_parser.cpp similarity index 100% rename from common/XMLParser.cpp rename to common/xml_parser.cpp From 06f18225cec42e618e15a7ea6bfe1aaf522eed2a Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 17:26:32 -0700 Subject: [PATCH 147/217] Renaming headers is hard work --- client_files/export/main.cpp | 2 +- client_files/import/main.cpp | 2 +- common/CMakeLists.txt | 23 ++++++++----------- common/EQPacket.h | 2 +- common/EQStream.h | 2 +- common/EQStreamFactory.h | 2 +- common/base_packet.cpp | 2 +- common/{BasePacket.h => base_packet.h} | 0 common/condition.cpp | 2 +- common/{Condition.h => condition.h} | 0 common/{CRC16.h => crc16.h} | 0 common/dbcore.h | 2 +- common/emu_tcp_connection.cpp | 4 ++-- ...muTCPConnection.h => emu_tcp_connection.h} | 0 common/emu_tcp_server.cpp | 4 ++-- common/{EmuTCPServer.h => emu_tcp_server.h} | 0 common/eq_packet.cpp | 2 +- common/eq_stream.cpp | 2 +- common/eqdb.cpp | 2 +- common/{EQDB.h => eqdb.h} | 2 +- common/eqdb_res.cpp | 2 +- common/{EQDBRes.h => eqdb_res.h} | 0 common/eqemu_config.cpp | 2 +- common/{EQEmuConfig.h => eqemu_config.h} | 4 ++-- ...fig_elements.h => eqemu_config_elements.h} | 0 common/perl_eqdb.cpp | 2 +- common/perl_eqdb_res.cpp | 2 +- common/worldconn.cpp | 2 +- common/worldconn.h | 2 +- eqlaunch/ZoneLaunch.cpp | 2 +- eqlaunch/eqlaunch.cpp | 2 +- eqlaunch/worldserver.cpp | 2 +- loginserver/ServerManager.h | 4 ++-- loginserver/WorldServer.h | 4 ++-- queryserv/queryservconfig.h | 2 +- shared_memory/main.cpp | 2 +- socket_server/socket_server_config.h | 2 +- ucs/clientlist.cpp | 4 ++-- ucs/ucsconfig.h | 2 +- world/EQWParser.cpp | 2 +- world/HTTPRequest.cpp | 2 +- world/LauncherLink.cpp | 2 +- world/LauncherLink.h | 2 +- world/LoginServer.h | 2 +- world/LoginServerList.h | 2 +- world/WorldConfig.h | 2 +- world/console.h | 2 +- world/net.cpp | 6 ++--- world/queryserv.cpp | 2 +- world/queryserv.h | 2 +- world/ucs.cpp | 2 +- world/ucs.h | 2 +- world/zoneserver.h | 2 +- zone/ZoneConfig.h | 2 +- zone/zone_logsys.cpp | 2 +- 55 files changed, 64 insertions(+), 69 deletions(-) rename common/{BasePacket.h => base_packet.h} (100%) rename common/{Condition.h => condition.h} (100%) rename common/{CRC16.h => crc16.h} (100%) rename common/{EmuTCPConnection.h => emu_tcp_connection.h} (100%) rename common/{EmuTCPServer.h => emu_tcp_server.h} (100%) rename common/{EQDB.h => eqdb.h} (98%) rename common/{EQDBRes.h => eqdb_res.h} (100%) rename common/{EQEmuConfig.h => eqemu_config.h} (98%) rename common/{EQEmuConfig_elements.h => eqemu_config_elements.h} (100%) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index aca5ddc56..b5669338e 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -19,7 +19,7 @@ #include #include "../../common/debug.h" #include "../../common/shareddb.h" -#include "../../common/EQEmuConfig.h" +#include "../../common/eqemu_config.h" #include "../../common/platform.h" #include "../../common/crash.h" #include "../../common/rulesys.h" diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 321e3a17b..3a0968d92 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -18,7 +18,7 @@ #include "../../common/debug.h" #include "../../common/shareddb.h" -#include "../../common/EQEmuConfig.h" +#include "../../common/eqemu_config.h" #include "../../common/platform.h" #include "../../common/crash.h" #include "../../common/rulesys.h" diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index fb4416868..f15e57c51 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -93,14 +93,14 @@ SET(common_sources ) SET(common_headers - BasePacket.h + base_packet.h base_data.h bodytypes.h breakdowns.h classes.h - Condition.h + condition.h crash.h - CRC16.h + crc16.h crc32.h database.h dbasync.h @@ -109,16 +109,16 @@ SET(common_headers deity.h emu_opcodes.h emu_oplist.h - EmuTCPConnection.h - EmuTCPServer.h + emu_tcp_connection.h + emu_tcp_server.h eq_constants.h eq_dictionary.h eq_packet_structs.h - EQDB.h - EQDBRes.h + eqdb.h + eqdb_res.h eqemu_exception.h - EQEmuConfig.h - EQEmuConfig_elements.h + eqemu_config.h + eqemu_config_elements.h EQEMuError.h EQPacket.h EQStream.h @@ -215,11 +215,6 @@ SET(common_headers patches/RoF_itemfields.h patches/RoF_ops.h patches/RoF_structs.h - #patches/RoF2.h - #patches/RoF2_constants.h - #patches/RoF2_itemfields.h - #patches/RoF2_ops.h - #patches/RoF2_structs.h patches/Titanium.h patches/Titanium_constants.h patches/Titanium_itemfields.h diff --git a/common/EQPacket.h b/common/EQPacket.h index 8b1f7b628..83a37da32 100644 --- a/common/EQPacket.h +++ b/common/EQPacket.h @@ -18,7 +18,7 @@ #ifndef _EQPACKET_H #define _EQPACKET_H -#include "BasePacket.h" +#include "base_packet.h" #include "EQStreamType.h" #include "op_codes.h" #include "platform.h" diff --git a/common/EQStream.h b/common/EQStream.h index 97d304642..2b32492d6 100644 --- a/common/EQStream.h +++ b/common/EQStream.h @@ -15,7 +15,7 @@ #include "Mutex.h" #include "../common/opcodemgr.h" #include "../common/misc.h" -#include "../common/Condition.h" +#include "../common/condition.h" #include "../common/timer.h" #define FLAG_COMPRESSED 0x01 diff --git a/common/EQStreamFactory.h b/common/EQStreamFactory.h index dd0b7f1b8..8e2208152 100644 --- a/common/EQStreamFactory.h +++ b/common/EQStreamFactory.h @@ -5,7 +5,7 @@ #include #include #include "../common/EQStream.h" -#include "../common/Condition.h" +#include "../common/condition.h" #include "../common/timeoutmgr.h" #include "../common/opcodemgr.h" #include "../common/timer.h" diff --git a/common/base_packet.cpp b/common/base_packet.cpp index 613e5e25a..44b3643b5 100644 --- a/common/base_packet.cpp +++ b/common/base_packet.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "debug.h" -#include "BasePacket.h" +#include "base_packet.h" #include "misc.h" #include "packet_dump.h" diff --git a/common/BasePacket.h b/common/base_packet.h similarity index 100% rename from common/BasePacket.h rename to common/base_packet.h diff --git a/common/condition.cpp b/common/condition.cpp index 7d99d0a43..2dc90b26d 100644 --- a/common/condition.cpp +++ b/common/condition.cpp @@ -17,7 +17,7 @@ */ #include "debug.h" -#include "Condition.h" +#include "condition.h" #ifdef _WINDOWS diff --git a/common/Condition.h b/common/condition.h similarity index 100% rename from common/Condition.h rename to common/condition.h diff --git a/common/CRC16.h b/common/crc16.h similarity index 100% rename from common/CRC16.h rename to common/crc16.h diff --git a/common/dbcore.h b/common/dbcore.h index 2c3602a81..e90c5e249 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -13,7 +13,7 @@ #include "../common/linked_list.h" #include "../common/queue.h" #include "../common/timer.h" -#include "../common/Condition.h" +#include "../common/condition.h" #include "../common/MySQLRequestResult.h" class DBcore { diff --git a/common/emu_tcp_connection.cpp b/common/emu_tcp_connection.cpp index 638825f08..41a39d3ab 100644 --- a/common/emu_tcp_connection.cpp +++ b/common/emu_tcp_connection.cpp @@ -30,8 +30,8 @@ tremendously. #include #include -#include "EmuTCPConnection.h" -#include "EmuTCPServer.h" +#include "emu_tcp_connection.h" +#include "emu_tcp_server.h" #include "../common/servertalk.h" #include "../common/packet_dump.h" diff --git a/common/EmuTCPConnection.h b/common/emu_tcp_connection.h similarity index 100% rename from common/EmuTCPConnection.h rename to common/emu_tcp_connection.h diff --git a/common/emu_tcp_server.cpp b/common/emu_tcp_server.cpp index 3549abacd..985be6edd 100644 --- a/common/emu_tcp_server.cpp +++ b/common/emu_tcp_server.cpp @@ -1,6 +1,6 @@ #include "debug.h" -#include "EmuTCPServer.h" -#include "EmuTCPConnection.h" +#include "emu_tcp_server.h" +#include "emu_tcp_connection.h" EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat) : TCPServer(iPort), diff --git a/common/EmuTCPServer.h b/common/emu_tcp_server.h similarity index 100% rename from common/EmuTCPServer.h rename to common/emu_tcp_server.h diff --git a/common/eq_packet.cpp b/common/eq_packet.cpp index 36e8c83af..b2d335b41 100644 --- a/common/eq_packet.cpp +++ b/common/eq_packet.cpp @@ -22,7 +22,7 @@ #include "EQPacket.h" #include "misc.h" #include "op_codes.h" -#include "CRC16.h" +#include "crc16.h" #include "platform.h" #ifndef STATIC_OPCODE #include "opcodemgr.h" diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index 785c11ff3..473a986a7 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -22,7 +22,7 @@ #include "misc.h" #include "Mutex.h" #include "op_codes.h" -#include "CRC16.h" +#include "crc16.h" #include "platform.h" #include diff --git a/common/eqdb.cpp b/common/eqdb.cpp index 124f2e817..03746b0d4 100644 --- a/common/eqdb.cpp +++ b/common/eqdb.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "debug.h" -#include "EQDB.h" +#include "eqdb.h" #include "database.h" #include #include diff --git a/common/EQDB.h b/common/eqdb.h similarity index 98% rename from common/EQDB.h rename to common/eqdb.h index 8333d6990..b07517b69 100644 --- a/common/EQDB.h +++ b/common/eqdb.h @@ -22,7 +22,7 @@ #include #include #include "types.h" -#include "EQDBRes.h" +#include "eqdb_res.h" #include //this is the main object exported to perl. diff --git a/common/eqdb_res.cpp b/common/eqdb_res.cpp index 964746c0b..f34229a1f 100644 --- a/common/eqdb_res.cpp +++ b/common/eqdb_res.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "debug.h" -#include "EQDBRes.h" +#include "eqdb_res.h" #include std::vector EQDBRes::fetch_row_array() { diff --git a/common/EQDBRes.h b/common/eqdb_res.h similarity index 100% rename from common/EQDBRes.h rename to common/eqdb_res.h diff --git a/common/eqemu_config.cpp b/common/eqemu_config.cpp index d60d8df82..1d0dadd15 100644 --- a/common/eqemu_config.cpp +++ b/common/eqemu_config.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "EQEmuConfig.h" +#include "eqemu_config.h" #include "MiscFunctions.h" #include #include diff --git a/common/EQEmuConfig.h b/common/eqemu_config.h similarity index 98% rename from common/EQEmuConfig.h rename to common/eqemu_config.h index a3ab021a4..0a8cf833b 100644 --- a/common/EQEmuConfig.h +++ b/common/eqemu_config.h @@ -112,14 +112,14 @@ protected: #define ELEMENT(name) \ void do_##name(TiXmlElement *ele); - #include "EQEmuConfig_elements.h" + #include "eqemu_config_elements.h" EQEmuConfig() { // import the needed handler prototypes #define ELEMENT(name) \ Handlers[#name]=(ElementHandler)&EQEmuConfig::do_##name; - #include "EQEmuConfig_elements.h" + #include "eqemu_config_elements.h" // Set sane defaults diff --git a/common/EQEmuConfig_elements.h b/common/eqemu_config_elements.h similarity index 100% rename from common/EQEmuConfig_elements.h rename to common/eqemu_config_elements.h diff --git a/common/perl_eqdb.cpp b/common/perl_eqdb.cpp index 960809871..8e7fb1138 100644 --- a/common/perl_eqdb.cpp +++ b/common/perl_eqdb.cpp @@ -30,7 +30,7 @@ typedef const char Const_char; #ifdef EMBPERL #include "../common/debug.h" #include "../common/useperl.h" -#include "EQDB.h" +#include "eqdb.h" #ifdef THIS /* this macro seems to leak out on some systems */ #undef THIS diff --git a/common/perl_eqdb_res.cpp b/common/perl_eqdb_res.cpp index 15979c3a7..b4f22affb 100644 --- a/common/perl_eqdb_res.cpp +++ b/common/perl_eqdb_res.cpp @@ -30,7 +30,7 @@ typedef const char Const_char; #ifdef EMBPERL #include "../common/debug.h" #include "../common/useperl.h" -#include "EQDBRes.h" +#include "eqdb_res.h" XS(XS_EQDBRes_num_rows); /* prototype to pass -Wmissing-prototypes */ diff --git a/common/worldconn.cpp b/common/worldconn.cpp index 42375cb8a..73946d6f5 100644 --- a/common/worldconn.cpp +++ b/common/worldconn.cpp @@ -26,7 +26,7 @@ #include #include "worldconn.h" -#include "EQEmuConfig.h" +#include "eqemu_config.h" #include "md5.h" #include "database.h" #include "servertalk.h" diff --git a/common/worldconn.h b/common/worldconn.h index 08ceafb37..83d9a9cd7 100644 --- a/common/worldconn.h +++ b/common/worldconn.h @@ -19,7 +19,7 @@ #ifndef WORLDCONNECTION_H #define WORLDCONNECTION_H -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include class ServerPacket; diff --git a/eqlaunch/ZoneLaunch.cpp b/eqlaunch/ZoneLaunch.cpp index e1332fdce..42d1debe8 100644 --- a/eqlaunch/ZoneLaunch.cpp +++ b/eqlaunch/ZoneLaunch.cpp @@ -20,7 +20,7 @@ #include "ZoneLaunch.h" #include "worldserver.h" -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" //static const uint32 ZONE_RESTART_DELAY = 10000; //static const uint32 ZONE_TERMINATE_WAIT = 10000; diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index dafceaf30..58db80cb8 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -18,7 +18,7 @@ #include "../common/debug.h" #include "../common/ProcLauncher.h" -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" #include "../common/servertalk.h" #include "../common/platform.h" #include "../common/crash.h" diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index c6e44fccd..5872e17d5 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -19,7 +19,7 @@ #include "worldserver.h" #include "../common/servertalk.h" #include "ZoneLaunch.h" -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" #include "../common/StringUtil.h" diff --git a/loginserver/ServerManager.h b/loginserver/ServerManager.h index cf15522db..8bfd8c8ee 100644 --- a/loginserver/ServerManager.h +++ b/loginserver/ServerManager.h @@ -20,8 +20,8 @@ #include "../common/debug.h" #include "../common/EQStreamFactory.h" -#include "../common/EmuTCPConnection.h" -#include "../common/EmuTCPServer.h" +#include "../common/emu_tcp_connection.h" +#include "../common/emu_tcp_server.h" #include "../common/servertalk.h" #include "../common/packet_dump.h" #include "WorldServer.h" diff --git a/loginserver/WorldServer.h b/loginserver/WorldServer.h index 2b8b6ff61..655cbc578 100644 --- a/loginserver/WorldServer.h +++ b/loginserver/WorldServer.h @@ -20,8 +20,8 @@ #include "../common/debug.h" #include "../common/EQStreamFactory.h" -#include "../common/EmuTCPConnection.h" -#include "../common/EmuTCPServer.h" +#include "../common/emu_tcp_connection.h" +#include "../common/emu_tcp_server.h" #include "../common/servertalk.h" #include "../common/packet_dump.h" #include diff --git a/queryserv/queryservconfig.h b/queryserv/queryservconfig.h index e28f6b02a..b48ecdecd 100644 --- a/queryserv/queryservconfig.h +++ b/queryserv/queryservconfig.h @@ -20,7 +20,7 @@ #ifndef __queryservconfig_H #define __queryservconfig_H -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" class queryservconfig : public EQEmuConfig { public: diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index 1c15b0a8e..8cc554441 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -19,7 +19,7 @@ #include #include "../common/debug.h" #include "../common/shareddb.h" -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" #include "../common/platform.h" #include "../common/crash.h" #include "../common/rulesys.h" diff --git a/socket_server/socket_server_config.h b/socket_server/socket_server_config.h index bc86107d3..73b966ce4 100644 --- a/socket_server/socket_server_config.h +++ b/socket_server/socket_server_config.h @@ -20,7 +20,7 @@ #ifndef __socket_server_config_H #define __socket_server_config_H -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" class socket_server_config : public EQEmuConfig { public: diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index aa019a2cc..31d54e3b5 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -25,8 +25,8 @@ #include "chatchannel.h" #include "../common/EQStreamFactory.h" -#include "../common/EmuTCPConnection.h" -#include "../common/EmuTCPServer.h" +#include "../common/emu_tcp_connection.h" +#include "../common/emu_tcp_server.h" #include #include #include diff --git a/ucs/ucsconfig.h b/ucs/ucsconfig.h index 6c4fb8579..23bc82a4f 100644 --- a/ucs/ucsconfig.h +++ b/ucs/ucsconfig.h @@ -20,7 +20,7 @@ #ifndef __ucsconfig_H #define __ucsconfig_H -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" class ucsconfig : public EQEmuConfig { public: diff --git a/world/EQWParser.cpp b/world/EQWParser.cpp index 840c01fe3..53d430171 100644 --- a/world/EQWParser.cpp +++ b/world/EQWParser.cpp @@ -23,7 +23,7 @@ #include "../common/debug.h" #include "EQWParser.h" #include "EQW.h" -#include "../common/EQDB.h" +#include "../common/eqdb.h" #include "../common/logsys.h" #include "worlddb.h" diff --git a/world/HTTPRequest.cpp b/world/HTTPRequest.cpp index b05aa5d66..e366b6471 100644 --- a/world/HTTPRequest.cpp +++ b/world/HTTPRequest.cpp @@ -18,7 +18,7 @@ #include "../common/debug.h" #include "HTTPRequest.h" #include "EQWHTTPHandler.h" -#include "../common/EQDB.h" +#include "../common/eqdb.h" #include "../common/SocketLib/HttpdForm.h" #include diff --git a/world/LauncherLink.cpp b/world/LauncherLink.cpp index 00d93da35..de0f20384 100644 --- a/world/LauncherLink.cpp +++ b/world/LauncherLink.cpp @@ -24,7 +24,7 @@ #include "../common/md5.h" #include "../common/packet_dump.h" #include "../common/servertalk.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/StringUtil.h" #include "worlddb.h" #include "EQLConfig.h" diff --git a/world/LauncherLink.h b/world/LauncherLink.h index c5936bd3d..d1d8b6d61 100644 --- a/world/LauncherLink.h +++ b/world/LauncherLink.h @@ -18,7 +18,7 @@ #ifndef LAUNCHERLINK_H_ #define LAUNCHERLINK_H_ -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/timer.h" #include #include diff --git a/world/LoginServer.h b/world/LoginServer.h index 6cb6957cf..45cb9c214 100644 --- a/world/LoginServer.h +++ b/world/LoginServer.h @@ -24,7 +24,7 @@ #include "../common/queue.h" #include "../common/eq_packet_structs.h" #include "../common/Mutex.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" class LoginServer{ public: diff --git a/world/LoginServerList.h b/world/LoginServerList.h index 29ee8ed74..f47587920 100644 --- a/world/LoginServerList.h +++ b/world/LoginServerList.h @@ -7,7 +7,7 @@ #include "../common/queue.h" #include "../common/eq_packet_structs.h" #include "../common/Mutex.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #ifdef _WINDOWS void AutoInitLoginServer(void *tmp); diff --git a/world/WorldConfig.h b/world/WorldConfig.h index 316e6cfc4..4689aa08f 100644 --- a/world/WorldConfig.h +++ b/world/WorldConfig.h @@ -18,7 +18,7 @@ #ifndef __WorldConfig_H #define __WorldConfig_H -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" class WorldConfig : public EQEmuConfig { public: diff --git a/world/console.h b/world/console.h index 26aa95648..3c900f0f0 100644 --- a/world/console.h +++ b/world/console.h @@ -38,7 +38,7 @@ enum { #include "../common/linked_list.h" #include "../common/timer.h" #include "../common/queue.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "WorldTCPConnection.h" #include "../common/Mutex.h" diff --git a/world/net.cpp b/world/net.cpp index d7179bffe..663205286 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -68,15 +68,15 @@ #endif +#include "../common/dbasync.h" +#include "../common/emu_tcp_server.h" +#include "../common/patches/patches.h" #include "zoneserver.h" #include "console.h" #include "LoginServer.h" #include "LoginServerList.h" #include "EQWHTTPHandler.h" -#include "../common/dbasync.h" -#include "../common/EmuTCPServer.h" #include "WorldConfig.h" -#include "../common/patches/patches.h" #include "zoneserver.h" #include "zonelist.h" #include "clientlist.h" diff --git a/world/queryserv.cpp b/world/queryserv.cpp index eaa428332..f1e80b555 100644 --- a/world/queryserv.cpp +++ b/world/queryserv.cpp @@ -6,7 +6,7 @@ #include "../common/logsys.h" #include "../common/logtypes.h" #include "../common/md5.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/packet_dump.h" extern ClientList client_list; diff --git a/world/queryserv.h b/world/queryserv.h index df6dde7f8..5053d7c99 100644 --- a/world/queryserv.h +++ b/world/queryserv.h @@ -2,7 +2,7 @@ #define QueryServ_H #include "../common/types.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/servertalk.h" class QueryServConnection diff --git a/world/ucs.cpp b/world/ucs.cpp index 262e8c187..8e510b5f8 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -4,7 +4,7 @@ #include "../common/logsys.h" #include "../common/logtypes.h" #include "../common/md5.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/packet_dump.h" UCSConnection::UCSConnection() diff --git a/world/ucs.h b/world/ucs.h index a65d82e3d..a6e8ae032 100644 --- a/world/ucs.h +++ b/world/ucs.h @@ -2,7 +2,7 @@ #define UCS_H #include "../common/types.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include "../common/servertalk.h" class UCSConnection diff --git a/world/zoneserver.h b/world/zoneserver.h index 955c0b376..7984b4178 100644 --- a/world/zoneserver.h +++ b/world/zoneserver.h @@ -19,7 +19,7 @@ #define ZONESERVER_H #include "WorldTCPConnection.h" -#include "../common/EmuTCPConnection.h" +#include "../common/emu_tcp_connection.h" #include #include diff --git a/zone/ZoneConfig.h b/zone/ZoneConfig.h index dac5a371d..d67cb5201 100644 --- a/zone/ZoneConfig.h +++ b/zone/ZoneConfig.h @@ -18,7 +18,7 @@ #ifndef __ZoneConfig_H #define __ZoneConfig_H -#include "../common/EQEmuConfig.h" +#include "../common/eqemu_config.h" class ZoneConfig : public EQEmuConfig { public: diff --git a/zone/zone_logsys.cpp b/zone/zone_logsys.cpp index 3ecf9ec6b..59b4755dc 100644 --- a/zone/zone_logsys.cpp +++ b/zone/zone_logsys.cpp @@ -18,7 +18,7 @@ #include "../common/debug.h" #include "../common/logsys.h" -#include "../common/BasePacket.h" +#include "../common/base_packet.h" #include "mob.h" #include #include From e429260763258b746ac456544492f25a14d83a46 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 17:30:00 -0700 Subject: [PATCH 148/217] Missed eq stream factory --- common/{eq_stream_factor.cpp => eq_stream_factory.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename common/{eq_stream_factor.cpp => eq_stream_factory.cpp} (100%) diff --git a/common/eq_stream_factor.cpp b/common/eq_stream_factory.cpp similarity index 100% rename from common/eq_stream_factor.cpp rename to common/eq_stream_factory.cpp From 7fc21b9e3a546c36ba53c3ea15581fc3b1c20ad9 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 19:33:02 -0700 Subject: [PATCH 149/217] Tons of renames --- client_files/export/main.cpp | 2 +- client_files/import/main.cpp | 2 +- common/CMakeLists.txt | 201 +- common/EQNetwork.cpp | 405 ---- common/EQNetwork.h | 120 -- common/MaxSkill.cpp | 1900 ----------------- common/SocketLib/HTTPSocket.cpp | 2 +- common/SocketLib/HTTPSocket.h | 2 +- common/database.cpp | 2 +- common/database.h | 6 +- common/dbasync.cpp | 4 +- common/dbcore.cpp | 2 +- common/dbcore.h | 2 +- common/debug.cpp | 4 +- common/emu_tcp_connection.h | 2 +- common/emu_tcp_server.h | 2 +- common/eq_dictionary.cpp | 2 +- common/eq_dictionary.h | 14 +- common/eq_packet.cpp | 2 +- common/{EQPacket.h => eq_packet.h} | 2 +- common/eq_stream.cpp | 4 +- common/{EQStream.h => eq_stream.h} | 6 +- common/eq_stream_factory.cpp | 4 +- ...{EQStreamFactory.h => eq_stream_factory.h} | 2 +- common/eq_stream_ident.cpp | 4 +- common/{EQStreamIdent.h => eq_stream_ident.h} | 2 +- common/{EQStreamIntf.h => eq_stream_intf.h} | 0 ...{EQStreamLocator.h => eq_stream_locator.h} | 0 common/eq_stream_proxy.cpp | 6 +- common/{EQStreamProxy.h => eq_stream_proxy.h} | 2 +- common/{EQStreamType.h => eq_stream_type.h} | 0 common/eqemu_config.cpp | 2 +- common/eqemu_config.h | 2 +- common/eqemu_error.cpp | 4 +- common/{EQEMuError.h => eqemu_error.h} | 0 common/extprofile.h | 2 +- common/guild_base.cpp | 4 +- common/guilds.cpp | 2 +- common/item.cpp | 4 +- common/{Item.h => item.h} | 0 common/logsys.cpp | 2 +- common/logsys_eqemu.cpp | 2 +- common/md5.cpp | 2 +- common/misc_functions.cpp | 2 +- common/{MiscFunctions.h => misc_functions.h} | 0 common/mysql_request_result.cpp | 2 +- ...RequestResult.h => mysql_request_result.h} | 2 +- common/mysql_request_row.cpp | 2 +- ...{MySQLRequestRow.h => mysql_request_row.h} | 0 common/packet_dump.cpp | 2 +- common/packet_dump_file.cpp | 2 +- common/patches/client62.cpp | 22 +- common/patches/{Client62.h => client62.h} | 8 +- ...ent62_constants.h => client62_constants.h} | 0 ...t62_itemfields.h => client62_itemfields.h} | 0 .../{Client62_ops.h => client62_ops.h} | 0 ...{Client62_structs.h => client62_structs.h} | 0 common/patches/patches.cpp | 14 +- common/patches/rof.cpp | 18 +- common/patches/{RoF.h => rof.h} | 6 +- .../{RoF_constants.h => rof_constants.h} | 0 .../{RoF_itemfields.h => rof_itemfields.h} | 0 common/patches/{RoF_ops.h => rof_ops.h} | 0 .../patches/{RoF_structs.h => rof_structs.h} | 0 common/patches/sod.cpp | 18 +- common/patches/{SoD.h => sod.h} | 6 +- .../{SoD_constants.h => sod_constants.h} | 0 .../{SoD_itemfields.h => sod_itemfields.h} | 0 common/patches/{SoD_ops.h => sod_ops.h} | 0 .../patches/{SoD_structs.h => sod_structs.h} | 0 common/patches/sof.cpp | 16 +- common/patches/{SoF.h => sof.h} | 6 +- .../{SoF_constants.h => sof_constants.h} | 0 .../{SoF_itemfields.h => sof_itemfields.h} | 0 common/patches/{SoF_ops.h => sof_ops.h} | 0 .../patches/{SoF_structs.h => sof_structs.h} | 0 common/patches/{SSDeclare.h => ss_declare.h} | 0 common/patches/{SSDefine.h => ss_define.h} | 0 .../patches/{SSRegister.h => ss_register.h} | 0 common/patches/template.cpp | 6 +- common/patches/template.h | 4 +- common/patches/titanium.cpp | 20 +- common/patches/{Titanium.h => titanium.h} | 6 +- ...anium_constants.h => titanium_constants.h} | 0 ...ium_itemfields.h => titanium_itemfields.h} | 0 .../{Titanium_ops.h => titanium_ops.h} | 0 ...{Titanium_structs.h => titanium_structs.h} | 0 common/patches/underfoot.cpp | 18 +- common/patches/{Underfoot.h => underfoot.h} | 6 +- ...foot_constants.h => underfoot_constants.h} | 0 ...ot_itemfields.h => underfoot_itemfields.h} | 0 .../{Underfoot_ops.h => underfoot_ops.h} | 0 ...nderfoot_structs.h => underfoot_structs.h} | 0 common/proc_launcher.cpp | 2 +- common/{ProcLauncher.h => proc_launcher.h} | 0 common/ptimer.cpp | 2 +- common/rulesys.cpp | 2 +- common/shareddb.cpp | 4 +- common/shareddb.h | 2 +- common/spdat.cpp | 2 +- common/string_util.cpp | 2 +- common/{StringUtil.h => string_util.h} | 0 common/struct_strategy.cpp | 4 +- .../{StructStrategy.h => struct_strategy.h} | 0 .../{TCPBasicServer.h => tcp_basic_server.h} | 4 +- common/tcp_connection.cpp | 2 +- common/{TCPConnection.h => tcp_connection.h} | 2 +- common/tcp_server.cpp | 2 +- common/{TCPServer.h => tcp_server.h} | 0 common/xml_parser.cpp | 2 +- common/{XMLParser.h => xml_parser.h} | 0 common/{ZoneNumbers.h => zone_numbers.h} | 0 eqlaunch/ZoneLaunch.h | 2 +- eqlaunch/eqlaunch.cpp | 2 +- eqlaunch/worldserver.cpp | 2 +- loginserver/Client.cpp | 2 +- loginserver/Client.h | 4 +- loginserver/ClientManager.h | 4 +- loginserver/Main.cpp | 2 +- loginserver/ServerManager.h | 2 +- loginserver/WorldServer.h | 2 +- queryserv/database.cpp | 2 +- queryserv/lfguild.cpp | 2 +- queryserv/queryserv.cpp | 2 +- socket_server/database.cpp | 2 +- socket_server/socket_server.cpp | 2 +- tests/atobool_test.h | 2 +- tests/fixed_memory_test.h | 2 +- tests/hextoi_32_64_test.h | 2 +- ucs/chatchannel.cpp | 2 +- ucs/clientlist.cpp | 4 +- ucs/clientlist.h | 4 +- ucs/database.cpp | 4 +- ucs/ucs.cpp | 2 +- .../player_profile_set/MiscFunctions.cpp | 2 +- .../player_profile_set/database.h | 2 +- world/Adventure.cpp | 4 +- world/AdventureManager.cpp | 4 +- world/CMakeLists.txt | 2 +- world/EQLConfig.cpp | 2 +- world/EQW.cpp | 2 +- world/EQWHTTPHandler.h | 4 +- world/LauncherLink.cpp | 2 +- world/LoginServer.cpp | 2 +- world/client.cpp | 12 +- world/client.h | 2 +- world/cliententry.cpp | 2 +- world/clientlist.cpp | 2 +- world/console.cpp | 4 +- world/lfplist.cpp | 2 +- world/net.cpp | 13 +- world/world_logsys.cpp | 2 +- world/worlddb.cpp | 8 +- world/worlddb.h | 2 +- world/zonelist.cpp | 2 +- world/zoneserver.cpp | 2 +- zone/AA.cpp | 2 +- zone/MobAI.cpp | 4 +- zone/Object.cpp | 4 +- zone/QGlobals.cpp | 2 +- zone/QuestParserCollection.cpp | 2 +- zone/QuestParserCollection.h | 2 +- zone/aggro.cpp | 2 +- zone/attack.cpp | 2 +- zone/bonuses.cpp | 2 +- zone/bot.cpp | 2 +- zone/bot.h | 2 +- zone/botspellsai.cpp | 2 +- zone/client.cpp | 4 +- zone/client.h | 6 +- zone/client_mods.cpp | 2 +- zone/client_packet.cpp | 4 +- zone/client_process.cpp | 2 +- zone/command.cpp | 4 +- zone/command.h | 2 +- zone/corpse.cpp | 2 +- zone/doors.cpp | 2 +- zone/effects.cpp | 2 +- zone/embparser.cpp | 4 +- zone/embparser_api.cpp | 2 +- zone/exp.cpp | 2 +- zone/fearpath.cpp | 2 +- zone/forage.cpp | 4 +- zone/groups.cpp | 2 +- zone/guild.cpp | 4 +- zone/guild_mgr.cpp | 2 +- zone/hate_list.cpp | 2 +- zone/horse.cpp | 4 +- zone/inventory.cpp | 4 +- zone/loottables.cpp | 2 +- zone/lua_parser_events.cpp | 2 +- zone/map.cpp | 2 +- zone/merc.cpp | 4 +- zone/mob.cpp | 2 +- zone/net.cpp | 12 +- zone/npc.cpp | 4 +- zone/object.h | 2 +- zone/oldcode.cpp | 4 +- zone/pathing.cpp | 2 +- zone/perl_questitem.cpp | 2 +- zone/perlpacket.cpp | 2 +- zone/petitions.cpp | 2 +- zone/petitions.h | 2 +- zone/pets.cpp | 4 +- zone/questmgr.cpp | 2 +- zone/raids.cpp | 2 +- zone/spawn2.cpp | 2 +- zone/spawngroup.cpp | 4 +- zone/special_attacks.cpp | 2 +- zone/spell_effects.cpp | 2 +- zone/spells.cpp | 4 +- zone/tasks.cpp | 4 +- zone/titles.cpp | 2 +- zone/tradeskills.cpp | 4 +- zone/trading.cpp | 2 +- zone/trap.cpp | 4 +- zone/tribute.cpp | 2 +- zone/waypoints.cpp | 4 +- zone/worldserver.cpp | 2 +- zone/zone.cpp | 6 +- zone/zonedb.cpp | 4 +- zone/zonedbasync.cpp | 2 +- zone/zonedump.h | 2 +- zone/zoning.cpp | 2 +- 224 files changed, 424 insertions(+), 2857 deletions(-) delete mode 100644 common/EQNetwork.cpp delete mode 100644 common/EQNetwork.h delete mode 100644 common/MaxSkill.cpp rename common/{EQPacket.h => eq_packet.h} (99%) rename common/{EQStream.h => eq_stream.h} (99%) rename common/{EQStreamFactory.h => eq_stream_factory.h} (97%) rename common/{EQStreamIdent.h => eq_stream_ident.h} (97%) rename common/{EQStreamIntf.h => eq_stream_intf.h} (100%) rename common/{EQStreamLocator.h => eq_stream_locator.h} (100%) rename common/{EQStreamProxy.h => eq_stream_proxy.h} (98%) rename common/{EQStreamType.h => eq_stream_type.h} (100%) rename common/{EQEMuError.h => eqemu_error.h} (100%) rename common/{Item.h => item.h} (100%) rename common/{MiscFunctions.h => misc_functions.h} (100%) rename common/{MySQLRequestResult.h => mysql_request_result.h} (98%) rename common/{MySQLRequestRow.h => mysql_request_row.h} (100%) rename common/patches/{Client62.h => client62.h} (84%) rename common/patches/{Client62_constants.h => client62_constants.h} (100%) rename common/patches/{Client62_itemfields.h => client62_itemfields.h} (100%) rename common/patches/{Client62_ops.h => client62_ops.h} (100%) rename common/patches/{Client62_structs.h => client62_structs.h} (100%) rename common/patches/{RoF.h => rof.h} (87%) rename common/patches/{RoF_constants.h => rof_constants.h} (100%) rename common/patches/{RoF_itemfields.h => rof_itemfields.h} (100%) rename common/patches/{RoF_ops.h => rof_ops.h} (100%) rename common/patches/{RoF_structs.h => rof_structs.h} (100%) rename common/patches/{SoD.h => sod.h} (87%) rename common/patches/{SoD_constants.h => sod_constants.h} (100%) rename common/patches/{SoD_itemfields.h => sod_itemfields.h} (100%) rename common/patches/{SoD_ops.h => sod_ops.h} (100%) rename common/patches/{SoD_structs.h => sod_structs.h} (100%) rename common/patches/{SoF.h => sof.h} (87%) rename common/patches/{SoF_constants.h => sof_constants.h} (100%) rename common/patches/{SoF_itemfields.h => sof_itemfields.h} (100%) rename common/patches/{SoF_ops.h => sof_ops.h} (100%) rename common/patches/{SoF_structs.h => sof_structs.h} (100%) rename common/patches/{SSDeclare.h => ss_declare.h} (100%) rename common/patches/{SSDefine.h => ss_define.h} (100%) rename common/patches/{SSRegister.h => ss_register.h} (100%) rename common/patches/{Titanium.h => titanium.h} (87%) rename common/patches/{Titanium_constants.h => titanium_constants.h} (100%) rename common/patches/{Titanium_itemfields.h => titanium_itemfields.h} (100%) rename common/patches/{Titanium_ops.h => titanium_ops.h} (100%) rename common/patches/{Titanium_structs.h => titanium_structs.h} (100%) rename common/patches/{Underfoot.h => underfoot.h} (87%) rename common/patches/{Underfoot_constants.h => underfoot_constants.h} (100%) rename common/patches/{Underfoot_itemfields.h => underfoot_itemfields.h} (100%) rename common/patches/{Underfoot_ops.h => underfoot_ops.h} (100%) rename common/patches/{Underfoot_structs.h => underfoot_structs.h} (100%) rename common/{ProcLauncher.h => proc_launcher.h} (100%) rename common/{StringUtil.h => string_util.h} (100%) rename common/{StructStrategy.h => struct_strategy.h} (100%) rename common/{TCPBasicServer.h => tcp_basic_server.h} (89%) rename common/{TCPConnection.h => tcp_connection.h} (99%) rename common/{TCPServer.h => tcp_server.h} (100%) rename common/{XMLParser.h => xml_parser.h} (100%) rename common/{ZoneNumbers.h => zone_numbers.h} (100%) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index b5669338e..c4faa4718 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -23,7 +23,7 @@ #include "../../common/platform.h" #include "../../common/crash.h" #include "../../common/rulesys.h" -#include "../../common/StringUtil.h" +#include "../../common/string_util.h" void ExportSpells(SharedDatabase *db); void ExportSkillCaps(SharedDatabase *db); diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 3a0968d92..9683e3bfe 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -22,7 +22,7 @@ #include "../../common/platform.h" #include "../../common/crash.h" #include "../../common/rulesys.h" -#include "../../common/StringUtil.h" +#include "../../common/string_util.h" void ImportSpells(SharedDatabase *db); void ImportSkillCaps(SharedDatabase *db); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index f15e57c51..ccea68596 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -119,15 +119,15 @@ SET(common_headers eqemu_exception.h eqemu_config.h eqemu_config_elements.h - EQEMuError.h - EQPacket.h - EQStream.h - EQStreamFactory.h - EQStreamIdent.h - EQStreamIntf.h - EQStreamLocator.h - EQStreamProxy.h - EQStreamType.h + eqemu_error.h + eq_packet.h + eq_stream.h + eq_stream_factory.h + eq_stream_ident.h + eq_stream_intf.h + eq_stream_locator.h + eq_stream_proxy.h + eq_stream_type.h eqtime.h errmsg.h extprofile.h @@ -138,7 +138,7 @@ SET(common_headers guild_base.h guilds.h ipc_mutex.h - Item.h + item.h item_fieldlist.h item_struct.h languages.h @@ -150,18 +150,19 @@ SET(common_headers md5.h memory_mapped_file.h misc.h - MiscFunctions.h + misc_functions.h moremath.h Mutex.h - MySQLRequestResult.h - MySQLRequestRow.h + mysql_request_result.h + mysql_request_row.h op_codes.h opcode_dispatch.h opcodemgr.h packet_dump.h packet_dump_file.h packet_functions.h - ProcLauncher.h + platform.h + proc_launcher.h profiler.h ptimer.h queue.h @@ -175,11 +176,11 @@ SET(common_headers shareddb.h skills.h spdat.h - StringUtil.h - StructStrategy.h - TCPBasicServer.h - TCPConnection.h - TCPServer.h + string_util.h + struct_strategy.h + tcp_basic_server.h + tcp_connection.h + tcp_server.h timeoutmgr.h timer.h types.h @@ -187,44 +188,43 @@ SET(common_headers useperl.h version.h worldconn.h - XMLParser.h - ZoneNumbers.h - platform.h - patches/Client62.h - patches/Client62_constants.h - patches/Client62_itemfields.h - patches/Client62_ops.h - patches/Client62_structs.h + xml_parser.h + zone_numbers.h + patches/client62.h + patches/client62_constants.h + patches/client62_itemfields.h + patches/client62_ops.h + patches/client62_structs.h patches/patches.h - patches/SoD.h - patches/SoD_constants.h - patches/SoD_itemfields.h - patches/SoD_ops.h - patches/SoD_structs.h - patches/SoF.h - patches/SoF_constants.h - patches/SoF_itemfields.h - patches/SoF_opcode_list.h - patches/SoF_ops.h - patches/SoF_structs.h - patches/SSDeclare.h - patches/SSDefine.h - patches/SSRegister.h - patches/RoF.h - patches/RoF_constants.h - patches/RoF_itemfields.h - patches/RoF_ops.h - patches/RoF_structs.h - patches/Titanium.h - patches/Titanium_constants.h - patches/Titanium_itemfields.h - patches/Titanium_ops.h - patches/Titanium_structs.h - patches/Underfoot.h - patches/Underfoot_constants.h - patches/Underfoot_itemfields.h - patches/Underfoot_ops.h - patches/Underfoot_structs.h + patches/sod.h + patches/sod_constants.h + patches/sod_itemfields.h + patches/sod_ops.h + patches/sod_structs.h + patches/sof.h + patches/sof_constants.h + patches/sof_itemfields.h + patches/sof_opcode_list.h + patches/sof_ops.h + patches/sof_structs.h + patches/ss_declare.h + patches/ss_define.h + patches/ss_register.h + patches/rof.h + patches/rof_constants.h + patches/rof_itemfields.h + patches/rof_ops.h + patches/rof_structs.h + patches/titanium.h + patches/titanium_constants.h + patches/titanium_itemfields.h + patches/titanium_ops.h + patches/titanium_structs.h + patches/underfoot.h + patches/underfoot_constants.h + patches/underfoot_itemfields.h + patches/underfoot_ops.h + patches/underfoot_structs.h SocketLib/Base64.h SocketLib/File.h SocketLib/HttpdCookies.h @@ -243,54 +243,48 @@ SET(common_headers ) SOURCE_GROUP(Patches FILES - patches/Client62.h - patches/Client62_itemfields.h - patches/Client62_ops.h - patches/Client62_constants.h - patches/Client62_structs.h + patches/client62.h + patches/client62_itemfields.h + patches/client62_ops.h + patches/client62_constants.h + patches/client62_structs.h patches/patches.h - patches/SoD.h - patches/SoD_itemfields.h - patches/SoD_ops.h - patches/SoD_constants.h - patches/SoD_structs.h - patches/SoF.h - patches/SoF_itemfields.h - patches/SoF_opcode_list.h - patches/SoF_ops.h - patches/SoF_constants.h - patches/SoF_structs.h - patches/SSDeclare.h - patches/SSDefine.h - patches/SSRegister.h - patches/RoF.h - patches/RoF_itemfields.h - patches/RoF_ops.h - patches/RoF_constants.h - patches/RoF_structs.h - #patches/RoF2.h - #patches/RoF2_itemfields.h - #patches/RoF2_ops.h - #patches/RoF2_constants.h - #patches/RoF2_structs.h - patches/Titanium.h - patches/Titanium_itemfields.h - patches/Titanium_ops.h - patches/Titanium_constants.h - patches/Titanium_structs.h - patches/Underfoot.h - patches/Underfoot_itemfields.h - patches/Underfoot_ops.h - patches/Underfoot_constants.h - patches/Underfoot_structs.h - patches/Client62.cpp + patches/sod.h + patches/sod_itemfields.h + patches/sod_ops.h + patches/sod_constants.h + patches/sod_structs.h + patches/sof.h + patches/sof_itemfields.h + patches/sof_opcode_list.h + patches/sof_ops.h + patches/sof_constants.h + patches/sof_structs.h + patches/ss_declare.h + patches/ss_define.h + patches/ss_register.h + patches/rof.h + patches/rof_itemfields.h + patches/rof_ops.h + patches/rof_constants.h + patches/rof_structs.h + patches/titanium.h + patches/titanium_itemfields.h + patches/titanium_ops.h + patches/titanium_constants.h + patches/titanium_structs.h + patches/underfoot.h + patches/underfoot_itemfields.h + patches/underfoot_ops.h + patches/underfoot_constants.h + patches/underfoot_structs.h + patches/client62.cpp patches/patches.cpp - patches/SoD.cpp - patches/SoF.cpp - patches/RoF.cpp - #patches/RoF2.cpp - patches/Titanium.cpp - patches/Underfoot.cpp + patches/sod.cpp + patches/sof.cpp + patches/rof.cpp + patches/titanium.cpp + patches/underfoot.cpp ) SOURCE_GROUP(SocketLib FILES @@ -339,8 +333,7 @@ ADD_LIBRARY(common ${common_sources} ${common_headers}) IF(UNIX) ADD_DEFINITIONS(-fPIC) - #TODO: Add "patches/RoF2.cpp" when it becomes active - SET_SOURCE_FILES_PROPERTIES("patches/SoD.cpp" "patches/SoF.cpp" "patches/RoF.cpp" "patches/Underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0) + SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0) ENDIF(UNIX) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/common/EQNetwork.cpp b/common/EQNetwork.cpp deleted file mode 100644 index c4ec019ea..000000000 --- a/common/EQNetwork.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * EQStream classes, by Quagmire -*/ - -#include "../common/debug.h" - -#include -#include -#ifdef WIN32 - #include -#else - #include - #include - #include - #include - #include - #include - #include - #include - #include "../common/unix.h" - #define SOCKET_ERROR -1 -#endif -#include "EQNetwork.h" -#include "EQStream.h" -#include "../common/packet_dump.h" -#include "../common/packet_dump_file.h" -#include "../common/packet_functions.h" -#include "../common/MiscFunctions.h" -#include "../common/crc32.h" -#include "../common/eq_packet_structs.h" - -#define EQN_DEBUG 0 -#define EQN_DEBUG_Error 0 -#define EQN_DEBUG_Packet 0 -#define EQN_DEBUG_Fragment 0 -#define EQN_DEBUG_ACK 0 -#define EQN_DEBUG_Unknown 0 -#define EQN_DEBUG_NewStream 0 -#define LOG_PACKETS 0 -#define LOG_RAW_PACKETS_OUT 0 -#define LOG_RAW_PACKETS_IN 0 -//#define PRIORITYTEST - -template // LO_BYTE -type LO_BYTE (type a) {return (a&=0xff);} -template // HI_BYTE -type HI_BYTE (type a) {return (a&=0xff00);} -template // LO_WORD -type LO_WORD (type a) {return (a&=0xffff);} -template // HI_WORD -type HI_WORD (type a) {return (a&=0xffff0000);} -template // HI_LOSWAPshort -type HI_LOSWAPshort (type a) {return (LO_BYTE(a)<<8) | (HI_BYTE(a)>>8);} -template // HI_LOSWAPlong -type HI_LOSWAPlong (type x) {return (LO_WORD(a)<<16) | (HIWORD(a)>>16);} - -EQStreamServer::EQStreamServer(uint16 iPort) { - RunLoop = false; - pPort = iPort; - pOpen = false; -#ifdef WIN32 - WORD version = MAKEWORD (1,1); - WSADATA wsadata; - WSAStartup (version, &wsadata); -#endif - sock = 0; -} - -EQStreamServer::~EQStreamServer() { - Close(); - RunLoop = false; - MLoopRunning.lock(); - MLoopRunning.unlock(); -#ifdef WIN32 - WSACleanup(); -#endif - connection_list.clear(); - while (!NewQueue.empty()) - NewQueue.pop(); // they're deleted with the list, clear this queue so it doesnt try to delete them again -} - -bool EQStreamServer::Open(uint16 iPort) { - LockMutex lock(&MOpen); - if (iPort && pPort != iPort) { - if (pOpen) - return false; - pPort = iPort; - } - if (!RunLoop) { - RunLoop = true; -#ifdef WIN32 - _beginthread(EQStreamServerLoop, 0, this); -#else - pthread_t thread; - pthread_create(&thread, NULL, &EQStreamServerLoop, this); -#endif - } - if (pOpen) { - return true; - } - else { - struct sockaddr_in address; -// int reuse_addr = 1; - int bufsize = 64 * 1024; // 64kbyte send/recieve buffers, up from default of 8k -#ifdef WIN32 - unsigned long nonblocking = 1; -#endif - - /* Setup internet address information. - This is used with the bind() call */ - memset((char *) &address, 0, sizeof(address)); - address.sin_family = AF_INET; - address.sin_port = htons(pPort); - address.sin_addr.s_addr = htonl(INADDR_ANY); - - /* Setting up UDP port for new clients */ - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock < 0) { - return false; - } - -//#ifdef WIN32 -// setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse_addr, sizeof(reuse_addr)); - setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize)); - setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char*) &bufsize, sizeof(bufsize)); -//#else -// setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr)); -// setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)); -// setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); -//#endif - - if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) { -#ifdef WIN32 - closesocket(sock); -#else - close(sock); -#endif - return false; - } - -#ifdef WIN32 - ioctlsocket (sock, FIONBIO, &nonblocking); -#else - fcntl(sock, F_SETFL, O_NONBLOCK); -#endif - pOpen = true; - return true; - } -} - -void EQStreamServer::Close() { - SetOpen(false); - if (sock) { -#ifdef WIN32 - closesocket(sock); -#else - close(sock); -#endif - } - sock = 0; -} - -bool EQStreamServer::IsOpen() { - MOpen.lock(); - bool ret = pOpen; - MOpen.unlock(); - return ret; -} - -void EQStreamServer::SetOpen(bool iOpen) { - MOpen.lock(); - pOpen = iOpen; - MOpen.unlock(); -} - -void EQStreamServer::Process() { - _CP(EQStreamServer_Process); - if (!IsOpen()) { - if (sock) { -#ifdef WIN32 - closesocket(sock); -#else - close(sock); -#endif - sock = 0; - } - return; - } - - uchar buffer[1518]; - - int status; - struct sockaddr_in from; - unsigned int fromlen; - - from.sin_family = AF_INET; - fromlen = sizeof(from); - - while (1) { -#ifdef WIN32 - status = recvfrom(sock, (char *) buffer, sizeof(buffer), 0,(struct sockaddr*) &from, (int *) &fromlen); -#else - status = recvfrom(sock, buffer, sizeof(buffer), 0,(struct sockaddr*) &from, &fromlen); -#endif - if (status >= 1) { - cout << "Got data from recvfrom" << endl; - RecvData(buffer, status, from.sin_addr.s_addr, from.sin_port); - } - else { - break; - } - } - - std::map ::iterator connection; - for (connection = connection_list.begin(); connection != connection_list.end();) { - if (!connection->second) { - connection = connection_list.erase(connection); - continue; - } - EQStream* eqs_data = connection->second; - if (eqs_data->IsFree() && (!eqs_data->CheckNetActive())) { - safe_delete(eqs_data); - connection = connection_list.erase(connection); - } else if (!eqs_data->RunLoop) { - eqs_data->Process(sock); - ++connection; - } - } -} - -void EQStreamServer::RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPort) { -/* - CHANGE HISTORY - - Version Author Date Comment - 1 Unknown Unknown Initial Revision - 2 Joolz 05-Jan-2003 Optimised - 3 Quagmire 05-Feb-2003 Changed so 2 connection objects wouldnt be created for the same ip/port pair, often happened -*/ - - // Check for invalid data - if (!data || size <= 4) return; - //if (CRC32::Generate(data, size-4) != ntohl(*((uint32*) &data[size-4]))) { -#if EQN_DEBUG_Error >= 1 - //cout << "Incomming Packet failed checksum" << endl; -#endif - //return; - //} - - char temp[25]; - sprintf(temp,"%lu:%u",(unsigned long)irIP,irPort); - cout << "Data from " << temp << endl; - EQStream* tmp = NULL; - std::map ::iterator connection; - if ((connection=connection_list.find(temp))!=connection_list.end()) - tmp=connection->second; - if(tmp != NULL && tmp->GetrPort() == irPort) - { - tmp->RecvData(data, size); - return; - } - else if(tmp != NULL && tmp->GetrPort() != irPort) - { - printf("Conflicting IPs & Ports: IP %i and Port %i is conflicting with IP %i and Port %i\n",irIP,irPort,tmp->GetrIP(),tmp->GetrPort()); - return; - } - - if (data[1]==0x01) { - cout << "New EQStream Connection." << endl; - EQStream* tmp = new EQStream(irIP, irPort); - tmp->RecvData(data, size); - connection_list[temp]=tmp; - if (connection_list.find(temp)==connection_list.end()) { - cerr <<"Could not find new connection we just added!" << endl; - } - MNewQueue.lock(); - NewQueue.push(tmp); - MNewQueue.unlock(); - return; - } -#if EQN_DEBUG >= 4 - struct in_addr in; - in.s_addr = irIP; - cout << "WARNING: Stray packet? " << inet_ntoa(in) << ":" << irPort << endl; -#endif -} - -EQStream* EQStreamServer::NewQueuePop() { - EQStream* ret = 0; - MNewQueue.lock(); - if (!NewQueue.empty()) { - ret = NewQueue.front(); - NewQueue.pop(); - } - MNewQueue.unlock(); - return ret; -} - -#ifdef WIN32 - void EQStreamServerLoop(void* tmp) -#else - void* EQStreamServerLoop(void* tmp) -#endif -{ -#ifdef WIN32 - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); -#endif - EQStreamServer* eqns = (EQStreamServer*) tmp; - eqns->MLoopRunning.lock(); - while (eqns->RunLoop) { - { - _CP(EQStreamServerLoop); - eqns->Process(); - } - Sleep(1); - } - eqns->MLoopRunning.unlock(); -#ifdef WIN32 - _endthread(); -#else - return 0; -#endif -} - -#ifdef WIN32 - void EQStreamInLoop(void* tmp) -#else - void* EQStreamInLoop(void* tmp) -#endif -{ - EQStream* eqs = (EQStream*) tmp; -#ifdef _DEBUG - if (eqs->ConnectionType != Outgoing) { - ThrowError("EQStreamInLoop: eqs->ConnectionType != Outgoing"); - } -#endif - eqs->MLoopRunning.lock(); - Timer* tmp_timer = new Timer(100); - tmp_timer->Start(); - while (eqs->RunLoop) { - { - _CP(EQStreamInLoop); - if(tmp_timer->Check()) - eqs->DoRecvData(); - } - Sleep(1); - } - safe_delete(tmp_timer); - eqs->MLoopRunning.unlock(); -#ifdef WIN32 - _endthread(); -#else - return 0; -#endif -} - -#ifdef WIN32 - void EQStreamOutLoop(void* tmp) -#else - void* EQStreamOutLoop(void* tmp) -#endif -{ - EQStream* eqs = (EQStream*) tmp; -#ifdef _DEBUG - if (eqs->ConnectionType != Outgoing) { - ThrowError("EQStreamOutLoop: eqs->ConnectionType != Outgoing"); - } -#endif - eqs->MLoopRunning.lock(); - Timer* tmp_timer = new Timer(100); - tmp_timer->Start(); - while (eqs->RunLoop) { - { - _CP(EQStreamOutLoop); - if(tmp_timer->Check()) - eqs->Process(eqs->outsock); - } - Sleep(1); - } - safe_delete(tmp_timer); - eqs->MLoopRunning.unlock(); -#ifdef WIN32 - _endthread(); -#else - return 0; -#endif -} - diff --git a/common/EQNetwork.h b/common/EQNetwork.h deleted file mode 100644 index 1ecb23d6d..000000000 --- a/common/EQNetwork.h +++ /dev/null @@ -1,120 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef EQNETWORK_H -#define EQNETWORK_H - -#include "../common/debug.h" - -//uncomment this to enable the packet profiler. Counts the number -//of each type of packet sent or received on a connection. -#ifdef ZONE -//#define PACKET_PROFILER 1 -#endif - -#include -#include -#include -#include - -#include "../common/types.h" -#include "../common/timer.h" -#include "../common/linked_list.h" -#include "../common/queue.h" -#include "../common/Mutex.h" -#include "../common/packet_functions.h" -#include "EQStream.h" -#ifdef PACKET_PROFILER -#include "../common/rdtsc.h" -#endif - -#define EQNC_TIMEOUT 60000 -#define NAS_TIMER 100 -#define KA_TIMER 400 /* keeps the lag bar constant */ -#define MAX_HEADER_SIZE 39 // Quag: 39 is the max header + opcode + crc32 + unknowns size - -class EQStreamServer; -class EQStream; -class EQStreamPacket; -class EQStreamFragmentGroupList; -class EQStreamFragmentGroup; -typedef EQStreamServer EQNServer; -typedef EQStream EQNConnection; -typedef EQStreamPacket EQNPacket; -typedef EQStreamFragmentGroupList EQNFragmentGroupList; -typedef EQStreamFragmentGroup EQNFragmentGroup; - -#define FLAG_COMPRESSED 0x1000 -#define FLAG_COMBINED 0x2000 -#define FLAG_ENCRYPTED 0x4000 -#define FLAG_IMPLICIT 0x8000 -#define FLAG_ALL 0xF000 -#define StripFlags(x) (x & ~FLAG_ALL) - -// Optimistic compression, used for guessing pre-alloc size on debug output -#define BEST_COMPR_RATIO 300 - -enum eappCompressed { appNormal, appInflated, appDeflated }; - -#ifdef WIN32 - void EQStreamServerLoop(void* tmp); - void EQStreamInLoop(void* tmp); - void EQStreamOutLoop(void* tmp); -#else - void* EQStreamServerLoop(void* tmp); - void* EQStreamInLoop(void* tmp); - void* EQStreamOutLoop(void* tmp); -#endif -class EQStreamServer { -public: - EQStreamServer(uint16 iPort = 0); - virtual ~EQStreamServer(); - - bool Open(uint16 iPort = 0); // opens the port - void Close(); // closes the port - void KillAll(); // kills all clients - inline uint16 GetPort() { return pPort; } - - EQStream* NewQueuePop(); -protected: -#ifdef WIN32 - friend void EQStreamServerLoop(void* tmp); -#else - friend void* EQStreamServerLoop(void* tmp); -#endif - void Process(); - bool IsOpen(); - void SetOpen(bool iOpen); - bool RunLoop; - Mutex MLoopRunning; -private: - void RecvData(uchar* data, uint32 size, uint32 irIP, uint16 irPort); -#ifdef WIN32 - SOCKET sock; -#else - int sock; -#endif - uint16 pPort; - bool pOpen; - Mutex MNewQueue; - Mutex MOpen; - - std::map connection_list; - std::queue NewQueue; -}; - -#endif diff --git a/common/MaxSkill.cpp b/common/MaxSkill.cpp deleted file mode 100644 index d24ffbc91..000000000 --- a/common/MaxSkill.cpp +++ /dev/null @@ -1,1900 +0,0 @@ -#include "../common/races.h" -#include "../common/classes.h" -#include "../zone/skills.h" - -uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level); -/* TODO: - Load MaxSkillTable function into ram as a really big matrix: - MaxSkillTable[skillid][race][eqclass][level] - - in preperation for that, dont put anything that wont work in - that table into MaxSkillTable (ie, AA checks, skill values that - depend on other skill values, etc), put it into MaxSkill instead -*/ -uint8 MaxSkill(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) { - uint8 ret = MaxSkillTable(skillid, race, eqclass, level); - return ret; -} - -/* SPECIAL VALUES: - level: - 0 = "skill level at character create" - TODO: catch levels > 65 (ie, npcs) - race: - NPCs will always have their skills maxed, and often ignore class - restrictions, accomplished by the special values below. - EMU_RACE_NPC - EMU_RACE_PET - EMU_RACE_UNKNOWN - return value: - TODO: Find out the specal values for the client for "your class/race doesnt have this skill" and - "must put one point in at GM", etc - -*/ -uint8 MaxSkillTable(uint16 skillid, uint16 race, uint16 eqclass, uint16 level) { - uint16 r_value = 0; - - switch (skillid) { - /////////////// - // Melee Weapon/ Hand to Hand - /////////////// - case _1H_BLUNT: - case _2H_BLUNT: - case PIERCING: - case HAND_TO_HAND: - case _1H_SLASHING: - case _2H_SLASHING:{ - switch (eqclass) { - // Pure melee classes - case WARRIOR: case WARRIORGM: { - r_value = 5 + (level*5); - if ( level < 51 && r_value > 200) - r_value = 200; - if ( level > 51 && r_value > 250 ) - r_value = 250; - switch (skillid) { - case PIERCING: { - if ( r_value > 240 ) - r_value = 240; - break; - } - case HAND_TO_HAND: { - if ( r_value > 100 ) - r_value = 100; - break; - } - default: - break; - } - break; - } - case MONK: case MONKGM: { - r_value = 5 + (level*5); - if ( level < 51 && r_value > 240) - if ( r_value > 240 ) - r_value = 240; - if ( r_value > 252 ) - r_value = 252; - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 225 && level < 51 ) - r_value = 225; - break; - } - case PIERCING: - case _1H_SLASHING: - case _2H_SLASHING:{ - r_value = 0; - break; - } - default: - break; - } - break; - } - case ROGUE: case ROGUEGM: { - r_value = 5 + (level*5); - if ( level > 50 ) { - if ( r_value > 250 ) - r_value = 250; - } - else if ( level < 51 ) { - if ( r_value > 200 && skillid != PIERCING ) - r_value = 200; - switch (skillid) { - case PIERCING: { - if (r_value > 210) - r_value = 210; - break; - } - default: - break; - } - } - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 100 ) - r_value = 100; - break; - } - default: - break; - - } - break; - } - - ////////////////////////////////////////////////////////////// - // Melee Weapon/ Hand to Hand - // Priest classes - ////////////////////////////////////////////////////////////// - case CLERIC: case CLERICGM:{ - r_value = 4 + (level*4); - if ( r_value > 175 ){ - r_value = 175; - } - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 75 ) - r_value = 75; - break; - } - case PIERCING: - case _1H_SLASHING: - case _2H_SLASHING: { - r_value = 0; - break; - } - default: - break; - } - break; - } - case DRUID: case DRUIDGM:{ - r_value = 4 + (level*4); - if ( r_value > 175 ){ - r_value = 175; - } - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 75 ) - r_value = 75; - } - case PIERCING: - case _2H_SLASHING:{ - r_value = 0; - break; - } - default: - break; - } - break; - } - case SHAMAN: case SHAMANGM:{ - r_value = 4 + (level*4); - if ( r_value > 200 ){ - r_value = 200; - } - switch (skillid) { - case HAND_TO_HAND: { - if ( r_value > 75 ) - r_value = 75; - } - case _1H_SLASHING: - case _2H_SLASHING:{ - r_value = 0; - break; - } - default: - break; - } - break; - } - - /////////////////////////////////////////////////////////// - // Melee Weapon/ Hand to Hand - // Hybrids - ////////////////////////////////////////////////////////// - case RANGER: case RANGERGM:{ - r_value = 5 + (level*5); - if ( level > 50 ) { - if ( r_value > 250 ) - r_value = 250; - - switch (skillid) { - case PIERCING: { - if ( r_value > 240 ) - r_value = 240; - break; - } - default: - break; - } - } - else if ( level < 51 ) { - if ( r_value > 200 ) - r_value = 200; - } - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 100 ) - r_value = 100; - break; - } - default: - break; - } - break; - } - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - r_value = 5 + (level*5); - if ( level > 50 ){ - if ( r_value > 225 ) - r_value = 225; - } - if ( level < 51 ){ - if ( r_value > 200 ) - r_value = 200; - } - - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 100 ) - r_value = 100; - break; - } - default: - break; - } - break; - } - case BARD: case BARDGM: { - r_value = 5 + (level*5); - if ( level > 51 && r_value > 225 ) - r_value = 225; - if ( level < 51 && r_value > 200 ) - r_value = 200; - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 100 ) - r_value = 100; - break; - } - case _2H_BLUNT: - case _2H_SLASHING:{ - r_value = 0; - - } - default: - break; - } - break; - } - - case BEASTLORD: case BEASTLORDGM:{ - r_value = 4 + (level*4); - if ( level > 51 ){ - if ( r_value > 225 && skillid != HAND_TO_HAND ) - r_value = 225; - } - if ( r_value > 250 ) - r_value = 250; - if ( level < 51 && r_value > 200 ) - r_value = 200; - - switch (skillid) { - case HAND_TO_HAND:{ - r_value = 5 + (level*5); - if ( level < 51 ) - r_value = 200; - - if ( r_value > 250 ) - r_value = 250; - break; - } - case _1H_SLASHING: - case _2H_SLASHING:{ - r_value = 0; - break; - } - default: - break; - } - break; - } - - // Melee Weapon/ Hand to Hand - // Pure casters - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM:{ - r_value = 3 + (level*3); - if ( r_value > 110 ) - r_value = 110; - switch (skillid) { - case HAND_TO_HAND:{ - if ( r_value > 75 ) - r_value = 75; - break; - } - case _1H_SLASHING: - case _2H_SLASHING:{ - r_value = 0; - break; - } - default: - break; - } - } - default: { - r_value = 0; - break; - } - }// end switch(eqclass) - break; - } // end case weapon skills - - -///////////////////////////////////////////////////////////// -// Combat non weapon -///////////////////////////////////////////////////////////// - -// Attack - case OFFENSE: { - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM: - case ROGUE: case ROGUEGM:{ - // 210 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 252) - r_value = 252; - break; - } - case MONK: case MONKGM:{ - // 230 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 230) - r_value = 230; - } - if (r_value > 252) - r_value = 252; - break; - } - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM:{ - // 200 200 4*level+4 - r_value = ((level*4) + 4); - if (r_value > 200) - r_value = 200; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM:{ - // 200 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 252) - r_value = 252; - break; - } - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - case BARD: case BARDGM:{ - // 200 225 5*level+5 - - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 225) - r_value = 225; - break; - } - case RANGER: case RANGERGM:{ - // 210 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 252) - r_value = 252; - break; - } - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM:{ - // 140 140 level*4 - r_value = (level*4); - if (r_value > 140) - r_value = 140; - break; - } - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case OFFENSE - case THROWING: { - switch (eqclass) { - // Melee - case ROGUE: case ROGUEGM:{ - // 220 250 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 220) - r_value = 220; - } - if (r_value > 250) - r_value = 250; - break; - } - case WARRIOR: case WARRIORGM: - case MONK: case MONKGM:{ - // 113 200 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 113) - r_value = 113; - } - if (r_value > 200) - r_value = 200; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case BARD: case BARDGM: - case RANGER: case RANGERGM:{ - // 113 - r_value = ((level*5) + 5); - if ( r_value > 113 ) - r_value = 113; - break; - } - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM:{ - // 75 - r_value = ((level*3) + 3); - if ( r_value > 75 ) - r_value = 75; - break; - } - // No skill classes - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case THROWING: - case ARCHERY: { - switch (eqclass) { - // Melee - case ROGUE: case ROGUEGM: - case WARRIOR: case WARRIORGM:{ - // 200 240 - r_value = ((level*5) + 5); - if ( level < 51 && r_value > 200) - r_value = 200; - if (r_value > 240) - r_value = 240; - break; - } - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 75 75 - r_value = ((level*5) + 5); - if ( r_value > 75 ) - r_value = 75; - break; - } - case RANGER: case RANGERGM:{ - // 240 240 - r_value = ((level*5) + 5); - if ( r_value > 240 ) - r_value = 240; - break; - } - // Pure - // No skill classes - // Melee - case MONK: case MONKGM: - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case BARD: case BARDGM: - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case ARCHERY: - case DOUBLE_ATTACK: { - switch (eqclass) { - // Melee - case ROGUE: case ROGUEGM:{ - // 16 200 240 - r_value = ((level*5) + 5); - if ( level < 16 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 240) - r_value = 240; - break; - } - case WARRIOR: case WARRIORGM:{ - // 15 205 245 - r_value = ((level*5) + 5); - if ( level < 15 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 245) - r_value = 245; - break; - } - case MONK: case MONKGM:{ - // 15 210 250 - r_value = ((level*5) + 5); - if ( level < 15 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 250) - r_value = 250; - break; - } - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 20 200 235 - r_value = ((level*5) + 5); - if ( level < 20 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 235) - r_value = 235; - break; - } - case RANGER: case RANGERGM:{ - // 20 200 245 - r_value = ((level*5) + 5); - if ( level < 20 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 245) - r_value = 245; - break; - } - // Pure - // No skill classes - // Melee - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case BARD: case BARDGM: - default: { - r_value = 0; - - break; - } - } // end switch (eqclass) - break; - } // end case DOUBLE_ATTACK: - case DUEL_WIELD: { - switch (eqclass) { - // Melee - case MONK: case MONKGM:{ - // 1 252 252 - r_value = level*7; // This can't be right can it? - break; - } - case WARRIOR: case WARRIORGM: - case ROGUE: case ROGUEGM: { - // 15 210 245 - r_value = ((level*5) + 5); - if ( level < 15 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 245) - r_value = 245; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM: - // 17 210 245 - case RANGER: case RANGERGM:{ - // 17 210 245 - r_value = ((level*5) + 5); - if ( level < 17 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 245) - r_value = 245; - break; - } - case BARD: case BARDGM:{ - // 17 210 210 - r_value = ((level*5) + 5); - if ( level < 17 ) - r_value = 0; - if (r_value > 210) - r_value = 210; - break; - } - // No skill classes - // Melee - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - default: { - r_value = 0; - break; - } - }// end Class switch - break; - } // end case DUEL_WIELD: - case KICK: { - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 1 149 210 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 149) - r_value = 149; - } - if (r_value > 210) - r_value = 210; - break; - } - case MONK: case MONKGM:{ - // 1 200 250 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 250) - r_value = 250; - break; - } - // Hybrid - case RANGER: case RANGERGM:{ - // 5 149 205 - r_value = ((level*5) + 5); - if ( level < 5 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 149) - r_value = 149; - } - if (r_value > 205) - r_value = 205; - break; - } - case BEASTLORD: case BEASTLORDGM:{ - // 5 180 230 - r_value = ((level*5) + 5); - if ( level < 5 ) - r_value = 0; - if ( level < 51 ) { - if (r_value > 180) - r_value = 180; - } - if (r_value > 230) - r_value = 230; - break; - } - // Pure - // No skill classes - case ROGUE: case ROGUEGM: - // Melee - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - case BARD: case BARDGM: - default: { - r_value = 0; - break; - } - } // end switch(eqclass) - break; - } // end case KICK: - /////////// - // FIXME Where is slam? - // Quagmire: Slam = bash w/ race check - case BASH:{ - r_value = ((level*5)+5); - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 6 220 240 - if (level < 6) - r_value = 0; - if (level < 51 && r_value > 220) - r_value = 220; - if (r_value > 240) - r_value = 240; - break; - } - // Priest - case CLERIC: case CLERICGM:{ - // 25 180 200 - if (level < 25) - r_value = 0; - if (level < 51 && r_value > 180) - r_value = 180; - if (r_value > 200) - r_value = 200; - break; - } - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 6 175 200 - if (level < 6) - r_value = 0; - if (level < 51 && r_value > 175) - r_value = 175; - if (r_value > 200) - r_value = 200; - break; - } - // Pure - // No skill classes - // Melee - case MONK: case MONKGM: - case ROGUE: case ROGUEGM: - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case RANGER: case RANGERGM: - case BARD: case BARDGM:{ - switch (race) { - case BARBARIAN: - case TROLL: - case OGRE:{ - r_value = 50; - break; - } - default: { - break; - } - } // end switch (race) - r_value = 0; - break; - } - } - break; - } // end case BASH: - ///////////////////////////////////// - ///////////////////////////////////// - // Defensive skills - case DEFENSE:{ - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 210 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 252) - r_value = 252; - break; - } - case ROGUE: case ROGUEGM:{ - // 200 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 252) - r_value = 252; - break; - } - case MONK: case MONKGM:{ - // 230 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 230) - r_value = 230; - } - if (r_value > 252) - r_value = 252; - break; - } - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM:{ - // 200 200 4*level+4 - r_value = ((level*4) + 4); - if (r_value > 200) - r_value = 200; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM:{ - // 210 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 252) - r_value = 252; - break; - } - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 210 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 210) - r_value = 210; - } - if (r_value > 252) - r_value = 252; - break; - } - case BARD: case BARDGM:{ - // 200 252 5*level+5 - r_value = ((level*5) + 5); - if ( level < 51 ) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 252) - r_value = 252; - break; - } - case RANGER: case RANGERGM:{ - // 200 200 5*level+5 - r_value = ((level*5) + 5); - if (r_value > 200) - r_value = 200; - break; - } - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM:{ - // 145 145 level*4 - r_value = (level*4); - if (r_value > 140) - r_value = 140; - break; - } - default: { - break; - } - } // end switch(eqclass) - break; - } // end case DEFENSE: - case PARRY:{ - switch (eqclass) { - // Melee - case ROGUE: case ROGUEGM:{ - // 12 200 230 - r_value = ((level*5) + 5); - if ( level < 12 ) - r_value = 0; - if (r_value > 200 && level < 51 ) - r_value = 200; - if (r_value > 230) - r_value = 230; - break; - } - case WARRIOR: case WARRIORGM:{ - // 10 200 230 - r_value = ((level*5) + 5); - if ( level < 10 ) - r_value = 0; - if (r_value > 200 && level < 51 ) - r_value = 200; - if (r_value > 230) - r_value = 230; - break; - } - // Hybrid - case BARD: case BARDGM:{ - // 53 0 75 - r_value = ((level*5) + 5); - if ( level < 53 ) - r_value = 0; - if (r_value > 75) - r_value = 75; - break; - } - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 17 175 205 - r_value = ((level*5) + 5); - if ( level < 17 ) - r_value = 0; - if (r_value > 175 && level < 51 ) - r_value = 175; - if (r_value > 205) - r_value = 205; - break; - } - case RANGER: case RANGERGM:{ - // 18 185 220 - r_value = ((level*5) + 5); - if ( level < 18 ) - r_value = 0; - if (r_value > 185 && level < 51 ) - r_value = 185; - if (r_value > 220) - r_value = 220; - break; - } - // Pure - // No skill classes - // Melee - case MONK: case MONKGM: - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BEASTLORD: case BEASTLORDGM: - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case PARRY: - case RIPOSTE:{ - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 25 200 225 - r_value = ((level*5) + 5); - if ( level < 25 ) - r_value = 0; - if (r_value > 200 && level < 51 ) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case ROGUE: case ROGUEGM:{ - // 30 200 225 - r_value = ((level*5) + 5); - if ( level < 30 ) - r_value = 0; - if (r_value > 200 && level < 51 ) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case MONK: case MONKGM:{ - // 35 200 225 - r_value = ((level*5) + 5); - if ( level < 35 ) - r_value = 0; - if (r_value > 200 && level < 51 ) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM:{ - // 40 150 185 - r_value = ((level*5) + 5); - if ( level < 40 ) - r_value = 0; - if (r_value > 150 && level < 51 ) - r_value = 150; - if (r_value > 185) - r_value = 185; - break; - } - case BARD: case BARDGM:{ - // 58 75 75 - r_value = ((level*5) + 5); - if ( level < 58 ) - r_value = 0; - if (r_value > 75) - r_value = 75; - break; - } - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 30 175 200 - r_value = ((level*5) + 5); - if ( level < 30 ) - r_value = 0; - if (r_value > 175 && level < 51 ) - r_value = 175; - if (r_value > 200) - r_value = 200; - break; - } - case RANGER: case RANGERGM:{ - // 35 150 150 - r_value = ((level*5) + 5); - if ( level < 35 ) - r_value = 0; - if (r_value > 150) - r_value = 150; - break; - } - // Pure - // No skill classes - // Melee - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case RIPOSTE: - case DODGE:{ - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 6 140 175 - r_value = ((level*5) + 5); - if ( level < 6 ) - r_value = 0; - if (r_value > 140 && level < 51 ) - r_value = 140; - if (r_value > 175) - r_value = 175; - break; - } - case ROGUE: case ROGUEGM:{ - // 4 150 210 - r_value = ((level*5) + 5); - if ( level < 4 ) - r_value = 0; - if (r_value > 150 && level < 51 ) - r_value = 150; - if (r_value > 210) - r_value = 210; - break; - } - case MONK: case MONKGM:{ - // 1 200 230 - r_value = ((level*5) + 5); - if (r_value > 200) - r_value = 200; - if (r_value > 230) - r_value = 230; - break; - } - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM:{ - // 15 75 75 4*level+4 - r_value = ((level*4) + 4); - if ( level < 15 ) - r_value = 0; - if (r_value > 75) - r_value = 75; - break; - } - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - case BARD: case BARDGM:{ - // 10 125 155 5*level+5 - r_value = ((level*5) + 5); - if ( level < 10 ) - r_value = 0; - if (r_value > 125 && level < 51 ) - r_value = 125; - if (r_value > 155) - r_value = 155; - break; - } - - case RANGER: case RANGERGM:{ - // 8 137 170 5*level+5 - r_value = ((level*5) + 5); - if ( level < 8 ) - r_value = 0; - if (r_value > 137 && level < 51 ) - r_value = 137; - if (r_value > 170) - r_value = 170; - break; - } - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM:{ - // 22 75 75 3*level+3 - r_value = ((level*3) + 3); - if ( level < 22 ) - r_value = 0; - if (r_value > 75) - r_value = 75; - break; - } - // No skill classes - // Melee - // Priest - // Pure - // Hybrid - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case DODGE: - // Other - case TAUNT:{ - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 1 200 200 - r_value = ((level*5) + 5); - if (r_value > 200) - r_value = 200; - break; - } - // Priest - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 1 180 180 - r_value = ((level*5) + 5); - if (r_value > 180) - r_value = 180; - break; - } - case RANGER: case RANGERGM:{ - // 1 150 150 - r_value = ((level*5) + 5); - if (r_value > 150) - r_value = 150; - break; - } - // Pure - // No skill classes - // Melee - case ROGUE: case ROGUEGM: - case MONK: case MONKGM: - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BEASTLORD: case BEASTLORDGM: - case BARD: case BARDGM: - default: { - r_value = 0; - break; - } - } // end swtich (eqclass) - break; - } // end case TAUNT: - - case DISARM:{ - switch (eqclass) { - // Melee - case WARRIOR: case WARRIORGM:{ - // 35 200 200 - r_value = ((level*5) + 5); - if (level < 35) - r_value = 0; - if (r_value > 200) - r_value = 200; - break; - } - case ROGUE: case ROGUEGM: - case MONK: case MONKGM:{ - // 27 200 200 - r_value = ((level*5) + 5); - if (level < 27) - r_value = 0; - if (r_value > 200) - r_value = 200; - break; - } - // Priest - // Hybrid - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 40 70 70 - r_value = ((level*5) + 5); - if (level < 40) - r_value = 0; - if (r_value > 70) - r_value = 70; - break; - } - case RANGER: case RANGERGM:{ - // 35 55 55 - r_value = ((level*5) + 5); - if (level < 35) - r_value = 0; - if (r_value > 55) - r_value = 55; - break; - } - // Pure - // No skill classes - // Melee - // Priest - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM: - case CLERIC: case CLERICGM: - // Pure - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM: - case MAGICIAN: case MAGICIANGM: - case ENCHANTER: case ENCHANTERGM: - // Hybrid - case BARD: case BARDGM: - case BEASTLORD: case BEASTLORDGM: - default: { - r_value = 0; - break; - } - } // end switch (eqclass) - break; - } // end case DISARM: - /////////////////////////////////////////// - /////////////////////////////////////////// - // Spell Skills - case MEDITATE: - case ABJURE: - - case ALTERATION: - case CHANNELING: - case CONJURATION: - case DIVINATION: - - case EVOCATION:{ - r_value = ((level*5) + 5); - switch(eqclass){ - // Hybrid - case RANGER: case RANGERGM:{ - // 9 235 235 - // Channel 9 200 215 - // Med 12 185 235 - if (level < 9) - r_value = 0; - if (level < 12 && skillid == MEDITATE) - r_value = 0; - if (r_value > 0 && skillid == CHANNELING) { - if ( level < 51 && r_value > 200) - r_value = 200; - if (r_value > 215) - r_value = 215; - } - if (r_value > 0 && skillid == MEDITATE) { - if ( level < 51 && r_value > 185) - r_value = 185; - if (r_value > 235) - r_value = 235; - } - break; - } - case BEASTLORD: case BEASTLORDGM: - case PALADIN: case PALADINGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM:{ - // 9 235 235 - // Channel 9 200 220 - // Med 12 185 235 - if (level < 9) - r_value = 0; - if (level < 12 && skillid == MEDITATE) - r_value = 0; - if (r_value > 0 && skillid == CHANNELING) { - if ( level < 51 && r_value > 185) - r_value = 185; - if (r_value > 220) - r_value = 220; - } - if (r_value > 0 && skillid == MEDITATE) { - if ( level < 51 && r_value > 185) - r_value = 185; - if (r_value > 235) - r_value = 235; - } - break; - } - // Priest - case CLERIC: case CLERICGM: - case DRUID: case DRUIDGM: - case SHAMAN: case SHAMANGM:{ - // 1 235 235 - // Channel 4 200 220 - // Med 8 235 252 - if (level < 4 && skillid == CHANNELING) - r_value = 0; - if (level < 8 && skillid == MEDITATE) - r_value = 0; - if (r_value > 0 && skillid == CHANNELING) { - if ( level < 51 && r_value > 200) - r_value = 200; - if (r_value > 220) - r_value = 220; - } - if (r_value > 0 && skillid == MEDITATE) { - if ( level < 51 && r_value > 235) - r_value = 235; - if (r_value > 252) - r_value = 252; - } - break; - } - // Int caster - case ENCHANTER: case ENCHANTERGM: - case MAGICIAN: case MAGICIANGM: - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM:{ - // 1 235 235 - // Channel 1 200 220 - // Med 4 235 252 - if (level < 4 && skillid == MEDITATE) - r_value = 0; - if (r_value > 0 && skillid == CHANNELING) { - if ( level < 51 && r_value > 200) - r_value = 200; - if (r_value > 220) - r_value = 220; - } - if (r_value > 0 && skillid == MEDITATE) { - if ( level < 51 && r_value > 235) - r_value = 235; - if (r_value > 252) - r_value = 252; - } - break; - } - case BARD: case BARDGM:{ - r_value = 0; - if (level > 9 && skillid == MEDITATE) - r_value = 1; - break; - } - default: { - // Unknown class - r_value = 0; - break; - } - }// Class Switch - break; - } // end spell skills - - case SPECIALIZE_ABJURE: - case SPECIALIZE_ALTERATION: - case SPECIALIZE_CONJURATION: - case SPECIALIZE_DIVINATION: - case SPECIALIZE_EVOCATION: - case RESEARCH:{ - r_value = ((level*5) + 5); - switch(eqclass){ - // Int caster - case ENCHANTER: case ENCHANTERGM: - case MAGICIAN: case MAGICIANGM: - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM:{ - // Res 16 200 200 - if (level < 16 && skillid == RESEARCH) - r_value = 0; - if (r_value > 0 && skillid == RESEARCH) { - if (r_value > 200) - r_value = 200; - } - if (r_value > 235) - r_value = 235; - // FIXME Only let one SPEC go above what ever limit theres supposed to be - break; - } - default:{ - r_value = 0; - break; - } - }// Class Switch - break; - } // end specilize & research skills - - case BRASS_INSTRUMENTS: - case SINGING: - case STRINGED_INSTRUMENTS: - case WIND_INSTRUMENTS: - case PERCUSSION_INSTRUMENTS:{ - switch(eqclass){ - case BARD: case BARDGM:{ - r_value = ((level*5) + 5); - if (level < 5 && skillid == PERCUSSION_INSTRUMENTS){ - r_value = 0; - } - if (level < 8 && skillid == STRINGED_INSTRUMENTS){ - r_value = 0; - } - if (level < 11 && skillid == BRASS_INSTRUMENTS){ - r_value = 0; - } - if (level < 14 && skillid == WIND_INSTRUMENTS){ - r_value = 0; - } - if (r_value > 235) - r_value = 235; - break; - } - default: { - r_value = 0; - } - break; - }// Class Switch - break; - } // bard song skills - /////////////////////////////////////////// - /////////////////////////////////////////// - // Class skills - // Rogue - case APPLY_POISON: - case MAKE_POISON: - case PICK_POCKETS: - case BACKSTAB:{ - switch (eqclass) { - // Melee - case ROGUE: case ROGUEGM: { - r_value = ((level*5) + 5); - switch (skillid){ - case APPLY_POISON:{ - // 18 200 200 - if (level < 18) - r_value = 0; - if (r_value > 200) - r_value = 200; - break; - } - case MAKE_POISON:{ - // 20 200 250 - if (level < 20) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 250) - r_value = 250; - break; - } - case PICK_POCKETS:{ - // 7 200 210 - if (level < 7) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 210) - r_value = 210; - break; - } - case BACKSTAB:{ - // 10 200 225 - if (level < 10) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - default: { - r_value = 0; - break; - } - } // end switch (skillid) - break; - } // end case ROGUE: case ROGUEGM: - default: { - r_value = 0; - break; - } - }// Class Switch - break; - } // end rogue skills - // Monk - case FEIGN_DEATH: - case MEND: - case DRAGON_PUNCH: - case EAGLE_STRIKE: - case FLYING_KICK: - case ROUND_KICK: - case TIGER_CLAW: - case BLOCKSKILL:{ - switch(eqclass){ - case MONK: case MONKGM:{ - r_value = ((level*5) + 5); - switch (skillid){ - case MEND:{ - // 1 200 200 - if (r_value > 200) - r_value = 200; - break; - } - case ROUND_KICK:{ - // 5 200 225 - if (level < 5) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case TIGER_CLAW:{ - // 10 200 225 - if (level < 10) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case BLOCKSKILL:{ - // 12 200 230 - if (level < 12) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 230) - r_value = 230; - break; - } - case FEIGN_DEATH:{ - // 17 200 200 - if (level < 17) - r_value = 0; - if (r_value > 200) - r_value = 200; - break; - } - case EAGLE_STRIKE:{ - // 20 200 225 - if (level < 20) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case DRAGON_PUNCH:{ - // 25 200 225 - if (level < 25) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - case FLYING_KICK:{ - // 30 200 225 - if (level < 30) - r_value = 0; - if (level < 51 && r_value > 200) - r_value = 200; - if (r_value > 225) - r_value = 225; - break; - } - default: { - r_value = 0; - break; - } - } // end switch (skillid) - break; - } // end case MONK: case MONKGM: - default: { - r_value = 0; - break; - } - }// Class Switch - break; - } // end monk skills - // Shaman - case ALCHEMY:{ - switch(eqclass){ - case SHAMAN: case SHAMANGM:{ - // 25 130 180 - r_value = ((level*5) + 5); - if (level < 25) - r_value = 0; - if (level < 51 && r_value > 130) - r_value = 130; - if (r_value > 180) - r_value = 180; - break; - } - default: { - r_value = 0; - break; - } - }// Class Switch - break; - } // end case ALCHEMY: - /////////////////////////////////////////// - ////////////////////////////////////////// - // Shared skill - // Shared Rogue - case HIDE: - case SNEAK:{ - switch(eqclass){ - // True class - case ROGUE: case ROGUEGM:{ - break; - } - // Hybrids - case MONK: case MONKGM: - case RANGER: case RANGERGM: - case SHADOWKNIGHT: case SHADOWKNIGHTGM: - case BARD: case BARDGM:{ - break; - } - default: { - r_value = 0; - break; - } - }// Class Switch - } // end sneak/hide - case SENSE_TRAPS: - case PICK_LOCK: - case DISARM_TRAPS:{ - switch(eqclass){ - // True class - case ROGUE: case ROGUEGM:{ - break; - } - // Hybrids - case BARD: case BARDGM:{ - break; - } - default: { - r_value = 0; - break; - } - }// Class Switch - break; - } // end case SENSE_TRAPS/PICK_LOCK/DISARM_TRAPS - case SAFE_FALL: - case INTIMIDATION:{ - switch(eqclass){ - // Melee - case MONK: case MONKGM: - case ROGUE: case ROGUEGM:{ - break; - } - default: { - r_value = 0; - break; - } - }// Class Switch - break; - } // end SAFE_FALL/INTIMIDATION - // Druid/Ranger/Bard - case FORAGE:{ - switch(eqclass) { - case DRUID: case DRUIDGM: - case RANGER: case RANGERGM:{ - if (r_value > 200) - r_value = 200; - break; - } - case BARD: case BARDGM: { - r_value = 55; - break; - } - default: { - r_value = 00; - break; - } - } // end switch (eqclass) - break; - } // end case FORAGE: - case TRACKING:{ - switch(eqclass){ - case RANGER: case RANGERGM: - case BARD: case BARDGM: - case DRUID: case DRUIDGM: { - } - default: { - r_value = 0; - break; - } - }// Class Switch - } // end case TRACKING - /////////////////////////////////////////// - /////////////////////////////////////////// - // Tradeskills - case BAKING: - case TAILORING: - case BLACKSMITHING: - case FLETCHING: - case BREWING: - case JEWELRY_MAKING: - case POTTERY: - case FISHING:{ - // Check for Any Trade above 200, check for X (aa skill) Trades above 200 - r_value = 200; - break; - } - - /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - // Gnome - /////////////////////////////////////////////////////////////////// - case TINKERING:{ - if ( race == GNOME && level > 24 ) { - r_value = ((level*5)+5); - break; - } - r_value = 0; - break; - } // end case TINKERING: - - ///////////////////////////////////////// - // Common - ///////////////////////////////////////// - case BIND_WOUND:{ - r_value = 5 + (level*5); - if (level > 50){ - // Check for aa and class - } - if (r_value > 200) - r_value = 200; - switch (eqclass) { - case ENCHANTER: case ENCHANTERGM: - case MAGICIAN: case MAGICIANGM: - case NECROMANCER: case NECROMANCERGM: - case WIZARD: case WIZARDGM:{ - if ( r_value > 100 ) - r_value = 100; - } - default: { - break; - } - } // end switch (eqclass) - break; - } // end case BIND_WOUND: - case SENSE_HEADING: - case SWIMMING: - case ALCOHOL_TOLERANCE: - case BEGGING:{ - r_value = 5 + (level*5); - if (r_value > 200) - r_value = 200; - break; - } - //case BERSERKING: - default: { - // Unknown skill we should like print something to a log/debug here - r_value = 0; - break; - } - } // end switch (skillid) -// NO skill may go over 252 - if (r_value > 252) - r_value = 252; - return r_value; -} diff --git a/common/SocketLib/HTTPSocket.cpp b/common/SocketLib/HTTPSocket.cpp index 9d0eaa5be..ecde78403 100644 --- a/common/SocketLib/HTTPSocket.cpp +++ b/common/SocketLib/HTTPSocket.cpp @@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "Parse.h" #include "HTTPSocket.h" -#include "../TCPConnection.h" +#include "../tcp_connection.h" #include #include diff --git a/common/SocketLib/HTTPSocket.h b/common/SocketLib/HTTPSocket.h index 96f4cf389..409c90bce 100644 --- a/common/SocketLib/HTTPSocket.h +++ b/common/SocketLib/HTTPSocket.h @@ -42,7 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include "../TCPConnection.h" +#include "../tcp_connection.h" #ifdef SOCKETS_NAMESPACE diff --git a/common/database.cpp b/common/database.cpp index 2d5bdbdcc..e82f350b1 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -43,7 +43,7 @@ #include "database.h" #include "eq_packet_structs.h" #include "guilds.h" -#include "StringUtil.h" +#include "string_util.h" #include "extprofile.h" extern Client client; diff --git a/common/database.h b/common/database.h index 9be05f0cd..61ed19ef4 100644 --- a/common/database.h +++ b/common/database.h @@ -26,11 +26,11 @@ #include "dbcore.h" #include "linked_list.h" #include "eq_packet_structs.h" -/*#include "EQStream.h" +/*#include "eq_stream.h" #include "guilds.h" -#include "MiscFunctions.h" +#include "misc_functions.h" #include "Mutex.h" -#include "Item.h" +#include "item.h" #include "extprofile.h"*/ #include #include diff --git a/common/dbasync.cpp b/common/dbasync.cpp index 4153bc6fa..00714c2a0 100644 --- a/common/dbasync.cpp +++ b/common/dbasync.cpp @@ -12,8 +12,8 @@ #include #include "dbcore.h" #include -//#include "../common/MiscFunctions.h" -#include "StringUtil.h" +//#include "../common/misc_functions.h" +#include "string_util.h" #define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) { diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 3d25236c7..21168efa0 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -10,7 +10,7 @@ #include #include "dbcore.h" #include -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include #ifdef _WINDOWS diff --git a/common/dbcore.h b/common/dbcore.h index e90c5e249..eb7a5832e 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -14,7 +14,7 @@ #include "../common/queue.h" #include "../common/timer.h" #include "../common/condition.h" -#include "../common/MySQLRequestResult.h" +#include "../common/mysql_request_result.h" class DBcore { public: diff --git a/common/debug.cpp b/common/debug.cpp index fa114a338..228d57631 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -19,8 +19,8 @@ #endif #include "debug.h" -#include "StringUtil.h" -#include "MiscFunctions.h" +#include "string_util.h" +#include "misc_functions.h" #include "platform.h" #ifndef va_copy diff --git a/common/emu_tcp_connection.h b/common/emu_tcp_connection.h index ff7dd8995..c7d88965d 100644 --- a/common/emu_tcp_connection.h +++ b/common/emu_tcp_connection.h @@ -1,7 +1,7 @@ #ifndef EmuTCPCONNECTION_H_ #define EmuTCPCONNECTION_H_ -#include "TCPConnection.h" +#include "tcp_connection.h" #include "timer.h" //moved out of TCPConnection:: to be more exportable diff --git a/common/emu_tcp_server.h b/common/emu_tcp_server.h index c84524662..8941812ad 100644 --- a/common/emu_tcp_server.h +++ b/common/emu_tcp_server.h @@ -1,7 +1,7 @@ #ifndef EmuTCPSERVER_H_ #define EmuTCPSERVER_H_ -#include "TCPServer.h" +#include "tcp_server.h" class EmuTCPConnection; struct EmuTCPNetPacket_Struct; diff --git a/common/eq_dictionary.cpp b/common/eq_dictionary.cpp index 4c772689d..595d0cc5f 100644 --- a/common/eq_dictionary.cpp +++ b/common/eq_dictionary.cpp @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "eq_dictionary.h" -#include "StringUtil.h" +#include "string_util.h" // // class EmuConstants diff --git a/common/eq_dictionary.h b/common/eq_dictionary.h index eb35f5127..14f9d53d3 100644 --- a/common/eq_dictionary.h +++ b/common/eq_dictionary.h @@ -26,13 +26,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "eq_constants.h" #include "clientversions.h" #include -#include "../common/patches/Client62_constants.h" -#include "../common/patches/Titanium_constants.h" -#include "../common/patches/SoF_constants.h" -#include "../common/patches/SoD_constants.h" -#include "../common/patches/Underfoot_constants.h" -#include "../common/patches/RoF_constants.h" -//#include "../common/patches/RoF2_constants.h" +#include "../common/patches/client62_constants.h" +#include "../common/patches/titanium_constants.h" +#include "../common/patches/sof_constants.h" +#include "../common/patches/sod_constants.h" +#include "../common/patches/underfoot_constants.h" +#include "../common/patches/rof_constants.h" +//#include "../common/patches/rof2_constants.h" // *** DO NOT CHANGE without a full understanding of the consequences..the server is set up to use these settings explicitly!! *** // *** You will cause compilation failures and corrupt your database if partial or incorrect attempts to change them are made!! *** diff --git a/common/eq_packet.cpp b/common/eq_packet.cpp index b2d335b41..3ea622040 100644 --- a/common/eq_packet.cpp +++ b/common/eq_packet.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "EQPacket.h" +#include "eq_packet.h" #include "misc.h" #include "op_codes.h" #include "crc16.h" diff --git a/common/EQPacket.h b/common/eq_packet.h similarity index 99% rename from common/EQPacket.h rename to common/eq_packet.h index 83a37da32..9e0bcec3e 100644 --- a/common/EQPacket.h +++ b/common/eq_packet.h @@ -19,7 +19,7 @@ #define _EQPACKET_H #include "base_packet.h" -#include "EQStreamType.h" +#include "eq_stream_type.h" #include "op_codes.h" #include "platform.h" diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index 473a986a7..cb4aeb853 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -17,8 +17,8 @@ */ #include "debug.h" -#include "EQPacket.h" -#include "EQStream.h" +#include "eq_packet.h" +#include "eq_stream.h" #include "misc.h" #include "Mutex.h" #include "op_codes.h" diff --git a/common/EQStream.h b/common/eq_stream.h similarity index 99% rename from common/EQStream.h rename to common/eq_stream.h index 2b32492d6..ed3e26623 100644 --- a/common/EQStream.h +++ b/common/eq_stream.h @@ -9,9 +9,9 @@ #ifndef WIN32 #include #endif -#include "EQStreamType.h" -#include "EQPacket.h" -#include "EQStreamIntf.h" +#include "eq_stream_type.h" +#include "eq_packet.h" +#include "eq_stream_intf.h" #include "Mutex.h" #include "../common/opcodemgr.h" #include "../common/misc.h" diff --git a/common/eq_stream_factory.cpp b/common/eq_stream_factory.cpp index 0eb6fe25f..bc3e2e2ba 100644 --- a/common/eq_stream_factory.cpp +++ b/common/eq_stream_factory.cpp @@ -1,5 +1,5 @@ #include "debug.h" -#include "EQStreamFactory.h" +#include "eq_stream_factory.h" #ifdef _WINDOWS #include #include @@ -16,7 +16,7 @@ #include #include #include "op_codes.h" -#include "EQStream.h" +#include "eq_stream.h" #include "logsys.h" ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) diff --git a/common/EQStreamFactory.h b/common/eq_stream_factory.h similarity index 97% rename from common/EQStreamFactory.h rename to common/eq_stream_factory.h index 8e2208152..7aa5d66ac 100644 --- a/common/EQStreamFactory.h +++ b/common/eq_stream_factory.h @@ -4,7 +4,7 @@ #include #include -#include "../common/EQStream.h" +#include "../common/eq_stream.h" #include "../common/condition.h" #include "../common/timeoutmgr.h" #include "../common/opcodemgr.h" diff --git a/common/eq_stream_ident.cpp b/common/eq_stream_ident.cpp index d4332c9a0..b60ac28d0 100644 --- a/common/eq_stream_ident.cpp +++ b/common/eq_stream_ident.cpp @@ -1,6 +1,6 @@ #include "debug.h" -#include "EQStreamIdent.h" -#include "EQStreamProxy.h" +#include "eq_stream_ident.h" +#include "eq_stream_proxy.h" #include "logsys.h" EQStreamIdentifier::~EQStreamIdentifier() { diff --git a/common/EQStreamIdent.h b/common/eq_stream_ident.h similarity index 97% rename from common/EQStreamIdent.h rename to common/eq_stream_ident.h index 855838c86..c038daf26 100644 --- a/common/EQStreamIdent.h +++ b/common/eq_stream_ident.h @@ -1,7 +1,7 @@ #ifndef EQSTREAMIDENT_H_ #define EQSTREAMIDENT_H_ -#include "EQStream.h" +#include "eq_stream.h" #include "timer.h" #include #include diff --git a/common/EQStreamIntf.h b/common/eq_stream_intf.h similarity index 100% rename from common/EQStreamIntf.h rename to common/eq_stream_intf.h diff --git a/common/EQStreamLocator.h b/common/eq_stream_locator.h similarity index 100% rename from common/EQStreamLocator.h rename to common/eq_stream_locator.h diff --git a/common/eq_stream_proxy.cpp b/common/eq_stream_proxy.cpp index 90ea6ffce..20fc4ea06 100644 --- a/common/eq_stream_proxy.cpp +++ b/common/eq_stream_proxy.cpp @@ -1,8 +1,8 @@ #include "debug.h" -#include "EQStreamProxy.h" -#include "EQStream.h" -#include "StructStrategy.h" +#include "eq_stream_proxy.h" +#include "eq_stream.h" +#include "struct_strategy.h" EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes) diff --git a/common/EQStreamProxy.h b/common/eq_stream_proxy.h similarity index 98% rename from common/EQStreamProxy.h rename to common/eq_stream_proxy.h index cecdf9f38..34ea3a9fc 100644 --- a/common/EQStreamProxy.h +++ b/common/eq_stream_proxy.h @@ -3,7 +3,7 @@ #include "types.h" -#include "EQStreamIntf.h" +#include "eq_stream_intf.h" class EQStream; class StructStrategy; diff --git a/common/EQStreamType.h b/common/eq_stream_type.h similarity index 100% rename from common/EQStreamType.h rename to common/eq_stream_type.h diff --git a/common/eqemu_config.cpp b/common/eqemu_config.cpp index 1d0dadd15..165b0786f 100644 --- a/common/eqemu_config.cpp +++ b/common/eqemu_config.cpp @@ -17,7 +17,7 @@ */ #include "../common/debug.h" #include "eqemu_config.h" -#include "MiscFunctions.h" +#include "misc_functions.h" #include #include diff --git a/common/eqemu_config.h b/common/eqemu_config.h index 0a8cf833b..9fa21bea6 100644 --- a/common/eqemu_config.h +++ b/common/eqemu_config.h @@ -18,7 +18,7 @@ #ifndef __EQEmuConfig_H #define __EQEmuConfig_H -#include "XMLParser.h" +#include "xml_parser.h" #include "linked_list.h" struct LoginConfig { diff --git a/common/eqemu_error.cpp b/common/eqemu_error.cpp index 6dc5f9e96..79ce129ac 100644 --- a/common/eqemu_error.cpp +++ b/common/eqemu_error.cpp @@ -18,10 +18,10 @@ #ifdef _WINDOWS #include #endif -#include "EQEMuError.h" +#include "eqemu_error.h" #include "linked_list.h" #include "Mutex.h" -#include "MiscFunctions.h" +#include "misc_functions.h" #include #include #ifdef _WINDOWS diff --git a/common/EQEMuError.h b/common/eqemu_error.h similarity index 100% rename from common/EQEMuError.h rename to common/eqemu_error.h diff --git a/common/extprofile.h b/common/extprofile.h index 114983444..2e29fbf4a 100644 --- a/common/extprofile.h +++ b/common/extprofile.h @@ -19,7 +19,7 @@ #define EXTENDED_PROFILE_H #include "eq_packet_structs.h" -#include "Item.h" +#include "item.h" #pragma pack(1) diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 717cb49c3..8f6144270 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -20,8 +20,8 @@ #include "guild_base.h" #include "database.h" #include "logsys.h" -//#include "MiscFunctions.h" -#include "StringUtil.h" +//#include "misc_functions.h" +#include "string_util.h" #include #include diff --git a/common/guilds.cpp b/common/guilds.cpp index 22b2ca240..4f5c08bb6 100644 --- a/common/guilds.cpp +++ b/common/guilds.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "MiscFunctions.h" +#include "misc_functions.h" #include "guilds.h" #include "database.h" #include "eq_packet_structs.h" diff --git a/common/item.cpp b/common/item.cpp index ff02d1574..7d6618335 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -17,8 +17,8 @@ */ #include "debug.h" -#include "StringUtil.h" -#include "Item.h" +#include "string_util.h" +#include "item.h" #include "database.h" #include "misc.h" #include "races.h" diff --git a/common/Item.h b/common/item.h similarity index 100% rename from common/Item.h rename to common/item.h diff --git a/common/logsys.cpp b/common/logsys.cpp index 7f04d01b8..2b90c8b4a 100644 --- a/common/logsys.cpp +++ b/common/logsys.cpp @@ -22,7 +22,7 @@ #include #include #include "misc.h" -#include "EQPacket.h" +#include "eq_packet.h" #define LOG_CATEGORY(category) #category , diff --git a/common/logsys_eqemu.cpp b/common/logsys_eqemu.cpp index e1e75996c..b5f846b4a 100644 --- a/common/logsys_eqemu.cpp +++ b/common/logsys_eqemu.cpp @@ -18,7 +18,7 @@ #include "debug.h" #include "logsys.h" -#include "StringUtil.h" +#include "string_util.h" #include #include diff --git a/common/md5.cpp b/common/md5.cpp index 8e9197e56..724279bba 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -9,7 +9,7 @@ */ #include /* for memcpy() */ #include "../common/md5.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/seperator.h" MD5::MD5() { diff --git a/common/misc_functions.cpp b/common/misc_functions.cpp index cf371adc1..e7b581733 100644 --- a/common/misc_functions.cpp +++ b/common/misc_functions.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "MiscFunctions.h" +#include "misc_functions.h" #include #include #include diff --git a/common/MiscFunctions.h b/common/misc_functions.h similarity index 100% rename from common/MiscFunctions.h rename to common/misc_functions.h diff --git a/common/mysql_request_result.cpp b/common/mysql_request_result.cpp index f364bf9b2..ffbc3ef40 100644 --- a/common/mysql_request_result.cpp +++ b/common/mysql_request_result.cpp @@ -1,4 +1,4 @@ -#include "MySQLRequestResult.h" +#include "mysql_request_result.h" MySQLRequestResult::MySQLRequestResult() diff --git a/common/MySQLRequestResult.h b/common/mysql_request_result.h similarity index 98% rename from common/MySQLRequestResult.h rename to common/mysql_request_result.h index 2983dd4bf..cd561be56 100644 --- a/common/MySQLRequestResult.h +++ b/common/mysql_request_result.h @@ -8,7 +8,7 @@ #include #include "types.h" -#include "MySQLRequestRow.h" +#include "mysql_request_row.h" #include #include #include diff --git a/common/mysql_request_row.cpp b/common/mysql_request_row.cpp index f8c2b4c06..ac5fa1592 100644 --- a/common/mysql_request_row.cpp +++ b/common/mysql_request_row.cpp @@ -1,4 +1,4 @@ -#include "MySQLRequestRow.h" +#include "mysql_request_row.h" MySQLRequestRow::MySQLRequestRow(const MySQLRequestRow& row) : m_Result(row.m_Result), m_MySQLRow(row.m_MySQLRow) diff --git a/common/MySQLRequestRow.h b/common/mysql_request_row.h similarity index 100% rename from common/MySQLRequestRow.h rename to common/mysql_request_row.h diff --git a/common/packet_dump.cpp b/common/packet_dump.cpp index a9c70b493..6bb412f6b 100644 --- a/common/packet_dump.cpp +++ b/common/packet_dump.cpp @@ -21,7 +21,7 @@ #include #include "packet_dump.h" -#include "EQPacket.h" +#include "eq_packet.h" #include "../common/servertalk.h" void DumpPacketAscii(const uchar* buf, uint32 size, uint32 cols, uint32 skip) { diff --git a/common/packet_dump_file.cpp b/common/packet_dump_file.cpp index 8e0e3c274..32aa7d984 100644 --- a/common/packet_dump_file.cpp +++ b/common/packet_dump_file.cpp @@ -35,7 +35,7 @@ #include #endif -#include "EQStream.h" +#include "eq_stream.h" #include "packet_dump_file.h" void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) { diff --git a/common/patches/client62.cpp b/common/patches/client62.cpp index 8e45217e5..10cc331ec 100644 --- a/common/patches/client62.cpp +++ b/common/patches/client62.cpp @@ -1,17 +1,17 @@ #include "../debug.h" -#include "Client62.h" +#include "client62.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../eq_packet_structs.h" -#include "../MiscFunctions.h" -#include "../StringUtil.h" -#include "../Item.h" +#include "../misc_functions.h" +#include "../string_util.h" +#include "../item.h" #include "../clientversions.h" -#include "Client62_structs.h" +#include "client62_structs.h" namespace Client62 { @@ -84,8 +84,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "Client62_ops.h" + #include "ss_register.h" + #include "client62_ops.h" } std::string Strategy::Describe() const { @@ -100,7 +100,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClient62; } -#include "SSDefine.h" +#include "ss_define.h" /* @@ -1042,7 +1042,7 @@ char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 d #define C(field) "|%s" #define S(field) "|%s" #define F(field) "|%f" -#include "Client62_itemfields.h" +#include "client62_itemfields.h" "%.*s\"" // Quotes (and protection, if needed) around static data "|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" // Sub items "%.*s%s" // For trailing quotes (and protection) if a subitem; @@ -1054,7 +1054,7 @@ char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 d #define C(field) ,field #define S(field) ,item->field #define F(field) ,item->field -#include "Client62_itemfields.h" +#include "client62_itemfields.h" ,depth,protection ,sub_items[0] ? sub_items[0] : "" ,sub_items[1] ? sub_items[1] : "" diff --git a/common/patches/Client62.h b/common/patches/client62.h similarity index 84% rename from common/patches/Client62.h rename to common/patches/client62.h index f4a70bc90..08d1a9716 100644 --- a/common/patches/Client62.h +++ b/common/patches/client62.h @@ -1,8 +1,8 @@ #ifndef CLIENT62_H_ #define CLIENT62_H_ -#include "../StructStrategy.h" -#include "../Item.h" +#include "../struct_strategy.h" +#include "../item.h" class EQStreamIdentifier; @@ -27,8 +27,8 @@ namespace Client62 { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "Client62_ops.h" + #include "ss_declare.h" + #include "client62_ops.h" }; diff --git a/common/patches/Client62_constants.h b/common/patches/client62_constants.h similarity index 100% rename from common/patches/Client62_constants.h rename to common/patches/client62_constants.h diff --git a/common/patches/Client62_itemfields.h b/common/patches/client62_itemfields.h similarity index 100% rename from common/patches/Client62_itemfields.h rename to common/patches/client62_itemfields.h diff --git a/common/patches/Client62_ops.h b/common/patches/client62_ops.h similarity index 100% rename from common/patches/Client62_ops.h rename to common/patches/client62_ops.h diff --git a/common/patches/Client62_structs.h b/common/patches/client62_structs.h similarity index 100% rename from common/patches/Client62_structs.h rename to common/patches/client62_structs.h diff --git a/common/patches/patches.cpp b/common/patches/patches.cpp index febb344d7..212042210 100644 --- a/common/patches/patches.cpp +++ b/common/patches/patches.cpp @@ -2,13 +2,13 @@ #include "../debug.h" #include "patches.h" -#include "Client62.h" -#include "Titanium.h" -#include "Underfoot.h" -#include "SoF.h" -#include "SoD.h" -#include "RoF.h" -//#include "RoF2.h" +#include "client62.h" +#include "titanium.h" +#include "underfoot.h" +#include "sof.h" +#include "sod.h" +#include "rof.h" +//#include "rof2.h" void RegisterAllPatches(EQStreamIdentifier &into) { Client62::Register(into); diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 7fcce53b2..90ff9ab9e 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -1,16 +1,16 @@ #include "../debug.h" -#include "RoF.h" +#include "rof.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../eq_packet_structs.h" -#include "../MiscFunctions.h" -#include "../StringUtil.h" -#include "../Item.h" -#include "RoF_structs.h" +#include "../misc_functions.h" +#include "../string_util.h" +#include "../item.h" +#include "rof_structs.h" #include "../rulesys.h" #include @@ -89,8 +89,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "RoF_ops.h" + #include "ss_register.h" + #include "rof_ops.h" } std::string Strategy::Describe() const { @@ -105,7 +105,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClientRoF; } -#include "SSDefine.h" +#include "ss_define.h" // Converts Server Slot IDs to RoF Slot IDs for use in Encodes diff --git a/common/patches/RoF.h b/common/patches/rof.h similarity index 87% rename from common/patches/RoF.h rename to common/patches/rof.h index fc2e94c95..220341970 100644 --- a/common/patches/RoF.h +++ b/common/patches/rof.h @@ -1,7 +1,7 @@ #ifndef RoF_H_ #define RoF_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -26,8 +26,8 @@ namespace RoF { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "RoF_ops.h" + #include "ss_declare.h" + #include "rof_ops.h" }; }; diff --git a/common/patches/RoF_constants.h b/common/patches/rof_constants.h similarity index 100% rename from common/patches/RoF_constants.h rename to common/patches/rof_constants.h diff --git a/common/patches/RoF_itemfields.h b/common/patches/rof_itemfields.h similarity index 100% rename from common/patches/RoF_itemfields.h rename to common/patches/rof_itemfields.h diff --git a/common/patches/RoF_ops.h b/common/patches/rof_ops.h similarity index 100% rename from common/patches/RoF_ops.h rename to common/patches/rof_ops.h diff --git a/common/patches/RoF_structs.h b/common/patches/rof_structs.h similarity index 100% rename from common/patches/RoF_structs.h rename to common/patches/rof_structs.h diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index dcc95ec75..db2f1f989 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -1,16 +1,16 @@ #include "../debug.h" -#include "SoD.h" +#include "sod.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../eq_packet_structs.h" -#include "../MiscFunctions.h" -#include "../StringUtil.h" -#include "../Item.h" -#include "SoD_structs.h" +#include "../misc_functions.h" +#include "../string_util.h" +#include "../item.h" +#include "sod_structs.h" #include "../rulesys.h" #include @@ -89,8 +89,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "SoD_ops.h" + #include "ss_register.h" + #include "sod_ops.h" } std::string Strategy::Describe() const { @@ -105,7 +105,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClientSoD; } -#include "SSDefine.h" +#include "ss_define.h" // Converts Server Slot IDs to SoD Slot IDs for use in Encodes diff --git a/common/patches/SoD.h b/common/patches/sod.h similarity index 87% rename from common/patches/SoD.h rename to common/patches/sod.h index 960cd2afa..0377573c2 100644 --- a/common/patches/SoD.h +++ b/common/patches/sod.h @@ -1,7 +1,7 @@ #ifndef SoD_H_ #define SoD_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -26,8 +26,8 @@ namespace SoD { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "SoD_ops.h" + #include "ss_declare.h" + #include "sod_ops.h" }; }; diff --git a/common/patches/SoD_constants.h b/common/patches/sod_constants.h similarity index 100% rename from common/patches/SoD_constants.h rename to common/patches/sod_constants.h diff --git a/common/patches/SoD_itemfields.h b/common/patches/sod_itemfields.h similarity index 100% rename from common/patches/SoD_itemfields.h rename to common/patches/sod_itemfields.h diff --git a/common/patches/SoD_ops.h b/common/patches/sod_ops.h similarity index 100% rename from common/patches/SoD_ops.h rename to common/patches/sod_ops.h diff --git a/common/patches/SoD_structs.h b/common/patches/sod_structs.h similarity index 100% rename from common/patches/SoD_structs.h rename to common/patches/sod_structs.h diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index d607ff472..4116d3251 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -1,15 +1,15 @@ #include "../debug.h" -#include "SoF.h" +#include "sof.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../eq_packet_structs.h" -#include "../StringUtil.h" -#include "../Item.h" -#include "SoF_structs.h" +#include "../string_util.h" +#include "../item.h" +#include "sof_structs.h" #include "../rulesys.h" #include @@ -88,8 +88,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "SoF_ops.h" + #include "ss_register.h" + #include "sof_ops.h" } std::string Strategy::Describe() const { @@ -104,7 +104,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClientSoF; } -#include "SSDefine.h" +#include "ss_define.h" // Converts Server Slot IDs to SoF Slot IDs for use in Encodes diff --git a/common/patches/SoF.h b/common/patches/sof.h similarity index 87% rename from common/patches/SoF.h rename to common/patches/sof.h index 615bc1f99..fc68ba334 100644 --- a/common/patches/SoF.h +++ b/common/patches/sof.h @@ -1,7 +1,7 @@ #ifndef SoF_H_ #define SoF_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -26,8 +26,8 @@ namespace SoF { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "SoF_ops.h" + #include "ss_declare.h" + #include "sof_ops.h" }; }; diff --git a/common/patches/SoF_constants.h b/common/patches/sof_constants.h similarity index 100% rename from common/patches/SoF_constants.h rename to common/patches/sof_constants.h diff --git a/common/patches/SoF_itemfields.h b/common/patches/sof_itemfields.h similarity index 100% rename from common/patches/SoF_itemfields.h rename to common/patches/sof_itemfields.h diff --git a/common/patches/SoF_ops.h b/common/patches/sof_ops.h similarity index 100% rename from common/patches/SoF_ops.h rename to common/patches/sof_ops.h diff --git a/common/patches/SoF_structs.h b/common/patches/sof_structs.h similarity index 100% rename from common/patches/SoF_structs.h rename to common/patches/sof_structs.h diff --git a/common/patches/SSDeclare.h b/common/patches/ss_declare.h similarity index 100% rename from common/patches/SSDeclare.h rename to common/patches/ss_declare.h diff --git a/common/patches/SSDefine.h b/common/patches/ss_define.h similarity index 100% rename from common/patches/SSDefine.h rename to common/patches/ss_define.h diff --git a/common/patches/SSRegister.h b/common/patches/ss_register.h similarity index 100% rename from common/patches/SSRegister.h rename to common/patches/ss_register.h diff --git a/common/patches/template.cpp b/common/patches/template.cpp index 219e30f71..8c4be992c 100644 --- a/common/patches/template.cpp +++ b/common/patches/template.cpp @@ -2,7 +2,7 @@ #include "TEMPLATE.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../eq_packet_structs.h" #include "TEMPLATE_structs.h" @@ -68,7 +68,7 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" + #include "ss_register.h" #include "TEMPLATE_ops.h" } @@ -80,7 +80,7 @@ std::string Strategy::Describe() const { } -#include "SSDefine.h" +#include "ss_define.h" /*ENCODE(OP_PlayerProfile) { diff --git a/common/patches/template.h b/common/patches/template.h index 16f869fc1..1391516b1 100644 --- a/common/patches/template.h +++ b/common/patches/template.h @@ -1,7 +1,7 @@ #ifndef TEMPLATE_H_ #define TEMPLATE_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -25,7 +25,7 @@ namespace TEMPLATE { virtual std::string Describe() const; virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcodes - #include "SSDeclare.h" + #include "ss_declare.h" #include "TEMPLATE_ops.h" }; diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index ea44c3c38..c79fa5d4f 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -1,16 +1,16 @@ #include "../debug.h" -#include "Titanium.h" +#include "titanium.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../races.h" #include "../eq_packet_structs.h" -#include "../StringUtil.h" -#include "../Item.h" -#include "Titanium_structs.h" +#include "../string_util.h" +#include "../item.h" +#include "titanium_structs.h" #include namespace Titanium { @@ -86,8 +86,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "Titanium_ops.h" + #include "ss_register.h" + #include "titanium_ops.h" } std::string Strategy::Describe() const { @@ -102,7 +102,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClientTitanium; } -#include "SSDefine.h" +#include "ss_define.h" /* @@ -1460,7 +1460,7 @@ char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 d #define C(field) "|%s" #define S(field) "|%s" #define F(field) "|%f" -#include "Titanium_itemfields.h" +#include "titanium_itemfields.h" "%.*s\"" // Quotes (and protection, if needed) around static data "|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" // Sub items "%.*s%s" // For trailing quotes (and protection) if a subitem; @@ -1472,7 +1472,7 @@ char *SerializeItem(const ItemInst *inst, int16 slot_id, uint32 *length, uint8 d #define C(field) ,field #define S(field) ,item->field #define F(field) ,item->field -#include "Titanium_itemfields.h" +#include "titanium_itemfields.h" ,depth,protection ,sub_items[0] ? sub_items[0] : "" ,sub_items[1] ? sub_items[1] : "" diff --git a/common/patches/Titanium.h b/common/patches/titanium.h similarity index 87% rename from common/patches/Titanium.h rename to common/patches/titanium.h index 337556938..421ef319a 100644 --- a/common/patches/Titanium.h +++ b/common/patches/titanium.h @@ -1,7 +1,7 @@ #ifndef Titanium_H_ #define Titanium_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -26,8 +26,8 @@ namespace Titanium { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "Titanium_ops.h" + #include "ss_declare.h" + #include "titanium_ops.h" }; }; diff --git a/common/patches/Titanium_constants.h b/common/patches/titanium_constants.h similarity index 100% rename from common/patches/Titanium_constants.h rename to common/patches/titanium_constants.h diff --git a/common/patches/Titanium_itemfields.h b/common/patches/titanium_itemfields.h similarity index 100% rename from common/patches/Titanium_itemfields.h rename to common/patches/titanium_itemfields.h diff --git a/common/patches/Titanium_ops.h b/common/patches/titanium_ops.h similarity index 100% rename from common/patches/Titanium_ops.h rename to common/patches/titanium_ops.h diff --git a/common/patches/Titanium_structs.h b/common/patches/titanium_structs.h similarity index 100% rename from common/patches/Titanium_structs.h rename to common/patches/titanium_structs.h diff --git a/common/patches/underfoot.cpp b/common/patches/underfoot.cpp index b56d3f511..bdac3c72b 100644 --- a/common/patches/underfoot.cpp +++ b/common/patches/underfoot.cpp @@ -1,16 +1,16 @@ #include "../debug.h" -#include "Underfoot.h" +#include "underfoot.h" #include "../opcodemgr.h" #include "../logsys.h" -#include "../EQStreamIdent.h" +#include "../eq_stream_ident.h" #include "../crc32.h" #include "../eq_packet_structs.h" -#include "../MiscFunctions.h" -#include "../StringUtil.h" -#include "../Item.h" -#include "Underfoot_structs.h" +#include "../misc_functions.h" +#include "../string_util.h" +#include "../item.h" +#include "underfoot_structs.h" #include "../rulesys.h" #include @@ -90,8 +90,8 @@ Strategy::Strategy() : StructStrategy() { //all opcodes default to passthrough. - #include "SSRegister.h" - #include "Underfoot_ops.h" + #include "ss_register.h" + #include "underfoot_ops.h" } std::string Strategy::Describe() const { @@ -106,7 +106,7 @@ const EQClientVersion Strategy::ClientVersion() const return EQClientUnderfoot; } -#include "SSDefine.h" +#include "ss_define.h" // Converts Server Slot IDs to Underfoot Slot IDs for use in Encodes diff --git a/common/patches/Underfoot.h b/common/patches/underfoot.h similarity index 87% rename from common/patches/Underfoot.h rename to common/patches/underfoot.h index fb66a3488..b14d4a420 100644 --- a/common/patches/Underfoot.h +++ b/common/patches/underfoot.h @@ -1,7 +1,7 @@ #ifndef Underfoot_H_ #define Underfoot_H_ -#include "../StructStrategy.h" +#include "../struct_strategy.h" class EQStreamIdentifier; @@ -26,8 +26,8 @@ namespace Underfoot { virtual const EQClientVersion ClientVersion() const; //magic macro to declare our opcode processors - #include "SSDeclare.h" - #include "Underfoot_ops.h" + #include "ss_declare.h" + #include "underfoot_ops.h" }; }; diff --git a/common/patches/Underfoot_constants.h b/common/patches/underfoot_constants.h similarity index 100% rename from common/patches/Underfoot_constants.h rename to common/patches/underfoot_constants.h diff --git a/common/patches/Underfoot_itemfields.h b/common/patches/underfoot_itemfields.h similarity index 100% rename from common/patches/Underfoot_itemfields.h rename to common/patches/underfoot_itemfields.h diff --git a/common/patches/Underfoot_ops.h b/common/patches/underfoot_ops.h similarity index 100% rename from common/patches/Underfoot_ops.h rename to common/patches/underfoot_ops.h diff --git a/common/patches/Underfoot_structs.h b/common/patches/underfoot_structs.h similarity index 100% rename from common/patches/Underfoot_structs.h rename to common/patches/underfoot_structs.h diff --git a/common/proc_launcher.cpp b/common/proc_launcher.cpp index da0cd81e9..0ea0d9636 100644 --- a/common/proc_launcher.cpp +++ b/common/proc_launcher.cpp @@ -20,7 +20,7 @@ #include #include "debug.h" -#include "ProcLauncher.h" +#include "proc_launcher.h" #ifdef _WINDOWS #include #else diff --git a/common/ProcLauncher.h b/common/proc_launcher.h similarity index 100% rename from common/ProcLauncher.h rename to common/proc_launcher.h diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 1e1aa7349..c9b25b1a5 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -20,7 +20,7 @@ #include "timer.h" #include "ptimer.h" #include "database.h" -#include "StringUtil.h" +#include "string_util.h" #include #include #include diff --git a/common/rulesys.cpp b/common/rulesys.cpp index f23d482b3..95f22754c 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -19,7 +19,7 @@ #include "rulesys.h" #include "logsys.h" #include "database.h" -#include "StringUtil.h" +#include "string_util.h" #include #include diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 7a9858789..8e999da54 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -4,11 +4,11 @@ #include "shareddb.h" #include "mysql.h" -#include "Item.h" +#include "item.h" #include "classes.h" #include "rulesys.h" #include "seperator.h" -#include "StringUtil.h" +#include "string_util.h" #include "eq_packet_structs.h" #include "guilds.h" #include "extprofile.h" diff --git a/common/shareddb.h b/common/shareddb.h index 05c3db6ef..0fd72426c 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -6,7 +6,7 @@ #include "database.h" #include "skills.h" #include "spdat.h" -#include "Item.h" +#include "item.h" #include "base_data.h" #include "fixed_memory_hash_set.h" #include "fixed_memory_variable_hash_set.h" diff --git a/common/spdat.cpp b/common/spdat.cpp index 8e93f4e1f..1ff8f2696 100644 --- a/common/spdat.cpp +++ b/common/spdat.cpp @@ -74,7 +74,7 @@ #include "spdat.h" #include "packet_dump.h" #include "moremath.h" -#include "Item.h" +#include "item.h" #include "skills.h" #include "bodytypes.h" #include "classes.h" diff --git a/common/string_util.cpp b/common/string_util.cpp index 80c92fa88..0ccd0e4ef 100644 --- a/common/string_util.cpp +++ b/common/string_util.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "StringUtil.h" +#include "string_util.h" #include // for strncpy #include diff --git a/common/StringUtil.h b/common/string_util.h similarity index 100% rename from common/StringUtil.h rename to common/string_util.h diff --git a/common/struct_strategy.cpp b/common/struct_strategy.cpp index 9056fad72..9507fd231 100644 --- a/common/struct_strategy.cpp +++ b/common/struct_strategy.cpp @@ -1,8 +1,8 @@ #include "debug.h" -#include "StructStrategy.h" +#include "struct_strategy.h" #include "logsys.h" -#include "EQStream.h" +#include "eq_stream.h" #include diff --git a/common/StructStrategy.h b/common/struct_strategy.h similarity index 100% rename from common/StructStrategy.h rename to common/struct_strategy.h diff --git a/common/TCPBasicServer.h b/common/tcp_basic_server.h similarity index 89% rename from common/TCPBasicServer.h rename to common/tcp_basic_server.h index 3a01051d3..1d317bc8f 100644 --- a/common/TCPBasicServer.h +++ b/common/tcp_basic_server.h @@ -1,8 +1,8 @@ #ifndef TCPBASICSERVER_H_ #define TCPBASICSERVER_H_ -#include "TCPServer.h" -#include "TCPConnection.h" +#include "tcp_server.h" +#include "tcp_connection.h" class TCPBasicServer : public TCPServer { public: diff --git a/common/tcp_connection.cpp b/common/tcp_connection.cpp index 1e5f49600..ea57a6301 100644 --- a/common/tcp_connection.cpp +++ b/common/tcp_connection.cpp @@ -22,7 +22,7 @@ #include #include -#include "TCPConnection.h" +#include "tcp_connection.h" #include "../common/servertalk.h" #include "../common/timer.h" #include "../common/packet_dump.h" diff --git a/common/TCPConnection.h b/common/tcp_connection.h similarity index 99% rename from common/TCPConnection.h rename to common/tcp_connection.h index 5321c5e3a..fbf34491c 100644 --- a/common/TCPConnection.h +++ b/common/tcp_connection.h @@ -46,7 +46,7 @@ #include "types.h" #include "Mutex.h" #include "queue.h" -#include "MiscFunctions.h" +#include "misc_functions.h" class BaseTCPServer; class ServerPacket; diff --git a/common/tcp_server.cpp b/common/tcp_server.cpp index 2e3abfe2f..415f76fa1 100644 --- a/common/tcp_server.cpp +++ b/common/tcp_server.cpp @@ -1,5 +1,5 @@ #include "debug.h" -#include "TCPServer.h" +#include "tcp_server.h" #include #include #include diff --git a/common/TCPServer.h b/common/tcp_server.h similarity index 100% rename from common/TCPServer.h rename to common/tcp_server.h diff --git a/common/xml_parser.cpp b/common/xml_parser.cpp index f6f64ed13..7f84e0d47 100644 --- a/common/xml_parser.cpp +++ b/common/xml_parser.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "debug.h" -#include "XMLParser.h" +#include "xml_parser.h" XMLParser::XMLParser() { ParseOkay = false; diff --git a/common/XMLParser.h b/common/xml_parser.h similarity index 100% rename from common/XMLParser.h rename to common/xml_parser.h diff --git a/common/ZoneNumbers.h b/common/zone_numbers.h similarity index 100% rename from common/ZoneNumbers.h rename to common/zone_numbers.h diff --git a/eqlaunch/ZoneLaunch.h b/eqlaunch/ZoneLaunch.h index 2694e5bd5..3dc0fd697 100644 --- a/eqlaunch/ZoneLaunch.h +++ b/eqlaunch/ZoneLaunch.h @@ -18,7 +18,7 @@ #ifndef ZONELAUNCH_H_ #define ZONELAUNCH_H_ -#include "../common/ProcLauncher.h" +#include "../common/proc_launcher.h" #include "../common/timer.h" #include diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index 58db80cb8..da14c40e8 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -17,7 +17,7 @@ */ #include "../common/debug.h" -#include "../common/ProcLauncher.h" +#include "../common/proc_launcher.h" #include "../common/eqemu_config.h" #include "../common/servertalk.h" #include "../common/platform.h" diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index 5872e17d5..7b542a183 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -20,7 +20,7 @@ #include "../common/servertalk.h" #include "ZoneLaunch.h" #include "../common/eqemu_config.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" WorldServer::WorldServer(std::map &zones, const char *name, const EQEmuConfig *config) diff --git a/loginserver/Client.cpp b/loginserver/Client.cpp index 9fd96118a..98128e286 100644 --- a/loginserver/Client.cpp +++ b/loginserver/Client.cpp @@ -19,7 +19,7 @@ #include "ErrorLog.h" #include "LoginServer.h" #include "LoginStructures.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" extern ErrorLog *server_log; extern LoginServer server; diff --git a/loginserver/Client.h b/loginserver/Client.h index 1cb248344..d080aa01b 100644 --- a/loginserver/Client.h +++ b/loginserver/Client.h @@ -20,8 +20,8 @@ #include "../common/debug.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamType.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_type.h" +#include "../common/eq_stream_factory.h" #ifndef WIN32 #include "EQCryptoAPI.h" #endif diff --git a/loginserver/ClientManager.h b/loginserver/ClientManager.h index 287a9212d..fc6205a8a 100644 --- a/loginserver/ClientManager.h +++ b/loginserver/ClientManager.h @@ -20,8 +20,8 @@ #include "../common/debug.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamType.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_type.h" +#include "../common/eq_stream_factory.h" #include "Client.h" #include diff --git a/loginserver/Main.cpp b/loginserver/Main.cpp index 54a3e9ba4..ec5a3b4ed 100644 --- a/loginserver/Main.cpp +++ b/loginserver/Main.cpp @@ -18,7 +18,7 @@ #include "../common/debug.h" #include "../common/types.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/timer.h" #include "../common/platform.h" #include "../common/crash.h" diff --git a/loginserver/ServerManager.h b/loginserver/ServerManager.h index 8bfd8c8ee..3d03db06d 100644 --- a/loginserver/ServerManager.h +++ b/loginserver/ServerManager.h @@ -19,7 +19,7 @@ #define EQEMU_SERVERMANAGER_H #include "../common/debug.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_server.h" #include "../common/servertalk.h" diff --git a/loginserver/WorldServer.h b/loginserver/WorldServer.h index 655cbc578..ff790e103 100644 --- a/loginserver/WorldServer.h +++ b/loginserver/WorldServer.h @@ -19,7 +19,7 @@ #define EQEMU_WORLDSERVER_H #include "../common/debug.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_server.h" #include "../common/servertalk.h" diff --git a/queryserv/database.cpp b/queryserv/database.cpp index 14d4c34a9..d03957140 100644 --- a/queryserv/database.cpp +++ b/queryserv/database.cpp @@ -43,7 +43,7 @@ #include "database.h" #include "../common/eq_packet_structs.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/servertalk.h" Database::Database () diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index a98c23ddc..9fc4d0b62 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -2,7 +2,7 @@ #include "lfguild.h" #include "database.h" #include "worldserver.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/packet_dump.h" #include "../common/rulesys.h" diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index 30dc9970e..3827ceea1 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -19,7 +19,7 @@ #include "../common/debug.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/rulesys.h" #include "../common/servertalk.h" #include "../common/platform.h" diff --git a/socket_server/database.cpp b/socket_server/database.cpp index a2c04bbb4..d27079af0 100644 --- a/socket_server/database.cpp +++ b/socket_server/database.cpp @@ -43,7 +43,7 @@ #include "database.h" #include "../common/eq_packet_structs.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/servertalk.h" Database::Database () diff --git a/socket_server/socket_server.cpp b/socket_server/socket_server.cpp index 997d9965f..71c8342ff 100644 --- a/socket_server/socket_server.cpp +++ b/socket_server/socket_server.cpp @@ -39,7 +39,7 @@ using websocketpp::lib::condition_variable; #include "../common/debug.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/rulesys.h" #include "../common/servertalk.h" #include "../common/platform.h" diff --git a/tests/atobool_test.h b/tests/atobool_test.h index ce02df02d..5cc9ad872 100644 --- a/tests/atobool_test.h +++ b/tests/atobool_test.h @@ -20,7 +20,7 @@ #define __EQEMU_TESTS_ATOBOOL_H #include "cppunit/cpptest.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" class atoboolTest : public Test::Suite { typedef void(atoboolTest::*TestFunction)(void); diff --git a/tests/fixed_memory_test.h b/tests/fixed_memory_test.h index 089b8f7c0..fcff0c9e8 100644 --- a/tests/fixed_memory_test.h +++ b/tests/fixed_memory_test.h @@ -21,7 +21,7 @@ #include "cppunit/cpptest.h" #include "../common/fixed_memory_hash_set.h" -#include "../common/Item.h" +#include "../common/item.h" class FixedMemoryHashTest : public Test::Suite { typedef void(FixedMemoryHashTest::*TestFunction)(void); diff --git a/tests/hextoi_32_64_test.h b/tests/hextoi_32_64_test.h index eda5e7fc2..1ad6c9d24 100644 --- a/tests/hextoi_32_64_test.h +++ b/tests/hextoi_32_64_test.h @@ -20,7 +20,7 @@ #define __EQEMU_TESTS_HEXTOI_32_64_H #include "cppunit/cpptest.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" class hextoi_32_64_Test : public Test::Suite { typedef void(hextoi_32_64_Test::*TestFunction)(void); diff --git a/ucs/chatchannel.cpp b/ucs/chatchannel.cpp index a33ad65db..56b7eb5b9 100644 --- a/ucs/chatchannel.cpp +++ b/ucs/chatchannel.cpp @@ -20,7 +20,7 @@ #include "chatchannel.h" #include "clientlist.h" #include "database.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include extern Database database; diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 31d54e3b5..8a60fc749 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -18,13 +18,13 @@ */ #include "../common/debug.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "clientlist.h" #include "database.h" #include "chatchannel.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_server.h" #include diff --git a/ucs/clientlist.h b/ucs/clientlist.h index b8a1609ea..266986542 100644 --- a/ucs/clientlist.h +++ b/ucs/clientlist.h @@ -21,8 +21,8 @@ #define CHATSERVER_CLIENTLIST_H #include "../common/opcodemgr.h" -#include "../common/EQStreamType.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_type.h" +#include "../common/eq_stream_factory.h" #include "../common/rulesys.h" #include "chatchannel.h" #include diff --git a/ucs/database.cpp b/ucs/database.cpp index 4e41a3180..4d055e2a4 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -43,8 +43,8 @@ #include "database.h" #include "../common/eq_packet_structs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "chatchannel.h" extern Clientlist *CL; diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index 322b58983..46d898f6b 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -20,7 +20,7 @@ #include "../common/debug.h" #include "clientlist.h" #include "../common/opcodemgr.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream_factory.h" #include "../common/rulesys.h" #include "../common/servertalk.h" #include "../common/platform.h" diff --git a/utils/player_profile_set/player_profile_set/MiscFunctions.cpp b/utils/player_profile_set/player_profile_set/MiscFunctions.cpp index 5af82a611..aae237489 100644 --- a/utils/player_profile_set/player_profile_set/MiscFunctions.cpp +++ b/utils/player_profile_set/player_profile_set/MiscFunctions.cpp @@ -1,4 +1,4 @@ -#include "MiscFunctions.h" +#include "misc_functions.h" #include #include #include diff --git a/utils/player_profile_set/player_profile_set/database.h b/utils/player_profile_set/player_profile_set/database.h index 499449634..cc82333d9 100644 --- a/utils/player_profile_set/player_profile_set/database.h +++ b/utils/player_profile_set/player_profile_set/database.h @@ -1,7 +1,7 @@ #if !defined(_L__EQDATAB__H) #define _L__EQDATAB__H -#include "MiscFunctions.h" +#include "misc_functions.h" #ifdef WIN32 #include diff --git a/world/Adventure.cpp b/world/Adventure.cpp index 162c4563b..b66735176 100644 --- a/world/Adventure.cpp +++ b/world/Adventure.cpp @@ -2,8 +2,8 @@ #include "../common/servertalk.h" #include "../common/extprofile.h" #include "../common/rulesys.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "Adventure.h" #include "AdventureManager.h" #include "worlddb.h" diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 5768bb9b2..33ac522b8 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -1,6 +1,6 @@ #include "../common/debug.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/servertalk.h" #include "../common/rulesys.h" #include "Adventure.h" diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index ca48ea610..7d4e2adeb 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -53,7 +53,7 @@ SET(world_headers LoginServerList.h net.h queryserv.h - SoFCharCreateData.h + sofCharCreateData.h ucs.h wguild_mgr.h WorldConfig.h diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 6c5ddaf39..c89c90428 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -20,7 +20,7 @@ #include "worlddb.h" #include "LauncherLink.h" #include "LauncherList.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include #include diff --git a/world/EQW.cpp b/world/EQW.cpp index 070383dc3..8ff7ac298 100644 --- a/world/EQW.cpp +++ b/world/EQW.cpp @@ -25,7 +25,7 @@ #include "../common/races.h" #include "../common/classes.h" #include "../common/misc.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "zoneserver.h" #include "zonelist.h" #include "clientlist.h" diff --git a/world/EQWHTTPHandler.h b/world/EQWHTTPHandler.h index ab88a6e0b..0545adb42 100644 --- a/world/EQWHTTPHandler.h +++ b/world/EQWHTTPHandler.h @@ -18,8 +18,8 @@ #ifndef EQWHTTPHandler_H #define EQWHTTPHandler_H -#include "../common/TCPServer.h" -#include "../common/TCPConnection.h" +#include "../common/tcp_server.h" +#include "../common/tcp_connection.h" #include "../common/SocketLib/HttpdSocket.h" #include "../common/SocketLib/Mime.h" #include "../common/types.h" diff --git a/world/LauncherLink.cpp b/world/LauncherLink.cpp index de0f20384..3b2463880 100644 --- a/world/LauncherLink.cpp +++ b/world/LauncherLink.cpp @@ -25,7 +25,7 @@ #include "../common/packet_dump.h" #include "../common/servertalk.h" #include "../common/emu_tcp_connection.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "worlddb.h" #include "EQLConfig.h" diff --git a/world/LoginServer.cpp b/world/LoginServer.cpp index 992f1d50a..3b4781a2a 100644 --- a/world/LoginServer.cpp +++ b/world/LoginServer.cpp @@ -56,7 +56,7 @@ #include "LoginServerList.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "zoneserver.h" #include "worlddb.h" #include "zonelist.h" diff --git a/world/client.cpp b/world/client.cpp index fd45567c6..150d6a9c9 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1,19 +1,19 @@ #include "../common/debug.h" -#include "../common/EQPacket.h" -#include "../common/EQStreamIntf.h" +#include "../common/eq_packet.h" +#include "../common/eq_stream_intf.h" #include "../common/misc.h" #include "../common/rulesys.h" #include "../common/emu_opcodes.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" -#include "../common/EQStreamIntf.h" -#include "../common/Item.h" +#include "../common/eq_stream_intf.h" +#include "../common/item.h" #include "../common/races.h" #include "../common/classes.h" #include "../common/languages.h" #include "../common/skills.h" #include "../common/extprofile.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/clientversions.h" #include "client.h" @@ -25,7 +25,7 @@ #include "zonelist.h" #include "clientlist.h" #include "wguild_mgr.h" -#include "SoFCharCreateData.h" +#include "sofCharCreateData.h" #include #include diff --git a/world/client.h b/world/client.h index 8d17864ec..bdf1afbec 100644 --- a/world/client.h +++ b/world/client.h @@ -20,7 +20,7 @@ #include -//#include "../common/EQStream.h" +//#include "../common/eq_stream.h" #include "../common/linked_list.h" #include "../common/timer.h" //#include "zoneserver.h" diff --git a/world/cliententry.cpp b/world/cliententry.cpp index a125b706f..131fceb3d 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -24,7 +24,7 @@ #include "zoneserver.h" #include "WorldConfig.h" #include "../common/guilds.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" extern uint32 numplayers; extern LoginServerList loginserverlist; diff --git a/world/clientlist.cpp b/world/clientlist.cpp index acb582d22..6de17d176 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -22,7 +22,7 @@ #include "client.h" #include "console.h" #include "worlddb.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/guilds.h" #include "../common/races.h" #include "../common/classes.h" diff --git a/world/console.cpp b/world/console.cpp index 2cd4dac80..e46a880e8 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -30,7 +30,7 @@ #include "../common/packet_dump.h" #include "../common/seperator.h" #include "../common/eq_packet_structs.h" -#include "../common/EQPacket.h" +#include "../common/eq_packet.h" #include "LoginServer.h" #include "LoginServerList.h" #include "../common/serverinfo.h" @@ -38,7 +38,7 @@ #include "../common/opcodemgr.h" #include "../common/rulesys.h" #include "../common/ruletypes.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "WorldConfig.h" #include "zoneserver.h" #include "zonelist.h" diff --git a/world/lfplist.cpp b/world/lfplist.cpp index 3e2e7611c..52474dfda 100644 --- a/world/lfplist.cpp +++ b/world/lfplist.cpp @@ -22,7 +22,7 @@ #include "zoneserver.h" #include "zonelist.h" #include "../common/logsys.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" extern ClientList client_list; extern ZSList zoneserver_list; diff --git a/world/net.cpp b/world/net.cpp index 663205286..885d27c7d 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -27,22 +27,21 @@ #include "../common/debug.h" #include "../common/queue.h" #include "../common/timer.h" -#include "../common/EQStreamFactory.h" -#include "../common/EQPacket.h" -#include "client.h" -#include "worlddb.h" +#include "../common/eq_stream_factory.h" +#include "../common/eq_packet.h" #include "../common/seperator.h" #include "../common/version.h" #include "../common/eqtime.h" #include "../common/timeoutmgr.h" -#include "../common/EQEMuError.h" +#include "../common/eqemu_error.h" #include "../common/opcodemgr.h" #include "../common/guilds.h" -#include "../common/EQStreamIdent.h" -//#include "../common/patches/Client62.h" +#include "../common/eq_stream_ident.h" #include "../common/rulesys.h" #include "../common/platform.h" #include "../common/crash.h" +#include "client.h" +#include "worlddb.h" #ifdef _WINDOWS #include #define snprintf _snprintf diff --git a/world/world_logsys.cpp b/world/world_logsys.cpp index d7f798b6c..351af9767 100644 --- a/world/world_logsys.cpp +++ b/world/world_logsys.cpp @@ -1,7 +1,7 @@ #include "../common/debug.h" #include "../common/logsys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "zoneserver.h" #include "client.h" diff --git a/world/worlddb.cpp b/world/worlddb.cpp index ab8f6099a..e6c3492e9 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -17,16 +17,16 @@ */ #include "worlddb.h" -//#include "../common/Item.h" -#include "../common/StringUtil.h" +//#include "../common/item.h" +#include "../common/string_util.h" #include "../common/eq_packet_structs.h" -#include "../common/Item.h" +#include "../common/item.h" #include "../common/dbasync.h" #include "../common/rulesys.h" #include #include #include -#include "SoFCharCreateData.h" +#include "sofCharCreateData.h" WorldDatabase database; extern std::vector character_create_allocations; diff --git a/world/worlddb.h b/world/worlddb.h index 0dcb6ef44..24f43d308 100644 --- a/world/worlddb.h +++ b/world/worlddb.h @@ -19,7 +19,7 @@ #define WORLDDB_H_ #include "../common/shareddb.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" struct PlayerProfile_Struct; struct CharCreate_Struct; diff --git a/world/zonelist.cpp b/world/zonelist.cpp index db4843926..6b82c0fe9 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -23,7 +23,7 @@ #include "console.h" #include "WorldConfig.h" #include "../common/servertalk.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" extern uint32 numzones; extern bool holdzones; diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 9c40ce516..6f8833bd1 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -29,7 +29,7 @@ #include "../common/guilds.h" #include "../common/packet_dump.h" #include "../common/misc.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "cliententry.h" #include "wguild_mgr.h" #include "lfplist.h" diff --git a/zone/AA.cpp b/zone/AA.cpp index de3704fcd..3c3375fd9 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -34,7 +34,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) #include "../common/classes.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/logsys.h" #include "zonedb.h" #include "StringIDs.h" diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index 021d6f76b..d367c417e 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -27,8 +27,8 @@ #include "map.h" #include "../common/moremath.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "../common/features.h" #include "QuestParserCollection.h" diff --git a/zone/Object.cpp b/zone/Object.cpp index ea746c090..666f5da1f 100644 --- a/zone/Object.cpp +++ b/zone/Object.cpp @@ -24,8 +24,8 @@ #include "zonedb.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/features.h" #include "StringIDs.h" diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index d21bebf2d..85165820b 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -1,5 +1,5 @@ #include "../common/debug.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "QGlobals.h" #include "masterentity.h" #include "zone.h" diff --git a/zone/QuestParserCollection.cpp b/zone/QuestParserCollection.cpp index 834cf1528..513334ff1 100644 --- a/zone/QuestParserCollection.cpp +++ b/zone/QuestParserCollection.cpp @@ -17,7 +17,7 @@ */ #include "../common/debug.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "../common/features.h" #include "QuestParserCollection.h" #include "QuestInterface.h" diff --git a/zone/QuestParserCollection.h b/zone/QuestParserCollection.h index f9da8c79c..ff8eb967e 100644 --- a/zone/QuestParserCollection.h +++ b/zone/QuestParserCollection.h @@ -20,7 +20,7 @@ #define _EQE_QUESTPARSERCOLLECTION_H #include "../common/types.h" -#include "../common/Item.h" +#include "../common/item.h" #include "masterentity.h" #include "QuestInterface.h" diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 3c6c306ac..bb8e1c390 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -23,7 +23,7 @@ #include "map.h" #include "../common/spdat.h" #include "../common/skills.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "../common/rulesys.h" #include "StringIDs.h" #include diff --git a/zone/attack.cpp b/zone/attack.cpp index 234149eff..c8d29efac 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -37,7 +37,7 @@ #include "../common/spdat.h" #include "zone.h" #include "StringIDs.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "QuestParserCollection.h" #include "water_map.h" diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 8ccc8d64e..a57648ac6 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -20,7 +20,7 @@ #include "masterentity.h" #include "../common/packet_dump.h" #include "../common/moremath.h" -#include "../common/Item.h" +#include "../common/item.h" #include "worldserver.h" #include "../common/skills.h" #include "../common/bodytypes.h" diff --git a/zone/bot.cpp b/zone/bot.cpp index aa5ab33f0..a2aa4504b 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4,7 +4,7 @@ #include "object.h" #include "doors.h" #include "QuestParserCollection.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" extern volatile bool ZoneLoaded; diff --git a/zone/bot.h b/zone/bot.h index eba10a54e..3799b5f0b 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -11,7 +11,7 @@ #include "corpse.h" #include "zonedb.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "../common/debug.h" #include "guild_mgr.h" #include "worldserver.h" diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 14f243d19..4917ed953 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1,7 +1,7 @@ #ifdef BOTS #include "bot.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { diff --git a/zone/client.cpp b/zone/client.cpp index 2f2b4d370..617eceddf 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -49,12 +49,12 @@ extern volatile bool RunLoops; #include "../common/packet_functions.h" #include "petitions.h" #include "../common/serverinfo.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" #include "../common/breakdowns.h" #include "../common/rulesys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "forage.h" #include "command.h" #include "StringIDs.h" diff --git a/zone/client.h b/zone/client.h index 718efbb6e..5bd910ce9 100644 --- a/zone/client.h +++ b/zone/client.h @@ -24,15 +24,15 @@ class Client; #include "../common/emu_opcodes.h" #include "../common/eq_packet_structs.h" #include "../common/eq_constants.h" -#include "../common/EQStreamIntf.h" -#include "../common/EQPacket.h" +#include "../common/eq_stream_intf.h" +#include "../common/eq_packet.h" #include "../common/linked_list.h" #include "../common/extprofile.h" #include "../common/classes.h" #include "../common/races.h" #include "../common/deity.h" #include "../common/seperator.h" -#include "../common/Item.h" +#include "../common/item.h" #include "../common/guilds.h" #include "../common/item_struct.h" #include "../common/clientversions.h" diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 66eeb9d11..08c652c75 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -22,7 +22,7 @@ #include "../common/packet_dump.h" #include "../common/packet_functions.h" #include "../common/serverinfo.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" #include "../common/logsys.h" diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ff8b9e717..8a1c39934 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -45,7 +45,7 @@ #include "worldserver.h" #include "../common/rdtsc.h" #include "../common/packet_dump_file.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/breakdowns.h" #include "../common/guilds.h" #include "../common/rulesys.h" @@ -67,7 +67,7 @@ #include "pathing.h" #include "water_map.h" #include "merc.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "QuestParserCollection.h" extern Zone* zone; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index acdf67be8..be8b23622 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -47,7 +47,7 @@ #include "../common/packet_dump.h" #include "worldserver.h" #include "../common/packet_dump_file.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/spdat.h" #include "petitions.h" #include "NpcAI.h" diff --git a/zone/command.cpp b/zone/command.cpp index 11f60bfd1..c50956d39 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -47,10 +47,10 @@ #include "../common/packet_dump.h" #include "../common/serverinfo.h" #include "../common/opcodemgr.h" -#include "../common/EQPacket.h" +#include "../common/eq_packet.h" #include "../common/guilds.h" #include "../common/rulesys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" //#include "../common/servertalk.h" // for oocmute and revoke #include "worldserver.h" #include "masterentity.h" diff --git a/zone/command.h b/zone/command.h index 087e1204c..6a880625e 100644 --- a/zone/command.h +++ b/zone/command.h @@ -21,7 +21,7 @@ #define COMMAND_H #include "../common/seperator.h" -#include "../common/EQStream.h" +#include "../common/eq_stream.h" #include "client.h" #define COMMAND_CHAR '#' diff --git a/zone/corpse.cpp b/zone/corpse.cpp index d4e1a5693..8d0f1d5e1 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -35,7 +35,7 @@ Child of the Mob class. #include "masterentity.h" #include "../common/packet_functions.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/crc32.h" #include "StringIDs.h" #include "worldserver.h" diff --git a/zone/doors.cpp b/zone/doors.cpp index a453191a1..a2b774038 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -25,7 +25,7 @@ #include "zonedb.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "guild_mgr.h" #define OPEN_DOOR 0x02 diff --git a/zone/effects.cpp b/zone/effects.cpp index 1b1eeb2ea..1b87de0fe 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -24,7 +24,7 @@ #include "../common/packet_functions.h" #include "petitions.h" #include "../common/serverinfo.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" #include "StringIDs.h" diff --git a/zone/embparser.cpp b/zone/embparser.cpp index c869104f8..1e38597ae 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -20,8 +20,8 @@ #include "../common/debug.h" #include "../common/seperator.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/features.h" #include "masterentity.h" #include "embparser.h" diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 91b6d1836..b2c4b02ad 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -22,7 +22,7 @@ #ifdef EMBPERL_XS #include "../common/debug.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "embparser.h" #include "questmgr.h" #include "embxs.h" diff --git a/zone/exp.cpp b/zone/exp.cpp index 75d95bf25..95f786e55 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -19,7 +19,7 @@ #include "../common/features.h" #include "masterentity.h" #include "StringIDs.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "QuestParserCollection.h" diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index 10c66b730..636422b3f 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -23,7 +23,7 @@ #include #include "../common/rulesys.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "map.h" #include "zone.h" #include "pathing.h" diff --git a/zone/forage.cpp b/zone/forage.cpp index 19e52d96d..ba4542575 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -31,8 +31,8 @@ #include "water_map.h" #include "titles.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "zonedb.h" diff --git a/zone/groups.cpp b/zone/groups.cpp index d948eb476..5075ee82a 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -20,7 +20,7 @@ #include "NpcAI.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "worldserver.h" extern EntityList entity_list; extern WorldServer worldserver; diff --git a/zone/guild.cpp b/zone/guild.cpp index 21e350cdf..b803636f1 100644 --- a/zone/guild.cpp +++ b/zone/guild.cpp @@ -25,10 +25,10 @@ #include "../common/packet_functions.h" #include "petitions.h" #include "../common/serverinfo.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "guild_mgr.h" #include "StringIDs.h" #include "NpcAI.h" diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index f6f57fe51..087878ffc 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -20,7 +20,7 @@ #include "zonedb.h" #include "worldserver.h" #include "../common/servertalk.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "client.h" #include "entity.h" diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 2d7bd3ea6..5d9cde5c1 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -23,7 +23,7 @@ #include #include "masterentity.h" #include "../common/rulesys.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "hate_list.h" #include "QuestParserCollection.h" #include "zone.h" diff --git a/zone/horse.cpp b/zone/horse.cpp index 04c826df0..02d08b1bb 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -18,9 +18,9 @@ #include "../common/debug.h" #include "masterentity.h" -#include "../common/Item.h" +#include "../common/item.h" #include "../common/linked_list.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include #include #include "worldserver.h" diff --git a/zone/inventory.cpp b/zone/inventory.cpp index c626fad43..e013b32e0 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -25,11 +25,11 @@ #include "../common/packet_functions.h" #include "petitions.h" #include "../common/serverinfo.h" -#include "../common/ZoneNumbers.h" +#include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" #include "../common/logsys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "StringIDs.h" #include "NpcAI.h" #include "QuestParserCollection.h" diff --git a/zone/loottables.cpp b/zone/loottables.cpp index 41de7c6eb..b2ebec5ff 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -22,7 +22,7 @@ #include "npc.h" #include "masterentity.h" #include "zonedb.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #ifdef _WINDOWS #define snprintf _snprintf #endif diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 8064106dc..472962b59 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -10,7 +10,7 @@ #include "masterentity.h" #include "../common/seperator.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "lua_item.h" #include "lua_iteminst.h" #include "lua_entity.h" diff --git a/zone/map.cpp b/zone/map.cpp index 42c295e0d..25e57340f 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -1,5 +1,5 @@ #include "../common/debug.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "map.h" #include "RaycastMesh.h" #include "zone.h" diff --git a/zone/merc.cpp b/zone/merc.cpp index ff4581489..aabf3c6b7 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -8,8 +8,8 @@ #include "../common/spdat.h" #include "zone.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "QuestParserCollection.h" #include "water_map.h" diff --git a/zone/mob.cpp b/zone/mob.cpp index a6baabd1a..07f7b43b1 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -21,7 +21,7 @@ #include "StringIDs.h" #include "worldserver.h" #include "QuestParserCollection.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include #include diff --git a/zone/net.cpp b/zone/net.cpp index 15e108e42..968de9490 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -22,20 +22,20 @@ #include "../common/features.h" #include "../common/queue.h" #include "../common/timer.h" -#include "../common/EQStream.h" -#include "../common/EQStreamFactory.h" +#include "../common/eq_stream.h" +#include "../common/eq_stream_factory.h" #include "../common/eq_packet_structs.h" #include "../common/Mutex.h" #include "../common/version.h" -#include "../common/EQEMuError.h" +#include "../common/eqemu_error.h" #include "../common/packet_dump_file.h" #include "../common/opcodemgr.h" #include "../common/guilds.h" -#include "../common/EQStreamIdent.h" +#include "../common/eq_stream_ident.h" #include "../common/patches/patches.h" #include "../common/rulesys.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/platform.h" #include "../common/crash.h" #include "../common/ipc_mutex.h" diff --git a/zone/npc.cpp b/zone/npc.cpp index f4e307bbc..32d33d75b 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -40,8 +40,8 @@ #include "../common/spdat.h" #include "../common/bodytypes.h" #include "spawngroup.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "StringIDs.h" diff --git a/zone/object.h b/zone/object.h index 1f0955c1f..226b02ec5 100644 --- a/zone/object.h +++ b/zone/object.h @@ -25,7 +25,7 @@ #include "../common/linked_list.h" #include "../common/emu_opcodes.h" #include "../common/eq_packet_structs.h" -#include "../common/Item.h" +#include "../common/item.h" #include "client.h" #include "mob.h" #include "npc.h" diff --git a/zone/oldcode.cpp b/zone/oldcode.cpp index 031e2492f..7abc79b5c 100644 --- a/zone/oldcode.cpp +++ b/zone/oldcode.cpp @@ -67,12 +67,12 @@ extern volatile bool ZoneLoaded; #include "../common/queue.h" #include "../common/timer.h" -#include "../common/EQStream.h" +#include "../common/eq_stream.h" #include "../common/eq_packet_structs.h" #include "../common/Mutex.h" #include "../common/version.h" #include "../common/files.h" -#include "../common/EQEMuError.h" +#include "../common/eqemu_error.h" #include "../common/packet_dump_file.h" #include "masterentity.h" diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 54e1f06a6..c860913fe 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -7,7 +7,7 @@ #include #include "pathing.h" #include "water_map.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "doors.h" #include "client.h" #include "zone.h" diff --git a/zone/perl_questitem.cpp b/zone/perl_questitem.cpp index f9128718b..7738b12fb 100644 --- a/zone/perl_questitem.cpp +++ b/zone/perl_questitem.cpp @@ -26,7 +26,7 @@ #undef seed #endif -#include "../common/Item.h" +#include "../common/item.h" #ifdef THIS /* this macro seems to leak out on some systems */ #undef THIS diff --git a/zone/perlpacket.cpp b/zone/perlpacket.cpp index 262c2a278..1475ff448 100644 --- a/zone/perlpacket.cpp +++ b/zone/perlpacket.cpp @@ -22,7 +22,7 @@ #include "entity.h" #include "../common/opcodemgr.h" #include "../common/packet_dump.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" PerlPacket::PerlPacket(const char *opcode, uint32 length) { SetOpcode(opcode); diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 040a1dfcf..e7a210a6e 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -32,7 +32,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" #include "../common/packet_dump_file.h" diff --git a/zone/petitions.h b/zone/petitions.h index 76db9b006..732b54250 100644 --- a/zone/petitions.h +++ b/zone/petitions.h @@ -23,7 +23,7 @@ #include "zonedb.h" #include "client.h" #include "../common/Mutex.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" class Petition { diff --git a/zone/pets.cpp b/zone/pets.cpp index c7b4b1eac..f2876e0b0 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -20,13 +20,13 @@ #include "masterentity.h" #include "../common/packet_dump.h" #include "../common/moremath.h" -#include "../common/Item.h" +#include "../common/item.h" #include "zonedb.h" #include "worldserver.h" #include "../common/skills.h" #include "../common/bodytypes.h" #include "../common/classes.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "pets.h" #include #include diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 3d3dfd225..fd5c3a376 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -67,7 +67,7 @@ And then at then end of embparser.cpp, add: #include "zonedb.h" #include "../common/spdat.h" #include "../common/packet_functions.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "spawn2.h" #include "zone.h" #include "event_codes.h" diff --git a/zone/raids.cpp b/zone/raids.cpp index c712fc4bd..06630afee 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -20,7 +20,7 @@ #include "NpcAI.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "worldserver.h" extern EntityList entity_list; extern WorldServer worldserver; diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 8d2d47fc0..dd541e0a2 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include #include "spawn2.h" #include "entity.h" diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index 0044b06eb..04e37cd59 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -23,8 +23,8 @@ #include #include "../common/types.h" #include "zonedb.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" extern EntityList entity_list; diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index bd6708a88..691cc98b3 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -24,7 +24,7 @@ #include "masterentity.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "../common/rulesys.h" diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 2092aeb2f..3856f66da 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -20,7 +20,7 @@ #include "masterentity.h" #include "../common/packet_dump.h" #include "../common/moremath.h" -#include "../common/Item.h" +#include "../common/item.h" #include "worldserver.h" #include "../common/skills.h" #include "../common/bodytypes.h" diff --git a/zone/spells.cpp b/zone/spells.cpp index 5d891629e..96980b986 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -71,13 +71,13 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include "masterentity.h" #include "../common/packet_dump.h" #include "../common/moremath.h" -#include "../common/Item.h" +#include "../common/item.h" #include "worldserver.h" #include "../common/skills.h" #include "../common/bodytypes.h" #include "../common/classes.h" #include "../common/rulesys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include #include diff --git a/zone/tasks.cpp b/zone/tasks.cpp index ddcabb3f4..c73cdd0fd 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -27,8 +27,8 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) #define strcasecmp _stricmp #endif -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "masterentity.h" #include "../common/features.h" diff --git a/zone/titles.cpp b/zone/titles.cpp index f51937dba..802d33935 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -19,7 +19,7 @@ #include "../common/eq_packet_structs.h" #include "masterentity.h" #include "titles.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "worldserver.h" extern WorldServer worldserver; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index d89692dbb..dc5a4a1e3 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -30,8 +30,8 @@ #include "../common/packet_dump.h" #include "titles.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "QuestParserCollection.h" diff --git a/zone/trading.cpp b/zone/trading.cpp index 9a504d2cb..d8f17cd9b 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -18,7 +18,7 @@ #include "../common/debug.h" #include "masterentity.h" #include "StringIDs.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "QuestParserCollection.h" #include "worldserver.h" diff --git a/zone/trap.cpp b/zone/trap.cpp index 2ab431c24..badd14c6c 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -20,8 +20,8 @@ #include "entity.h" #include "masterentity.h" #include "../common/spdat.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" /* diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 63166cc41..c70afc992 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -20,7 +20,7 @@ #include "../common/features.h" #include "masterentity.h" #include "../common/packet_dump.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include #include diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index eb22f13a8..1f30b7ff3 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -29,8 +29,8 @@ #include "water_map.h" #include "../common/moremath.h" #include "StringIDs.h" -#include "../common/MiscFunctions.h" -#include "../common/StringUtil.h" +#include "../common/misc_functions.h" +#include "../common/string_util.h" #include "../common/rulesys.h" #include "../common/features.h" #include "QuestParserCollection.h" diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index edadc94f3..4c3e53189 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -36,7 +36,7 @@ #include "worldserver.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" -#include "../common/MiscFunctions.h" +#include "../common/misc_functions.h" #include "zonedb.h" #include "zone.h" #include "entity.h" diff --git a/zone/zone.cpp b/zone/zone.cpp index d0d8efb2f..7252d843e 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -43,9 +43,9 @@ #include "net.h" #include "../common/seperator.h" #include "../common/packet_dump_file.h" -#include "../common/EQStreamFactory.h" -#include "../common/EQStream.h" -#include "../common/StringUtil.h" +#include "../common/eq_stream_factory.h" +#include "../common/eq_stream.h" +#include "../common/string_util.h" #include "ZoneConfig.h" #include "../common/breakdowns.h" #include "map.h" diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 0d1653453..92bf3cc22 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1,7 +1,7 @@ #include "zonedb.h" -#include "../common/Item.h" -#include "../common/StringUtil.h" +#include "../common/item.h" +#include "../common/string_util.h" #include "../common/extprofile.h" #include "../common/guilds.h" #include "../common/rulesys.h" diff --git a/zone/zonedbasync.cpp b/zone/zonedbasync.cpp index 4d1bf8491..579517d55 100644 --- a/zone/zonedbasync.cpp +++ b/zone/zonedbasync.cpp @@ -2,7 +2,7 @@ #include #include "entity.h" #include "masterentity.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "../common/breakdowns.h" #include diff --git a/zone/zonedump.h b/zone/zonedump.h index 052f7446d..0d2bcb1d2 100644 --- a/zone/zonedump.h +++ b/zone/zonedump.h @@ -28,7 +28,7 @@ spawn2 mediumblob, npcs mediumblob, npc_loot mediumblob, gmspawntype mediumblob, #define ZONEDUMP_H #include "../common/faction.h" #include "../common/eq_packet_structs.h" -#include "../common/Item.h" +#include "../common/item.h" #pragma pack(1) diff --git a/zone/zoning.cpp b/zone/zoning.cpp index f69598ce5..35041a4c1 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -22,7 +22,7 @@ #include "masterentity.h" #include "../common/packet_dump.h" #include "../common/rulesys.h" -#include "../common/StringUtil.h" +#include "../common/string_util.h" #include "StringIDs.h" #include "QuestParserCollection.h" From 0b63eaa25d4a8b97f3ee1f30505b7f2549f4457c Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 19:34:45 -0700 Subject: [PATCH 150/217] Got rid of socket_server, why the heck is it still around --- socket_server/CMakeLists.txt | 44 ---- socket_server/database.cpp | 131 ------------ socket_server/database.h | 54 ----- socket_server/socket_server.cpp | 281 ------------------------- socket_server/socket_server_config.cpp | 28 --- socket_server/socket_server_config.h | 55 ----- socket_server/worldserver.cpp | 68 ------ socket_server/worldserver.h | 35 --- 8 files changed, 696 deletions(-) delete mode 100644 socket_server/CMakeLists.txt delete mode 100644 socket_server/database.cpp delete mode 100644 socket_server/database.h delete mode 100644 socket_server/socket_server.cpp delete mode 100644 socket_server/socket_server_config.cpp delete mode 100644 socket_server/socket_server_config.h delete mode 100644 socket_server/worldserver.cpp delete mode 100644 socket_server/worldserver.h diff --git a/socket_server/CMakeLists.txt b/socket_server/CMakeLists.txt deleted file mode 100644 index abaec0f21..000000000 --- a/socket_server/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) - -SET(socket_server_sources - database.cpp - socket_server.cpp - socket_server_config.cpp - worldserver.cpp -) - -SET(socket_server_headers - database.h - socket_server_config.h - worldserver.h -) - -ADD_EXECUTABLE(socket_server ${socket_server_sources} ${socket_server_headers}) - -INSTALL(TARGETS socket_server RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) - -ADD_DEFINITIONS(-DQSERV) - -TARGET_LINK_LIBRARIES(socket_server Common ${Boost_LIBRARIES} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) - -IF(MSVC) - SET_TARGET_PROPERTIES(socket_server PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") - TARGET_LINK_LIBRARIES(socket_server "Ws2_32.lib") -ENDIF(MSVC) - -IF(MINGW) - TARGET_LINK_LIBRARIES(socket_server "WS2_32") -ENDIF(MINGW) - -IF(UNIX) - TARGET_LINK_LIBRARIES(socket_server "${CMAKE_DL_LIBS}") - TARGET_LINK_LIBRARIES(socket_server "z") - TARGET_LINK_LIBRARIES(socket_server "m") - IF(NOT DARWIN) - TARGET_LINK_LIBRARIES(socket_server "rt") - ENDIF(NOT DARWIN) - TARGET_LINK_LIBRARIES(socket_server "pthread") - ADD_DEFINITIONS(-fPIC) -ENDIF(UNIX) - -SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin) diff --git a/socket_server/database.cpp b/socket_server/database.cpp deleted file mode 100644 index d27079af0..000000000 --- a/socket_server/database.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - - -#include "../common/debug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Disgrace: for windows compile -#ifdef _WINDOWS -#include -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#else -#include "../common/unix.h" -#include -#endif - -#include "database.h" -#include "../common/eq_packet_structs.h" -#include "../common/string_util.h" -#include "../common/servertalk.h" - -Database::Database () -{ - DBInitVars(); -} - -/* -Establish a connection to a mysql database with the supplied parameters -*/ - -Database::Database(const char* host, const char* user, const char* passwd, const char* database, uint32 port) -{ - DBInitVars(); - Connect(host, user, passwd, database, port); -} - -bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port) -{ - uint32 errnum= 0; - char errbuf[MYSQL_ERRMSG_SIZE]; - if (!Open(host, user, passwd, database, port, &errnum, errbuf)) - { - LogFile->write(EQEMuLog::Error, "Failed to connect to database: Error: %s", errbuf); - HandleMysqlError(errnum); - - return false; - } - else - { - LogFile->write(EQEMuLog::Status, "Using database '%s' at %s:%d",database,host,port); - return true; - } -} - -void Database::DBInitVars() { - -} - - - -void Database::HandleMysqlError(uint32 errnum) { -} - -/* - -Close the connection to the database -*/ -Database::~Database() -{ -} - -bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) { - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `value` from `variables` where `varname`='%s'", varname), errbuf, &result)) { - - _log(UCS__ERROR, "Unable to get message count from database. %s %s", query, errbuf); - - safe_delete_array(query); - - return false; - } - - safe_delete_array(query); - - if (mysql_num_rows(result) != 1) { - - mysql_free_result(result); - - return false; - } - - row = mysql_fetch_row(result); - - snprintf(varvalue, varvalue_len, "%s", row[0]); - - mysql_free_result(result); - - return true; -} \ No newline at end of file diff --git a/socket_server/database.h b/socket_server/database.h deleted file mode 100644 index 6500ffad6..000000000 --- a/socket_server/database.h +++ /dev/null @@ -1,54 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -#ifndef CHATSERVER_DATABASE_H -#define CHATSERVER_DATABASE_H - -#define AUTHENTICATION_TIMEOUT 60 -#define INVALID_ID 0xFFFFFFFF - -#include "../common/debug.h" -#include "../common/types.h" -#include "../common/dbcore.h" -#include "../common/linked_list.h" -#include "../common/servertalk.h" -#include -#include -#include - -//atoi is not uint32 or uint32 safe!!!! -#define atoul(str) strtoul(str, nullptr, 10) - -class Database : public DBcore { -public: - Database(); - 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); - ~Database(); - - bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); -protected: - void HandleMysqlError(uint32 errnum); -private: - void DBInitVars(); - -}; - -#endif - diff --git a/socket_server/socket_server.cpp b/socket_server/socket_server.cpp deleted file mode 100644 index 71c8342ff..000000000 --- a/socket_server/socket_server.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -#include -#include -#include -/*#include -#include -#include */ -#include - -typedef websocketpp::server server; - -using websocketpp::connection_hdl; -using websocketpp::lib::placeholders::_1; -using websocketpp::lib::placeholders::_2; -using websocketpp::lib::bind; - -using websocketpp::lib::thread; -using websocketpp::lib::mutex; -using websocketpp::lib::unique_lock; -using websocketpp::lib::condition_variable; - -#include "../common/debug.h" -#include "../common/opcodemgr.h" -#include "../common/eq_stream_factory.h" -#include "../common/rulesys.h" -#include "../common/servertalk.h" -#include "../common/platform.h" -#include "../common/crash.h" -#include "database.h" -#include "socket_server_config.h" -#include "worldserver.h" -#include - -#include -volatile bool RunLoops = true; -TimeoutManager timeout_manager; -Database database; -std::string WorldShortName; - -const socket_server_config *Config; -WorldServer *worldserver = 0; - -void CatchSignal(int sig_num) { - RunLoops = false; - if(worldserver) - worldserver->Disconnect(); -} - -/* Web Sockets Start Shit */ - -enum action_type { - SUBSCRIBE, - UNSUBSCRIBE, - MESSAGE -}; - -struct action { - action(action_type t, connection_hdl h) : type(t), hdl(h) {} - action(action_type t, connection_hdl h, server::message_ptr m) - : type(t), hdl(h), msg(m) {} - - action_type type; - websocketpp::connection_hdl hdl; - server::message_ptr msg; -}; - -class broadcast_server { -public: - broadcast_server() { - // Initialize Asio Transport - m_server.init_asio(); - - // Register handler callbacks - m_server.set_open_handler(bind(&broadcast_server::on_open, this, ::_1)); - m_server.set_close_handler(bind(&broadcast_server::on_close, this, ::_1)); - m_server.set_message_handler(bind(&broadcast_server::on_message, this, ::_1, ::_2)); - } - - void run(uint16_t port) { - // listen on specified port - m_server.listen(port); - - // Start the server accept loop - m_server.start_accept(); - - // Start the ASIO io_service run loop - try { - m_server.run(); - } - catch (const std::exception & e) { - std::cout << e.what() << std::endl; - } - catch (websocketpp::lib::error_code e) { - std::cout << e.message() << std::endl; - } - catch (...) { - std::cout << "other exception" << std::endl; - } - } - - void on_open(connection_hdl hdl) { - unique_lock lock(m_action_lock); - //std::cout << "on_open" << std::endl; - m_actions.push(action(SUBSCRIBE, hdl)); - lock.unlock(); - m_action_cond.notify_one(); - } - - void on_close(connection_hdl hdl) { - unique_lock lock(m_action_lock); - //std::cout << "on_close" << std::endl; - m_actions.push(action(UNSUBSCRIBE, hdl)); - lock.unlock(); - m_action_cond.notify_one(); - } - - void on_message(connection_hdl hdl, server::message_ptr msg) { - // queue message up for sending by processing thread - unique_lock lock(m_action_lock); - msg->set_payload("Niggers"); - // std::cout << "on_message" << std::endl; - m_actions.push(action(MESSAGE, hdl, msg)); - lock.unlock(); - m_action_cond.notify_one(); - } - - void process_messages() { - while (1) { - unique_lock lock(m_action_lock); - - while (m_actions.empty()) { - m_action_cond.wait(lock); - } - - action a = m_actions.front(); - m_actions.pop(); - - lock.unlock(); - - if (a.type == SUBSCRIBE) { - unique_lock con_lock(m_connection_lock); - m_connections.insert(a.hdl); - } - else if (a.type == UNSUBSCRIBE) { - unique_lock con_lock(m_connection_lock); - m_connections.erase(a.hdl); - } - else if (a.type == MESSAGE) { - unique_lock con_lock(m_connection_lock); - - con_list::iterator it; - for (it = m_connections.begin(); it != m_connections.end(); ++it) { - m_server.send(*it, a.msg); - } - } - else { - // undefined. - } - } - } -private: - typedef std::set> con_list; - - server m_server; - con_list m_connections; - std::queue m_actions; - - mutex m_action_lock; - mutex m_connection_lock; - condition_variable m_action_cond; -}; - -/* Web Sockets Shit End*/ - -int main() { - - try { - broadcast_server server_instance; - - // Start a thread to run the processing loop - thread t(bind(&broadcast_server::process_messages, &server_instance)); - - // Run the asio loop with the main thread - server_instance.run(9002); - - t.join(); - - } - catch (std::exception & e) { - std::cout << e.what() << std::endl; - } - - RegisterExecutablePlatform(ExePlatformSocket_Server); - set_exception_handler(); - Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect - _log(SOCKET_SERVER__INIT, "Starting EQEmu Socket Server."); - if (!socket_server_config::LoadConfig()) { - _log(SOCKET_SERVER__INIT, "Loading server configuration failed."); - return 1; - } - - Config = socket_server_config::get(); - - if(!load_log_settings(Config->LogSettingsFile.c_str())) - _log(SOCKET_SERVER__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str()); - else - _log(SOCKET_SERVER__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str()); - - WorldShortName = Config->ShortName; - - /* - _log(SOCKET_SERVER__INIT, "Connecting to MySQL..."); - - if (!database.Connect( - Config->QSDatabaseHost.c_str(), - Config->QSDatabaseUsername.c_str(), - Config->QSDatabasePassword.c_str(), - Config->QSDatabaseDB.c_str(), - Config->QSDatabasePort)) { - _log(WORLD__INIT_ERR, "Cannot continue without a database connection."); - return 1; - } - */ - - if (signal(SIGINT, CatchSignal) == SIG_ERR) { - _log(SOCKET_SERVER__ERROR, "Could not set signal handler"); - return 1; - } - if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - _log(SOCKET_SERVER__ERROR, "Could not set signal handler"); - return 1; - } - - worldserver = new WorldServer; - worldserver->Connect(); - - while(RunLoops) { - Timer::SetCurrentTime(); - if (InterserverTimer.Check()) { - if (worldserver->TryReconnect() && (!worldserver->Connected())) - worldserver->AsyncConnect(); - } - worldserver->Process(); - timeout_manager.CheckTimeouts(); - Sleep(100); - } - - - -} - -void UpdateWindowTitle(char* iNewTitle) { -#ifdef _WINDOWS - char tmp[500]; - if (iNewTitle) { - snprintf(tmp, sizeof(tmp), "SOCKET_SERVER: %s", iNewTitle); - } - else { - snprintf(tmp, sizeof(tmp), "SOCKET_SERVER"); - } - SetConsoleTitle(tmp); -#endif -} diff --git a/socket_server/socket_server_config.cpp b/socket_server/socket_server_config.cpp deleted file mode 100644 index 8f08eba9d..000000000 --- a/socket_server/socket_server_config.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -#include "../common/debug.h" -#include "socket_server_config.h" - -socket_server_config *socket_server_config::_chat_config = nullptr; - -std::string socket_server_config::GetByName(const std::string &var_name) const { - return(EQEmuConfig::GetByName(var_name)); -} - diff --git a/socket_server/socket_server_config.h b/socket_server/socket_server_config.h deleted file mode 100644 index 73b966ce4..000000000 --- a/socket_server/socket_server_config.h +++ /dev/null @@ -1,55 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -#ifndef __socket_server_config_H -#define __socket_server_config_H - -#include "../common/eqemu_config.h" - -class socket_server_config : public EQEmuConfig { -public: - virtual std::string GetByName(const std::string &var_name) const; - -private: - - static socket_server_config *_chat_config; - -public: - - // Produce a const singleton - static const socket_server_config *get() { - if (_chat_config == nullptr) - LoadConfig(); - return(_chat_config); - } - - // Load the config - static bool LoadConfig() { - if (_chat_config != nullptr) - delete _chat_config; - _chat_config=new socket_server_config; - _config=_chat_config; - - return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server"); - } - -}; - -#endif - diff --git a/socket_server/worldserver.cpp b/socket_server/worldserver.cpp deleted file mode 100644 index 9c6afa138..000000000 --- a/socket_server/worldserver.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include "../common/debug.h" -#include -#include -#include -#include -#include -#include -#include - -#include "../common/servertalk.h" -#include "worldserver.h" -#include "socket_server_config.h" -#include "database.h" -#include "../common/packet_functions.h" -#include "../common/md5.h" -#include "../common/packet_dump.h" - -extern WorldServer worldserver; -extern const socket_server_config *Config; -extern Database database; - -WorldServer::WorldServer() -: WorldConnection(EmuTCPConnection::packetModeSocket_Server, Config->SharedKey.c_str()){ - pTryReconnect = true; -} - -WorldServer::~WorldServer(){ -} - -void WorldServer::OnConnected(){ - _log(SOCKET_SERVER__INIT, "Connected to World."); - WorldConnection::OnConnected(); -} - -void WorldServer::Process(){ - WorldConnection::Process(); - if (!Connected()) - return; - - ServerPacket *pack = 0; - while((pack = tcpc.PopPacket())){ - _log(SOCKET_SERVER__TRACE, "Received Opcode: %4X", pack->opcode); - switch(pack->opcode) { - case 0: { break; } - case ServerOP_KeepAlive: { break; } - } - } - - safe_delete(pack); - return; -} \ No newline at end of file diff --git a/socket_server/worldserver.h b/socket_server/worldserver.h deleted file mode 100644 index 167342248..000000000 --- a/socket_server/worldserver.h +++ /dev/null @@ -1,35 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef WORLDSERVER_H -#define WORLDSERVER_H - -#include "../common/worldconn.h" -#include "../common/eq_packet_structs.h" - -class WorldServer : public WorldConnection -{ - public: - WorldServer(); - virtual ~WorldServer(); - virtual void Process(); - - private: - virtual void OnConnected(); -}; -#endif - From 504a8b19ce3f00dc52f1b11a9b2666a3964c7b9e Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 19:36:50 -0700 Subject: [PATCH 151/217] Missed Mutex.h --- common/CMakeLists.txt | 2 +- common/SocketLib/socket_include.h | 2 +- common/database.h | 2 +- common/dbcore.h | 2 +- common/debug.h | 2 +- common/eq_stream.cpp | 2 +- common/eq_stream.h | 2 +- common/eqemu_error.cpp | 2 +- common/mutex.cpp | 2 +- common/{Mutex.h => mutex.h} | 0 common/opcodemgr.h | 2 +- common/tcp_connection.h | 2 +- loginserver/ErrorLog.h | 2 +- world/LoginServer.h | 2 +- world/LoginServerList.h | 2 +- world/console.h | 2 +- zone/net.cpp | 2 +- zone/oldcode.cpp | 2 +- zone/petitions.h | 2 +- zone/zone.h | 2 +- 20 files changed, 19 insertions(+), 19 deletions(-) rename common/{Mutex.h => mutex.h} (100%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ccea68596..f02212161 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -152,7 +152,7 @@ SET(common_headers misc.h misc_functions.h moremath.h - Mutex.h + mutex.h mysql_request_result.h mysql_request_row.h op_codes.h diff --git a/common/SocketLib/socket_include.h b/common/SocketLib/socket_include.h index 20bc39370..c7489ffa3 100644 --- a/common/SocketLib/socket_include.h +++ b/common/SocketLib/socket_include.h @@ -211,7 +211,7 @@ typedef unsigned short port_t; #endif #ifdef _THREADSAFE_SOCKETS -#include "Mutex.h" +#include "mutex.h" #include "Lock.h" #endif diff --git a/common/database.h b/common/database.h index 61ed19ef4..f912c18d1 100644 --- a/common/database.h +++ b/common/database.h @@ -29,7 +29,7 @@ /*#include "eq_stream.h" #include "guilds.h" #include "misc_functions.h" -#include "Mutex.h" +#include "mutex.h" #include "item.h" #include "extprofile.h"*/ #include diff --git a/common/dbcore.h b/common/dbcore.h index eb7a5832e..56f326467 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -9,7 +9,7 @@ #include #include #include "../common/types.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/linked_list.h" #include "../common/queue.h" #include "../common/timer.h" diff --git a/common/debug.h b/common/debug.h index 856e851e1..6184e4cbc 100644 --- a/common/debug.h +++ b/common/debug.h @@ -69,7 +69,7 @@ #include "logsys.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include #include diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index cb4aeb853..61dc201be 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -20,7 +20,7 @@ #include "eq_packet.h" #include "eq_stream.h" #include "misc.h" -#include "Mutex.h" +#include "mutex.h" #include "op_codes.h" #include "crc16.h" #include "platform.h" diff --git a/common/eq_stream.h b/common/eq_stream.h index ed3e26623..5a637c46e 100644 --- a/common/eq_stream.h +++ b/common/eq_stream.h @@ -12,7 +12,7 @@ #include "eq_stream_type.h" #include "eq_packet.h" #include "eq_stream_intf.h" -#include "Mutex.h" +#include "mutex.h" #include "../common/opcodemgr.h" #include "../common/misc.h" #include "../common/condition.h" diff --git a/common/eqemu_error.cpp b/common/eqemu_error.cpp index 79ce129ac..ff9a7bbd6 100644 --- a/common/eqemu_error.cpp +++ b/common/eqemu_error.cpp @@ -20,7 +20,7 @@ #endif #include "eqemu_error.h" #include "linked_list.h" -#include "Mutex.h" +#include "mutex.h" #include "misc_functions.h" #include #include diff --git a/common/mutex.cpp b/common/mutex.cpp index 763f10db4..7bea92b0d 100644 --- a/common/mutex.cpp +++ b/common/mutex.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include diff --git a/common/Mutex.h b/common/mutex.h similarity index 100% rename from common/Mutex.h rename to common/mutex.h diff --git a/common/opcodemgr.h b/common/opcodemgr.h index 690f5442a..138fadd97 100644 --- a/common/opcodemgr.h +++ b/common/opcodemgr.h @@ -20,7 +20,7 @@ #define OPCODE_MANAGER_H #include "types.h" -#include "Mutex.h" +#include "mutex.h" #include "emu_opcodes.h" #include diff --git a/common/tcp_connection.h b/common/tcp_connection.h index fbf34491c..2e5b7e883 100644 --- a/common/tcp_connection.h +++ b/common/tcp_connection.h @@ -44,7 +44,7 @@ #endif #include "types.h" -#include "Mutex.h" +#include "mutex.h" #include "queue.h" #include "misc_functions.h" diff --git a/loginserver/ErrorLog.h b/loginserver/ErrorLog.h index 224eeb352..ad54e12b7 100644 --- a/loginserver/ErrorLog.h +++ b/loginserver/ErrorLog.h @@ -23,7 +23,7 @@ #include #include -#include "../common/Mutex.h" +#include "../common/mutex.h" /** * Dictates the log type specified in ErrorLog for Log(...) diff --git a/world/LoginServer.h b/world/LoginServer.h index 45cb9c214..766bdbf38 100644 --- a/world/LoginServer.h +++ b/world/LoginServer.h @@ -23,7 +23,7 @@ #include "../common/timer.h" #include "../common/queue.h" #include "../common/eq_packet_structs.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/emu_tcp_connection.h" class LoginServer{ diff --git a/world/LoginServerList.h b/world/LoginServerList.h index f47587920..200e53b93 100644 --- a/world/LoginServerList.h +++ b/world/LoginServerList.h @@ -6,7 +6,7 @@ #include "../common/timer.h" #include "../common/queue.h" #include "../common/eq_packet_structs.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/emu_tcp_connection.h" #ifdef _WINDOWS diff --git a/world/console.h b/world/console.h index 3c900f0f0..0588d8598 100644 --- a/world/console.h +++ b/world/console.h @@ -40,7 +40,7 @@ enum { #include "../common/queue.h" #include "../common/emu_tcp_connection.h" #include "WorldTCPConnection.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" struct ServerChannelMessage_Struct; diff --git a/zone/net.cpp b/zone/net.cpp index 968de9490..6fba81d49 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -25,7 +25,7 @@ #include "../common/eq_stream.h" #include "../common/eq_stream_factory.h" #include "../common/eq_packet_structs.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/version.h" #include "../common/eqemu_error.h" #include "../common/packet_dump_file.h" diff --git a/zone/oldcode.cpp b/zone/oldcode.cpp index 7abc79b5c..30adb7f2f 100644 --- a/zone/oldcode.cpp +++ b/zone/oldcode.cpp @@ -69,7 +69,7 @@ extern volatile bool ZoneLoaded; #include "../common/timer.h" #include "../common/eq_stream.h" #include "../common/eq_packet_structs.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/version.h" #include "../common/files.h" #include "../common/eqemu_error.h" diff --git a/zone/petitions.h b/zone/petitions.h index 732b54250..4b68362e0 100644 --- a/zone/petitions.h +++ b/zone/petitions.h @@ -22,7 +22,7 @@ #include "../common/types.h" #include "zonedb.h" #include "client.h" -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/misc_functions.h" class Petition diff --git a/zone/zone.h b/zone/zone.h index 1553b72e8..0256beeec 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -18,7 +18,7 @@ #ifndef ZONE_H #define ZONE_H -#include "../common/Mutex.h" +#include "../common/mutex.h" #include "../common/linked_list.h" #include "../common/types.h" #include "../common/eqtime.h" From 8394cc9e2b28c7499b4b82ed8d2c428054876fd0 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Fri, 22 Aug 2014 00:35:14 -0400 Subject: [PATCH 152/217] Fix for NPC ranged attacks not allowing for multiple hits if set by special attack 11, also changed paramater 0 (which was incorrectly set as both 'amount of attacks' and 'min range' 0 = amount attacks 4 = min attack range Fix to spell directional effect targeting. --- zone/MobAI.cpp | 6 +- zone/special_attacks.cpp | 201 ++++++++++++++++++++------------------- zone/spells.cpp | 2 +- 3 files changed, 105 insertions(+), 104 deletions(-) diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index 021d6f76b..aae842fc8 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -1569,11 +1569,7 @@ void Mob::AI_Process() { //Do Ranged attack here if(doranged) { - int attacks = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 0); - attacks = attacks > 0 ? attacks : 1; - for(int i = 0; i < attacks; ++i) { - RangedAttack(target); - } + RangedAttack(target); } } diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index bd6708a88..9fa90cf9e 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -973,113 +973,118 @@ void NPC::RangedAttack(Mob* other) return; } - //if we have SPECATK_RANGED_ATK set then we range attack without weapon or ammo - const Item_Struct* weapon = nullptr; - const Item_Struct* ammo = nullptr; - if(!GetSpecialAbility(SPECATK_RANGED_ATK)) - { - //find our bow and ammo return if we can't find them... - return; - } + int attacks = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 0); + attacks = attacks > 0 ? attacks : 1; + for(int i = 0; i < attacks; ++i) { - int sa_min_range = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 0); //Min Range of NPC attack - int sa_max_range = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 1); //Max Range of NPC attack - - float min_range = static_cast(RuleI(Combat, MinRangedAttackDist)); - float max_range = 250; // needs to be longer than 200(most spells) - - if (sa_max_range) - max_range = static_cast(sa_max_range); - - if (sa_min_range) - min_range = static_cast(sa_min_range); - - mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", max_range); - max_range *= max_range; - if(DistNoRootNoZ(*other) > max_range) { - mlog(COMBAT__RANGED, "Ranged attack out of range...%.2f vs %.2f", DistNoRootNoZ(*other), max_range); - //target is out of range, client does a message - return; - } - else if(DistNoRootNoZ(*other) < (min_range * min_range)) - return; - - - if(!other || !IsAttackAllowed(other) || - IsCasting() || - DivineAura() || - IsStunned() || - IsFeared() || - IsMezzed() || - (GetAppearance() == eaDead)){ - return; - } - - SkillUseTypes skillinuse = SkillArchery; - skillinuse = static_cast(GetRangedSkill()); - - if(!ammo && !GetAmmoIDfile()) - ammo = database.GetItem(8005); - - if(ammo) - SendItemAnimation(other, ammo, SkillArchery); - else - ProjectileAnimation(other, 0,false,0,0,0,0,GetAmmoIDfile(),skillinuse); - - FaceTarget(other); - - if (!other->CheckHitChance(this, skillinuse, MainRange, GetSpecialAbilityParam(SPECATK_RANGED_ATK, 2))) - { - mlog(COMBAT__RANGED, "Ranged attack missed %s.", other->GetName()); - other->Damage(this, 0, SPELL_UNKNOWN, skillinuse); - } - else - { - int16 WDmg = GetWeaponDamage(other, weapon); - int16 ADmg = GetWeaponDamage(other, ammo); - int32 TotalDmg = 0; - if(WDmg > 0 || ADmg > 0) + //if we have SPECATK_RANGED_ATK set then we range attack without weapon or ammo + const Item_Struct* weapon = nullptr; + const Item_Struct* ammo = nullptr; + if(!GetSpecialAbility(SPECATK_RANGED_ATK)) { - mlog(COMBAT__RANGED, "Ranged attack hit %s.", other->GetName()); - - int32 MaxDmg = max_dmg * RuleR(Combat, ArcheryNPCMultiplier); // should add a field to npc_types - int32 MinDmg = min_dmg * RuleR(Combat, ArcheryNPCMultiplier); - - if(RuleB(Combat, UseIntervalAC)) - TotalDmg = MaxDmg; - else - TotalDmg = MakeRandomInt(MinDmg, MaxDmg); - - TotalDmg += TotalDmg * GetSpecialAbilityParam(SPECATK_RANGED_ATK, 3) / 100; //Damage modifier - - other->AvoidDamage(this, TotalDmg, false); - other->MeleeMitigation(this, TotalDmg, MinDmg); - if (TotalDmg > 0) - CommonOutgoingHitSuccess(other, TotalDmg, skillinuse); + //find our bow and ammo return if we can't find them... + return; } + int sa_min_range = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 4); //Min Range of NPC attack + int sa_max_range = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 1); //Max Range of NPC attack + + float min_range = static_cast(RuleI(Combat, MinRangedAttackDist)); + float max_range = 250; // needs to be longer than 200(most spells) + + if (sa_max_range) + max_range = static_cast(sa_max_range); + + if (sa_min_range) + min_range = static_cast(sa_min_range); + + mlog(COMBAT__RANGED, "Calculated bow range to be %.1f", max_range); + max_range *= max_range; + if(DistNoRootNoZ(*other) > max_range) { + mlog(COMBAT__RANGED, "Ranged attack out of range...%.2f vs %.2f", DistNoRootNoZ(*other), max_range); + //target is out of range, client does a message + return; + } + else if(DistNoRootNoZ(*other) < (min_range * min_range)) + return; + + + if(!other || !IsAttackAllowed(other) || + IsCasting() || + DivineAura() || + IsStunned() || + IsFeared() || + IsMezzed() || + (GetAppearance() == eaDead)){ + return; + } + + SkillUseTypes skillinuse = SkillArchery; + skillinuse = static_cast(GetRangedSkill()); + + if(!ammo && !GetAmmoIDfile()) + ammo = database.GetItem(8005); + + if(ammo) + SendItemAnimation(other, ammo, SkillArchery); + else + ProjectileAnimation(other, 0,false,0,0,0,0,GetAmmoIDfile(),skillinuse); + + FaceTarget(other); + + if (!other->CheckHitChance(this, skillinuse, MainRange, GetSpecialAbilityParam(SPECATK_RANGED_ATK, 2))) + { + mlog(COMBAT__RANGED, "Ranged attack missed %s.", other->GetName()); + other->Damage(this, 0, SPELL_UNKNOWN, skillinuse); + } else - TotalDmg = -5; + { + int16 WDmg = GetWeaponDamage(other, weapon); + int16 ADmg = GetWeaponDamage(other, ammo); + int32 TotalDmg = 0; + if(WDmg > 0 || ADmg > 0) + { + mlog(COMBAT__RANGED, "Ranged attack hit %s.", other->GetName()); + + int32 MaxDmg = max_dmg * RuleR(Combat, ArcheryNPCMultiplier); // should add a field to npc_types + int32 MinDmg = min_dmg * RuleR(Combat, ArcheryNPCMultiplier); - if (TotalDmg > 0) - other->AddToHateList(this, TotalDmg, 0, false); - else - other->AddToHateList(this, 0, 0, false); + if(RuleB(Combat, UseIntervalAC)) + TotalDmg = MaxDmg; + else + TotalDmg = MakeRandomInt(MinDmg, MaxDmg); - other->Damage(this, TotalDmg, SPELL_UNKNOWN, skillinuse); + TotalDmg += TotalDmg * GetSpecialAbilityParam(SPECATK_RANGED_ATK, 3) / 100; //Damage modifier + + other->AvoidDamage(this, TotalDmg, false); + other->MeleeMitigation(this, TotalDmg, MinDmg); + if (TotalDmg > 0) + CommonOutgoingHitSuccess(other, TotalDmg, skillinuse); + } - if (TotalDmg > 0 && HasSkillProcSuccess() && GetTarget() && !other->HasDied()) - TrySkillProc(other, skillinuse, 0, true, MainRange); + else + TotalDmg = -5; + + if (TotalDmg > 0) + other->AddToHateList(this, TotalDmg, 0, false); + else + other->AddToHateList(this, 0, 0, false); + + other->Damage(this, TotalDmg, SPELL_UNKNOWN, skillinuse); + + if (TotalDmg > 0 && HasSkillProcSuccess() && GetTarget() && !other->HasDied()) + TrySkillProc(other, skillinuse, 0, true, MainRange); + } + + //try proc on hits and misses + if(other && !other->HasDied()) + TrySpellProc(nullptr, (const Item_Struct*)nullptr, other, MainRange); + + if (HasSkillProcs() && other && !other->HasDied()) + TrySkillProc(other, skillinuse, 0, false, MainRange); + + CommonBreakInvisible(); } - - //try proc on hits and misses - if(other && !other->HasDied()) - TrySpellProc(nullptr, (const Item_Struct*)nullptr, other, MainRange); - - if (HasSkillProcs() && other && !other->HasDied()) - TrySkillProc(other, skillinuse, 0, false, MainRange); - - CommonBreakInvisible(); } uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) diff --git a/zone/spells.cpp b/zone/spells.cpp index 5d891629e..1abdbf690 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2143,7 +2143,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 { if(CheckLosFN((*iter)) || spells[spell_id].npc_no_los){ (*iter)->CalcSpellPowerDistanceMod(spell_id, 0, this); - SpellOnTarget(spell_id, spell_target, false, true, resist_adjust); + SpellOnTarget(spell_id, (*iter), false, true, resist_adjust); } } } From cd0824ee71fbac1b7073bdbcece5a68c56bf0304 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 22:43:33 -0700 Subject: [PATCH 153/217] Moved some around, more renames --- eqlaunch/CMakeLists.txt | 4 ++-- eqlaunch/eqlaunch.cpp | 2 +- eqlaunch/worldserver.cpp | 5 ++--- eqlaunch/{ZoneLaunch.cpp => zone_launch.cpp} | 7 +++---- eqlaunch/{ZoneLaunch.h => zone_launch.h} | 0 utils/{ => deprecated}/azone2/3d.hpp | 0 utils/{ => deprecated}/azone2/3d_base.hpp | 0 utils/{ => deprecated}/azone2/GLModelViewer.cpp | 0 utils/{ => deprecated}/azone2/GLModelViewer.h | 0 utils/{ => deprecated}/azone2/README | 0 utils/{ => deprecated}/azone2/archive.hpp | 0 utils/{ => deprecated}/azone2/awater.cpp | 0 utils/{ => deprecated}/azone2/awater.h | 0 utils/{ => deprecated}/azone2/azone.cpp | 0 utils/{ => deprecated}/azone2/azone.h | 0 utils/{ => deprecated}/azone2/azone.ini | 0 utils/{ => deprecated}/azone2/dat.cpp | 0 utils/{ => deprecated}/azone2/dat.hpp | 0 utils/{ => deprecated}/azone2/file.cpp | 0 utils/{ => deprecated}/azone2/file.hpp | 0 utils/{ => deprecated}/azone2/file_loader.hpp | 0 utils/{ => deprecated}/azone2/global.cpp | 0 utils/{ => deprecated}/azone2/global.hpp | 0 utils/{ => deprecated}/azone2/listobj.cpp | 0 utils/{ => deprecated}/azone2/octree.hpp | 0 utils/{ => deprecated}/azone2/pfs.cpp | 0 utils/{ => deprecated}/azone2/pfs.hpp | 0 utils/{ => deprecated}/azone2/s3d.h | 0 utils/{ => deprecated}/azone2/ter.cpp | 0 utils/{ => deprecated}/azone2/ter.hpp | 0 utils/{ => deprecated}/azone2/types.h | 0 utils/{ => deprecated}/azone2/wld.cpp | 0 utils/{ => deprecated}/azone2/wld.hpp | 0 utils/{ => deprecated}/azone2/wld_structs.hpp | 0 utils/{ => deprecated}/azone2/zon.cpp | 0 utils/{ => deprecated}/azone2/zon.hpp | 0 utils/{ => deprecated}/azone2/zonv4.cpp | 0 utils/{ => deprecated}/azone2/zonv4.hpp | 0 utils/{ => deprecated}/pfs_list/CMakeLists.txt | 0 utils/{ => deprecated}/pfs_list/Common/CMakeLists.txt | 0 utils/{ => deprecated}/pfs_list/Common/Include/Archive.h | 0 .../{ => deprecated}/pfs_list/Common/Include/Compression.h | 0 .../{ => deprecated}/pfs_list/Common/Include/PFSArchive.h | 0 .../pfs_list/Common/Include/PFSDataStructs.h | 0 .../pfs_list/Common/Source/Compression.cpp | 0 .../{ => deprecated}/pfs_list/Common/Source/PFSArchive.cpp | 0 utils/{ => deprecated}/pfs_list/PFSList/CMakeLists.txt | 0 utils/{ => deprecated}/pfs_list/PFSList/Source/main.cpp | 0 utils/{ => deprecated}/player_profile_set/Readme.txt | 0 utils/{ => deprecated}/player_profile_set/bin/database.ini | 0 .../player_profile_set/player_profile_set.sln | 0 .../player_profile_set/MiscFunctions.cpp | 0 .../player_profile_set/player_profile_set/MiscFunctions.h | 0 .../player_profile_set/player_profile_set/database.cpp | 0 .../player_profile_set/player_profile_set/database.h | 0 .../player_profile_set/eq_player_structs.h | 0 .../player_profile_set/player_profile_set/eqemu_string.h | 0 .../player_profile_set/player_profile_set/ini.cpp | 0 .../player_profile_set/player_profile_set/ini.h | 0 .../player_profile_set/player_profile_set/main.cpp | 0 .../player_profile_set/player_profile_set/main.h | 0 .../player_profile_set/player_profile_set.vcproj | 0 .../player_profile_set/player_profile_set/types.h | 0 63 files changed, 8 insertions(+), 10 deletions(-) rename eqlaunch/{ZoneLaunch.cpp => zone_launch.cpp} (99%) rename eqlaunch/{ZoneLaunch.h => zone_launch.h} (100%) rename utils/{ => deprecated}/azone2/3d.hpp (100%) rename utils/{ => deprecated}/azone2/3d_base.hpp (100%) rename utils/{ => deprecated}/azone2/GLModelViewer.cpp (100%) rename utils/{ => deprecated}/azone2/GLModelViewer.h (100%) rename utils/{ => deprecated}/azone2/README (100%) rename utils/{ => deprecated}/azone2/archive.hpp (100%) rename utils/{ => deprecated}/azone2/awater.cpp (100%) rename utils/{ => deprecated}/azone2/awater.h (100%) rename utils/{ => deprecated}/azone2/azone.cpp (100%) rename utils/{ => deprecated}/azone2/azone.h (100%) rename utils/{ => deprecated}/azone2/azone.ini (100%) rename utils/{ => deprecated}/azone2/dat.cpp (100%) rename utils/{ => deprecated}/azone2/dat.hpp (100%) rename utils/{ => deprecated}/azone2/file.cpp (100%) rename utils/{ => deprecated}/azone2/file.hpp (100%) rename utils/{ => deprecated}/azone2/file_loader.hpp (100%) rename utils/{ => deprecated}/azone2/global.cpp (100%) rename utils/{ => deprecated}/azone2/global.hpp (100%) rename utils/{ => deprecated}/azone2/listobj.cpp (100%) rename utils/{ => deprecated}/azone2/octree.hpp (100%) rename utils/{ => deprecated}/azone2/pfs.cpp (100%) rename utils/{ => deprecated}/azone2/pfs.hpp (100%) rename utils/{ => deprecated}/azone2/s3d.h (100%) rename utils/{ => deprecated}/azone2/ter.cpp (100%) rename utils/{ => deprecated}/azone2/ter.hpp (100%) rename utils/{ => deprecated}/azone2/types.h (100%) rename utils/{ => deprecated}/azone2/wld.cpp (100%) rename utils/{ => deprecated}/azone2/wld.hpp (100%) rename utils/{ => deprecated}/azone2/wld_structs.hpp (100%) rename utils/{ => deprecated}/azone2/zon.cpp (100%) rename utils/{ => deprecated}/azone2/zon.hpp (100%) rename utils/{ => deprecated}/azone2/zonv4.cpp (100%) rename utils/{ => deprecated}/azone2/zonv4.hpp (100%) rename utils/{ => deprecated}/pfs_list/CMakeLists.txt (100%) rename utils/{ => deprecated}/pfs_list/Common/CMakeLists.txt (100%) rename utils/{ => deprecated}/pfs_list/Common/Include/Archive.h (100%) rename utils/{ => deprecated}/pfs_list/Common/Include/Compression.h (100%) rename utils/{ => deprecated}/pfs_list/Common/Include/PFSArchive.h (100%) rename utils/{ => deprecated}/pfs_list/Common/Include/PFSDataStructs.h (100%) rename utils/{ => deprecated}/pfs_list/Common/Source/Compression.cpp (100%) rename utils/{ => deprecated}/pfs_list/Common/Source/PFSArchive.cpp (100%) rename utils/{ => deprecated}/pfs_list/PFSList/CMakeLists.txt (100%) rename utils/{ => deprecated}/pfs_list/PFSList/Source/main.cpp (100%) rename utils/{ => deprecated}/player_profile_set/Readme.txt (100%) rename utils/{ => deprecated}/player_profile_set/bin/database.ini (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set.sln (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/MiscFunctions.cpp (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/MiscFunctions.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/database.cpp (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/database.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/eq_player_structs.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/eqemu_string.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/ini.cpp (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/ini.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/main.cpp (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/main.h (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/player_profile_set.vcproj (100%) rename utils/{ => deprecated}/player_profile_set/player_profile_set/types.h (100%) diff --git a/eqlaunch/CMakeLists.txt b/eqlaunch/CMakeLists.txt index 922522d86..376bc8147 100644 --- a/eqlaunch/CMakeLists.txt +++ b/eqlaunch/CMakeLists.txt @@ -3,12 +3,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(eqlaunch_sources eqlaunch.cpp worldserver.cpp - ZoneLaunch.cpp + zone_launch.cpp ) SET(eqlaunch_headers worldserver.h - ZoneLaunch.h + zone_launch.h ) ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers}) diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index da14c40e8..fbac09541 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -23,7 +23,7 @@ #include "../common/platform.h" #include "../common/crash.h" #include "worldserver.h" -#include "ZoneLaunch.h" +#include "zone_launch.h" #include #include #include diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index 7b542a183..1754b6564 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -16,12 +16,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "worldserver.h" #include "../common/servertalk.h" -#include "ZoneLaunch.h" #include "../common/eqemu_config.h" #include "../common/string_util.h" - +#include "worldserver.h" +#include "zone_launch.h" WorldServer::WorldServer(std::map &zones, const char *name, const EQEmuConfig *config) : WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()), diff --git a/eqlaunch/ZoneLaunch.cpp b/eqlaunch/zone_launch.cpp similarity index 99% rename from eqlaunch/ZoneLaunch.cpp rename to eqlaunch/zone_launch.cpp index 42d1debe8..fee133da7 100644 --- a/eqlaunch/ZoneLaunch.cpp +++ b/eqlaunch/zone_launch.cpp @@ -16,11 +16,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - - -#include "ZoneLaunch.h" -#include "worldserver.h" +#include "../common/debug.h" #include "../common/eqemu_config.h" +#include "zone_launch.h" +#include "worldserver.h" //static const uint32 ZONE_RESTART_DELAY = 10000; //static const uint32 ZONE_TERMINATE_WAIT = 10000; diff --git a/eqlaunch/ZoneLaunch.h b/eqlaunch/zone_launch.h similarity index 100% rename from eqlaunch/ZoneLaunch.h rename to eqlaunch/zone_launch.h diff --git a/utils/azone2/3d.hpp b/utils/deprecated/azone2/3d.hpp similarity index 100% rename from utils/azone2/3d.hpp rename to utils/deprecated/azone2/3d.hpp diff --git a/utils/azone2/3d_base.hpp b/utils/deprecated/azone2/3d_base.hpp similarity index 100% rename from utils/azone2/3d_base.hpp rename to utils/deprecated/azone2/3d_base.hpp diff --git a/utils/azone2/GLModelViewer.cpp b/utils/deprecated/azone2/GLModelViewer.cpp similarity index 100% rename from utils/azone2/GLModelViewer.cpp rename to utils/deprecated/azone2/GLModelViewer.cpp diff --git a/utils/azone2/GLModelViewer.h b/utils/deprecated/azone2/GLModelViewer.h similarity index 100% rename from utils/azone2/GLModelViewer.h rename to utils/deprecated/azone2/GLModelViewer.h diff --git a/utils/azone2/README b/utils/deprecated/azone2/README similarity index 100% rename from utils/azone2/README rename to utils/deprecated/azone2/README diff --git a/utils/azone2/archive.hpp b/utils/deprecated/azone2/archive.hpp similarity index 100% rename from utils/azone2/archive.hpp rename to utils/deprecated/azone2/archive.hpp diff --git a/utils/azone2/awater.cpp b/utils/deprecated/azone2/awater.cpp similarity index 100% rename from utils/azone2/awater.cpp rename to utils/deprecated/azone2/awater.cpp diff --git a/utils/azone2/awater.h b/utils/deprecated/azone2/awater.h similarity index 100% rename from utils/azone2/awater.h rename to utils/deprecated/azone2/awater.h diff --git a/utils/azone2/azone.cpp b/utils/deprecated/azone2/azone.cpp similarity index 100% rename from utils/azone2/azone.cpp rename to utils/deprecated/azone2/azone.cpp diff --git a/utils/azone2/azone.h b/utils/deprecated/azone2/azone.h similarity index 100% rename from utils/azone2/azone.h rename to utils/deprecated/azone2/azone.h diff --git a/utils/azone2/azone.ini b/utils/deprecated/azone2/azone.ini similarity index 100% rename from utils/azone2/azone.ini rename to utils/deprecated/azone2/azone.ini diff --git a/utils/azone2/dat.cpp b/utils/deprecated/azone2/dat.cpp similarity index 100% rename from utils/azone2/dat.cpp rename to utils/deprecated/azone2/dat.cpp diff --git a/utils/azone2/dat.hpp b/utils/deprecated/azone2/dat.hpp similarity index 100% rename from utils/azone2/dat.hpp rename to utils/deprecated/azone2/dat.hpp diff --git a/utils/azone2/file.cpp b/utils/deprecated/azone2/file.cpp similarity index 100% rename from utils/azone2/file.cpp rename to utils/deprecated/azone2/file.cpp diff --git a/utils/azone2/file.hpp b/utils/deprecated/azone2/file.hpp similarity index 100% rename from utils/azone2/file.hpp rename to utils/deprecated/azone2/file.hpp diff --git a/utils/azone2/file_loader.hpp b/utils/deprecated/azone2/file_loader.hpp similarity index 100% rename from utils/azone2/file_loader.hpp rename to utils/deprecated/azone2/file_loader.hpp diff --git a/utils/azone2/global.cpp b/utils/deprecated/azone2/global.cpp similarity index 100% rename from utils/azone2/global.cpp rename to utils/deprecated/azone2/global.cpp diff --git a/utils/azone2/global.hpp b/utils/deprecated/azone2/global.hpp similarity index 100% rename from utils/azone2/global.hpp rename to utils/deprecated/azone2/global.hpp diff --git a/utils/azone2/listobj.cpp b/utils/deprecated/azone2/listobj.cpp similarity index 100% rename from utils/azone2/listobj.cpp rename to utils/deprecated/azone2/listobj.cpp diff --git a/utils/azone2/octree.hpp b/utils/deprecated/azone2/octree.hpp similarity index 100% rename from utils/azone2/octree.hpp rename to utils/deprecated/azone2/octree.hpp diff --git a/utils/azone2/pfs.cpp b/utils/deprecated/azone2/pfs.cpp similarity index 100% rename from utils/azone2/pfs.cpp rename to utils/deprecated/azone2/pfs.cpp diff --git a/utils/azone2/pfs.hpp b/utils/deprecated/azone2/pfs.hpp similarity index 100% rename from utils/azone2/pfs.hpp rename to utils/deprecated/azone2/pfs.hpp diff --git a/utils/azone2/s3d.h b/utils/deprecated/azone2/s3d.h similarity index 100% rename from utils/azone2/s3d.h rename to utils/deprecated/azone2/s3d.h diff --git a/utils/azone2/ter.cpp b/utils/deprecated/azone2/ter.cpp similarity index 100% rename from utils/azone2/ter.cpp rename to utils/deprecated/azone2/ter.cpp diff --git a/utils/azone2/ter.hpp b/utils/deprecated/azone2/ter.hpp similarity index 100% rename from utils/azone2/ter.hpp rename to utils/deprecated/azone2/ter.hpp diff --git a/utils/azone2/types.h b/utils/deprecated/azone2/types.h similarity index 100% rename from utils/azone2/types.h rename to utils/deprecated/azone2/types.h diff --git a/utils/azone2/wld.cpp b/utils/deprecated/azone2/wld.cpp similarity index 100% rename from utils/azone2/wld.cpp rename to utils/deprecated/azone2/wld.cpp diff --git a/utils/azone2/wld.hpp b/utils/deprecated/azone2/wld.hpp similarity index 100% rename from utils/azone2/wld.hpp rename to utils/deprecated/azone2/wld.hpp diff --git a/utils/azone2/wld_structs.hpp b/utils/deprecated/azone2/wld_structs.hpp similarity index 100% rename from utils/azone2/wld_structs.hpp rename to utils/deprecated/azone2/wld_structs.hpp diff --git a/utils/azone2/zon.cpp b/utils/deprecated/azone2/zon.cpp similarity index 100% rename from utils/azone2/zon.cpp rename to utils/deprecated/azone2/zon.cpp diff --git a/utils/azone2/zon.hpp b/utils/deprecated/azone2/zon.hpp similarity index 100% rename from utils/azone2/zon.hpp rename to utils/deprecated/azone2/zon.hpp diff --git a/utils/azone2/zonv4.cpp b/utils/deprecated/azone2/zonv4.cpp similarity index 100% rename from utils/azone2/zonv4.cpp rename to utils/deprecated/azone2/zonv4.cpp diff --git a/utils/azone2/zonv4.hpp b/utils/deprecated/azone2/zonv4.hpp similarity index 100% rename from utils/azone2/zonv4.hpp rename to utils/deprecated/azone2/zonv4.hpp diff --git a/utils/pfs_list/CMakeLists.txt b/utils/deprecated/pfs_list/CMakeLists.txt similarity index 100% rename from utils/pfs_list/CMakeLists.txt rename to utils/deprecated/pfs_list/CMakeLists.txt diff --git a/utils/pfs_list/Common/CMakeLists.txt b/utils/deprecated/pfs_list/Common/CMakeLists.txt similarity index 100% rename from utils/pfs_list/Common/CMakeLists.txt rename to utils/deprecated/pfs_list/Common/CMakeLists.txt diff --git a/utils/pfs_list/Common/Include/Archive.h b/utils/deprecated/pfs_list/Common/Include/Archive.h similarity index 100% rename from utils/pfs_list/Common/Include/Archive.h rename to utils/deprecated/pfs_list/Common/Include/Archive.h diff --git a/utils/pfs_list/Common/Include/Compression.h b/utils/deprecated/pfs_list/Common/Include/Compression.h similarity index 100% rename from utils/pfs_list/Common/Include/Compression.h rename to utils/deprecated/pfs_list/Common/Include/Compression.h diff --git a/utils/pfs_list/Common/Include/PFSArchive.h b/utils/deprecated/pfs_list/Common/Include/PFSArchive.h similarity index 100% rename from utils/pfs_list/Common/Include/PFSArchive.h rename to utils/deprecated/pfs_list/Common/Include/PFSArchive.h diff --git a/utils/pfs_list/Common/Include/PFSDataStructs.h b/utils/deprecated/pfs_list/Common/Include/PFSDataStructs.h similarity index 100% rename from utils/pfs_list/Common/Include/PFSDataStructs.h rename to utils/deprecated/pfs_list/Common/Include/PFSDataStructs.h diff --git a/utils/pfs_list/Common/Source/Compression.cpp b/utils/deprecated/pfs_list/Common/Source/Compression.cpp similarity index 100% rename from utils/pfs_list/Common/Source/Compression.cpp rename to utils/deprecated/pfs_list/Common/Source/Compression.cpp diff --git a/utils/pfs_list/Common/Source/PFSArchive.cpp b/utils/deprecated/pfs_list/Common/Source/PFSArchive.cpp similarity index 100% rename from utils/pfs_list/Common/Source/PFSArchive.cpp rename to utils/deprecated/pfs_list/Common/Source/PFSArchive.cpp diff --git a/utils/pfs_list/PFSList/CMakeLists.txt b/utils/deprecated/pfs_list/PFSList/CMakeLists.txt similarity index 100% rename from utils/pfs_list/PFSList/CMakeLists.txt rename to utils/deprecated/pfs_list/PFSList/CMakeLists.txt diff --git a/utils/pfs_list/PFSList/Source/main.cpp b/utils/deprecated/pfs_list/PFSList/Source/main.cpp similarity index 100% rename from utils/pfs_list/PFSList/Source/main.cpp rename to utils/deprecated/pfs_list/PFSList/Source/main.cpp diff --git a/utils/player_profile_set/Readme.txt b/utils/deprecated/player_profile_set/Readme.txt similarity index 100% rename from utils/player_profile_set/Readme.txt rename to utils/deprecated/player_profile_set/Readme.txt diff --git a/utils/player_profile_set/bin/database.ini b/utils/deprecated/player_profile_set/bin/database.ini similarity index 100% rename from utils/player_profile_set/bin/database.ini rename to utils/deprecated/player_profile_set/bin/database.ini diff --git a/utils/player_profile_set/player_profile_set.sln b/utils/deprecated/player_profile_set/player_profile_set.sln similarity index 100% rename from utils/player_profile_set/player_profile_set.sln rename to utils/deprecated/player_profile_set/player_profile_set.sln diff --git a/utils/player_profile_set/player_profile_set/MiscFunctions.cpp b/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp similarity index 100% rename from utils/player_profile_set/player_profile_set/MiscFunctions.cpp rename to utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp diff --git a/utils/player_profile_set/player_profile_set/MiscFunctions.h b/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.h similarity index 100% rename from utils/player_profile_set/player_profile_set/MiscFunctions.h rename to utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.h diff --git a/utils/player_profile_set/player_profile_set/database.cpp b/utils/deprecated/player_profile_set/player_profile_set/database.cpp similarity index 100% rename from utils/player_profile_set/player_profile_set/database.cpp rename to utils/deprecated/player_profile_set/player_profile_set/database.cpp diff --git a/utils/player_profile_set/player_profile_set/database.h b/utils/deprecated/player_profile_set/player_profile_set/database.h similarity index 100% rename from utils/player_profile_set/player_profile_set/database.h rename to utils/deprecated/player_profile_set/player_profile_set/database.h diff --git a/utils/player_profile_set/player_profile_set/eq_player_structs.h b/utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h similarity index 100% rename from utils/player_profile_set/player_profile_set/eq_player_structs.h rename to utils/deprecated/player_profile_set/player_profile_set/eq_player_structs.h diff --git a/utils/player_profile_set/player_profile_set/eqemu_string.h b/utils/deprecated/player_profile_set/player_profile_set/eqemu_string.h similarity index 100% rename from utils/player_profile_set/player_profile_set/eqemu_string.h rename to utils/deprecated/player_profile_set/player_profile_set/eqemu_string.h diff --git a/utils/player_profile_set/player_profile_set/ini.cpp b/utils/deprecated/player_profile_set/player_profile_set/ini.cpp similarity index 100% rename from utils/player_profile_set/player_profile_set/ini.cpp rename to utils/deprecated/player_profile_set/player_profile_set/ini.cpp diff --git a/utils/player_profile_set/player_profile_set/ini.h b/utils/deprecated/player_profile_set/player_profile_set/ini.h similarity index 100% rename from utils/player_profile_set/player_profile_set/ini.h rename to utils/deprecated/player_profile_set/player_profile_set/ini.h diff --git a/utils/player_profile_set/player_profile_set/main.cpp b/utils/deprecated/player_profile_set/player_profile_set/main.cpp similarity index 100% rename from utils/player_profile_set/player_profile_set/main.cpp rename to utils/deprecated/player_profile_set/player_profile_set/main.cpp diff --git a/utils/player_profile_set/player_profile_set/main.h b/utils/deprecated/player_profile_set/player_profile_set/main.h similarity index 100% rename from utils/player_profile_set/player_profile_set/main.h rename to utils/deprecated/player_profile_set/player_profile_set/main.h diff --git a/utils/player_profile_set/player_profile_set/player_profile_set.vcproj b/utils/deprecated/player_profile_set/player_profile_set/player_profile_set.vcproj similarity index 100% rename from utils/player_profile_set/player_profile_set/player_profile_set.vcproj rename to utils/deprecated/player_profile_set/player_profile_set/player_profile_set.vcproj diff --git a/utils/player_profile_set/player_profile_set/types.h b/utils/deprecated/player_profile_set/player_profile_set/types.h similarity index 100% rename from utils/player_profile_set/player_profile_set/types.h rename to utils/deprecated/player_profile_set/player_profile_set/types.h From 5bf49d2ef9170330b2bc4d498e3030eeef1e3ce0 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 23:05:21 -0700 Subject: [PATCH 154/217] More renames --- loginserver/CMakeLists.txt | 48 +++++++++---------- loginserver/{Client.cpp => client.cpp} | 8 ++-- loginserver/{Client.h => client.h} | 2 +- .../{ClientManager.cpp => client_manager.cpp} | 6 +-- .../{ClientManager.h => client_manager.h} | 2 +- loginserver/{Config.cpp => config.cpp} | 4 +- loginserver/{Config.h => config.h} | 0 loginserver/{Database.h => database.h} | 0 .../{DatabaseMySQL.cpp => database_mysql.cpp} | 8 ++-- .../{DatabaseMySQL.h => database_mysql.h} | 2 +- ...PostgreSQL.cpp => database_postgreSQL.cpp} | 8 ++-- ...basePostgreSQL.h => database_postgresql.h} | 2 +- .../{Encryption.cpp => encryption.cpp} | 4 +- loginserver/{Encryption.h => encryption.h} | 0 .../{EQCryptoAPI.h => eq_crypto_api.h} | 0 loginserver/{ErrorLog.cpp => error_log.cpp} | 2 +- loginserver/{ErrorLog.h => error_log.h} | 0 loginserver/{LoginServer.h => login_server.h} | 18 +++---- .../{LoginStructures.h => login_structures.h} | 0 loginserver/{Main.cpp => main.cpp} | 2 +- loginserver/{Options.h => options.h} | 0 .../{ServerManager.cpp => server_manager.cpp} | 8 ++-- .../{ServerManager.h => server_manager.h} | 4 +- .../{WorldServer.cpp => world_server.cpp} | 8 ++-- loginserver/{WorldServer.h => world_server.h} | 0 25 files changed, 68 insertions(+), 68 deletions(-) rename loginserver/{Client.cpp => client.cpp} (99%) rename loginserver/{Client.h => client.h} (99%) rename loginserver/{ClientManager.cpp => client_manager.cpp} (98%) rename loginserver/{ClientManager.h => client_manager.h} (99%) rename loginserver/{Config.cpp => config.cpp} (99%) rename loginserver/{Config.h => config.h} (100%) rename loginserver/{Database.h => database.h} (100%) rename loginserver/{DatabaseMySQL.cpp => database_mysql.cpp} (98%) rename loginserver/{DatabaseMySQL.h => database_mysql.h} (99%) rename loginserver/{DatabasePostgreSQL.cpp => database_postgreSQL.cpp} (98%) rename loginserver/{DatabasePostgreSQL.h => database_postgresql.h} (99%) rename loginserver/{Encryption.cpp => encryption.cpp} (98%) rename loginserver/{Encryption.h => encryption.h} (100%) rename loginserver/{EQCryptoAPI.h => eq_crypto_api.h} (100%) rename loginserver/{ErrorLog.cpp => error_log.cpp} (99%) rename loginserver/{ErrorLog.h => error_log.h} (100%) rename loginserver/{LoginServer.h => login_server.h} (86%) rename loginserver/{LoginStructures.h => login_structures.h} (100%) rename loginserver/{Main.cpp => main.cpp} (99%) rename loginserver/{Options.h => options.h} (100%) rename loginserver/{ServerManager.cpp => server_manager.cpp} (98%) rename loginserver/{ServerManager.h => server_manager.h} (98%) rename loginserver/{WorldServer.cpp => world_server.cpp} (99%) rename loginserver/{WorldServer.h => world_server.h} (100%) diff --git a/loginserver/CMakeLists.txt b/loginserver/CMakeLists.txt index f09d3043a..f588cbc48 100644 --- a/loginserver/CMakeLists.txt +++ b/loginserver/CMakeLists.txt @@ -1,37 +1,37 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(eqlogin_sources - Client.cpp - ClientManager.cpp - Config.cpp - DatabaseMySQL.cpp - DatabasePostgreSQL.cpp - ErrorLog.cpp - Main.cpp - ServerManager.cpp - WorldServer.cpp + client.cpp + client_manager.cpp + config.cpp + database_mysql.cpp + database_postgresql.cpp + error_log.cpp + main.cpp + server_manager.cpp + world_server.cpp ) IF(MSVC OR MINGW) ADD_DEFINITIONS(-DNOMINMAX) - SET(eqlogin_sources ${eqlogin_sources} Encryption.cpp) + SET(eqlogin_sources ${eqlogin_sources} encryption.cpp) ENDIF(MSVC OR MINGW) SET(eqlogin_headers - Client.h - ClientManager.h - Config.h - Database.h - DatabaseMySQL.h - DatabasePostgreSQL.h - Encryption.h - EQCryptoAPI.h - ErrorLog.h - LoginServer.h - LoginStructures.h - Options.h - ServerManager.h - WorldServer.h + client.h + client_manager.h + config.h + database.h + database_mysql.h + database_postgresql.h + encryption.h + eq_crypto_api.h + error_log.h + login_server.h + login_structures.h + options.h + server_manager.h + world_server.h ) IF(UNIX) diff --git a/loginserver/Client.cpp b/loginserver/client.cpp similarity index 99% rename from loginserver/Client.cpp rename to loginserver/client.cpp index 98128e286..9883c059d 100644 --- a/loginserver/Client.cpp +++ b/loginserver/client.cpp @@ -15,10 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "Client.h" -#include "ErrorLog.h" -#include "LoginServer.h" -#include "LoginStructures.h" +#include "client.h" +#include "error_log.h" +#include "login_server.h" +#include "login_structures.h" #include "../common/misc_functions.h" extern ErrorLog *server_log; diff --git a/loginserver/Client.h b/loginserver/client.h similarity index 99% rename from loginserver/Client.h rename to loginserver/client.h index d080aa01b..3248aefb5 100644 --- a/loginserver/Client.h +++ b/loginserver/client.h @@ -23,7 +23,7 @@ #include "../common/eq_stream_type.h" #include "../common/eq_stream_factory.h" #ifndef WIN32 -#include "EQCryptoAPI.h" +#include "eq_crypto_api.h" #endif #include diff --git a/loginserver/ClientManager.cpp b/loginserver/client_manager.cpp similarity index 98% rename from loginserver/ClientManager.cpp rename to loginserver/client_manager.cpp index cbf720f27..d6f6b760f 100644 --- a/loginserver/ClientManager.cpp +++ b/loginserver/client_manager.cpp @@ -15,9 +15,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ClientManager.h" -#include "ErrorLog.h" -#include "LoginServer.h" +#include "client_manager.h" +#include "error_log.h" +#include "login_server.h" extern ErrorLog *server_log; extern LoginServer server; diff --git a/loginserver/ClientManager.h b/loginserver/client_manager.h similarity index 99% rename from loginserver/ClientManager.h rename to loginserver/client_manager.h index fc6205a8a..4c3920f04 100644 --- a/loginserver/ClientManager.h +++ b/loginserver/client_manager.h @@ -22,7 +22,7 @@ #include "../common/opcodemgr.h" #include "../common/eq_stream_type.h" #include "../common/eq_stream_factory.h" -#include "Client.h" +#include "client.h" #include using namespace std; diff --git a/loginserver/Config.cpp b/loginserver/config.cpp similarity index 99% rename from loginserver/Config.cpp rename to loginserver/config.cpp index 44906b889..8815622d2 100644 --- a/loginserver/Config.cpp +++ b/loginserver/config.cpp @@ -16,8 +16,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "Config.h" -#include "ErrorLog.h" +#include "config.h" +#include "error_log.h" extern ErrorLog *server_log; /** diff --git a/loginserver/Config.h b/loginserver/config.h similarity index 100% rename from loginserver/Config.h rename to loginserver/config.h diff --git a/loginserver/Database.h b/loginserver/database.h similarity index 100% rename from loginserver/Database.h rename to loginserver/database.h diff --git a/loginserver/DatabaseMySQL.cpp b/loginserver/database_mysql.cpp similarity index 98% rename from loginserver/DatabaseMySQL.cpp rename to loginserver/database_mysql.cpp index 7d7b20970..924538f38 100644 --- a/loginserver/DatabaseMySQL.cpp +++ b/loginserver/database_mysql.cpp @@ -16,12 +16,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "Database.h" +#include "database.h" #ifdef EQEMU_MYSQL_ENABLED -#include "DatabaseMySQL.h" -#include "ErrorLog.h" -#include "LoginServer.h" +#include "database_mysql.h" +#include "error_log.h" +#include "login_server.h" extern ErrorLog *server_log; extern LoginServer server; diff --git a/loginserver/DatabaseMySQL.h b/loginserver/database_mysql.h similarity index 99% rename from loginserver/DatabaseMySQL.h rename to loginserver/database_mysql.h index 05af22315..4249cb614 100644 --- a/loginserver/DatabaseMySQL.h +++ b/loginserver/database_mysql.h @@ -18,7 +18,7 @@ #ifndef EQEMU_DATABASEMYSQL_H #define EQEMU_DATABASEMYSQL_H -#include "Database.h" +#include "database.h" #ifdef EQEMU_MYSQL_ENABLED #include diff --git a/loginserver/DatabasePostgreSQL.cpp b/loginserver/database_postgreSQL.cpp similarity index 98% rename from loginserver/DatabasePostgreSQL.cpp rename to loginserver/database_postgreSQL.cpp index 9effac49b..e57679f64 100644 --- a/loginserver/DatabasePostgreSQL.cpp +++ b/loginserver/database_postgreSQL.cpp @@ -16,12 +16,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "Database.h" +#include "database.h" #ifdef EQEMU_POSTGRESQL_ENABLED -#include "DatabasePostgreSQL.h" -#include "ErrorLog.h" -#include "LoginServer.h" +#include "database_postgresql.h" +#include "error_log.h" +#include "login_server.h" extern ErrorLog *server_log; extern LoginServer server; diff --git a/loginserver/DatabasePostgreSQL.h b/loginserver/database_postgresql.h similarity index 99% rename from loginserver/DatabasePostgreSQL.h rename to loginserver/database_postgresql.h index 8d2685fcc..0dfbe53aa 100644 --- a/loginserver/DatabasePostgreSQL.h +++ b/loginserver/database_postgresql.h @@ -18,7 +18,7 @@ #ifndef EQEMU_DATABASEPOSTGRESQL_H #define EQEMU_DATABASEPOSTGRESQL_H -#include "Database.h" +#include "database.h" #ifdef EQEMU_POSTGRESQL_ENABLED #include diff --git a/loginserver/Encryption.cpp b/loginserver/encryption.cpp similarity index 98% rename from loginserver/Encryption.cpp rename to loginserver/encryption.cpp index bd947593b..5585487b1 100644 --- a/loginserver/Encryption.cpp +++ b/loginserver/encryption.cpp @@ -16,8 +16,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "Encryption.h" -#include "ErrorLog.h" +#include "encryption.h" +#include "error_log.h" #include extern ErrorLog *server_log; diff --git a/loginserver/Encryption.h b/loginserver/encryption.h similarity index 100% rename from loginserver/Encryption.h rename to loginserver/encryption.h diff --git a/loginserver/EQCryptoAPI.h b/loginserver/eq_crypto_api.h similarity index 100% rename from loginserver/EQCryptoAPI.h rename to loginserver/eq_crypto_api.h diff --git a/loginserver/ErrorLog.cpp b/loginserver/error_log.cpp similarity index 99% rename from loginserver/ErrorLog.cpp rename to loginserver/error_log.cpp index db5b6c89a..03021f6c7 100644 --- a/loginserver/ErrorLog.cpp +++ b/loginserver/error_log.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -#include "ErrorLog.h" +#include "error_log.h" const char *eqLogTypes[_log_largest_type] = { diff --git a/loginserver/ErrorLog.h b/loginserver/error_log.h similarity index 100% rename from loginserver/ErrorLog.h rename to loginserver/error_log.h diff --git a/loginserver/LoginServer.h b/loginserver/login_server.h similarity index 86% rename from loginserver/LoginServer.h rename to loginserver/login_server.h index 54e62e551..f83154b8f 100644 --- a/loginserver/LoginServer.h +++ b/loginserver/login_server.h @@ -18,15 +18,15 @@ #ifndef EQEMU_LOGINSERVER_H #define EQEMU_LOGINSERVER_H -#include "ErrorLog.h" -#include "Config.h" -#include "Database.h" -#include "DatabaseMySQL.h" -#include "DatabasePostgreSQL.h" -#include "Encryption.h" -#include "Options.h" -#include "ServerManager.h" -#include "ClientManager.h" +#include "error_log.h" +#include "config.h" +#include "database.h" +#include "database_mysql.h" +#include "database_postgresql.h" +#include "encryption.h" +#include "options.h" +#include "server_manager.h" +#include "client_manager.h" /** * Login server struct, contains every variable for the server that needs to exist diff --git a/loginserver/LoginStructures.h b/loginserver/login_structures.h similarity index 100% rename from loginserver/LoginStructures.h rename to loginserver/login_structures.h diff --git a/loginserver/Main.cpp b/loginserver/main.cpp similarity index 99% rename from loginserver/Main.cpp rename to loginserver/main.cpp index ec5a3b4ed..820cc9113 100644 --- a/loginserver/Main.cpp +++ b/loginserver/main.cpp @@ -22,7 +22,7 @@ #include "../common/timer.h" #include "../common/platform.h" #include "../common/crash.h" -#include "LoginServer.h" +#include "login_server.h" #include #include #include diff --git a/loginserver/Options.h b/loginserver/options.h similarity index 100% rename from loginserver/Options.h rename to loginserver/options.h diff --git a/loginserver/ServerManager.cpp b/loginserver/server_manager.cpp similarity index 98% rename from loginserver/ServerManager.cpp rename to loginserver/server_manager.cpp index baa21aae2..6a1b57d6f 100644 --- a/loginserver/ServerManager.cpp +++ b/loginserver/server_manager.cpp @@ -15,10 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ServerManager.h" -#include "LoginServer.h" -#include "ErrorLog.h" -#include "LoginStructures.h" +#include "server_manager.h" +#include "login_server.h" +#include "error_log.h" +#include "login_structures.h" #include extern ErrorLog *server_log; diff --git a/loginserver/ServerManager.h b/loginserver/server_manager.h similarity index 98% rename from loginserver/ServerManager.h rename to loginserver/server_manager.h index 3d03db06d..e2453701d 100644 --- a/loginserver/ServerManager.h +++ b/loginserver/server_manager.h @@ -24,8 +24,8 @@ #include "../common/emu_tcp_server.h" #include "../common/servertalk.h" #include "../common/packet_dump.h" -#include "WorldServer.h" -#include "Client.h" +#include "world_server.h" +#include "client.h" #include /** diff --git a/loginserver/WorldServer.cpp b/loginserver/world_server.cpp similarity index 99% rename from loginserver/WorldServer.cpp rename to loginserver/world_server.cpp index 16b9addec..c91f1b702 100644 --- a/loginserver/WorldServer.cpp +++ b/loginserver/world_server.cpp @@ -15,10 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "WorldServer.h" -#include "ErrorLog.h" -#include "LoginServer.h" -#include "LoginStructures.h" +#include "world_server.h" +#include "error_log.h" +#include "login_server.h" +#include "login_structures.h" extern ErrorLog *server_log; extern LoginServer server; diff --git a/loginserver/WorldServer.h b/loginserver/world_server.h similarity index 100% rename from loginserver/WorldServer.h rename to loginserver/world_server.h From 4821ed79fb0dc2ea72737858229e29f3d1ac0de2 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 23:30:09 -0700 Subject: [PATCH 155/217] More renames, world should be done --- world/CMakeLists.txt | 60 +++++++++---------- world/{Adventure.cpp => adventure.cpp} | 4 +- world/{Adventure.h => adventure.h} | 2 +- ...ntureManager.cpp => adventure_manager.cpp} | 4 +- ...AdventureManager.h => adventure_manager.h} | 4 +- ...ventureTemplate.h => adventure_template.h} | 0 world/client.cpp | 8 +-- world/cliententry.cpp | 6 +- world/console.cpp | 8 +-- world/console.h | 2 +- world/{EQLConfig.cpp => eql_config.cpp} | 6 +- world/{EQLConfig.h => eql_config.h} | 0 world/{EQW.cpp => eqw.cpp} | 14 ++--- world/{EQW.h => eqw.h} | 0 ...QWHTTPHandler.cpp => eqw_http_handler.cpp} | 8 +-- .../{EQWHTTPHandler.h => eqw_http_handler.h} | 0 world/{EQWParser.cpp => eqw_parser.cpp} | 4 +- world/{EQWParser.h => eqw_parser.h} | 0 world/{HTTPRequest.cpp => http_request.cpp} | 4 +- world/{HTTPRequest.h => http_request.h} | 0 world/{LauncherLink.cpp => launcher_link.cpp} | 8 +-- world/{LauncherLink.h => launcher_link.h} | 0 world/{LauncherList.cpp => launcher_list.cpp} | 6 +- world/{LauncherList.h => launcher_list.h} | 0 world/{LoginServer.cpp => login_server.cpp} | 6 +- world/{LoginServer.h => login_server.h} | 0 ...inServerList.cpp => login_server_list.cpp} | 6 +- ...{LoginServerList.h => login_server_list.h} | 0 world/net.cpp | 12 ++-- ...perl_EQLConfig.cpp => perl_eql_config.cpp} | 4 +- world/{perl_EQW.cpp => perl_eqw.cpp} | 4 +- ..._HTTPRequest.cpp => perl_http_request.cpp} | 4 +- world/queryserv.cpp | 2 +- ...harCreateData.h => sof_char_create_data.h} | 0 world/ucs.cpp | 2 +- world/{WorldConfig.cpp => world_config.cpp} | 2 +- world/{WorldConfig.h => world_config.h} | 0 ...TCPConnection.h => world_tcp_connection.h} | 0 world/worlddb.cpp | 2 +- world/zonelist.cpp | 4 +- world/zoneserver.cpp | 8 +-- world/zoneserver.h | 2 +- 42 files changed, 103 insertions(+), 103 deletions(-) rename world/{Adventure.cpp => adventure.cpp} (99%) rename world/{Adventure.h => adventure.h} (98%) rename world/{AdventureManager.cpp => adventure_manager.cpp} (99%) rename world/{AdventureManager.h => adventure_manager.h} (98%) rename world/{AdventureTemplate.h => adventure_template.h} (100%) rename world/{EQLConfig.cpp => eql_config.cpp} (99%) rename world/{EQLConfig.h => eql_config.h} (100%) rename world/{EQW.cpp => eqw.cpp} (98%) rename world/{EQW.h => eqw.h} (100%) rename world/{EQWHTTPHandler.cpp => eqw_http_handler.cpp} (98%) rename world/{EQWHTTPHandler.h => eqw_http_handler.h} (100%) rename world/{EQWParser.cpp => eqw_parser.cpp} (99%) rename world/{EQWParser.h => eqw_parser.h} (100%) rename world/{HTTPRequest.cpp => http_request.cpp} (97%) rename world/{HTTPRequest.h => http_request.h} (100%) rename world/{LauncherLink.cpp => launcher_link.cpp} (98%) rename world/{LauncherLink.h => launcher_link.h} (100%) rename world/{LauncherList.cpp => launcher_list.cpp} (98%) rename world/{LauncherList.h => launcher_list.h} (100%) rename world/{LoginServer.cpp => login_server.cpp} (99%) rename world/{LoginServer.h => login_server.h} (100%) rename world/{LoginServerList.cpp => login_server_list.cpp} (98%) rename world/{LoginServerList.h => login_server_list.h} (100%) rename world/{perl_EQLConfig.cpp => perl_eql_config.cpp} (99%) rename world/{perl_EQW.cpp => perl_eqw.cpp} (99%) rename world/{perl_HTTPRequest.cpp => perl_http_request.cpp} (99%) rename world/{SoFCharCreateData.h => sof_char_create_data.h} (100%) rename world/{WorldConfig.cpp => world_config.cpp} (97%) rename world/{WorldConfig.h => world_config.h} (100%) rename world/{WorldTCPConnection.h => world_tcp_connection.h} (100%) diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index 7d4e2adeb..a9dd63478 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -1,64 +1,64 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(world_sources - Adventure.cpp - AdventureManager.cpp + adventure.cpp + adventure_manager.cpp client.cpp cliententry.cpp clientlist.cpp CMakeLists.txt console.cpp - EQLConfig.cpp - EQW.cpp - EQWHTTPHandler.cpp - EQWParser.cpp - HTTPRequest.cpp - LauncherLink.cpp - LauncherList.cpp + eql_config.cpp + eqw.cpp + eqw_http_handler.cpp + eqw_parser.cpp + http_request.cpp + launcher_link.cpp + launcher_list.cpp lfplist.cpp - LoginServer.cpp - LoginServerList.cpp + login_server.cpp + login_server_list.cpp net.cpp - perl_EQLConfig.cpp - perl_EQW.cpp - perl_HTTPRequest.cpp + perl_eql_config.cpp + perl_eqw.cpp + perl_http_request.cpp queryserv.cpp ucs.cpp wguild_mgr.cpp world_logsys.cpp - WorldConfig.cpp + world_config.cpp worlddb.cpp zonelist.cpp zoneserver.cpp ) SET(world_headers - Adventure.h - AdventureManager.h - AdventureTemplate.h + adventure.h + adventure_manager.h + adventure_template.h client.h cliententry.h clientlist.h CMakeLists.txt console.h - EQLConfig.h - EQW.h - EQWHTTPHandler.h - EQWParser.h - HTTPRequest.h - LauncherLink.h - LauncherList.h + eql_config.h + eqw.h + eqw_http_handler.h + eqw_parser.h + http_request.h + launcher_link.h + launcher_list.h lfplist.h - LoginServer.h - LoginServerList.h + login_server.h + login_server_list.h net.h queryserv.h - sofCharCreateData.h + sof_char_create_data.h ucs.h wguild_mgr.h - WorldConfig.h + world_config.h worlddb.h - WorldTCPConnection.h + world_tcp_connection.h zonelist.h zoneserver.h ) diff --git a/world/Adventure.cpp b/world/adventure.cpp similarity index 99% rename from world/Adventure.cpp rename to world/adventure.cpp index b66735176..45dd206e5 100644 --- a/world/Adventure.cpp +++ b/world/adventure.cpp @@ -4,8 +4,8 @@ #include "../common/rulesys.h" #include "../common/misc_functions.h" #include "../common/string_util.h" -#include "Adventure.h" -#include "AdventureManager.h" +#include "adventure.h" +#include "adventure_manager.h" #include "worlddb.h" #include "zonelist.h" #include "clientlist.h" diff --git a/world/Adventure.h b/world/adventure.h similarity index 98% rename from world/Adventure.h rename to world/adventure.h index cb14609ae..dec691eda 100644 --- a/world/Adventure.h +++ b/world/adventure.h @@ -4,7 +4,7 @@ #include "../common/debug.h" #include "../common/types.h" #include "../common/timer.h" -#include "AdventureTemplate.h" +#include "adventure_template.h" #include #include #include diff --git a/world/AdventureManager.cpp b/world/adventure_manager.cpp similarity index 99% rename from world/AdventureManager.cpp rename to world/adventure_manager.cpp index 33ac522b8..047aca326 100644 --- a/world/AdventureManager.cpp +++ b/world/adventure_manager.cpp @@ -3,8 +3,8 @@ #include "../common/string_util.h" #include "../common/servertalk.h" #include "../common/rulesys.h" -#include "Adventure.h" -#include "AdventureManager.h" +#include "adventure.h" +#include "adventure_manager.h" #include "worlddb.h" #include "zonelist.h" #include "clientlist.h" diff --git a/world/AdventureManager.h b/world/adventure_manager.h similarity index 98% rename from world/AdventureManager.h rename to world/adventure_manager.h index e7055ac8d..ce6d7331a 100644 --- a/world/AdventureManager.h +++ b/world/adventure_manager.h @@ -4,8 +4,8 @@ #include "../common/debug.h" #include "../common/types.h" #include "../common/timer.h" -#include "Adventure.h" -#include "AdventureTemplate.h" +#include "adventure.h" +#include "adventure_template.h" #include #include diff --git a/world/AdventureTemplate.h b/world/adventure_template.h similarity index 100% rename from world/AdventureTemplate.h rename to world/adventure_template.h diff --git a/world/client.cpp b/world/client.cpp index 150d6a9c9..fc7e525db 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -18,14 +18,14 @@ #include "client.h" #include "worlddb.h" -#include "WorldConfig.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "world_config.h" +#include "login_server.h" +#include "login_server_list.h" #include "zoneserver.h" #include "zonelist.h" #include "clientlist.h" #include "wguild_mgr.h" -#include "sofCharCreateData.h" +#include "sof_char_create_data.h" #include #include diff --git a/world/cliententry.cpp b/world/cliententry.cpp index 131fceb3d..d4b85acc3 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -18,11 +18,11 @@ #include "../common/debug.h" #include "cliententry.h" #include "clientlist.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "worlddb.h" #include "zoneserver.h" -#include "WorldConfig.h" +#include "world_config.h" #include "../common/guilds.h" #include "../common/string_util.h" diff --git a/world/console.cpp b/world/console.cpp index e46a880e8..d5433067e 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -31,19 +31,19 @@ #include "../common/seperator.h" #include "../common/eq_packet_structs.h" #include "../common/eq_packet.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "../common/serverinfo.h" #include "../common/md5.h" #include "../common/opcodemgr.h" #include "../common/rulesys.h" #include "../common/ruletypes.h" #include "../common/string_util.h" -#include "WorldConfig.h" +#include "world_config.h" #include "zoneserver.h" #include "zonelist.h" #include "clientlist.h" -#include "LauncherList.h" +#include "launcher_list.h" #include "ucs.h" #include "queryserv.h" diff --git a/world/console.h b/world/console.h index 0588d8598..e0a72f590 100644 --- a/world/console.h +++ b/world/console.h @@ -39,7 +39,7 @@ enum { #include "../common/timer.h" #include "../common/queue.h" #include "../common/emu_tcp_connection.h" -#include "WorldTCPConnection.h" +#include "world_tcp_connection.h" #include "../common/mutex.h" struct ServerChannelMessage_Struct; diff --git a/world/EQLConfig.cpp b/world/eql_config.cpp similarity index 99% rename from world/EQLConfig.cpp rename to world/eql_config.cpp index c89c90428..f99ba0fb6 100644 --- a/world/EQLConfig.cpp +++ b/world/eql_config.cpp @@ -16,10 +16,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "EQLConfig.h" +#include "eql_config.h" #include "worlddb.h" -#include "LauncherLink.h" -#include "LauncherList.h" +#include "launcher_link.h" +#include "launcher_list.h" #include "../common/string_util.h" #include #include diff --git a/world/EQLConfig.h b/world/eql_config.h similarity index 100% rename from world/EQLConfig.h rename to world/eql_config.h diff --git a/world/EQW.cpp b/world/eqw.cpp similarity index 98% rename from world/EQW.cpp rename to world/eqw.cpp index 8ff7ac298..343aa9ebd 100644 --- a/world/EQW.cpp +++ b/world/eqw.cpp @@ -19,9 +19,9 @@ #ifdef EMBPERL #include "../common/debug.h" -#include "EQW.h" -#include "EQWParser.h" -#include "WorldConfig.h" +#include "eqw.h" +#include "eqw_parser.h" +#include "world_config.h" #include "../common/races.h" #include "../common/classes.h" #include "../common/misc.h" @@ -30,12 +30,12 @@ #include "zonelist.h" #include "clientlist.h" #include "cliententry.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "worlddb.h" #include "client.h" -#include "LauncherList.h" -#include "LauncherLink.h" +#include "launcher_list.h" +#include "launcher_link.h" #include "wguild_mgr.h" #ifdef seed diff --git a/world/EQW.h b/world/eqw.h similarity index 100% rename from world/EQW.h rename to world/eqw.h diff --git a/world/EQWHTTPHandler.cpp b/world/eqw_http_handler.cpp similarity index 98% rename from world/EQWHTTPHandler.cpp rename to world/eqw_http_handler.cpp index f3126e6a3..6a703172a 100644 --- a/world/EQWHTTPHandler.cpp +++ b/world/eqw_http_handler.cpp @@ -16,11 +16,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "EQWHTTPHandler.h" +#include "eqw_http_handler.h" #include "../common/SocketLib/Base64.h" -#include "EQWParser.h" -#include "EQW.h" -#include "HTTPRequest.h" +#include "eqw_parser.h" +#include "eqw.h" +#include "http_request.h" #include "../common/logsys.h" #include "worlddb.h" #include "console.h" diff --git a/world/EQWHTTPHandler.h b/world/eqw_http_handler.h similarity index 100% rename from world/EQWHTTPHandler.h rename to world/eqw_http_handler.h diff --git a/world/EQWParser.cpp b/world/eqw_parser.cpp similarity index 99% rename from world/EQWParser.cpp rename to world/eqw_parser.cpp index 53d430171..9aa372308 100644 --- a/world/EQWParser.cpp +++ b/world/eqw_parser.cpp @@ -21,8 +21,8 @@ #ifdef EMBPERL #include "../common/debug.h" -#include "EQWParser.h" -#include "EQW.h" +#include "eqw_parser.h" +#include "eqw.h" #include "../common/eqdb.h" #include "../common/logsys.h" #include "worlddb.h" diff --git a/world/EQWParser.h b/world/eqw_parser.h similarity index 100% rename from world/EQWParser.h rename to world/eqw_parser.h diff --git a/world/HTTPRequest.cpp b/world/http_request.cpp similarity index 97% rename from world/HTTPRequest.cpp rename to world/http_request.cpp index e366b6471..fa7bc78f1 100644 --- a/world/HTTPRequest.cpp +++ b/world/http_request.cpp @@ -16,8 +16,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "HTTPRequest.h" -#include "EQWHTTPHandler.h" +#include "http_request.h" +#include "eqw_http_handler.h" #include "../common/eqdb.h" #include "../common/SocketLib/HttpdForm.h" #include diff --git a/world/HTTPRequest.h b/world/http_request.h similarity index 100% rename from world/HTTPRequest.h rename to world/http_request.h diff --git a/world/LauncherLink.cpp b/world/launcher_link.cpp similarity index 98% rename from world/LauncherLink.cpp rename to world/launcher_link.cpp index 3b2463880..180e742a5 100644 --- a/world/LauncherLink.cpp +++ b/world/launcher_link.cpp @@ -17,9 +17,9 @@ */ #include "../common/debug.h" -#include "LauncherLink.h" -#include "LauncherList.h" -#include "WorldConfig.h" +#include "launcher_link.h" +#include "launcher_list.h" +#include "world_config.h" #include "../common/logsys.h" #include "../common/md5.h" #include "../common/packet_dump.h" @@ -27,7 +27,7 @@ #include "../common/emu_tcp_connection.h" #include "../common/string_util.h" #include "worlddb.h" -#include "EQLConfig.h" +#include "eql_config.h" #include #include diff --git a/world/LauncherLink.h b/world/launcher_link.h similarity index 100% rename from world/LauncherLink.h rename to world/launcher_link.h diff --git a/world/LauncherList.cpp b/world/launcher_list.cpp similarity index 98% rename from world/LauncherList.cpp rename to world/launcher_list.cpp index f22476343..9c3bada2b 100644 --- a/world/LauncherList.cpp +++ b/world/launcher_list.cpp @@ -18,10 +18,10 @@ #include "../common/debug.h" -#include "LauncherList.h" -#include "LauncherLink.h" +#include "launcher_list.h" +#include "launcher_link.h" #include "../common/logsys.h" -#include "EQLConfig.h" +#include "eql_config.h" LauncherList::LauncherList() : nextID(1) diff --git a/world/LauncherList.h b/world/launcher_list.h similarity index 100% rename from world/LauncherList.h rename to world/launcher_list.h diff --git a/world/LoginServer.cpp b/world/login_server.cpp similarity index 99% rename from world/LoginServer.cpp rename to world/login_server.cpp index 3b4781a2a..83f432ca0 100644 --- a/world/LoginServer.cpp +++ b/world/login_server.cpp @@ -52,8 +52,8 @@ #define IGNORE_LS_FATAL_ERROR #include "../common/servertalk.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" #include "../common/string_util.h" @@ -61,7 +61,7 @@ #include "worlddb.h" #include "zonelist.h" #include "clientlist.h" -#include "WorldConfig.h" +#include "world_config.h" extern ZSList zoneserver_list; extern ClientList client_list; diff --git a/world/LoginServer.h b/world/login_server.h similarity index 100% rename from world/LoginServer.h rename to world/login_server.h diff --git a/world/LoginServerList.cpp b/world/login_server_list.cpp similarity index 98% rename from world/LoginServerList.cpp rename to world/login_server_list.cpp index 5316804de..8e3780463 100644 --- a/world/LoginServerList.cpp +++ b/world/login_server_list.cpp @@ -26,15 +26,15 @@ #define IGNORE_LS_FATAL_ERROR #include "../common/servertalk.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "../common/eq_packet_structs.h" #include "../common/packet_dump.h" #include "zoneserver.h" #include "worlddb.h" #include "zonelist.h" #include "clientlist.h" -#include "WorldConfig.h" +#include "world_config.h" extern ZSList zoneserver_list; extern LoginServerList loginserverlist; diff --git a/world/LoginServerList.h b/world/login_server_list.h similarity index 100% rename from world/LoginServerList.h rename to world/login_server_list.h diff --git a/world/net.cpp b/world/net.cpp index 885d27c7d..4bfdc3c1a 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -72,17 +72,17 @@ #include "../common/patches/patches.h" #include "zoneserver.h" #include "console.h" -#include "LoginServer.h" -#include "LoginServerList.h" -#include "EQWHTTPHandler.h" -#include "WorldConfig.h" +#include "login_server.h" +#include "login_server_list.h" +#include "eqw_http_handler.h" +#include "world_config.h" #include "zoneserver.h" #include "zonelist.h" #include "clientlist.h" -#include "LauncherList.h" +#include "launcher_list.h" #include "wguild_mgr.h" #include "lfplist.h" -#include "AdventureManager.h" +#include "adventure_manager.h" #include "ucs.h" #include "queryserv.h" diff --git a/world/perl_EQLConfig.cpp b/world/perl_eql_config.cpp similarity index 99% rename from world/perl_EQLConfig.cpp rename to world/perl_eql_config.cpp index 5179839a6..19ea7c9f6 100644 --- a/world/perl_EQLConfig.cpp +++ b/world/perl_eql_config.cpp @@ -29,8 +29,8 @@ typedef const char Const_char; #ifdef EMBPERL #include "../common/debug.h" -#include "EQWParser.h" -#include "EQLConfig.h" +#include "eqw_parser.h" +#include "eql_config.h" #ifdef seed #undef seed diff --git a/world/perl_EQW.cpp b/world/perl_eqw.cpp similarity index 99% rename from world/perl_EQW.cpp rename to world/perl_eqw.cpp index e6896a08c..0a564164d 100644 --- a/world/perl_EQW.cpp +++ b/world/perl_eqw.cpp @@ -29,8 +29,8 @@ typedef const char Const_char; #ifdef EMBPERL #include "../common/debug.h" -#include "EQWParser.h" -#include "EQW.h" +#include "eqw_parser.h" +#include "eqw.h" #ifdef seed #undef seed diff --git a/world/perl_HTTPRequest.cpp b/world/perl_http_request.cpp similarity index 99% rename from world/perl_HTTPRequest.cpp rename to world/perl_http_request.cpp index 54fa48780..12d70002c 100644 --- a/world/perl_HTTPRequest.cpp +++ b/world/perl_http_request.cpp @@ -29,8 +29,8 @@ typedef const char Const_char; #ifdef EMBPERL #include "../common/debug.h" -#include "EQWParser.h" -#include "HTTPRequest.h" +#include "eqw_parser.h" +#include "http_request.h" #ifdef seed #undef seed diff --git a/world/queryserv.cpp b/world/queryserv.cpp index f1e80b555..2539fff63 100644 --- a/world/queryserv.cpp +++ b/world/queryserv.cpp @@ -1,6 +1,6 @@ #include "../common/debug.h" #include "queryserv.h" -#include "WorldConfig.h" +#include "world_config.h" #include "clientlist.h" #include "zonelist.h" #include "../common/logsys.h" diff --git a/world/SoFCharCreateData.h b/world/sof_char_create_data.h similarity index 100% rename from world/SoFCharCreateData.h rename to world/sof_char_create_data.h diff --git a/world/ucs.cpp b/world/ucs.cpp index 8e510b5f8..f89874ae2 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -1,6 +1,6 @@ #include "../common/debug.h" #include "ucs.h" -#include "WorldConfig.h" +#include "world_config.h" #include "../common/logsys.h" #include "../common/logtypes.h" #include "../common/md5.h" diff --git a/world/WorldConfig.cpp b/world/world_config.cpp similarity index 97% rename from world/WorldConfig.cpp rename to world/world_config.cpp index 96313ded3..2f9464e13 100644 --- a/world/WorldConfig.cpp +++ b/world/world_config.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "WorldConfig.h" +#include "world_config.h" WorldConfig *WorldConfig::_world_config = nullptr; diff --git a/world/WorldConfig.h b/world/world_config.h similarity index 100% rename from world/WorldConfig.h rename to world/world_config.h diff --git a/world/WorldTCPConnection.h b/world/world_tcp_connection.h similarity index 100% rename from world/WorldTCPConnection.h rename to world/world_tcp_connection.h diff --git a/world/worlddb.cpp b/world/worlddb.cpp index e6c3492e9..7a07c6f6f 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -26,7 +26,7 @@ #include #include #include -#include "sofCharCreateData.h" +#include "sof_char_create_data.h" WorldDatabase database; extern std::vector character_create_allocations; diff --git a/world/zonelist.cpp b/world/zonelist.cpp index 6b82c0fe9..fdf9db5cf 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -18,10 +18,10 @@ #include "../common/debug.h" #include "zonelist.h" #include "zoneserver.h" -#include "WorldTCPConnection.h" +#include "world_tcp_connection.h" #include "worlddb.h" #include "console.h" -#include "WorldConfig.h" +#include "world_config.h" #include "../common/servertalk.h" #include "../common/string_util.h" diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 6f8833bd1..a719deecf 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -18,14 +18,14 @@ #include "../common/debug.h" #include "zoneserver.h" #include "clientlist.h" -#include "LoginServer.h" -#include "LoginServerList.h" +#include "login_server.h" +#include "login_server_list.h" #include "zonelist.h" #include "worlddb.h" #include "console.h" #include "client.h" #include "../common/md5.h" -#include "WorldConfig.h" +#include "world_config.h" #include "../common/guilds.h" #include "../common/packet_dump.h" #include "../common/misc.h" @@ -33,7 +33,7 @@ #include "cliententry.h" #include "wguild_mgr.h" #include "lfplist.h" -#include "AdventureManager.h" +#include "adventure_manager.h" #include "ucs.h" #include "queryserv.h" diff --git a/world/zoneserver.h b/world/zoneserver.h index 7984b4178..661e03019 100644 --- a/world/zoneserver.h +++ b/world/zoneserver.h @@ -18,7 +18,7 @@ #ifndef ZONESERVER_H #define ZONESERVER_H -#include "WorldTCPConnection.h" +#include "world_tcp_connection.h" #include "../common/emu_tcp_connection.h" #include #include From 07a2cbe9a55de1d1ad7a80cc5b073d24a6d253ad Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 23:46:01 -0700 Subject: [PATCH 156/217] Renamed zone files --- zone/CMakeLists.txt | 36 +++++------ zone/{AA.cpp => aa.cpp} | 10 +-- zone/{AA.h => aa.h} | 2 +- zone/aggro.cpp | 2 +- zone/attack.cpp | 6 +- zone/bonuses.cpp | 4 +- zone/bot.cpp | 2 +- zone/bot.h | 4 +- zone/{botStructs.h => bot_structs.h} | 0 zone/client.cpp | 6 +- zone/client.h | 4 +- zone/client_mods.cpp | 4 +- zone/client_packet.cpp | 10 +-- zone/client_process.cpp | 6 +- zone/command.cpp | 6 +- zone/corpse.cpp | 4 +- zone/doors.cpp | 2 +- zone/effects.cpp | 4 +- zone/embparser.cpp | 2 +- zone/embparser.h | 4 +- zone/entity.cpp | 4 +- zone/entity.h | 2 +- zone/exp.cpp | 4 +- zone/forage.cpp | 4 +- zone/groups.cpp | 2 +- zone/guild.cpp | 4 +- zone/hate_list.cpp | 2 +- zone/inventory.cpp | 6 +- zone/lua_general.cpp | 4 +- zone/lua_parser.h | 4 +- zone/lua_parser_events.cpp | 4 +- zone/map.cpp | 2 +- zone/merc.cpp | 6 +- zone/mob.cpp | 4 +- zone/{MobAI.cpp => mob_ai.cpp} | 6 +- zone/mod_functions.cpp | 2 +- zone/mod_functions_base.cpp | 2 +- zone/net.cpp | 6 +- zone/npc.cpp | 4 +- zone/npc.h | 2 +- zone/{NpcAI.cpp => npc_ai.cpp} | 0 zone/{NpcAI.h => npc_ai.h} | 0 zone/{Object.cpp => object.cpp} | 4 +- ...layerCorpse.cpp => perl_player_corpse.cpp} | 0 zone/pets.cpp | 2 +- zone/{QGlobals.cpp => qglobals.cpp} | 2 +- zone/{QGlobals.h => qglobals.h} | 0 zone/{Quest.cpp => quest.cpp} | 2 +- zone/{Quest.h => quest.h} | 0 zone/{QuestInterface.h => quest_interface.h} | 0 ...ection.cpp => quest_parser_collection.cpp} | 4 +- ...Collection.h => quest_parser_collection.h} | 2 +- zone/questmgr.cpp | 4 +- zone/raids.cpp | 2 +- zone/{RaycastMesh.cpp => raycast_mesh.cpp} | 2 +- zone/{RaycastMesh.h => raycast_mesh.h} | 0 zone/special_attacks.cpp | 2 +- zone/spell_effects.cpp | 4 +- zone/spells.cpp | 4 +- zone/{StringIDs.h => string_ids.h} | 0 zone/tasks.cpp | 2 +- zone/tradeskills.cpp | 62 +++++++++---------- zone/trading.cpp | 4 +- zone/waypoints.cpp | 6 +- zone/worldserver.cpp | 6 +- zone/zone.cpp | 4 +- zone/zone.h | 2 +- zone/{ZoneConfig.cpp => zone_config.cpp} | 2 +- zone/{ZoneConfig.h => zone_config.h} | 0 zone/zoning.cpp | 4 +- 70 files changed, 159 insertions(+), 159 deletions(-) rename zone/{AA.cpp => aa.cpp} (99%) rename zone/{AA.h => aa.h} (99%) rename zone/{botStructs.h => bot_structs.h} (100%) rename zone/{MobAI.cpp => mob_ai.cpp} (99%) rename zone/{NpcAI.cpp => npc_ai.cpp} (100%) rename zone/{NpcAI.h => npc_ai.h} (100%) rename zone/{Object.cpp => object.cpp} (99%) rename zone/{perl_PlayerCorpse.cpp => perl_player_corpse.cpp} (100%) rename zone/{QGlobals.cpp => qglobals.cpp} (99%) rename zone/{QGlobals.h => qglobals.h} (100%) rename zone/{Quest.cpp => quest.cpp} (99%) rename zone/{Quest.h => quest.h} (100%) rename zone/{QuestInterface.h => quest_interface.h} (100%) rename zone/{QuestParserCollection.cpp => quest_parser_collection.cpp} (99%) rename zone/{QuestParserCollection.h => quest_parser_collection.h} (99%) rename zone/{RaycastMesh.cpp => raycast_mesh.cpp} (99%) rename zone/{RaycastMesh.h => raycast_mesh.h} (100%) rename zone/{StringIDs.h => string_ids.h} (100%) rename zone/{ZoneConfig.cpp => zone_config.cpp} (97%) rename zone/{ZoneConfig.h => zone_config.h} (100%) diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 9f7250d4e..8459fb79a 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(zone_sources - AA.cpp + aa.cpp aggro.cpp attack.cpp beacon.cpp @@ -69,12 +69,12 @@ SET(zone_sources map.cpp merc.cpp mob.cpp - MobAI.cpp + mob_ai.cpp mod_functions.cpp net.cpp npc.cpp - NpcAI.cpp - Object.cpp + npc_ai.cpp + object.cpp oriented_bounding_box.cpp pathing.cpp perl_client.cpp @@ -86,17 +86,17 @@ SET(zone_sources perl_npc.cpp perl_object.cpp perl_perlpacket.cpp - perl_PlayerCorpse.cpp + perl_player_corpse.cpp perl_questitem.cpp perl_raids.cpp perlpacket.cpp petitions.cpp pets.cpp - QGlobals.cpp + qglobals.cpp questmgr.cpp - QuestParserCollection.cpp + quest_parser_collection.cpp raids.cpp - RaycastMesh.cpp + raycast_mesh.cpp spawn2.cpp spawn2.h spawngroup.cpp @@ -116,18 +116,18 @@ SET(zone_sources worldserver.cpp zone.cpp zone_logsys.cpp - ZoneConfig.cpp + zone_config.cpp zonedb.cpp zonedbasync.cpp zoning.cpp ) SET(zone_headers - AA.h + aa.h basic_functions.h beacon.h bot.h - botStructs.h + bot_structs.h client.h client_logs.h client_packet.h @@ -175,25 +175,25 @@ SET(zone_headers mob.h net.h npc.h - NpcAI.h + npc_ai.h object.h oriented_bounding_box.h pathing.h perlpacket.h petitions.h pets.h - QGlobals.h - QuestInterface.h + qglobals.h + quest_interface.h questmgr.h - QuestParserCollection.h + quest_parser_collection.h raid.h raids.h - RaycastMesh.h + raycast_mesh.h skills.h spawn2.cpp spawn2.h spawngroup.h - StringIDs.h + string_ids.h tasks.h titles.h trap.h @@ -202,7 +202,7 @@ SET(zone_headers water_map_v2.h worldserver.h zone.h - ZoneConfig.h + zone_config.h zonedb.h zonedbasync.h zonedump.h diff --git a/zone/AA.cpp b/zone/aa.cpp similarity index 99% rename from zone/AA.cpp rename to zone/aa.cpp index 3c3375fd9..735776b79 100644 --- a/zone/AA.cpp +++ b/zone/aa.cpp @@ -19,7 +19,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) // Test 1 #include "../common/debug.h" -#include "AA.h" +#include "aa.h" #include "mob.h" #include "client.h" #include "groups.h" @@ -37,7 +37,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) #include "../common/string_util.h" #include "../common/logsys.h" #include "zonedb.h" -#include "StringIDs.h" +#include "string_ids.h" //static data arrays, really not big enough to warrant shared mem. AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] @@ -458,7 +458,7 @@ void Client::HandleAAAction(aaID activate) { Escape(); break; - // Don't think this code is used any longer for Bestial Alignment as the AA has a spell_id and no nonspell_action. + // Don't think this code is used any longer for Bestial Alignment as the aa.has a spell_id and no nonspell_action. case aaActionBeastialAlignment: switch(GetBaseRace()) { case BARBARIAN: @@ -1237,7 +1237,7 @@ void Client::SendAA(uint32 id, int seq) { Note: There were many ways to achieve this effect - The method used proved to be the most straight forward and consistent. Stacking does not currently work ideally for AA's that use hotkeys, therefore they will be excluded at this time. - TODO: Problem with AA hotkeys - When you reach max rank of an AA tier (ie 5/5), it automatically displays the next AA in + TODO: Problem with aa.hotkeys - When you reach max rank of an AA tier (ie 5/5), it automatically displays the next AA in the series and you can not transfer the hotkey to the next AA series. To the best of the my ability and through many different variations of coding I could not find an ideal solution to this issue. @@ -1676,7 +1676,7 @@ bool ZoneDatabase::LoadAAEffects() { return true; } -//Returns the number effects an AA has when we send them to the client +//Returns the number effects an aa.has when we send them to the client //For the purposes of sizing a packet because every skill does not //have the same number effects, they can range from none to a few depending on AA. //counts the # of effects by counting the different slots of an AAID in the DB. diff --git a/zone/AA.h b/zone/aa.h similarity index 99% rename from zone/AA.h rename to zone/aa.h index 3adc887e3..b143aae9a 100644 --- a/zone/AA.h +++ b/zone/aa.h @@ -2134,7 +2134,7 @@ struct AALevelCost_Struct uint32 Cost; }; -//assumes that no activatable AA has more than 5 ranks +//assumes that no activatable aa.has more than 5 ranks #define MAX_AA_ACTION_RANKS 20 extern AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] extern std::map AA_SwarmPets; //key=spell_id diff --git a/zone/aggro.cpp b/zone/aggro.cpp index bb8e1c390..d55dab4fd 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -25,7 +25,7 @@ #include "../common/skills.h" #include "../common/misc_functions.h" #include "../common/rulesys.h" -#include "StringIDs.h" +#include "string_ids.h" #include extern Zone* zone; diff --git a/zone/attack.cpp b/zone/attack.cpp index c8d29efac..dd14b1770 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -29,17 +29,17 @@ #include #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/packet_dump.h" #include "../common/eq_packet_structs.h" #include "../common/eq_constants.h" #include "../common/skills.h" #include "../common/spdat.h" #include "zone.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "water_map.h" #include "worldserver.h" extern WorldServer worldserver; diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index a57648ac6..f1105ce73 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -26,7 +26,7 @@ #include "../common/bodytypes.h" #include "../common/classes.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include #include #include @@ -35,7 +35,7 @@ #include "../common/unix.h" #endif -#include "StringIDs.h" +#include "string_ids.h" void Mob::CalcBonuses() { diff --git a/zone/bot.cpp b/zone/bot.cpp index a2aa4504b..e782e6db8 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -3,7 +3,7 @@ #include "bot.h" #include "object.h" #include "doors.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "../common/string_util.h" extern volatile bool ZoneLoaded; diff --git a/zone/bot.h b/zone/bot.h index 3799b5f0b..9c1ec9cb2 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -3,14 +3,14 @@ #ifdef BOTS -#include "botStructs.h" +#include "bot_structs.h" #include "mob.h" #include "client.h" #include "pets.h" #include "groups.h" #include "corpse.h" #include "zonedb.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/debug.h" #include "guild_mgr.h" diff --git a/zone/botStructs.h b/zone/bot_structs.h similarity index 100% rename from zone/botStructs.h rename to zone/bot_structs.h diff --git a/zone/client.cpp b/zone/client.cpp index 617eceddf..d986dbe22 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -57,11 +57,11 @@ extern volatile bool RunLoops; #include "../common/string_util.h" #include "forage.h" #include "command.h" -#include "StringIDs.h" -#include "NpcAI.h" +#include "string_ids.h" +#include "npc_ai.h" #include "client_logs.h" #include "guild_mgr.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" extern EntityList entity_list; diff --git a/zone/client.h b/zone/client.h index 5bd910ce9..b78530ae1 100644 --- a/zone/client.h +++ b/zone/client.h @@ -43,9 +43,9 @@ class Client; #include "npc.h" #include "merc.h" #include "zone.h" -#include "AA.h" +#include "aa.h" #include "questmgr.h" -#include "QGlobals.h" +#include "qglobals.h" #ifdef _WINDOWS // since windows defines these within windef.h (which windows.h include) diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 08c652c75..ba8eae47e 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -30,8 +30,8 @@ #include "worldserver.h" #include "zonedb.h" #include "petitions.h" -#include "StringIDs.h" -#include "NpcAI.h" +#include "string_ids.h" +#include "npc_ai.h" // Return max stat value for level diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8a1c39934..ce6b1a323 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -51,24 +51,24 @@ #include "../common/rulesys.h" #include "../common/spdat.h" #include "petitions.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/skills.h" #include "forage.h" #include "zone.h" #include "event_codes.h" #include "../common/faction.h" #include "../common/crc32.h" -#include "StringIDs.h" +#include "string_ids.h" #include "map.h" #include "titles.h" #include "pets.h" -#include "ZoneConfig.h" +#include "zone_config.h" #include "guild_mgr.h" #include "pathing.h" #include "water_map.h" #include "merc.h" #include "../common/zone_numbers.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" extern Zone* zone; extern volatile bool ZoneLoaded; @@ -8970,7 +8970,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { continue; } - if(aa[a]->value > 1) //hack in some stuff for sony's new AA method (where each level of each AA has a seperate ID) + if(aa[a]->value > 1) //hack in some stuff for sony's new AA method (where each level of each aa.has a seperate ID) aa_points[(id - aa[a]->value +1)] = aa[a]->value; else aa_points[id] = aa[a]->value; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index be8b23622..3fea686ab 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -50,7 +50,7 @@ #include "../common/string_util.h" #include "../common/spdat.h" #include "petitions.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/skills.h" #include "forage.h" #include "zone.h" @@ -58,11 +58,11 @@ #include "../common/faction.h" #include "../common/crc32.h" #include "../common/rulesys.h" -#include "StringIDs.h" +#include "string_ids.h" #include "map.h" #include "guild_mgr.h" #include -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" extern Zone* zone; extern volatile bool ZoneLoaded; diff --git a/zone/command.cpp b/zone/command.cpp index c50956d39..555804cfa 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -68,11 +68,11 @@ extern WorldServer worldserver; extern TaskManager *taskmanager; void CatchSignal(int sig_num); -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" -#include "StringIDs.h" +#include "string_ids.h" #include "command.h" -#include "QGlobals.h" +#include "qglobals.h" //struct cl_struct *commandlist; // the actual linked list of commands int commandcount; // how many commands we have diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 8d0f1d5e1..aa7841a64 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -37,10 +37,10 @@ Child of the Mob class. #include "../common/packet_functions.h" #include "../common/string_util.h" #include "../common/crc32.h" -#include "StringIDs.h" +#include "string_ids.h" #include "worldserver.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" extern EntityList entity_list; extern Zone* zone; diff --git a/zone/doors.cpp b/zone/doors.cpp index a2b774038..c353ce568 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -21,7 +21,7 @@ #include #include "masterentity.h" #include "worldserver.h" -#include "StringIDs.h" +#include "string_ids.h" #include "zonedb.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" diff --git a/zone/effects.cpp b/zone/effects.cpp index 1b87de0fe..a24a6b39b 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -27,8 +27,8 @@ #include "../common/zone_numbers.h" #include "../common/moremath.h" #include "../common/guilds.h" -#include "StringIDs.h" -#include "NpcAI.h" +#include "string_ids.h" +#include "npc_ai.h" float Client::GetActSpellRange(uint16 spell_id, float range, bool IsBard) { diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 1e38597ae..8c4a82f55 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -26,7 +26,7 @@ #include "masterentity.h" #include "embparser.h" #include "questmgr.h" -#include "QGlobals.h" +#include "qglobals.h" #include "zone.h" #include #include diff --git a/zone/embparser.h b/zone/embparser.h index ffca78075..3cb3a57f7 100644 --- a/zone/embparser.h +++ b/zone/embparser.h @@ -20,8 +20,8 @@ #define EQMEU_EMBPARSER_H #ifdef EMBPERL -#include "QuestParserCollection.h" -#include "QuestInterface.h" +#include "quest_parser_collection.h" +#include "quest_interface.h" #include #include #include diff --git a/zone/entity.cpp b/zone/entity.cpp index d904dbdfe..469bf8111 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -39,11 +39,11 @@ #include "petitions.h" #include "../common/spdat.h" #include "../common/features.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/dbasync.h" #include "guild_mgr.h" #include "raids.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #ifdef _WINDOWS #define snprintf _snprintf diff --git a/zone/entity.h b/zone/entity.h index c1ba0936c..d61298b0a 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -29,7 +29,7 @@ #include "zonedb.h" #include "zonedump.h" #include "zonedbasync.h" -#include "QGlobals.h" +#include "qglobals.h" class EQApplicationPacket; diff --git a/zone/exp.cpp b/zone/exp.cpp index 95f786e55..73d339af6 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -18,10 +18,10 @@ #include "../common/debug.h" #include "../common/features.h" #include "masterentity.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" static uint32 MaxBankedGroupLeadershipPoints(int Level) diff --git a/zone/forage.cpp b/zone/forage.cpp index ba4542575..aaa3451d5 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -30,7 +30,7 @@ #include "npc.h" #include "water_map.h" #include "titles.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" @@ -40,7 +40,7 @@ #define snprintf _snprintf #endif -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" //max number of items which can be in the foraging table //for a given zone. diff --git a/zone/groups.cpp b/zone/groups.cpp index 5075ee82a..598fa4989 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -17,7 +17,7 @@ */ #include "../common/debug.h" #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" #include "../common/string_util.h" diff --git a/zone/guild.cpp b/zone/guild.cpp index b803636f1..92635c185 100644 --- a/zone/guild.cpp +++ b/zone/guild.cpp @@ -30,8 +30,8 @@ #include "../common/guilds.h" #include "../common/string_util.h" #include "guild_mgr.h" -#include "StringIDs.h" -#include "NpcAI.h" +#include "string_ids.h" +#include "npc_ai.h" extern WorldServer worldserver; diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 5d9cde5c1..c7f44e6ba 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -25,7 +25,7 @@ #include "../common/rulesys.h" #include "../common/misc_functions.h" #include "hate_list.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "zone.h" #include "water_map.h" diff --git a/zone/inventory.cpp b/zone/inventory.cpp index e013b32e0..5c5f80122 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -30,9 +30,9 @@ #include "../common/guilds.h" #include "../common/logsys.h" #include "../common/string_util.h" -#include "StringIDs.h" -#include "NpcAI.h" -#include "QuestParserCollection.h" +#include "string_ids.h" +#include "npc_ai.h" +#include "quest_parser_collection.h" extern WorldServer worldserver; // @merth: this needs to be touched up diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 508112f4a..878f82225 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -13,9 +13,9 @@ #include "lua_client.h" #include "lua_npc.h" #include "lua_entity_list.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "questmgr.h" -#include "QGlobals.h" +#include "qglobals.h" #include "../common/timer.h" struct Events { }; diff --git a/zone/lua_parser.h b/zone/lua_parser.h index b30e3d3b7..732f7d235 100644 --- a/zone/lua_parser.h +++ b/zone/lua_parser.h @@ -2,8 +2,8 @@ #define _EQE_LUA_PARSER_H #ifdef LUA_EQEMU -#include "QuestParserCollection.h" -#include "QuestInterface.h" +#include "quest_parser_collection.h" +#include "quest_interface.h" #include #include #include diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 472962b59..56e5d236d 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -5,8 +5,8 @@ #include #include -#include "QuestParserCollection.h" -#include "QuestInterface.h" +#include "quest_parser_collection.h" +#include "quest_interface.h" #include "masterentity.h" #include "../common/seperator.h" diff --git a/zone/map.cpp b/zone/map.cpp index 25e57340f..a023cc125 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -1,7 +1,7 @@ #include "../common/debug.h" #include "../common/misc_functions.h" #include "map.h" -#include "RaycastMesh.h" +#include "raycast_mesh.h" #include "zone.h" #include #include diff --git a/zone/merc.cpp b/zone/merc.cpp index aabf3c6b7..cb9a166ab 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1,17 +1,17 @@ #include "merc.h" #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/packet_dump.h" #include "../common/eq_packet_structs.h" #include "../common/eq_constants.h" #include "../common/skills.h" #include "../common/spdat.h" #include "zone.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "water_map.h" extern volatile bool ZoneLoaded; diff --git a/zone/mob.cpp b/zone/mob.cpp index 07f7b43b1..6297d4ee8 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -18,9 +18,9 @@ #include "../common/debug.h" #include "masterentity.h" #include "../common/spdat.h" -#include "StringIDs.h" +#include "string_ids.h" #include "worldserver.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "../common/string_util.h" #include diff --git a/zone/MobAI.cpp b/zone/mob_ai.cpp similarity index 99% rename from zone/MobAI.cpp rename to zone/mob_ai.cpp index d367c417e..d6a336a7c 100644 --- a/zone/MobAI.cpp +++ b/zone/mob_ai.cpp @@ -23,15 +23,15 @@ #include #include "npc.h" #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "map.h" #include "../common/moremath.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" #include "../common/features.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "water_map.h" extern EntityList entity_list; diff --git a/zone/mod_functions.cpp b/zone/mod_functions.cpp index 0a9a66537..b948dff38 100644 --- a/zone/mod_functions.cpp +++ b/zone/mod_functions.cpp @@ -12,7 +12,7 @@ #include "mob.h" #include "client.h" #include "worldserver.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "event_codes.h" #include "embparser.h" #include diff --git a/zone/mod_functions_base.cpp b/zone/mod_functions_base.cpp index 8beb6cd79..e9e172997 100644 --- a/zone/mod_functions_base.cpp +++ b/zone/mod_functions_base.cpp @@ -12,7 +12,7 @@ #include "mob.h" #include "client.h" #include "worldserver.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "event_codes.h" #include "embparser.h" #include diff --git a/zone/net.cpp b/zone/net.cpp index 6fba81d49..d81ea71e3 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -43,18 +43,18 @@ #include "../common/eqemu_exception.h" #include "../common/spdat.h" -#include "ZoneConfig.h" +#include "zone_config.h" #include "masterentity.h" #include "worldserver.h" #include "net.h" #include "zone.h" #include "command.h" -#include "ZoneConfig.h" +#include "zone_config.h" #include "titles.h" #include "guild_mgr.h" #include "tasks.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "embparser.h" #include "lua_parser.h" #include "client_logs.h" diff --git a/zone/npc.cpp b/zone/npc.cpp index 32d33d75b..f70c1e847 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -43,7 +43,7 @@ #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "StringIDs.h" +#include "string_ids.h" //#define SPELLQUEUE //Use only if you want to be spammed by spell testing @@ -52,7 +52,7 @@ extern Zone* zone; extern volatile bool ZoneLoaded; extern EntityList entity_list; -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float heading, int iflymode, bool IsCorpse) : Mob(d->name, diff --git a/zone/npc.h b/zone/npc.h index 34fcfcd0a..5b28260d4 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -29,7 +29,7 @@ class NPC; #include "spawn2.h" #include "../common/loottable.h" #include "zonedump.h" -#include "QGlobals.h" +#include "qglobals.h" #include "../common/rulesys.h" #ifdef _WINDOWS diff --git a/zone/NpcAI.cpp b/zone/npc_ai.cpp similarity index 100% rename from zone/NpcAI.cpp rename to zone/npc_ai.cpp diff --git a/zone/NpcAI.h b/zone/npc_ai.h similarity index 100% rename from zone/NpcAI.h rename to zone/npc_ai.h diff --git a/zone/Object.cpp b/zone/object.cpp similarity index 99% rename from zone/Object.cpp rename to zone/object.cpp index 666f5da1f..a2c418b40 100644 --- a/zone/Object.cpp +++ b/zone/object.cpp @@ -27,9 +27,9 @@ #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/features.h" -#include "StringIDs.h" +#include "string_ids.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" const char DEFAULT_OBJECT_NAME[] = "IT63_ACTORDEF"; const char DEFAULT_OBJECT_NAME_SUFFIX[] = "_ACTORDEF"; diff --git a/zone/perl_PlayerCorpse.cpp b/zone/perl_player_corpse.cpp similarity index 100% rename from zone/perl_PlayerCorpse.cpp rename to zone/perl_player_corpse.cpp diff --git a/zone/pets.cpp b/zone/pets.cpp index f2876e0b0..40d064521 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -35,7 +35,7 @@ #include "../common/unix.h" #endif -#include "StringIDs.h" +#include "string_ids.h" /////////////////////////////////////////////////////////////////////////////// // pet related functions diff --git a/zone/QGlobals.cpp b/zone/qglobals.cpp similarity index 99% rename from zone/QGlobals.cpp rename to zone/qglobals.cpp index 85165820b..53f64670b 100644 --- a/zone/QGlobals.cpp +++ b/zone/qglobals.cpp @@ -1,6 +1,6 @@ #include "../common/debug.h" #include "../common/string_util.h" -#include "QGlobals.h" +#include "qglobals.h" #include "masterentity.h" #include "zone.h" #include "zonedb.h" diff --git a/zone/QGlobals.h b/zone/qglobals.h similarity index 100% rename from zone/QGlobals.h rename to zone/qglobals.h diff --git a/zone/Quest.cpp b/zone/quest.cpp similarity index 99% rename from zone/Quest.cpp rename to zone/quest.cpp index 9a98902ab..fb2d9f851 100644 --- a/zone/Quest.cpp +++ b/zone/quest.cpp @@ -29,7 +29,7 @@ #include "../common/unix.h" #endif -#include "Quest.h" +#include "quest.h" pquest_entry Quest::m_pQuests; int Quest::m_nQuests; diff --git a/zone/Quest.h b/zone/quest.h similarity index 100% rename from zone/Quest.h rename to zone/quest.h diff --git a/zone/QuestInterface.h b/zone/quest_interface.h similarity index 100% rename from zone/QuestInterface.h rename to zone/quest_interface.h diff --git a/zone/QuestParserCollection.cpp b/zone/quest_parser_collection.cpp similarity index 99% rename from zone/QuestParserCollection.cpp rename to zone/quest_parser_collection.cpp index 513334ff1..376c121d3 100644 --- a/zone/QuestParserCollection.cpp +++ b/zone/quest_parser_collection.cpp @@ -19,8 +19,8 @@ #include "../common/debug.h" #include "../common/misc_functions.h" #include "../common/features.h" -#include "QuestParserCollection.h" -#include "QuestInterface.h" +#include "quest_parser_collection.h" +#include "quest_interface.h" #include "zone.h" #include "questmgr.h" diff --git a/zone/QuestParserCollection.h b/zone/quest_parser_collection.h similarity index 99% rename from zone/QuestParserCollection.h rename to zone/quest_parser_collection.h index ff8eb967e..902500231 100644 --- a/zone/QuestParserCollection.h +++ b/zone/quest_parser_collection.h @@ -23,7 +23,7 @@ #include "../common/item.h" #include "masterentity.h" -#include "QuestInterface.h" +#include "quest_interface.h" #include #include diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index fd5c3a376..d8b9094be 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -73,8 +73,8 @@ And then at then end of embparser.cpp, add: #include "event_codes.h" #include "guild_mgr.h" #include "../common/rulesys.h" -#include "QGlobals.h" -#include "QuestParserCollection.h" +#include "qglobals.h" +#include "quest_parser_collection.h" #ifdef BOTS #include "bot.h" diff --git a/zone/raids.cpp b/zone/raids.cpp index 06630afee..84ebcee7d 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -17,7 +17,7 @@ */ #include "../common/debug.h" #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" #include "../common/string_util.h" diff --git a/zone/RaycastMesh.cpp b/zone/raycast_mesh.cpp similarity index 99% rename from zone/RaycastMesh.cpp rename to zone/raycast_mesh.cpp index 404961bf0..078f225a1 100644 --- a/zone/RaycastMesh.cpp +++ b/zone/raycast_mesh.cpp @@ -1,4 +1,4 @@ -#include "RaycastMesh.h" +#include "raycast_mesh.h" #include #include #include diff --git a/zone/RaycastMesh.h b/zone/raycast_mesh.h similarity index 100% rename from zone/RaycastMesh.h rename to zone/raycast_mesh.h diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 691cc98b3..6ba7528b6 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -23,7 +23,7 @@ #include #include "masterentity.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/rulesys.h" diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 3856f66da..bb1c3c449 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -33,8 +33,8 @@ #include "../common/unix.h" #endif -#include "StringIDs.h" -#include "QuestParserCollection.h" +#include "string_ids.h" +#include "quest_parser_collection.h" extern Zone* zone; extern volatile bool ZoneLoaded; diff --git a/zone/spells.cpp b/zone/spells.cpp index 96980b986..8db861ae1 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -90,8 +90,8 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include "../common/packet_dump_file.h" #endif -#include "StringIDs.h" -#include "QuestParserCollection.h" +#include "string_ids.h" +#include "quest_parser_collection.h" extern Zone* zone; extern volatile bool ZoneLoaded; diff --git a/zone/StringIDs.h b/zone/string_ids.h similarity index 100% rename from zone/StringIDs.h rename to zone/string_ids.h diff --git a/zone/tasks.cpp b/zone/tasks.cpp index c73cdd0fd..994ebdc5d 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -32,7 +32,7 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) #include "../common/rulesys.h" #include "masterentity.h" #include "../common/features.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "mob.h" diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index dc5a4a1e3..4d4edb344 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -29,11 +29,11 @@ #include "../common/packet_functions.h" #include "../common/packet_dump.h" #include "titles.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" static const SkillUseTypes TradeskillUnknown = Skill1HBlunt; /* an arbitrary non-tradeskill */ @@ -928,20 +928,20 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { _log(TRADESKILLS__TRACE, "...Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR()); float res = MakeRandomFloat(0, 99); - int AAChance = 0; + int aa_chance = 0; //AA modifiers //can we do this with nested switches? if(spec->tradeskill == SkillAlchemy){ switch(GetAA(aaAlchemyMastery)){ case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -949,13 +949,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if(spec->tradeskill == SkillJewelryMaking){ switch(GetAA(aaJewelCraftMastery)){ case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -964,13 +964,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillBlacksmithing) { switch(GetAA(aaBlacksmithingMastery)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -978,13 +978,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillBaking) { switch(GetAA(aaBakingMastery)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -992,13 +992,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillBrewing) { switch(GetAA(aaBrewingMastery)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -1006,13 +1006,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillFletching) { switch(GetAA(aaFletchingMastery2)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -1020,13 +1020,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillPottery) { switch(GetAA(aaPotteryMastery)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -1034,13 +1034,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillTailoring) { switch(GetAA(aaTailoringMastery)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } @@ -1048,20 +1048,20 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (spec->tradeskill == SkillResearch) { switch(GetAA(aaArcaneTongues)) { case 1: - AAChance = 10; + aa_chance = 10; break; case 2: - AAChance = 25; + aa_chance = 25; break; case 3: - AAChance = 50; + aa_chance = 50; break; } } chance = mod_tradeskill_chance(chance, spec); - if (((spec->tradeskill==75) || GetGM() || (chance > res)) || MakeRandomInt(0, 99) < AAChance){ + if (((spec->tradeskill==75) || GetGM() || (chance > res)) || MakeRandomInt(0, 99) < aa_chance){ success_modifier = 1; if(over_trivial < 0) diff --git a/zone/trading.cpp b/zone/trading.cpp index d8f17cd9b..1efcbbb33 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -17,10 +17,10 @@ */ #include "../common/debug.h" #include "masterentity.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/string_util.h" #include "../common/rulesys.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #include "worldserver.h" extern WorldServer worldserver; diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 1f30b7ff3..8c8a3f218 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -24,16 +24,16 @@ #include #include "npc.h" #include "masterentity.h" -#include "NpcAI.h" +#include "npc_ai.h" #include "map.h" #include "water_map.h" #include "../common/moremath.h" -#include "StringIDs.h" +#include "string_ids.h" #include "../common/misc_functions.h" #include "../common/string_util.h" #include "../common/rulesys.h" #include "../common/features.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" struct wp_distance { diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 4c3e53189..791a34ee4 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -45,12 +45,12 @@ #include "petitions.h" #include "../common/packet_functions.h" #include "../common/md5.h" -#include "ZoneConfig.h" -#include "StringIDs.h" +#include "zone_config.h" +#include "string_ids.h" #include "guild_mgr.h" #include "../common/rulesys.h" #include "titles.h" -#include "QGlobals.h" +#include "qglobals.h" extern EntityList entity_list; diff --git a/zone/zone.cpp b/zone/zone.cpp index 7252d843e..6bf3689ce 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -46,7 +46,7 @@ #include "../common/eq_stream_factory.h" #include "../common/eq_stream.h" #include "../common/string_util.h" -#include "ZoneConfig.h" +#include "zone_config.h" #include "../common/breakdowns.h" #include "map.h" #include "water_map.h" @@ -57,7 +57,7 @@ #include "client_logs.h" #include "../common/rulesys.h" #include "guild_mgr.h" -#include "QuestParserCollection.h" +#include "quest_parser_collection.h" #ifdef _WINDOWS #define snprintf _snprintf diff --git a/zone/zone.h b/zone/zone.h index 0256beeec..77132124e 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -32,7 +32,7 @@ #include "spawn2.h" #include "tasks.h" #include "pathing.h" -#include "QGlobals.h" +#include "qglobals.h" #include class Map; diff --git a/zone/ZoneConfig.cpp b/zone/zone_config.cpp similarity index 97% rename from zone/ZoneConfig.cpp rename to zone/zone_config.cpp index 65ecefa13..3775f1e4b 100644 --- a/zone/ZoneConfig.cpp +++ b/zone/zone_config.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/debug.h" -#include "ZoneConfig.h" +#include "zone_config.h" ZoneConfig *ZoneConfig::_zone_config = nullptr; diff --git a/zone/ZoneConfig.h b/zone/zone_config.h similarity index 100% rename from zone/ZoneConfig.h rename to zone/zone_config.h diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 35041a4c1..3d638bfb5 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -23,8 +23,8 @@ #include "../common/packet_dump.h" #include "../common/rulesys.h" #include "../common/string_util.h" -#include "StringIDs.h" -#include "QuestParserCollection.h" +#include "string_ids.h" +#include "quest_parser_collection.h" extern WorldServer worldserver; extern Zone* zone; From 27dec165515844c04afdec83709a19b636ea2e58 Mon Sep 17 00:00:00 2001 From: KimLS Date: Thu, 21 Aug 2014 23:55:04 -0700 Subject: [PATCH 157/217] Missed a file, thanks NTFS --- common/patches/{SoF_opcode_list.h => sof_opcode_list.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename common/patches/{SoF_opcode_list.h => sof_opcode_list.h} (100%) diff --git a/common/patches/SoF_opcode_list.h b/common/patches/sof_opcode_list.h similarity index 100% rename from common/patches/SoF_opcode_list.h rename to common/patches/sof_opcode_list.h From 3b16c86007b8cda73d1a00253dd350f06ceb6b81 Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 22 Aug 2014 14:50:13 -0700 Subject: [PATCH 158/217] Fix for aa effect loading. --- zone/aa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/aa.cpp b/zone/aa.cpp index 01a34d9b2..1bf2ba690 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -1473,7 +1473,7 @@ bool ZoneDatabase::LoadAAEffects2() { return false; } - if (results.RowCount()) { //no results + if (!results.RowCount()) { //no results LogFile->write(EQEMuLog::Error, "Error loading AA Effects, none found in the database."); return false; } From 9a5d2d2bc575b34f4a8464e4db2501d7a6a365d0 Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 22 Aug 2014 20:48:11 -0400 Subject: [PATCH 159/217] Trade Stacking: BETA --- changelog.txt | 10 + common/item.cpp | 93 ++++++++ common/item.h | 1 + zone/common.h | 2 +- zone/inventory.cpp | 21 +- zone/trading.cpp | 533 ++++++++++++++++++++++++++++++--------------- 6 files changed, 475 insertions(+), 185 deletions(-) diff --git a/changelog.txt b/changelog.txt index bf2ea97f0..9d593e3e2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,15 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/22/2014 == +Uleat: Rework of Trade::FinishedTrade() and Trade::ResetTrade() to parse items a little more intelligently. + +Trade window items are now sent to client inventory in this order: + - Bags + - Partial stack movements + - All remaining items + +If any of these procedures cause any problems, please post them immediately. + == 08/20/2014 == Uleat: Rework of Trade::AddEntity() - function used to move items into the trade window. Now accepts argument for 'stack_size' and updates client properly. Note: I tested trade with Titanium:{SoF,SoD,UF,RoF} in both directions and no client generated an OP_MoveItem event for attempting to place a stackable diff --git a/common/item.cpp b/common/item.cpp index 7d6618335..bbb6f14f8 100644 --- a/common/item.cpp +++ b/common/item.cpp @@ -654,6 +654,99 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo return INVALID_INDEX; } +// This is a mix of HasSpaceForItem and FindFreeSlot..due to existing coding behavior, it was better to add a new helper function... +int16 Inventory::FindFreeSlotForTradeItem(const ItemInst* inst) { + // Do not arbitrarily use this function..it is designed for use with Client::ResetTrade() and Client::FinishTrade(). + // If you have a need, use it..but, understand it is not a compatible replacement for Inventory::FindFreeSlot(). + // + // I'll probably implement a bitmask in the new inventory system to avoid having to adjust stack bias -U + + if (!inst || !inst->GetID()) + return INVALID_INDEX; + + // step 1: find room for bags (caller should really ask for slots for bags first to avoid sending them to cursor..and bag item loss) + if (inst->IsType(ItemClassContainer)) { + for (int16 free_slot = EmuConstants::GENERAL_BEGIN; free_slot <= EmuConstants::GENERAL_END; ++free_slot) + if (!m_inv[free_slot]) + return free_slot; + + return MainCursor; // return cursor since bags do not stack and will not fit inside other bags..yet...) + } + + // step 2: find partial room for stackables + if (inst->IsStackable()) { + for (int16 free_slot = EmuConstants::GENERAL_BEGIN; free_slot <= EmuConstants::GENERAL_END; ++free_slot) { + const ItemInst* main_inst = m_inv[free_slot]; + + if (!main_inst) + continue; + + if ((main_inst->GetID() == inst->GetID()) && (main_inst->GetCharges() < main_inst->GetItem()->StackSize)) + return free_slot; + + if (main_inst->IsType(ItemClassContainer)) { // if item-specific containers already have bad items, we won't fix it here... + for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) { + const ItemInst* sub_inst = main_inst->GetItem(free_bag_slot); + + if (!sub_inst) + continue; + + if ((sub_inst->GetID() == inst->GetID()) && (sub_inst->GetCharges() < sub_inst->GetItem()->StackSize)) + return Inventory::CalcSlotId(free_slot, free_bag_slot); + } + } + } + } + + // step 3a: find room for container-specific items (ItemClassArrow) + if (inst->GetItem()->ItemType == ItemTypeArrow) { + for (int16 free_slot = EmuConstants::GENERAL_BEGIN; free_slot <= EmuConstants::GENERAL_END; ++free_slot) { + const ItemInst* main_inst = m_inv[free_slot]; + + if (!main_inst || (main_inst->GetItem()->BagType != BagTypeQuiver) || !main_inst->IsType(ItemClassContainer)) + continue; + + for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) + if (!main_inst->GetItem(free_bag_slot)) + return Inventory::CalcSlotId(free_slot, free_bag_slot); + } + } + + // step 3b: find room for container-specific items (ItemClassSmallThrowing) + if (inst->GetItem()->ItemType == ItemTypeSmallThrowing) { + for (int16 free_slot = EmuConstants::GENERAL_BEGIN; free_slot <= EmuConstants::GENERAL_END; ++free_slot) { + const ItemInst* main_inst = m_inv[free_slot]; + + if (!main_inst || (main_inst->GetItem()->BagType != BagTypeBandolier) || !main_inst->IsType(ItemClassContainer)) + continue; + + for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) + if (!main_inst->GetItem(free_bag_slot)) + return Inventory::CalcSlotId(free_slot, free_bag_slot); + } + } + + // step 4: just find an empty slot + for (int16 free_slot = EmuConstants::GENERAL_BEGIN; free_slot <= EmuConstants::GENERAL_END; ++free_slot) { + const ItemInst* main_inst = m_inv[free_slot]; + + if (!main_inst) + return free_slot; + + if (main_inst->IsType(ItemClassContainer)) { + if ((main_inst->GetItem()->BagSize < inst->GetItem()->Size) || (main_inst->GetItem()->BagType == BagTypeBandolier) || (main_inst->GetItem()->BagType == BagTypeQuiver)) + continue; + + for (uint8 free_bag_slot = SUB_BEGIN; (free_bag_slot < main_inst->GetItem()->BagSlots) && (free_bag_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++free_bag_slot) + if (!main_inst->GetItem(free_bag_slot)) + return Inventory::CalcSlotId(free_slot, free_bag_slot); + } + } + + //return INVALID_INDEX; // everything else pushes to the cursor + return MainCursor; +} + // Opposite of below: Get parent bag slot_id from a slot inside of bag int16 Inventory::CalcSlotId(int16 slot_id) { int16 parent_slot_id = INVALID_INDEX; diff --git a/common/item.h b/common/item.h index ef59ddd6f..f279bd2aa 100644 --- a/common/item.h +++ b/common/item.h @@ -172,6 +172,7 @@ public: // Locate an available inventory slot int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false); + int16 FindFreeSlotForTradeItem(const ItemInst* inst); // Calculate slot_id for an item within a bag static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id diff --git a/zone/common.h b/zone/common.h index 3cc1af1cf..eccffec62 100644 --- a/zone/common.h +++ b/zone/common.h @@ -526,7 +526,7 @@ public: Mob* With(); // Add item from cursor slot to trade bucket (automatically does bag data too) - void AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_size); + void AddEntity(uint16 trade_slot_id, uint32 stack_size); // Audit trade void LogTrade(); diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 5c5f80122..197841c76 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -822,25 +822,24 @@ bool Client::PushItemOnCursor(const ItemInst& inst, bool client_update) return database.SaveCursor(CharacterID(), s, e); } -bool Client::PutItemInInventory(int16 slot_id, const ItemInst& inst, bool client_update) -{ +bool Client::PutItemInInventory(int16 slot_id, const ItemInst& inst, bool client_update) { mlog(INVENTORY__SLOTS, "Putting item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); + if (slot_id == MainCursor) - { - return PushItemOnCursor(inst,client_update); - } + return PushItemOnCursor(inst, client_update); else m_inv.PutItem(slot_id, inst); - if (client_update) { - SendItemPacket(slot_id, &inst, (slot_id == MainCursor) ? ItemPacketSummonItem : ItemPacketTrade); - } + if (client_update) + SendItemPacket(slot_id, &inst, ((slot_id == MainCursor) ? ItemPacketSummonItem : ItemPacketTrade)); if (slot_id == MainCursor) { - std::list::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end(); + std::list::const_iterator s = m_inv.cursor_begin(), e = m_inv.cursor_end(); return database.SaveCursor(this->CharacterID(), s, e); - } else + } + else { return database.SaveInventory(this->CharacterID(), &inst, slot_id); + } CalcBonuses(); } @@ -1539,7 +1538,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // Also sends trade information to other client of trade session if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit - trade->AddEntity(src_slot_id, dst_slot_id, move_in->number_in_stack); + trade->AddEntity(dst_slot_id, move_in->number_in_stack); return true; } else { diff --git a/zone/trading.cpp b/zone/trading.cpp index 1efcbbb33..1ae9596b9 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -71,8 +71,8 @@ void Trade::Start(uint32 mob_id, bool initiate_with) } // Add item from a given slot to trade bucket (automatically does bag data too) -void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_size) { - // TODO: review for inventory saves +void Trade::AddEntity(uint16 trade_slot_id, uint32 stack_size) { + // TODO: review for inventory saves / consider changing return type to bool so failure can be passed to desync handler if (!owner || !owner->IsClient()) { // This should never happen @@ -121,7 +121,7 @@ void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_si if (_stack_size > 0) inst->SetCharges(_stack_size); else - client->DeleteItemInInventory(from_slot_id); + client->DeleteItemInInventory(MainCursor); SendItemData(inst2, trade_slot_id); } @@ -136,7 +136,7 @@ void Trade::AddEntity(uint16 from_slot_id, uint16 trade_slot_id, uint32 stack_si _log(TRADING__HOLDER, "%s added item '%s' to trade slot %i", owner->GetName(), inst->GetItem()->Name, trade_slot_id); client->PutItemInInventory(trade_slot_id, *inst); - client->DeleteItemInInventory(from_slot_id); + client->DeleteItemInInventory(MainCursor); } } @@ -316,206 +316,393 @@ void Trade::DumpTrade() #endif void Client::ResetTrade() { - const Item_Struct* TempItem = 0; - ItemInst* ins; - int x; AddMoneyToPP(trade->cp, trade->sp, trade->gp, trade->pp, true); - for(x = EmuConstants::TRADE_BEGIN; x <= EmuConstants::TRADE_END; x++) - { - TempItem = 0; - ins = GetInv().GetItem(x); - if (ins) - TempItem = ins->GetItem(); - if (TempItem) - { - bool is_arrow = (TempItem->ItemType == ItemTypeArrow) ? true : false; - int freeslotid = GetInv().FindFreeSlot(ins->IsType(ItemClassContainer), true, TempItem->Size, is_arrow); - if (freeslotid == INVALID_INDEX) - { - DropInst(ins); + + // step 1: process bags + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + const ItemInst* inst = m_inv[trade_slot]; + + if (inst && inst->IsType(ItemClassContainer)) { + int16 free_slot = m_inv.FindFreeSlotForTradeItem(inst); + + if (free_slot != INVALID_INDEX) { + PutItemInInventory(free_slot, *inst); + SendItemPacket(free_slot, inst, ItemPacketTrade); } - else - { - PutItemInInventory(freeslotid, *ins); - SendItemPacket(freeslotid, ins, ItemPacketTrade); + else { + DropInst(inst); } - DeleteItemInInventory(x); + + DeleteItemInInventory(trade_slot); + } + } + + // step 2a: process stackables + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + ItemInst* inst = GetInv().GetItem(trade_slot); + + if (inst && inst->IsStackable()) { + while (true) { + // there's no built-in safety check against an infinite loop..but, it should break on one of the conditional checks + int16 free_slot = m_inv.FindFreeSlotForTradeItem(inst); + + if ((free_slot == MainCursor) || (free_slot == INVALID_INDEX)) + break; + + ItemInst* partial_inst = GetInv().GetItem(free_slot); + + if (!partial_inst) + break; + + if (partial_inst->GetID() != inst->GetID()) { + _log(TRADING__ERROR, "Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); + + break; + } + + if ((partial_inst->GetCharges() + inst->GetCharges()) > partial_inst->GetItem()->StackSize) { + int16 new_charges = (partial_inst->GetCharges() + inst->GetCharges()) - partial_inst->GetItem()->StackSize; + + partial_inst->SetCharges(partial_inst->GetItem()->StackSize); + inst->SetCharges(new_charges); + } + else { + partial_inst->SetCharges(partial_inst->GetCharges() + inst->GetCharges()); + inst->SetCharges(0); + } + + PutItemInInventory(free_slot, *partial_inst); + SendItemPacket(free_slot, partial_inst, ItemPacketTrade); + + if (inst->GetCharges() == 0) { + DeleteItemInInventory(trade_slot); + + break; + } + } + } + } + + // step 2b: adjust trade stack bias + // (if any partial stacks exist before the final stack, FindFreeSlotForTradeItem() will return that slot in step 3 and an overwrite will occur) + for (int16 trade_slot = EmuConstants::TRADE_END; trade_slot >= EmuConstants::TRADE_BEGIN; --trade_slot) { + ItemInst* inst = GetInv().GetItem(trade_slot); + + if (inst && inst->IsStackable()) { + for (int16 bias_slot = EmuConstants::TRADE_BEGIN; bias_slot <= EmuConstants::TRADE_END; ++bias_slot) { + if (bias_slot >= trade_slot) + break; + + ItemInst* bias_inst = GetInv().GetItem(bias_slot); + + if (!bias_inst || (bias_inst->GetID() != inst->GetID()) || (bias_inst->GetCharges() >= bias_inst->GetItem()->StackSize)) + continue; + + if ((bias_inst->GetCharges() + inst->GetCharges()) > bias_inst->GetItem()->StackSize) { + int16 new_charges = (bias_inst->GetCharges() + inst->GetCharges()) - bias_inst->GetItem()->StackSize; + + bias_inst->SetCharges(bias_inst->GetItem()->StackSize); + inst->SetCharges(new_charges); + } + else { + bias_inst->SetCharges(bias_inst->GetCharges() + inst->GetCharges()); + inst->SetCharges(0); + } + + if (inst->GetCharges() == 0) { + DeleteItemInInventory(trade_slot); + + break; + } + } + } + } + + // step 3: process everything else + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + const ItemInst* inst = m_inv[trade_slot]; + + if (inst) { + int16 free_slot = m_inv.FindFreeSlotForTradeItem(inst); + + if (free_slot != INVALID_INDEX) { + PutItemInInventory(free_slot, *inst); + SendItemPacket(free_slot, inst, ItemPacketTrade); + } + else { + DropInst(inst); + } + + DeleteItemInInventory(trade_slot); } } } void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) { - if(tradingWith && tradingWith->IsClient()) { Client* other = tradingWith->CastToClient(); if(other) { mlog(TRADING__CLIENT, "Finishing trade with client %s", other->GetName()); - int16 slot_id; - const Item_Struct* item = nullptr; - QSPlayerLogTrade_Struct* qsaudit = nullptr; - bool QSPLT = false; - - // QS code - if(qspack && RuleB(QueryServ, PlayerLogTrades)) { - qsaudit = (QSPlayerLogTrade_Struct*) qspack->pBuffer; - QSPLT = true; - - if(finalizer) { qsaudit->char2_id = this->character_id; } - else { qsaudit->char1_id = this->character_id; } - } - - // Move each trade slot into free inventory slot - for(int16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++){ - const ItemInst* inst = m_inv[i]; - uint16 parent_offset = 0; - - if(inst == nullptr) { continue; } - - mlog(TRADING__CLIENT, "Giving %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, i, other->GetName()); - - /// Log Player Trades through QueryServ if Rule Enabled - if(QSPLT) { - uint16 item_count = qsaudit->char1_count + qsaudit->char2_count; - parent_offset = item_count; - - qsaudit->items[item_count].from_id = this->character_id; - qsaudit->items[item_count].from_slot = i; - qsaudit->items[item_count].to_id = other->CharacterID(); - qsaudit->items[item_count].to_slot = 0; - qsaudit->items[item_count].item_id = inst->GetID(); - qsaudit->items[item_count].charges = inst->GetCharges(); - qsaudit->items[item_count].aug_1 = inst->GetAugmentItemID(1); - qsaudit->items[item_count].aug_2 = inst->GetAugmentItemID(2); - qsaudit->items[item_count].aug_3 = inst->GetAugmentItemID(3); - qsaudit->items[item_count].aug_4 = inst->GetAugmentItemID(4); - qsaudit->items[item_count].aug_5 = inst->GetAugmentItemID(5); - - if(finalizer) { qsaudit->char2_count++; } - else { qsaudit->char1_count++; } - - if(inst->IsType(ItemClassContainer)) { - // Pseudo-Slot ID's are generated based on how the db saves bag items... - for(uint8 j = SUB_BEGIN; j < inst->GetItem()->BagSlots; j++) { - const ItemInst* baginst = inst->GetItem(j); - - if(baginst == nullptr) { continue; } - - int16 k=Inventory::CalcSlotId(i, j); - item_count = qsaudit->char1_count + qsaudit->char2_count; - - qsaudit->items[item_count].from_id = this->character_id; - qsaudit->items[item_count].from_slot = k; - qsaudit->items[item_count].to_id = other->CharacterID(); - qsaudit->items[item_count].to_slot = 0; - qsaudit->items[item_count].item_id = baginst->GetID(); - qsaudit->items[item_count].charges = baginst->GetCharges(); - qsaudit->items[item_count].aug_1 = baginst->GetAugmentItemID(1); - qsaudit->items[item_count].aug_2 = baginst->GetAugmentItemID(2); - qsaudit->items[item_count].aug_3 = baginst->GetAugmentItemID(3); - qsaudit->items[item_count].aug_4 = baginst->GetAugmentItemID(4); - qsaudit->items[item_count].aug_5 = baginst->GetAugmentItemID(5); - - if(finalizer) { qsaudit->char2_count++; } - else { qsaudit->char1_count++; } - } - } - } - - if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) { - bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false; - slot_id = other->GetInv().FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size, is_arrow); - - mlog(TRADING__CLIENT, "Trying to put %s (%d) into slot %d", inst->GetItem()->Name, inst->GetItem()->ID, slot_id); - - if(other->PutItemInInventory(slot_id, *inst, true)) { - mlog(TRADING__CLIENT, "Item %s (%d) successfully transfered, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); - - if(QSPLT) { - qsaudit->items[parent_offset].to_slot = slot_id; - - if(inst->IsType(ItemClassContainer)) { - for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) { - const ItemInst* bag_inst = inst->GetItem(bagslot_idx); - - if(bag_inst == nullptr) { continue; } - int16 to_bagslot_id = Inventory::CalcSlotId(slot_id, bagslot_idx); - - qsaudit->items[++parent_offset].to_slot = to_bagslot_id; - } - } - } - } - else { - PushItemOnCursor(*inst, true); - mlog(TRADING__ERROR, "Unable to give item %d (%d) to %s, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); - - if(QSPLT) { - qsaudit->items[parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = MainCursor; - - if(inst->IsType(ItemClassContainer)) { - for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) { - const ItemInst* bag_inst = inst->GetItem(bagslot_idx); - - if(bag_inst == nullptr) { continue; } - int16 to_bagslot_id = Inventory::CalcSlotId(MainCursor, bagslot_idx); - - qsaudit->items[++parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = to_bagslot_id; - } - } - } - } - - DeleteItemInInventory(i); - } - else { - PushItemOnCursor(*inst, true); - DeleteItemInInventory(i); - - if(QSPLT) { - qsaudit->items[parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = MainCursor; - - if(inst->IsType(ItemClassContainer)) { - for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) { - const ItemInst* bag_inst = inst->GetItem(bagslot_idx); - - if(bag_inst == nullptr) { continue; } - int16 to_bagslot_id = Inventory::CalcSlotId(MainCursor, bagslot_idx); - - qsaudit->items[++parent_offset].to_id = this->character_id; - qsaudit->items[parent_offset].to_slot = to_bagslot_id; - } - } - } - } - } - - // Money - look into how NPC's receive cash this->AddMoneyToPP(other->trade->cp, other->trade->sp, other->trade->gp, other->trade->pp, true); - // This is currently setup to show character offers, not receipts - if(QSPLT) { - if(finalizer) { + // step 0: pre-processing + // QS code + if (qspack && RuleB(QueryServ, PlayerLogTrades)) { + QSPlayerLogTrade_Struct* qsaudit = (QSPlayerLogTrade_Struct*)qspack->pBuffer; + + if (finalizer) { + qsaudit->char2_id = this->character_id; + qsaudit->char2_money.platinum = this->trade->pp; qsaudit->char2_money.gold = this->trade->gp; qsaudit->char2_money.silver = this->trade->sp; qsaudit->char2_money.copper = this->trade->cp; } else { - qsaudit->char1_money.platinum = this->trade->pp; + qsaudit->char1_id = this->character_id; + + qsaudit->char1_money.platinum = this->trade->pp; qsaudit->char1_money.gold = this->trade->gp; qsaudit->char1_money.silver = this->trade->sp; qsaudit->char1_money.copper = this->trade->cp; } + + // qsaudit->items[x].to_slot is disabled until QueryServ:PlayerLogTrades code is updated + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + const ItemInst* inst = m_inv[trade_slot]; + + if (!inst) + continue; + + uint16 item_offset = qsaudit->char1_count + qsaudit->char2_count; + + qsaudit->items[item_offset].from_id = this->character_id; + qsaudit->items[item_offset].from_slot = trade_slot; + qsaudit->items[item_offset].to_id = other->CharacterID(); + qsaudit->items[item_offset].to_slot = 0; // disabled + qsaudit->items[item_offset].item_id = inst->GetID(); + qsaudit->items[item_offset].charges = inst->GetCharges(); + qsaudit->items[item_offset].aug_1 = inst->GetAugmentItemID(1); + qsaudit->items[item_offset].aug_2 = inst->GetAugmentItemID(2); + qsaudit->items[item_offset].aug_3 = inst->GetAugmentItemID(3); + qsaudit->items[item_offset].aug_4 = inst->GetAugmentItemID(4); + qsaudit->items[item_offset].aug_5 = inst->GetAugmentItemID(5); + + if (finalizer) + ++qsaudit->char2_count; + else + ++qsaudit->char1_count; + + if (inst->IsType(ItemClassContainer)) { + // Pseudo-Slot ID's are generated based on how the db saves bag items... + for (uint8 sub_slot = SUB_BEGIN; sub_slot < inst->GetItem()->BagSlots; ++sub_slot) { + const ItemInst* sub_inst = inst->GetItem(sub_slot); + + if (!sub_inst) + continue; + + int16 from_slot = Inventory::CalcSlotId(trade_slot, sub_slot); + item_offset = qsaudit->char1_count + qsaudit->char2_count; + + qsaudit->items[item_offset].from_id = this->character_id; + qsaudit->items[item_offset].from_slot = from_slot; + qsaudit->items[item_offset].to_id = other->CharacterID(); + qsaudit->items[item_offset].to_slot = 0; // disabled + qsaudit->items[item_offset].item_id = sub_inst->GetID(); + qsaudit->items[item_offset].charges = sub_inst->GetCharges(); + qsaudit->items[item_offset].aug_1 = sub_inst->GetAugmentItemID(1); + qsaudit->items[item_offset].aug_2 = sub_inst->GetAugmentItemID(2); + qsaudit->items[item_offset].aug_3 = sub_inst->GetAugmentItemID(3); + qsaudit->items[item_offset].aug_4 = sub_inst->GetAugmentItemID(4); + qsaudit->items[item_offset].aug_5 = sub_inst->GetAugmentItemID(5); + + if (finalizer) + ++qsaudit->char2_count; + else + ++qsaudit->char1_count; + } + } + } + } + + // step 1: process bags + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + const ItemInst* inst = m_inv[trade_slot]; + + if (inst && inst->IsType(ItemClassContainer)) { + mlog(TRADING__CLIENT, "Giving container %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + + // TODO: need to check bag items/augments for no drop..everything for attuned... + if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) { + int16 free_slot = other->GetInv().FindFreeSlotForTradeItem(inst); + + if (free_slot != INVALID_INDEX) { + if (other->PutItemInInventory(free_slot, *inst, true)) { + mlog(TRADING__CLIENT, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + } + else { + mlog(TRADING__ERROR, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); + + PushItemOnCursor(*inst, true); + } + } + else { + mlog(TRADING__ERROR, "%s's inventory is full, returning container %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); + + PushItemOnCursor(*inst, true); + } + } + else { + mlog(TRADING__ERROR, "Container %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); + + PushItemOnCursor(*inst, true); + } + + DeleteItemInInventory(trade_slot); + } + } + + // step 2a: process stackables + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + ItemInst* inst = GetInv().GetItem(trade_slot); + + if (inst && inst->IsStackable()) { + while (true) { + // there's no built-in safety check against an infinite loop..but, it should break on one of the conditional checks + int16 partial_slot = other->GetInv().FindFreeSlotForTradeItem(inst); + + if ((partial_slot == MainCursor) || (partial_slot == INVALID_INDEX)) + break; + + ItemInst* partial_inst = other->GetInv().GetItem(partial_slot); + + if (!partial_inst) + break; + + if (partial_inst->GetID() != inst->GetID()) { + _log(TRADING__ERROR, "Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); + + break; + } + + int16 old_charges = inst->GetCharges(); + int16 partial_charges = partial_inst->GetCharges(); + + if ((partial_inst->GetCharges() + inst->GetCharges()) > partial_inst->GetItem()->StackSize) { + int16 new_charges = (partial_inst->GetCharges() + inst->GetCharges()) - partial_inst->GetItem()->StackSize; + + partial_inst->SetCharges(partial_inst->GetItem()->StackSize); + inst->SetCharges(new_charges); + } + else { + partial_inst->SetCharges(partial_inst->GetCharges() + inst->GetCharges()); + inst->SetCharges(0); + } + + mlog(TRADING__CLIENT, "Transferring partial stack %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + + if (other->PutItemInInventory(partial_slot, *partial_inst, true)) { + mlog(TRADING__CLIENT, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.", + inst->GetItem()->Name, inst->GetItem()->ID, (old_charges - inst->GetCharges())); + } + else { + mlog(TRADING__ERROR, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.", + inst->GetItem()->Name, inst->GetItem()->ID, other->GetName(), (old_charges - inst->GetCharges())); + + inst->SetCharges(old_charges); + partial_inst->SetCharges(partial_charges); + + break; + } + + if (inst->GetCharges() == 0) { + DeleteItemInInventory(trade_slot); + + break; + } + } + } + } + + // step 2b: adjust trade stack bias + // (if any partial stacks exist before the final stack, FindFreeSlotForTradeItem() will return that slot in step 3 and an overwrite will occur) + for (int16 trade_slot = EmuConstants::TRADE_END; trade_slot >= EmuConstants::TRADE_BEGIN; --trade_slot) { + ItemInst* inst = GetInv().GetItem(trade_slot); + + if (inst && inst->IsStackable()) { + for (int16 bias_slot = EmuConstants::TRADE_BEGIN; bias_slot <= EmuConstants::TRADE_END; ++bias_slot) { + if (bias_slot >= trade_slot) + break; + + ItemInst* bias_inst = GetInv().GetItem(bias_slot); + + if (!bias_inst || (bias_inst->GetID() != inst->GetID()) || (bias_inst->GetCharges() >= bias_inst->GetItem()->StackSize)) + continue; + + if ((bias_inst->GetCharges() + inst->GetCharges()) > bias_inst->GetItem()->StackSize) { + int16 new_charges = (bias_inst->GetCharges() + inst->GetCharges()) - bias_inst->GetItem()->StackSize; + + bias_inst->SetCharges(bias_inst->GetItem()->StackSize); + inst->SetCharges(new_charges); + } + else { + bias_inst->SetCharges(bias_inst->GetCharges() + inst->GetCharges()); + inst->SetCharges(0); + } + + if (inst->GetCharges() == 0) { + DeleteItemInInventory(trade_slot); + + break; + } + } + } + } + + // step 3: process everything else + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { + const ItemInst* inst = m_inv[trade_slot]; + + if (inst) { + mlog(TRADING__CLIENT, "Giving item %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + + // TODO: need to check bag items/augments for no drop..everything for attuned... + if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) { + int16 free_slot = other->GetInv().FindFreeSlotForTradeItem(inst); + + if (free_slot != INVALID_INDEX) { + if (other->PutItemInInventory(free_slot, *inst, true)) { + mlog(TRADING__CLIENT, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + } + else { + mlog(TRADING__ERROR, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); + + PushItemOnCursor(*inst, true); + } + } + else { + mlog(TRADING__ERROR, "%s's inventory is full, returning item %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); + + PushItemOnCursor(*inst, true); + } + } + else { + mlog(TRADING__ERROR, "Item %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); + + PushItemOnCursor(*inst, true); + } + + DeleteItemInInventory(trade_slot); + } } //Do not reset the trade here, done by the caller. } } + + // trading with npc doesn't require Inventory::FindFreeSlotForTradeItem() rework else if(tradingWith && tradingWith->IsNPC()) { QSPlayerLogHandin_Struct* qsaudit = nullptr; bool QSPLH = false; From 16d47a2c47b73525b6a2df464ffe0825a5a3e412 Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 22 Aug 2014 22:28:40 -0400 Subject: [PATCH 160/217] Revert accident in 089360a3a5c71df7944a8521a07c2e83e6cda64d. Looks like it was meant for 7-10 instead of 4-10. --- utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql b/utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql index 15ce809af..1ca4981f2 100644 --- a/utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql +++ b/utils/sql/git/required/2014_04_10_No_Target_With_Hotkey.sql @@ -1,5 +1 @@ --- npc_types -ALTER TABLE `npc_types` ADD `ammo_idfile` varchar( 30 ) NOT NULL DEFAULT 'IT10' AFTER `d_meele_texture2`; -ALTER TABLE `npc_types` ADD `ranged_type` tinyint( 4 ) UNSIGNED NOT NULL DEFAULT '7' AFTER `sec_melee_type`; - - +ALTER TABLE `npc_types` ADD `no_target_hotkey` tinyint( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `healscale`; From 85df09b3f2bd6399b564d982afb1041428f1e7e5 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sat, 23 Aug 2014 03:21:36 -0400 Subject: [PATCH 161/217] Implemented NPC special ability 40 'NPC_CHASE_DISTANCE' Param 0: Sets max distance you need to be away from an npc for it to chase you. Param 1: Sets min distance you need to be from npc for it to chase you. Usage: Ideally used with ranged attack npcs / casters who you DO NOT WANT to chase you unless you get too close or too far or out of sight. --- zone/aggro.cpp | 27 ++++++++++++++++++++++++++- zone/common.h | 3 ++- zone/mob.cpp | 2 ++ zone/mob.h | 7 ++++++- zone/special_attacks.cpp | 6 ++++++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index d55dab4fd..109720e47 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -873,7 +873,30 @@ bool Mob::CombatRange(Mob* other) if (size_mod > 10000) size_mod = size_mod / 7; - if (DistNoRoot(*other) <= size_mod) + float _DistNoRoot = DistNoRoot(*other); + + if (GetSpecialAbility(NPC_CHASE_DISTANCE)){ + + float max_dist = static_cast(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 0)); + float min_dist = static_cast(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 1)); + + if (max_dist == 1) + max_dist = 250.0f; //Default it to 250 if you forget to put a value + + max_dist = max_dist * max_dist; + + if (!min_dist) + min_dist = size_mod; //Default to melee range + else + min_dist = min_dist * min_dist; + + if (CheckLastLosState() && (_DistNoRoot >= min_dist && _DistNoRoot <= max_dist)) + SetPseudoRoot(true); + else + SetPseudoRoot(false); + } + + if (_DistNoRoot <= size_mod) { return true; } @@ -887,6 +910,8 @@ bool Mob::CheckLosFN(Mob* other) { if(other) Result = CheckLosFN(other->GetX(), other->GetY(), other->GetZ(), other->GetSize()); + SetLastLosState(Result); + return Result; } diff --git a/zone/common.h b/zone/common.h index 3cc1af1cf..0c1fe28bf 100644 --- a/zone/common.h +++ b/zone/common.h @@ -127,7 +127,8 @@ enum { FLEE_PERCENT = 37, ALLOW_BENEFICIAL = 38, DISABLE_MELEE = 39, - MAX_SPECIAL_ATTACK = 40 + NPC_CHASE_DISTANCE = 40, + MAX_SPECIAL_ATTACK = 41 }; diff --git a/zone/mob.cpp b/zone/mob.cpp index f9cdba950..0d7002253 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -183,6 +183,7 @@ Mob::Mob(const char* in_name, has_MGB = false; has_ProjectIllusion = false; SpellPowerDistanceMod = 0; + last_los_check = false; if(in_aa_title>0) aa_title = in_aa_title; @@ -341,6 +342,7 @@ Mob::Mob(const char* in_name, viral_spells[i] = 0; } pStandingPetOrder = SPO_Follow; + pseudo_rooted = false; see_invis = in_see_invis; see_invis_undead = in_see_invis_undead != 0; diff --git a/zone/mob.h b/zone/mob.h index fe0919f7e..55a57892b 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -464,6 +464,8 @@ public: bool CheckLosFN(float posX, float posY, float posZ, float mobSize); inline void SetChanged() { pLastChange = Timer::GetCurrentTime(); } inline const uint32 LastChange() const { return pLastChange; } + inline void SetLastLosState(bool value) { last_los_check = value; } + inline bool CheckLastLosState() const { return last_los_check; } //Quest void QuestReward(Client *c = nullptr, uint32 silver = 0, uint32 gold = 0, uint32 platinum = 0); @@ -752,7 +754,8 @@ public: inline const bool IsRooted() const { return rooted || permarooted; } inline const bool HasVirus() const { return has_virus; } int GetSnaredAmount(); - + inline const bool IsPseudoRooted() const { return pseudo_rooted; } + inline void SetPseudoRoot(bool prState) { pseudo_rooted = prState; } int GetCurWp() { return cur_wp; } @@ -1119,6 +1122,8 @@ protected: bool has_MGB; bool has_ProjectIllusion; int16 SpellPowerDistanceMod; + bool last_los_check; + bool pseudo_rooted; // Bind wound Timer bindwound_timer; diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index abc94f8f5..a523afa34 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -965,6 +965,9 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Item void NPC::RangedAttack(Mob* other) { + + if (!other) + return; //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())) @@ -973,6 +976,9 @@ void NPC::RangedAttack(Mob* other) return; } + if(!CheckLosFN(other)) + return; + int attacks = GetSpecialAbilityParam(SPECATK_RANGED_ATK, 0); attacks = attacks > 0 ? attacks : 1; for(int i = 0; i < attacks; ++i) { From a568a6f1947d54ded73acfa6113321284d0fc8c4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:10:30 -0700 Subject: [PATCH 162/217] GetAccountStatus converted to QueryDatabase --- ucs/database.cpp | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 4d055e2a4..c71601cdf 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -102,41 +102,34 @@ Database::~Database() { } -void Database::GetAccountStatus(Client *c) { - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `status`, `hideme`, `karma`, `revoked` from `account` where `id`='%i' limit 1", - c->GetAccountID()),errbuf,&result)){ - - _log(UCS__ERROR, "Unable to get account status for character %s, error %s", c->GetName().c_str(), errbuf); - - safe_delete_array(query); +void Database::GetAccountStatus(Client *client) { + std::string query = StringFormat("SELECT `status`, `hideme`, `karma`, `revoked` " + "FROM `account` WHERE `id` = '%i' LIMIT 1", + client->GetAccountID()); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str()); return; } - _log(UCS__TRACE, "GetAccountStatus Query: %s", query); - safe_delete_array(query); - if(mysql_num_rows(result) != 1) + _log(UCS__TRACE, "GetAccountStatus Query: %s", query.c_str()); + + if(results.RowCount() != 1) { _log(UCS__ERROR, "Error in GetAccountStatus"); - mysql_free_result(result); return; } - row = mysql_fetch_row(result); + auto row = results.begin(); - c->SetAccountStatus(atoi(row[0])); - c->SetHideMe(atoi(row[1]) != 0); - c->SetKarma(atoi(row[2])); - c->SetRevoked((atoi(row[3])==1?true:false)); + client->SetAccountStatus(atoi(row[0])); + client->SetHideMe(atoi(row[1]) != 0); + client->SetKarma(atoi(row[2])); + client->SetRevoked((atoi(row[3])==1?true:false)); + + _log(UCS__TRACE, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str()); - _log(UCS__TRACE, "Set account status to %i, hideme to %i and karma to %i for %s", c->GetAccountStatus(), c->GetHideMe(), c->GetKarma(), c->GetName().c_str()); - mysql_free_result(result); } int Database::FindAccount(const char *CharacterName, Client *c) { From 5c640b2d4007ba23bbec76dc0797f394ad5e17dd Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:16:05 -0700 Subject: [PATCH 163/217] FindAccount converted to QueryDatabase --- ucs/database.cpp | 61 ++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index c71601cdf..2ac80bda2 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -132,55 +132,44 @@ void Database::GetAccountStatus(Client *client) { } -int Database::FindAccount(const char *CharacterName, Client *c) { +int Database::FindAccount(const char *characterName, Client *client) { - _log(UCS__TRACE, "FindAccount for character %s", CharacterName); + _log(UCS__TRACE, "FindAccount for character %s", characterName); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - c->ClearCharacters(); - - if (!RunQuery(query,MakeAnyLenString(&query, "select `id`, `account_id`, `level` from `character_` where `name`='%s' limit 1", - CharacterName),errbuf,&result)) - { - _log(UCS__ERROR, "FindAccount query failed: %s", query); - safe_delete_array(query); + client->ClearCharacters(); + std::string query = StringFormat("SELECT `id`, `account_id`, `level` " + "FROM `character_` WHERE `name` = '%s' LIMIT 1", + characterName); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "FindAccount query failed: %s", query.c_str()); return -1; } - safe_delete_array(query); - if (mysql_num_rows(result) != 1) - { + if (results.RowCount() != 1) { _log(UCS__ERROR, "Bad result from query"); - mysql_free_result(result); return -1; } - row = mysql_fetch_row(result); - c->AddCharacter(atoi(row[0]), CharacterName, atoi(row[2])); - int AccountID = atoi(row[1]); + auto row = results.begin(); + client->AddCharacter(atoi(row[0]), characterName, atoi(row[2])); - mysql_free_result(result); - _log(UCS__TRACE, "Account ID for %s is %i", CharacterName, AccountID); + int accountID = atoi(row[1]); - if (!RunQuery(query,MakeAnyLenString(&query, "select `id`, `name`, `level` from `character_` where `account_id`=%i and `name` !='%s'", - AccountID, CharacterName),errbuf,&result)) - { - safe_delete_array(query); - return AccountID; - } - safe_delete_array(query); + _log(UCS__TRACE, "Account ID for %s is %i", characterName, accountID); - for(unsigned int i = 0; i < mysql_num_rows(result); i++) - { - row = mysql_fetch_row(result); - c->AddCharacter(atoi(row[0]), row[1], atoi(row[2])); - } - mysql_free_result(result); - return AccountID; + query = StringFormat("SELECT `id`, `name`, `level` FROM `character_` " + "WHERE `account_id` = %i AND `name` != '%s'", + accountID, characterName); + results = QueryDatabase(query); + if (!results.Success()) + return accountID; + + for (auto row = results.begin(); row != results.end(); ++row) + client->AddCharacter(atoi(row[0]), row[1], atoi(row[2])); + + return accountID; } bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) { From 6b90f883cd7ed30fca2d3c37242c8671d773f449 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:18:47 -0700 Subject: [PATCH 164/217] VerifyMailKey converted to QueryDatabase --- ucs/database.cpp | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 2ac80bda2..6d2606fd7 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -172,45 +172,31 @@ int Database::FindAccount(const char *characterName, Client *client) { return accountID; } -bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) { - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `mailkey` from `character_` where `name`='%s' limit 1", - CharacterName.c_str()),errbuf,&result)){ - - safe_delete_array(query); - - _log(UCS__ERROR, "Error retrieving mailkey from database: %s", errbuf); +bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::string MailKey) { + std::string query = StringFormat("SELECT `mailkey` FROM `character_` WHERE `name`='%s' LIMIT 1", + characterName.c_str()); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - row = mysql_fetch_row(result); + auto row = results.begin(); // The key is the client's IP address (expressed as 8 hex digits) and an 8 hex digit random string generated // by world. // - char CombinedKey[17]; + char combinedKey[17]; if(RuleB(Chat, EnableMailKeyIPVerification) == true) - sprintf(CombinedKey, "%08X%s", IPAddress, MailKey.c_str()); + sprintf(combinedKey, "%08X%s", IPAddress, MailKey.c_str()); else - sprintf(CombinedKey, "%s", MailKey.c_str()); + sprintf(combinedKey, "%s", MailKey.c_str()); - _log(UCS__TRACE, "DB key is [%s], Client key is [%s]", row[0], CombinedKey); - - bool Valid = !strcmp(row[0], CombinedKey); - - mysql_free_result(result); - - return Valid; + _log(UCS__TRACE, "DB key is [%s], Client key is [%s]", row[0], combinedKey); + return !strcmp(row[0], combinedKey); } int Database::FindCharacter(const char *CharacterName) { From de477553206230350d6ca6988c5cc0d7979def13 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:24:28 -0700 Subject: [PATCH 165/217] FindCharacter converted to QueryDatabase --- ucs/database.cpp | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 6d2606fd7..28eb93af5 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -199,46 +199,28 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri return !strcmp(row[0], combinedKey); } -int Database::FindCharacter(const char *CharacterName) { +int Database::FindCharacter(const char *characterName) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - char *SafeCharName = RemoveApostrophes(CharacterName); - - if (!RunQuery(query,MakeAnyLenString(&query, "select `id` from `character_` where `name`='%s' limit 1", - SafeCharName),errbuf,&result)){ - - _log(UCS__ERROR, "FindCharacter failed. %s %s", query, errbuf); - - safe_delete_array(query); - safe_delete_array(SafeCharName); + char *safeCharName = RemoveApostrophes(characterName); + std::string query = StringFormat("SELECT `id` FROM `character_` WHERE `name`='%s' LIMIT 1", safeCharName); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "FindCharacter failed. %s %s", query.c_str(), results.ErrorMessage().c_str()); + safe_delete(safeCharName); + return -1; + } + safe_delete(safeCharName); + if (results.RowCount() != 1) { + _log(UCS__ERROR, "Bad result from FindCharacter query for character %s", characterName); return -1; } - safe_delete_array(query); - safe_delete_array(SafeCharName); + auto row = results.begin(); - if (mysql_num_rows(result) != 1) { - - _log(UCS__ERROR, "Bad result from FindCharacter query for character %s", CharacterName); - - mysql_free_result(result); - - return -1; - } - - row = mysql_fetch_row(result); - - int CharacterID = atoi(row[0]); - - mysql_free_result(result); - - return CharacterID; + int characterID = atoi(row[0]); + return characterID; } bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) { From 19486bac0d2e253aa0b6a90699b7198d0237f51a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:27:18 -0700 Subject: [PATCH 166/217] GetVariable converted to QueryDatabase --- ucs/database.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 28eb93af5..155ee986a 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -225,35 +225,20 @@ int Database::FindCharacter(const char *characterName) { bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `value` from `variables` where `varname`='%s'", varname), errbuf, &result)) { - - _log(UCS__ERROR, "Unable to get message count from database. %s %s", query, errbuf); - - safe_delete_array(query); - + std::string query = StringFormat("SELECT `value` FROM `variables` WHERE `varname` = '%s'", varname); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - if (mysql_num_rows(result) != 1) { - - mysql_free_result(result); - + if (results.RowCount() != 1) return false; - } - row = mysql_fetch_row(result); + auto row = results.begin(); snprintf(varvalue, varvalue_len, "%s", row[0]); - mysql_free_result(result); - return true; } From 76fdfa87c1d60a30f605b067b5f92ad8843915de Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:31:26 -0700 Subject: [PATCH 167/217] LoadChatChannels converted to QueryDatabase --- ucs/database.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 155ee986a..3785992de 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -246,32 +246,21 @@ bool Database::LoadChatChannels() { _log(UCS__INIT, "Loading chat channels from the database."); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `name`,`owner`,`password`, `minstatus` from `chatchannels`"),errbuf,&result)){ - - _log(UCS__ERROR, "Failed to load channels. %s %s", query, errbuf); - safe_delete_array(query); - + const std::string query = "SELECT `name`, `owner`, `password`, `minstatus` FROM `chatchannels`"; + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "Failed to load channels. %s %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); + for (auto row = results.begin();row != results.end(); ++row) { + std::string channelName = row[0]; + std::string channelOwner = row[1]; + std::string channelPassword = row[2]; - while((row = mysql_fetch_row(result))) { - - std::string ChannelName = row[0]; - std::string ChannelOwner = row[1]; - std::string ChannelPassword = row[2]; - - ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3])); + ChannelList->CreateChannel(channelName, channelOwner, channelPassword, true, atoi(row[3])); } - mysql_free_result(result); - return true; } From 7a507e8d1ec5e2cddb6a028081364bce4d650b63 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:34:27 -0700 Subject: [PATCH 168/217] SetChannelPassword converted to QueryDatabase --- ucs/database.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 3785992de..063ab5e35 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -264,21 +264,16 @@ bool Database::LoadChatChannels() { return true; } -void Database::SetChannelPassword(std::string ChannelName, std::string Password) { +void Database::SetChannelPassword(std::string channelName, std::string password) { - _log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", ChannelName.c_str(), Password.c_str()); + _log(UCS__TRACE, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str()); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + std::string query = StringFormat("UPDATE `chatchannels` SET `password` = '%s' WHERE `name` = '%s'", + password.c_str(), channelName.c_str()); + auto results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__ERROR, "Error updating password in database: %s, %s", query.c_str(), results.ErrorMessage().c_str()); - if(!RunQuery(query, MakeAnyLenString(&query, "UPDATE `chatchannels` set `password`='%s' where `name`='%s'", Password.c_str(), - ChannelName.c_str()), errbuf)) { - - _log(UCS__ERROR, "Error updating password in database: %s, %s", query, errbuf); - - } - - safe_delete_array(query); } void Database::SetChannelOwner(std::string ChannelName, std::string Owner) { From 6e7136ea186e41666df7a2104b5460ac2ef32aec Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:38:57 -0700 Subject: [PATCH 169/217] SetChannelOwner converted to QueryDatabase --- ucs/database.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 063ab5e35..22f1431ae 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -276,21 +276,16 @@ void Database::SetChannelPassword(std::string channelName, std::string password) } -void Database::SetChannelOwner(std::string ChannelName, std::string Owner) { +void Database::SetChannelOwner(std::string channelName, std::string owner) { - _log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", ChannelName.c_str(), Owner.c_str()); + _log(UCS__TRACE, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str()); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + std::string query = StringFormat("UPDATE `chatchannels` SET `owner` = '%s' WHERE `name` = '%s'", + owner.c_str(), channelName.c_str()); + auto results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__ERROR, "Error updating Owner in database: %s, %s", query.c_str(), results.ErrorMessage().c_str()); - if(!RunQuery(query, MakeAnyLenString(&query, "UPDATE `chatchannels` set `owner`='%s' where `name`='%s'", Owner.c_str(), - ChannelName.c_str()), errbuf)) { - - _log(UCS__ERROR, "Error updating Owner in database: %s, %s", query, errbuf); - - } - - safe_delete_array(query); } void Database::SendHeaders(Client *c) { From 2bdc44dfb2fbe335a2e4d7aed904152ed4b59f03 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:47:59 -0700 Subject: [PATCH 170/217] SendHeaders converted to QueryDatabase --- ucs/database.cpp | 129 ++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 73 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 22f1431ae..b05810f0e 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -288,110 +288,93 @@ void Database::SetChannelOwner(std::string channelName, std::string owner) { } -void Database::SendHeaders(Client *c) { +void Database::SendHeaders(Client *client) { - int UnknownField2 = 25015275; - int UnknownField3 = 1; + int unknownField2 = 25015275; + int unknownField3 = 1; + int characterID = FindCharacter(client->MailBoxName().c_str()); - int CharacterID = FindCharacter(c->MailBoxName().c_str()); - _log(UCS__TRACE, "Sendheaders for %s, CharID is %i", c->MailBoxName().c_str(), CharacterID); - if(CharacterID <= 0) + _log(UCS__TRACE, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID); + + if(characterID <= 0) return; + std::string query = StringFormat("SELECT `msgid`,`timestamp`, `from`, `subject`, `status` " + "FROM `mail` WHERE `charid`=%i", characterID); + auto results = QueryDatabase(query); + if (!results.Success()) + return; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + char buffer[100]; - if (!RunQuery(query,MakeAnyLenString(&query, "select `msgid`,`timestamp`,`from`,`subject`, `status` from `mail` " - "where `charid`=%i", CharacterID),errbuf,&result)){ + int headerCountPacketLength = 0; - safe_delete_array(query); + sprintf(buffer, "%i", client->GetMailBoxNumber()); + headerCountPacketLength += (strlen(buffer) + 1); - return ; - } + sprintf(buffer, "%i", unknownField2); + headerCountPacketLength += (strlen(buffer) + 1); - safe_delete_array(query); + sprintf(buffer, "%i", unknownField3); + headerCountPacketLength += (strlen(buffer) + 1); - char Buf[100]; + sprintf(buffer, "%i", results.RowCount()); + headerCountPacketLength += (strlen(buffer) + 1); - uint32 NumRows = mysql_num_rows(result); + EQApplicationPacket *outapp = new EQApplicationPacket(OP_MailHeaderCount, headerCountPacketLength); - int HeaderCountPacketLength = 0; + char *packetBuffer = (char *)outapp->pBuffer; - sprintf(Buf, "%i", c->GetMailBoxNumber()); - HeaderCountPacketLength += (strlen(Buf) + 1); - - sprintf(Buf, "%i", UnknownField2); - HeaderCountPacketLength += (strlen(Buf) + 1); - - sprintf(Buf, "%i", UnknownField3); - HeaderCountPacketLength += (strlen(Buf) + 1); - - sprintf(Buf, "%i", NumRows); - HeaderCountPacketLength += (strlen(Buf) + 1); - - EQApplicationPacket *outapp = new EQApplicationPacket(OP_MailHeaderCount, HeaderCountPacketLength); - - char *PacketBuffer = (char *)outapp->pBuffer; - - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, c->GetMailBoxNumber()); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, UnknownField2); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, UnknownField3); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, NumRows); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, client->GetMailBoxNumber()); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, unknownField2); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, unknownField3); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, results.RowCount()); _pkt(UCS__PACKETS, outapp); - c->QueuePacket(outapp); + client->QueuePacket(outapp); safe_delete(outapp); - int RowNum = 0; + int rowIndex = 0; + for(auto row = results.begin(); row != results.end(); ++row, ++rowIndex) { + int headerPacketLength = 0; - while((row = mysql_fetch_row(result))) { + sprintf(buffer, "%i", client->GetMailBoxNumber()); + headerPacketLength += strlen(buffer) + 1; + sprintf(buffer, "%i", unknownField2); + headerPacketLength += strlen(buffer) + 1; + sprintf(buffer, "%i", rowIndex); + headerPacketLength += strlen(buffer) + 1; + headerPacketLength += strlen(row[0]) + 1; + headerPacketLength += strlen(row[1]) + 1; + headerPacketLength += strlen(row[4]) + 1; + headerPacketLength += GetMailPrefix().length() + strlen(row[2]) + 1; + headerPacketLength += strlen(row[3]) + 1; - int HeaderPacketLength = 0; + outapp = new EQApplicationPacket(OP_MailHeader, headerPacketLength); - sprintf(Buf, "%i", c->GetMailBoxNumber()); - HeaderPacketLength = HeaderPacketLength + strlen(Buf) + 1; - sprintf(Buf, "%i", UnknownField2); - HeaderPacketLength = HeaderPacketLength + strlen(Buf) + 1; - sprintf(Buf, "%i", RowNum); - HeaderPacketLength = HeaderPacketLength + strlen(Buf) + 1; + packetBuffer = (char *)outapp->pBuffer; - HeaderPacketLength = HeaderPacketLength + strlen(row[0]) + 1; - HeaderPacketLength = HeaderPacketLength + strlen(row[1]) + 1; - HeaderPacketLength = HeaderPacketLength + strlen(row[4]) + 1; - HeaderPacketLength = HeaderPacketLength + GetMailPrefix().length() + strlen(row[2]) + 1; - HeaderPacketLength = HeaderPacketLength + strlen(row[3]) + 1; - - outapp = new EQApplicationPacket(OP_MailHeader, HeaderPacketLength); - - PacketBuffer = (char *)outapp->pBuffer; - - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, c->GetMailBoxNumber()); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, UnknownField2); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, RowNum); - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[0]); - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[1]); - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[4]); - VARSTRUCT_ENCODE_STRING(PacketBuffer, GetMailPrefix().c_str()); PacketBuffer--; - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[2]); - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[3]); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, client->GetMailBoxNumber()); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, unknownField2); + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, rowIndex); + VARSTRUCT_ENCODE_STRING(packetBuffer, row[0]); + VARSTRUCT_ENCODE_STRING(packetBuffer, row[1]); + VARSTRUCT_ENCODE_STRING(packetBuffer, row[4]); + VARSTRUCT_ENCODE_STRING(packetBuffer, GetMailPrefix().c_str()); + packetBuffer--; + VARSTRUCT_ENCODE_STRING(packetBuffer, row[2]); + VARSTRUCT_ENCODE_STRING(packetBuffer, row[3]); _pkt(UCS__PACKETS, outapp); - c->QueuePacket(outapp); + client->QueuePacket(outapp); safe_delete(outapp); - - RowNum++; } - mysql_free_result(result); - } void Database::SendBody(Client *c, int MessageNumber) { From aaf5f8c9307cd99199309ed7d51bf080a939b2c7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 21:51:40 -0700 Subject: [PATCH 171/217] SendBody converted to QueryDatabase --- ucs/database.cpp | 69 ++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index b05810f0e..b704a271b 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -377,65 +377,52 @@ void Database::SendHeaders(Client *client) { } -void Database::SendBody(Client *c, int MessageNumber) { +void Database::SendBody(Client *client, int messageNumber) { - int CharacterID = FindCharacter(c->MailBoxName().c_str()); + int characterID = FindCharacter(client->MailBoxName().c_str()); - _log(UCS__TRACE, "SendBody: MsgID %i, to %s, CharID is %i", MessageNumber, c->MailBoxName().c_str(), CharacterID); + _log(UCS__TRACE, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID); - if(CharacterID <= 0) + if(characterID <= 0) return; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `msgid`, `body`, `to` from `mail` " - "where `charid`=%i and `msgid`=%i", CharacterID, MessageNumber), errbuf, &result)){ - safe_delete_array(query); - - return ; - } - - safe_delete_array(query); - - if (mysql_num_rows(result) != 1) { - - mysql_free_result(result); - + std::string query = StringFormat("SELECT `msgid`, `body`, `to` FROM `mail` " + "WHERE `charid`=%i AND `msgid`=%i", characterID, messageNumber); + auto results = QueryDatabase(query); + if (!results.Success()) return; - } - row = mysql_fetch_row(result); - _log(UCS__TRACE, "Message: %i body (%i bytes)", MessageNumber, strlen(row[1])); + if (results.RowCount() != 1) + return; - int PacketLength = 12 + strlen(row[0]) + strlen(row[1]) + strlen(row[2]); + auto row = results.begin(); - EQApplicationPacket *outapp = new EQApplicationPacket(OP_MailSendBody,PacketLength); + _log(UCS__TRACE, "Message: %i body (%i bytes)", messageNumber, strlen(row[1])); - char *PacketBuffer = (char *)outapp->pBuffer; + int packetLength = 12 + strlen(row[0]) + strlen(row[1]) + strlen(row[2]); - VARSTRUCT_ENCODE_INTSTRING(PacketBuffer, c->GetMailBoxNumber()); - VARSTRUCT_ENCODE_STRING(PacketBuffer,row[0]); - VARSTRUCT_ENCODE_STRING(PacketBuffer,row[1]); - VARSTRUCT_ENCODE_STRING(PacketBuffer,"1"); - VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, 0); - VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, 0x0a); - VARSTRUCT_ENCODE_STRING(PacketBuffer, "TO:"); PacketBuffer--; - VARSTRUCT_ENCODE_STRING(PacketBuffer, row[2]); PacketBuffer--; // Overwrite the null terminator - VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, 0x0a); + EQApplicationPacket *outapp = new EQApplicationPacket(OP_MailSendBody,packetLength); - mysql_free_result(result); + char *packetBuffer = (char *)outapp->pBuffer; + + VARSTRUCT_ENCODE_INTSTRING(packetBuffer, client->GetMailBoxNumber()); + VARSTRUCT_ENCODE_STRING(packetBuffer,row[0]); + VARSTRUCT_ENCODE_STRING(packetBuffer,row[1]); + VARSTRUCT_ENCODE_STRING(packetBuffer,"1"); + VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0); + VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0x0a); + VARSTRUCT_ENCODE_STRING(packetBuffer, "TO:"); + packetBuffer--; + VARSTRUCT_ENCODE_STRING(packetBuffer, row[2]); + packetBuffer--; // Overwrite the null terminator + VARSTRUCT_ENCODE_TYPE(uint8, packetBuffer, 0x0a); _pkt(UCS__PACKETS, outapp); - c->QueuePacket(outapp); + client->QueuePacket(outapp); safe_delete(outapp); - - } bool Database::SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString) { From 7f89191ffca9f53801a877d561cbb49f1b8eaa0c Mon Sep 17 00:00:00 2001 From: akkadius Date: Sat, 23 Aug 2014 23:59:20 -0500 Subject: [PATCH 172/217] Changed zone process window title format, example: 'crushbone :: clients: 6 inst_id: 1 inst_ver: 0 :: port: 7015' Most of the following changes are QueryServ related, fully implemented its original functionality to be able to offload intensive or metric based logging to a remote server process that could exist on another server entirely Implemented Player Event Logging Types (Go to table `qs_player_events`): 1 = Player_Log_Quest, 2 = Player_Log_Zoning, 3 = Player_Log_Deaths, 4 = Player_Log_Connect_State, 5 = Player_Log_Levels, 6 = Player_Log_Keyring_Addition, 7 = Player_Log_QGlobal_Update, 8 = Player_Log_Task_Updates, 9 = Player_Log_AA_Purchases, 10 = Player_Log_Trade_Skill_Events, 11 = Player_Log_Issued_Commands, 12 = Player_Log_Money_Transactions, 13 = Player_Log_Alternate_Currency_Transactions, - All QueryServ logging will be implemented with a front end in EoC 2.0 very soon Changed all QS Error related logging to 'QUERYSERV__ERROR' (Natedog) (Crash Fix) Legacy MySQL bug revert for loading AA's COALESCE( from COALESCE ( Implemented Perl Quest objects (LUA still needed to be exported): - quest::qs_send_query("MySQL query") - Will send a raw query to the QueryServ process, useful for custom logging - quest::qs_player_event(char_id, event_desc); - Will process a quest type event to table `qs_player_events` Added MySQL Tables: - `qs_player_aa_rate_hourly` - `qs_player_events` - Source table structures from: - utils\sql\git\queryserv\required\08_23_2014_player_events_and_player_aa_rate_hourly To get the complete QueryServ schema, source from here: - utils\sql\git\queryserv\required\Complete_QueryServ_Table_Structures.sql Added rules for each logging type, source rules here with them enabled by default: - utils\sql\git\queryserv\required\Complete_QueryServ_Rules_Enabled.sql Spawn related logging cleanup General code cleanup Added queryserv.cpp and queryserv.h with QueryServ class --- changelog.txt | 38 ++ common/logtypes.h | 17 +- common/ruletypes.h | 18 +- common/servertalk.h | 10 +- queryserv/database.cpp | 124 ++--- queryserv/database.h | 2 +- queryserv/lfguild.cpp | 2 +- queryserv/queryserv.cpp | 68 ++- queryserv/worldserver.cpp | 103 ++-- ...layer_events_and_player_aa_rate_hourly.sql | 23 + .../Complete_QueryServ_Rules_Disabled.sql | 45 ++ .../Complete_QueryServ_Rules_Enabled.sql | 45 ++ .../Complete_QueryServ_Table_Structures.sql | 247 ++++++++++ world/zoneserver.cpp | 4 +- zone/CMakeLists.txt | 5 +- zone/aa.cpp | 39 +- zone/attack.cpp | 62 +-- zone/client.cpp | 51 +- zone/client.h | 2 +- zone/client_packet.cpp | 457 +++++++++--------- zone/client_process.cpp | 30 +- zone/command.cpp | 9 +- zone/embparser_api.cpp | 34 ++ zone/entity.cpp | 14 + zone/entity.h | 1 + zone/exp.cpp | 123 ++--- zone/groups.cpp | 9 +- zone/hate_list.cpp | 2 +- zone/lua_client.cpp | 2 +- zone/net.cpp | 8 +- zone/perl_client.cpp | 6 +- zone/petitions.cpp | 2 - zone/queryserv.cpp | 48 ++ zone/queryserv.h | 35 ++ zone/questmgr.cpp | 112 +++-- zone/spawngroup.cpp | 23 +- zone/special_attacks.cpp | 202 +++----- zone/tasks.cpp | 25 +- zone/tradeskills.cpp | 30 +- zone/zoning.cpp | 18 +- 40 files changed, 1316 insertions(+), 779 deletions(-) create mode 100644 utils/sql/git/queryserv/required/08_23_2014_player_events_and_player_aa_rate_hourly.sql create mode 100644 utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Disabled.sql create mode 100644 utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Enabled.sql create mode 100644 utils/sql/git/queryserv/required/Complete_QueryServ_Table_Structures.sql create mode 100644 zone/queryserv.cpp create mode 100644 zone/queryserv.h diff --git a/changelog.txt b/changelog.txt index bf2ea97f0..3836b437e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,43 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/23/2014 == +Akkadius: Changed zone process window title format, example: 'crushbone :: clients: 6 inst_id: 1 inst_ver: 0 :: port: 7015' +Akkadius: Most of the following changes are QueryServ related, fully implemented its original functionality to be able to offload + intensive or metric based logging to a remote server process that could exist on another server entirely +Akkadius: Implemented Player Event Logging Types (Go to table `qs_player_events`): + 1 = Player_Log_Quest, + 2 = Player_Log_Zoning, + 3 = Player_Log_Deaths, + 4 = Player_Log_Connect_State, + 5 = Player_Log_Levels, + 6 = Player_Log_Keyring_Addition, + 7 = Player_Log_QGlobal_Update, + 8 = Player_Log_Task_Updates, + 9 = Player_Log_AA_Purchases, + 10 = Player_Log_Trade_Skill_Events, + 11 = Player_Log_Issued_Commands, + 12 = Player_Log_Money_Transactions, + 13 = Player_Log_Alternate_Currency_Transactions, + - All QueryServ logging will be implemented with a front end in EoC 2.0 very soon + - Architecture page: http://wiki.eqemulator.org/p?QueryServ_Architecture +Akkadius: Changed all QS Error related logging to 'QUERYSERV__ERROR' +Akkadius: (Natedog) (Crash Fix) Legacy MySQL bug revert for loading AA's COALESCE( from COALESCE ( +Akkadius: Implemented Perl Quest objects (LUA still needed to be exported): + - quest::qs_send_query("MySQL query") - Will send a raw query to the QueryServ process, useful for custom logging + - quest::qs_player_event(char_id, event_desc); - Will process a quest type event to table `qs_player_events` +Akkadius: Added MySQL Tables + - `qs_player_aa_rate_hourly` + - `qs_player_events` + - Source table structures from: + - utils\sql\git\queryserv\required\08_23_2014_player_events_and_player_aa_rate_hourly + To get the complete QueryServ schema, source from here: + - utils\sql\git\queryserv\required\Complete_QueryServ_Table_Structures.sql +Akkadius: Added rules for each logging type, source rules here with them enabled by default: + - utils\sql\git\queryserv\required\Complete_QueryServ_Rules_Enabled.sql +Akkadius: Spawn related logging cleanup +Akkadius: General code cleanup +Akkadius: More to come for QueryServ + == 08/20/2014 == Uleat: Rework of Trade::AddEntity() - function used to move items into the trade window. Now accepts argument for 'stack_size' and updates client properly. Note: I tested trade with Titanium:{SoF,SoD,UF,RoF} in both directions and no client generated an OP_MoveItem event for attempting to place a stackable diff --git a/common/logtypes.h b/common/logtypes.h index 1776c9518..8ebd48f9a 100644 --- a/common/logtypes.h +++ b/common/logtypes.h @@ -60,17 +60,17 @@ LOG_TYPE( UCS, PACKETS, DISABLED) LOG_CATEGORY( QUERYSERV ) LOG_TYPE( QUERYSERV, INIT, ENABLED ) -LOG_TYPE( QUERYSERV, ERROR, ENABLED ) +LOG_TYPE( QUERYSERV, ERROR, ENABLED ) LOG_TYPE( QUERYSERV, CLIENT, DISABLED ) LOG_TYPE( QUERYSERV, TRACE, DISABLED ) LOG_TYPE( QUERYSERV, PACKETS, DISABLED) -LOG_CATEGORY(SOCKET_SERVER) -LOG_TYPE(SOCKET_SERVER, INIT, ENABLED) -LOG_TYPE(SOCKET_SERVER, ERROR, ENABLED) -LOG_TYPE(SOCKET_SERVER, CLIENT, DISABLED) -LOG_TYPE(SOCKET_SERVER, TRACE, DISABLED) -LOG_TYPE(SOCKET_SERVER, PACKETS, DISABLED) +LOG_CATEGORY( SOCKET_SERVER) +LOG_TYPE( SOCKET_SERVER, INIT, ENABLED) +LOG_TYPE( SOCKET_SERVER, ERROR, ENABLED) +LOG_TYPE( SOCKET_SERVER, CLIENT, DISABLED) +LOG_TYPE( SOCKET_SERVER, TRACE, DISABLED) +LOG_TYPE( SOCKET_SERVER, PACKETS, DISABLED) LOG_CATEGORY( SPAWNS ) LOG_TYPE( SPAWNS, MAIN, DISABLED ) @@ -108,6 +108,7 @@ LOG_CATEGORY( FACTION ) LOG_CATEGORY( ZONE ) LOG_TYPE( ZONE, GROUND_SPAWNS, DISABLED ) +LOG_TYPE( ZONE, SPAWNS, ENABLED) LOG_TYPE( ZONE, INIT, ENABLED ) LOG_TYPE( ZONE, INIT_ERR, ENABLED ) LOG_TYPE( ZONE, WORLD, ENABLED ) @@ -116,7 +117,7 @@ LOG_TYPE( ZONE, WORLD_TRACE, DISABLED ) LOG_CATEGORY( TASKS ) LOG_TYPE( TASKS, GLOBALLOAD, DISABLED ) -LOG_TYPE( TASKS, CLIENTLOAD, DISABLED ) +LOG_TYPE( TASKS, CLIENTLOAD, DISABLED ) LOG_TYPE( TASKS, UPDATE, DISABLED ) LOG_TYPE( TASKS, CLIENTSAVE, DISABLED ) LOG_TYPE( TASKS, PACKETS, DISABLED ) diff --git a/common/ruletypes.h b/common/ruletypes.h index 91ade257b..73d538f8a 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -558,14 +558,28 @@ RULE_INT ( Console, SessionTimeOut, 600000 ) // Amount of time in ms for the con RULE_CATEGORY_END() RULE_CATEGORY( QueryServ ) -RULE_BOOL( QueryServ, PlayerChatLogging, false) // Logs Player Chat +RULE_BOOL( QueryServ, PlayerLogChat, false) // Logs Player Chat RULE_BOOL( QueryServ, PlayerLogTrades, false) // Logs Player Trades RULE_BOOL( QueryServ, PlayerLogHandins, false) // Logs Player Handins RULE_BOOL( QueryServ, PlayerLogNPCKills, false) // Logs Player NPC Kills RULE_BOOL( QueryServ, PlayerLogDeletes, false) // Logs Player Deletes RULE_BOOL( QueryServ, PlayerLogMoves, false) // Logs Player Moves -RULE_BOOL( QueryServ, MerchantLogTransactions, false) // Logs Merchant Transactions +RULE_BOOL( QueryServ, PlayerLogMerchantTransactions, false) // Logs Merchant Transactions RULE_BOOL( QueryServ, PlayerLogPCCoordinates, false) // Logs Player Coordinates with certain events +RULE_BOOL( QueryServ, PlayerLogDropItem, false) // Logs Player Drop Item +RULE_BOOL( QueryServ, PlayerLogZone, false) // Logs Player Zone Events +RULE_BOOL( QueryServ, PlayerLogDeaths, false) // Logs Player Deaths +RULE_BOOL( QueryServ, PlayerLogConnectDisconnect, false) // Logs Player Connect Disconnect State +RULE_BOOL( QueryServ, PlayerLogLevels, false) // Logs Player Leveling/Deleveling +RULE_BOOL( QueryServ, PlayerLogAARate, false) // Logs Player AA Experience Rates +RULE_BOOL( QueryServ, PlayerLogQGlobalUpdate, false) // Logs Player QGlobal Updates +RULE_BOOL( QueryServ, PlayerLogTaskUpdates, false) // Logs Player Task Updates +RULE_BOOL( QueryServ, PlayerLogKeyringAddition, false) // Log PLayer Keyring additions +RULE_BOOL( QueryServ, PlayerLogAAPurchases, false) // Log Player AA Purchases +RULE_BOOL( QueryServ, PlayerLogTradeSkillEvents, false) // Log Player Tradeskill Transactions +RULE_BOOL( QueryServ, PlayerLogIssuedCommandes, false ) // Log Player Issued Commands +RULE_BOOL( QueryServ, PlayerLogMoneyTransactions, false) // Log Player Money Transaction/Splits +RULE_BOOL( QueryServ, PlayerLogAlternateCurrencyTransactions, false) // Log Ploayer Alternate Currency Transactions RULE_CATEGORY_END() RULE_CATEGORY( Inventory ) diff --git a/common/servertalk.h b/common/servertalk.h index d5d7c3604..6d1a83a84 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -184,9 +184,11 @@ #define ServerOP_QSPlayerLogNPCKills 0x4012 #define ServerOP_QSPlayerLogDeletes 0x4013 #define ServerOP_QSPlayerLogMoves 0x4014 -#define ServerOP_QSMerchantLogTransactions 0x4015 +#define ServerOP_QSPlayerLogMerchantTransactions 0x4015 +#define ServerOP_QSSendQuery 0x4016 -enum { QSG_LFGuild = 0 }; +/* Query Serv Generic Packet Flag/Type Enumeration */ +enum { QSG_LFGuild = 0 }; enum { QSG_LFGuild_PlayerMatches = 0, QSG_LFGuild_UpdatePlayerInfo, QSG_LFGuild_RequestPlayerInfo, QSG_LFGuild_UpdateGuildInfo, QSG_LFGuild_GuildMatches, QSG_LFGuild_RequestGuildInfo }; @@ -1219,6 +1221,10 @@ struct QSMerchantLogTransaction_Struct { QSTransactionItems_Struct items[0]; }; +struct QSGeneralQuery_Struct { + char QueryString[0]; +}; + struct CZMessagePlayer_Struct { uint32 Type; char CharName[64]; diff --git a/queryserv/database.cpp b/queryserv/database.cpp index d03957140..4b94f215b 100644 --- a/queryserv/database.cpp +++ b/queryserv/database.cpp @@ -23,12 +23,13 @@ #include #include #include -#include +#include #include #include #include #include #include +#include // Disgrace: for windows compile #ifdef _WINDOWS @@ -95,42 +96,7 @@ Close the connection to the database Database::~Database() { } - -bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) { - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (!RunQuery(query,MakeAnyLenString(&query, "select `value` from `variables` where `varname`='%s'", varname), errbuf, &result)) { - - _log(UCS__ERROR, "Unable to get message count from database. %s %s", query, errbuf); - - safe_delete_array(query); - - return false; - } - - safe_delete_array(query); - - if (mysql_num_rows(result) != 1) { - - mysql_free_result(result); - - return false; - } - - row = mysql_fetch_row(result); - - snprintf(varvalue, varvalue_len, "%s", row[0]); - - mysql_free_result(result); - - return true; -} - - + void Database::AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; @@ -143,8 +109,8 @@ void Database::AddSpeech(const char* from, const char* to, const char* message, DoEscapeString(S3, message, strlen(message)); if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_speech` SET `from`='%s', `to`='%s', `message`='%s', `minstatus`='%i', `guilddbid`='%i', `type`='%i'", S1, S2, S3, minstatus, guilddbid, type), errbuf, 0, 0)) { - _log(NET__WORLD, "Failed Speech Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Speech Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } safe_delete_array(query); @@ -164,8 +130,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) { QS->char1_id, QS->char1_money.platinum, QS->char1_money.gold, QS->char1_money.silver, QS->char1_money.copper, QS->char1_count, QS->char2_id, QS->char2_money.platinum, QS->char2_money.gold, QS->char2_money.silver, QS->char2_money.copper, QS->char2_count), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed Trade Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Trade Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } if(Items > 0) { @@ -176,15 +142,14 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) { lastid, QS->items[i].from_id, QS->items[i].from_slot, QS->items[i].to_id, QS->items[i].to_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed Trade Log Record Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Trade Log Record Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } } -void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { - +void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; uint32 lastid = 0; @@ -194,8 +159,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { QS->quest_id, QS->char_id, QS->char_money.platinum, QS->char_money.gold, QS->char_money.silver, QS->char_money.copper, QS->char_count, QS->npc_id, QS->npc_money.platinum, QS->npc_money.gold, QS->npc_money.silver, QS->npc_money.copper, QS->npc_count), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed Handin Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Handin Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } if(Items > 0) { @@ -206,8 +171,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { lastid, QS->items[i].action_type, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed Handin Log Record Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Handin Log Record Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } @@ -218,15 +183,15 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){ char* query = 0; uint32 lastid = 0; if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_npc_kill_record` SET `npc_id`='%i', `type`='%i', `zone_id`='%i', `time`=NOW()", QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed NPC Kill Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed NPC Kill Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } if(Members > 0){ for (int i = 0; i < Members; i++) { if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_npc_kill_record_entries` SET `event_id`='%i', `char_id`='%i'", lastid, QS->Chars[i].char_id, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed NPC Kill Log Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed NPC Kill Log Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } @@ -241,8 +206,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) { "`char_id`='%i', `stack_size`='%i', `char_items`='%i'", QS->char_id, QS->stack_size, QS->char_count, QS->char_count), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed Delete Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Delete Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } if(Items > 0) { @@ -253,15 +218,15 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) { lastid, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed Delete Log Record Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Delete Log Record Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } } -void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) { - +void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) { + /* These are item moves */ char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; uint32 lastid = 0; @@ -269,10 +234,9 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) { "`char_id`='%i', `from_slot`='%i', `to_slot`='%i', `stack_size`='%i', `char_items`='%i', `postaction`='%i'", QS->char_id, QS->from_slot, QS->to_slot, QS->stack_size, QS->char_count, QS->postaction), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed Move Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); - } - + _log(QUERYSERV__ERROR, "Failed Move Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); + } if(Items > 0) { for(int i = 0; i < Items; i++) { if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_move_record_entries` SET `event_id`='%i', " @@ -281,16 +245,15 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) { QS->items[i].from_slot, QS->items[i].to_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed Move Log Record Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Move Log Record Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } } void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items) { - // Merchant transactions are from the perspective of the merchant, not the player -U - + /* Merchant transactions are from the perspective of the merchant, not the player -U */ char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; uint32 lastid = 0; @@ -300,8 +263,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3 QS->zone_id, QS->merchant_id, QS->merchant_money.platinum, QS->merchant_money.gold, QS->merchant_money.silver, QS->merchant_money.copper, QS->merchant_count, QS->char_id, QS->char_money.platinum, QS->char_money.gold, QS->char_money.silver, QS->char_money.copper, QS->char_count), errbuf, 0, 0, &lastid)) { - _log(NET__WORLD, "Failed Transaction Log Record Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Transaction Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } if(Items > 0) { @@ -312,10 +275,29 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3 lastid, QS->items[i].char_slot, QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5, errbuf, 0, 0))) { - _log(NET__WORLD, "Failed Transaction Log Record Entry Insert: %s", errbuf); - _log(NET__WORLD, "%s", query); + _log(QUERYSERV__ERROR, "Failed Transaction Log Record Entry Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); } } } + safe_delete_array(query); } +void Database::GeneralQueryReceive(ServerPacket *pack) { + /* + These are general queries passed from anywhere in zone instead of packing structures and breaking them down again and again + */ + char *Query = nullptr; + Query = new char[pack->ReadUInt32() + 1]; + pack->ReadString(Query); + char errbuf[MYSQL_ERRMSG_SIZE]; + char* query = 0; + uint32 lastid = 0; + if (!RunQuery(query, MakeAnyLenString(&query, Query), errbuf, 0, 0, &lastid)) { + _log(QUERYSERV__ERROR, "Failed Delete Log Record Insert: %s", errbuf); + _log(QUERYSERV__ERROR, "%s", query); + } + safe_delete_array(query); + safe_delete(pack); + safe_delete(Query); +} diff --git a/queryserv/database.h b/queryserv/database.h index 61664f90d..ac002a0b5 100644 --- a/queryserv/database.h +++ b/queryserv/database.h @@ -42,7 +42,6 @@ public: bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port); ~Database(); - bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); void AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type); void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items); void LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items); @@ -50,6 +49,7 @@ public: void LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items); void LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items); void LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items); + void GeneralQueryReceive(ServerPacket *pack); protected: void HandleMysqlError(uint32 errnum); private: diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index 9fc4d0b62..c135d4991 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -22,7 +22,7 @@ PlayerLookingForGuild::PlayerLookingForGuild(char *Name, char *Comments, uint32 GuildLookingForPlayers::GuildLookingForPlayers(char *Name, char *Comments, uint32 FromLevel, uint32 ToLevel, uint32 Classes, uint32 AACount, uint32 Timezone, uint32 TimePosted) { - this->Name = Name; + this->Name = Name; this->Comments = Comments; this->FromLevel = FromLevel; this->ToLevel = ToLevel; diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index 3827ceea1..22ddb87ee 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -33,56 +33,47 @@ volatile bool RunLoops = true; -uint32 MailMessagesSent = 0; -uint32 ChatMessagesSent = 0; - TimeoutManager timeout_manager; - Database database; LFGuildManager lfguildmanager; std::string WorldShortName; - const queryservconfig *Config; - WorldServer *worldserver = 0; - -void CatchSignal(int sig_num) { - - RunLoops = false; - +void CatchSignal(int sig_num) { + RunLoops = false; if(worldserver) worldserver->Disconnect(); } int main() { RegisterExecutablePlatform(ExePlatformQueryServ); - set_exception_handler(); - - Timer LFGuildExpireTimer(60000); - + set_exception_handler(); + Timer LFGuildExpireTimer(60000); Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect + /* Load XML from eqemu_config.xml + + 127.0.0.1 + 3306 + user + password + dbname + + */ + _log(QUERYSERV__INIT, "Starting EQEmu QueryServ."); - if (!queryservconfig::LoadConfig()) { - _log(QUERYSERV__INIT, "Loading server configuration failed."); - return 1; } - Config = queryservconfig::get(); - - if(!load_log_settings(Config->LogSettingsFile.c_str())) - _log(QUERYSERV__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str()); - else - _log(QUERYSERV__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str()); - - WorldShortName = Config->ShortName; + Config = queryservconfig::get(); + WorldShortName = Config->ShortName; _log(QUERYSERV__INIT, "Connecting to MySQL..."); - + + /* MySQL Connection */ if (!database.Connect( Config->QSDatabaseHost.c_str(), Config->QSDatabaseUsername.c_str(), @@ -93,6 +84,12 @@ int main() { return 1; } + /* Initialize Logging */ + if (!load_log_settings(Config->LogSettingsFile.c_str())) + _log(QUERYSERV__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str()); + else + _log(QUERYSERV__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str()); + if (signal(SIGINT, CatchSignal) == SIG_ERR) { _log(QUERYSERV__ERROR, "Could not set signal handler"); return 1; @@ -102,16 +99,15 @@ int main() { return 1; } + /* Initial Connection to Worldserver */ worldserver = new WorldServer; + worldserver->Connect(); - worldserver->Connect(); - + /* Load Looking For Guild Manager */ lfguildmanager.LoadDatabase(); - while(RunLoops) { - - Timer::SetCurrentTime(); - + while(RunLoops) { + Timer::SetCurrentTime(); if(LFGuildExpireTimer.Check()) lfguildmanager.ExpireEntries(); @@ -119,10 +115,8 @@ int main() { if (worldserver->TryReconnect() && (!worldserver->Connected())) worldserver->AsyncConnect(); } - worldserver->Process(); - - timeout_manager.CheckTimeouts(); - + worldserver->Process(); + timeout_manager.CheckTimeouts(); Sleep(100); } } diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index bb7523592..154db3a07 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -56,122 +56,109 @@ void WorldServer::OnConnected() void WorldServer::Process() { - WorldConnection::Process(); - + WorldConnection::Process(); if (!Connected()) return; - ServerPacket *pack = 0; - + ServerPacket *pack = 0; while((pack = tcpc.PopPacket())) { - _log(QUERYSERV__TRACE, "Received Opcode: %4X", pack->opcode); - - switch(pack->opcode) - { + _log(QUERYSERV__TRACE, "Received Opcode: %4X", pack->opcode); + switch(pack->opcode) { case 0: { break; } - case ServerOP_KeepAlive: - { + case ServerOP_KeepAlive: { break; } - case ServerOP_Speech: - { - Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer; - + case ServerOP_Speech: { + Server_Speech_Struct *SSS = (Server_Speech_Struct*)pack->pBuffer; std::string tmp1 = SSS->from; - std::string tmp2 = SSS->to; - + std::string tmp2 = SSS->to; database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type); break; } - case ServerOP_QSPlayerLogTrades: - { + case ServerOP_QSPlayerLogTrades: { QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)pack->pBuffer; uint32 Items = QS->char1_count + QS->char2_count; database.LogPlayerTrade(QS, Items); break; } - case ServerOP_QSPlayerLogHandins: - { + case ServerOP_QSPlayerLogHandins: { QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)pack->pBuffer; uint32 Items = QS->char_count + QS->npc_count; database.LogPlayerHandin(QS, Items); break; } - case ServerOP_QSPlayerLogNPCKills: - { + case ServerOP_QSPlayerLogNPCKills: { QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer; uint32 Members = pack->size - sizeof(QSPlayerLogNPCKill_Struct); if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct); database.LogPlayerNPCKill(QS, Members); break; } - case ServerOP_QSPlayerLogDeletes: - { + case ServerOP_QSPlayerLogDeletes: { QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)pack->pBuffer; uint32 Items = QS->char_count; database.LogPlayerDelete(QS, Items); break; } - case ServerOP_QSPlayerLogMoves: - { + case ServerOP_QSPlayerLogMoves: { QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)pack->pBuffer; uint32 Items = QS->char_count; database.LogPlayerMove(QS, Items); break; } - case ServerOP_QSMerchantLogTransactions: - { + case ServerOP_QSPlayerLogMerchantTransactions: { QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)pack->pBuffer; uint32 Items = QS->char_count + QS->merchant_count; database.LogMerchantTransaction(QS, Items); - break; + break; } - case ServerOP_QueryServGeneric: - { - // The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets - // each time we add functionality to queryserv. - // - // A ServerOP_QueryServGeneric packet has the following format: - // - // uint32 SourceZoneID - // uint32 SourceInstanceID - // char OriginatingCharacterName[0] // Null terminated name of the character this packet came from. This could be just - // // an empty string if it has no meaning in the context of a particular packet. - // uint32 Type - // - // The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added - // to queryserv would use 1, etc. - // - // Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The - // 'Generic' in the name of this ServerOP code relates to the four header fields. + case ServerOP_QueryServGeneric: { + /* + The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets + each time we add functionality to queryserv. + + A ServerOP_QueryServGeneric packet has the following format: + + uint32 SourceZoneID + uint32 SourceInstanceID + char OriginatingCharacterName[0] + - Null terminated name of the character this packet came from. This could be just + - an empty string if it has no meaning in the context of a particular packet. + uint32 Type + + The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added + to queryserv would use 1, etc. + + Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The + 'Generic' in the name of this ServerOP code relates to the four header fields. + */ + char From[64]; pack->SetReadPosition(8); pack->ReadString(From); uint32 Type = pack->ReadUInt32(); - switch(Type) - { - case QSG_LFGuild: - { - lfguildmanager.HandlePacket(pack); + switch(Type) { + case QSG_LFGuild:{ + lfguildmanager.HandlePacket(pack); break; } - default: _log(QUERYSERV__ERROR, "Received unhandled ServerOP_QueryServGeneric", Type); break; } - break; } - - + case ServerOP_QSSendQuery: { + /* Process all packets here */ + database.GeneralQueryReceive(pack); + break; + } } - } - + } safe_delete(pack); return; } diff --git a/utils/sql/git/queryserv/required/08_23_2014_player_events_and_player_aa_rate_hourly.sql b/utils/sql/git/queryserv/required/08_23_2014_player_events_and_player_aa_rate_hourly.sql new file mode 100644 index 000000000..2d5cbfa17 --- /dev/null +++ b/utils/sql/git/queryserv/required/08_23_2014_player_events_and_player_aa_rate_hourly.sql @@ -0,0 +1,23 @@ +-- ---------------------------- +-- Table structure for qs_player_events +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_events`; +CREATE TABLE `qs_player_events` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `char_id` int(11) DEFAULT '0', + `event` int(11) unsigned DEFAULT '0', + `event_desc` varchar(255) DEFAULT NULL, + `time` int(11) unsigned DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; + +-- ---------------------------- +-- Table structure for qs_player_aa_rate_hourly +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_aa_rate_hourly`; +CREATE TABLE `qs_player_aa_rate_hourly` ( + `char_id` int(11) NOT NULL DEFAULT '0', + `hour_time` int(11) NOT NULL, + `aa_count` varchar(11) DEFAULT NULL, + PRIMARY KEY (`char_id`,`hour_time`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Disabled.sql b/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Disabled.sql new file mode 100644 index 000000000..65206ce4c --- /dev/null +++ b/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Disabled.sql @@ -0,0 +1,45 @@ +-- Disable Player Logging for All -- +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogPCCoordinates', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogNPCKills', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTrades', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMerchantTransactions', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDeletes', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogHandins', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMoves', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogChat', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogKeyringAddition', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAAPurchases', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogIssuedCommandes', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMoneyTransactions', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAlternateCurrencyTransactions', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTradeSkillEvents', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogPCCoordinates', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDropItem', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMerchantTransactions', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDeletes', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogHandins', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMoves', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogNPCKills', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTrades', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogQGlobalUpdate', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTaskUpdates', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDeaths', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogZone', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogConnectDisconnect', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogLevels', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAARate', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogChat', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDropItem', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogZone', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDeaths', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogLevels', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogEXPRate', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAARate', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogQGlobalUpdate', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTaskUpdates', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogKeyringAddition', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAAPurchases', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTradeSkillEvents', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogIssuedCommandes', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMoneyTransactions', 'false', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAlternateCurrencyTransactions', 'false', ''); diff --git a/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Enabled.sql b/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Enabled.sql new file mode 100644 index 000000000..9426acc8f --- /dev/null +++ b/utils/sql/git/queryserv/required/Complete_QueryServ_Rules_Enabled.sql @@ -0,0 +1,45 @@ +-- Enable Player Logging for All -- +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogPCCoordinates', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogNPCKills', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTrades', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMerchantTransactions', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDeletes', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogHandins', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMoves', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogChat', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogKeyringAddition', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAAPurchases', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogIssuedCommandes', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMoneyTransactions', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAlternateCurrencyTransactions', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTradeSkillEvents', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogPCCoordinates', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDropItem', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMerchantTransactions', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDeletes', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogHandins', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogMoves', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogNPCKills', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTrades', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogQGlobalUpdate', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogTaskUpdates', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogDeaths', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogZone', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogConnectDisconnect', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogLevels', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (9, 'QueryServ:PlayerLogAARate', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogChat', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDropItem', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogZone', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogDeaths', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogLevels', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogEXPRate', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAARate', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogQGlobalUpdate', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTaskUpdates', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogKeyringAddition', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAAPurchases', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogTradeSkillEvents', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogIssuedCommandes', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogMoneyTransactions', 'true', ''); +REPLACE INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (0, 'QueryServ:PlayerLogAlternateCurrencyTransactions', 'true', ''); diff --git a/utils/sql/git/queryserv/required/Complete_QueryServ_Table_Structures.sql b/utils/sql/git/queryserv/required/Complete_QueryServ_Table_Structures.sql new file mode 100644 index 000000000..40dc41377 --- /dev/null +++ b/utils/sql/git/queryserv/required/Complete_QueryServ_Table_Structures.sql @@ -0,0 +1,247 @@ +-- QS Table Structures -- + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for qs_merchant_transaction_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_merchant_transaction_record`; +CREATE TABLE `qs_merchant_transaction_record` ( + `transaction_id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `zone_id` int(11) DEFAULT '0', + `merchant_id` int(11) DEFAULT '0', + `merchant_pp` int(11) DEFAULT '0', + `merchant_gp` int(11) DEFAULT '0', + `merchant_sp` int(11) DEFAULT '0', + `merchant_cp` int(11) DEFAULT '0', + `merchant_items` mediumint(7) DEFAULT '0', + `char_id` int(11) DEFAULT '0', + `char_pp` int(11) DEFAULT '0', + `char_gp` int(11) DEFAULT '0', + `char_sp` int(11) DEFAULT '0', + `char_cp` int(11) DEFAULT '0', + `char_items` mediumint(7) DEFAULT '0', + PRIMARY KEY (`transaction_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_merchant_transaction_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_merchant_transaction_record_entries`; +CREATE TABLE `qs_merchant_transaction_record_entries` ( + `event_id` int(11) DEFAULT '0', + `char_slot` mediumint(7) DEFAULT '0', + `item_id` int(11) DEFAULT '0', + `charges` mediumint(7) DEFAULT '0', + `aug_1` int(11) DEFAULT '0', + `aug_2` int(11) DEFAULT '0', + `aug_3` int(11) DEFAULT '0', + `aug_4` int(11) DEFAULT '0', + `aug_5` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_aa_rate_hourly +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_aa_rate_hourly`; +CREATE TABLE `qs_player_aa_rate_hourly` ( + `char_id` int(11) NOT NULL DEFAULT '0', + `hour_time` int(11) NOT NULL, + `aa_count` varchar(11) DEFAULT NULL, + PRIMARY KEY (`char_id`,`hour_time`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- ---------------------------- +-- Table structure for qs_player_delete_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_delete_record`; +CREATE TABLE `qs_player_delete_record` ( + `delete_id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `char_id` int(11) DEFAULT '0', + `stack_size` mediumint(7) DEFAULT '0', + `char_items` mediumint(7) DEFAULT '0', + PRIMARY KEY (`delete_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_delete_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_delete_record_entries`; +CREATE TABLE `qs_player_delete_record_entries` ( + `event_id` int(11) DEFAULT '0', + `char_slot` mediumint(7) DEFAULT '0', + `item_id` int(11) DEFAULT '0', + `charges` mediumint(7) DEFAULT '0', + `aug_1` int(11) DEFAULT '0', + `aug_2` int(11) DEFAULT '0', + `aug_3` int(11) DEFAULT '0', + `aug_4` int(11) DEFAULT '0', + `aug_5` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_events +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_events`; +CREATE TABLE `qs_player_events` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `char_id` int(11) DEFAULT '0', + `event` int(11) unsigned DEFAULT '0', + `event_desc` varchar(255) DEFAULT NULL, + `time` int(11) unsigned DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; + +-- ---------------------------- +-- Table structure for qs_player_handin_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_handin_record`; +CREATE TABLE `qs_player_handin_record` ( + `handin_id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `quest_id` int(11) DEFAULT '0', + `char_id` int(11) DEFAULT '0', + `char_pp` int(11) DEFAULT '0', + `char_gp` int(11) DEFAULT '0', + `char_sp` int(11) DEFAULT '0', + `char_cp` int(11) DEFAULT '0', + `char_items` mediumint(7) DEFAULT '0', + `npc_id` int(11) DEFAULT '0', + `npc_pp` int(11) DEFAULT '0', + `npc_gp` int(11) DEFAULT '0', + `npc_sp` int(11) DEFAULT '0', + `npc_cp` int(11) DEFAULT '0', + `npc_items` mediumint(7) DEFAULT '0', + PRIMARY KEY (`handin_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_handin_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_handin_record_entries`; +CREATE TABLE `qs_player_handin_record_entries` ( + `event_id` int(11) DEFAULT '0', + `action_type` char(6) DEFAULT 'action', + `char_slot` mediumint(7) DEFAULT '0', + `item_id` int(11) DEFAULT '0', + `charges` mediumint(7) DEFAULT '0', + `aug_1` int(11) DEFAULT '0', + `aug_2` int(11) DEFAULT '0', + `aug_3` int(11) DEFAULT '0', + `aug_4` int(11) DEFAULT '0', + `aug_5` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_move_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_move_record`; +CREATE TABLE `qs_player_move_record` ( + `move_id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `char_id` int(11) DEFAULT '0', + `from_slot` mediumint(7) DEFAULT '0', + `to_slot` mediumint(7) DEFAULT '0', + `stack_size` mediumint(7) DEFAULT '0', + `char_items` mediumint(7) DEFAULT '0', + `postaction` tinyint(1) DEFAULT '0', + PRIMARY KEY (`move_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_move_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_move_record_entries`; +CREATE TABLE `qs_player_move_record_entries` ( + `event_id` int(11) DEFAULT '0', + `from_slot` mediumint(7) DEFAULT '0', + `to_slot` mediumint(7) DEFAULT '0', + `item_id` int(11) DEFAULT '0', + `charges` mediumint(7) DEFAULT '0', + `aug_1` int(11) DEFAULT '0', + `aug_2` int(11) DEFAULT '0', + `aug_3` int(11) DEFAULT '0', + `aug_4` int(11) DEFAULT '0', + `aug_5` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_npc_kill_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_npc_kill_record`; +CREATE TABLE `qs_player_npc_kill_record` ( + `fight_id` int(11) NOT NULL AUTO_INCREMENT, + `npc_id` int(11) DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `zone_id` int(11) DEFAULT NULL, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`fight_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_npc_kill_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_npc_kill_record_entries`; +CREATE TABLE `qs_player_npc_kill_record_entries` ( + `event_id` int(11) DEFAULT '0', + `char_id` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_speech +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_speech`; +CREATE TABLE `qs_player_speech` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `from` varchar(64) NOT NULL, + `to` varchar(64) NOT NULL, + `message` varchar(256) NOT NULL, + `minstatus` smallint(5) NOT NULL, + `guilddbid` int(11) NOT NULL, + `type` tinyint(3) NOT NULL, + `timerecorded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_trade_record +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_trade_record`; +CREATE TABLE `qs_player_trade_record` ( + `trade_id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `char1_id` int(11) DEFAULT '0', + `char1_pp` int(11) DEFAULT '0', + `char1_gp` int(11) DEFAULT '0', + `char1_sp` int(11) DEFAULT '0', + `char1_cp` int(11) DEFAULT '0', + `char1_items` mediumint(7) DEFAULT '0', + `char2_id` int(11) DEFAULT '0', + `char2_pp` int(11) DEFAULT '0', + `char2_gp` int(11) DEFAULT '0', + `char2_sp` int(11) DEFAULT '0', + `char2_cp` int(11) DEFAULT '0', + `char2_items` mediumint(7) DEFAULT '0', + PRIMARY KEY (`trade_id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for qs_player_trade_record_entries +-- ---------------------------- +DROP TABLE IF EXISTS `qs_player_trade_record_entries`; +CREATE TABLE `qs_player_trade_record_entries` ( + `event_id` int(11) DEFAULT '0', + `from_id` int(11) DEFAULT '0', + `from_slot` mediumint(7) DEFAULT '0', + `to_id` int(11) DEFAULT '0', + `to_slot` mediumint(7) DEFAULT '0', + `item_id` int(11) DEFAULT '0', + `charges` mediumint(7) DEFAULT '0', + `aug_1` int(11) DEFAULT '0', + `aug_2` int(11) DEFAULT '0', + `aug_3` int(11) DEFAULT '0', + `aug_4` int(11) DEFAULT '0', + `aug_5` int(11) DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index a719deecf..7c4f4f963 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -1268,7 +1268,7 @@ bool ZoneServer::Process() { UCSLink.SendPacket(pack); break; } - + case ServerOP_QSSendQuery: case ServerOP_QueryServGeneric: case ServerOP_Speech: case ServerOP_QSPlayerLogTrades: @@ -1296,7 +1296,7 @@ bool ZoneServer::Process() { QSLink.SendPacket(pack); break; } - case ServerOP_QSMerchantLogTransactions: + case ServerOP_QSPlayerLogMerchantTransactions: { QSLink.SendPacket(pack); break; diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 8459fb79a..0b6ebc10a 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -16,7 +16,7 @@ SET(zone_sources command.cpp corpse.cpp doors.cpp - effects.cpp + effects.cpp embparser.cpp embparser_api.cpp embperl.cpp @@ -93,6 +93,7 @@ SET(zone_sources petitions.cpp pets.cpp qglobals.cpp + queryserv.cpp questmgr.cpp quest_parser_collection.cpp raids.cpp @@ -184,6 +185,8 @@ SET(zone_headers pets.h qglobals.h quest_interface.h + queryserv.h + quest_interface.h questmgr.h quest_parser_collection.h raid.h diff --git a/zone/aa.cpp b/zone/aa.cpp index 1bf2ba690..2964dc6f3 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -38,6 +38,9 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) #include "../common/logsys.h" #include "zonedb.h" #include "string_ids.h" +#include "queryserv.h" + +extern QueryServ* QServ; //static data arrays, really not big enough to warrant shared mem. AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] @@ -1039,16 +1042,16 @@ void Client::BuyAA(AA_Action* action) else real_cost = aa2->cost + (aa2->cost_inc * cur_level); - if(m_pp.aapoints >= real_cost && cur_level < aa2->max_level) { - SetAA(aa2->id, cur_level+1); + if (m_pp.aapoints >= real_cost && cur_level < aa2->max_level) { + SetAA(aa2->id, cur_level + 1); - mlog(AA__MESSAGE, "Set AA %d to level %d", aa2->id, cur_level+1); + mlog(AA__MESSAGE, "Set AA %d to level %d", aa2->id, cur_level + 1); m_pp.aapoints -= real_cost; Save(); if ((RuleB(AA, Stacking) && (GetClientVersionBit() >= 4) && (aa2->hotkey_sid == 4294967295u)) - && ((aa2->max_level == (cur_level+1)) && aa2->sof_next_id)){ + && ((aa2->max_level == (cur_level + 1)) && aa2->sof_next_id)){ SendAA(aa2->id); SendAA(aa2->sof_next_id); } @@ -1059,10 +1062,28 @@ void Client::BuyAA(AA_Action* action) //we are building these messages ourself instead of using the stringID to work around patch discrepencies //these are AA_GAIN_ABILITY (410) & AA_IMPROVE (411), respectively, in both Titanium & SoF. not sure about 6.2 - if(cur_level<1) - Message(15,"You have gained the ability \"%s\" at a cost of %d ability %s.", aa2->name, real_cost, (real_cost>1)?"points":"point"); - else - Message(15,"You have improved %s %d at a cost of %d ability %s.", aa2->name, cur_level+1, real_cost, (real_cost>1)?"points":"point"); + + /* Initial purchase of an AA ability */ + if (cur_level < 1){ + Message(15, "You have gained the ability \"%s\" at a cost of %d ability %s.", aa2->name, real_cost, (real_cost>1) ? "points" : "point"); + + /* QS: Player_Log_AA_Purchases */ + if (RuleB(QueryServ, PlayerLogAAPurchases)){ + std::string event_desc = StringFormat("Initial AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc); + } + } + /* Ranked purchase of an AA ability */ + else{ + Message(15, "You have improved %s %d at a cost of %d ability %s.", aa2->name, cur_level + 1, real_cost, (real_cost > 1) ? "points" : "point"); + + /* QS: Player_Log_AA_Purchases */ + if (RuleB(QueryServ, PlayerLogAAPurchases)){ + std::string event_desc = StringFormat("Ranked AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc); + } + } + SendAAStats(); @@ -1816,7 +1837,7 @@ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id) } query = StringFormat("SELECT a.cost, a.max_level, a.hotkey_sid, a.hotkey_sid2, a.title_sid, a.desc_sid, a.type, " - "COALESCE (" //So we can return 0 if it's null. + "COALESCE(" //So we can return 0 if it's null. "(" // this is our derived table that has the row # // that we can SELECT from, because the client is stupid. "SELECT p.prereq_index_num " diff --git a/zone/attack.cpp b/zone/attack.cpp index dd14b1770..5abba347b 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -42,6 +42,9 @@ #include "quest_parser_collection.h" #include "water_map.h" #include "worldserver.h" +#include "queryserv.h" + +extern QueryServ* QServ; extern WorldServer worldserver; #ifdef _WINDOWS @@ -1455,14 +1458,14 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att int exploss = 0; mlog(COMBAT__HITS, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob ? killerMob->GetName() : "Unknown", damage, spell, attack_skill); - // - // #1: Send death packet to everyone - // + /* + #1: Send death packet to everyone + */ uint8 killed_level = GetLevel(); SendLogoutPackets(); - //make our become corpse packet, and queue to ourself before OP_Death. + /* Make self become corpse packet */ EQApplicationPacket app2(OP_BecomeCorpse, sizeof(BecomeCorpse_Struct)); BecomeCorpse_Struct* bc = (BecomeCorpse_Struct*)app2.pBuffer; bc->spawn_id = GetID(); @@ -1471,7 +1474,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att bc->z = GetZ(); QueuePacket(&app2); - // make death packet + /* Make Death Packet */ EQApplicationPacket app(OP_Death, sizeof(Death_Struct)); Death_Struct* d = (Death_Struct*)app.pBuffer; d->spawn_id = GetID(); @@ -1484,9 +1487,9 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att app.priority = 6; entity_list.QueueClients(this, &app); - // - // #2: figure out things that affect the player dying and mark them dead - // + /* + #2: figure out things that affect the player dying and mark them dead + */ InterruptSpell(); SetPet(0); @@ -1541,9 +1544,9 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att //remove ourself from all proximities ClearAllProximities(); - // - // #3: exp loss and corpse generation - // + /* + #3: exp loss and corpse generation + */ // figure out if they should lose exp if(RuleB(Character, UseDeathExpLossMult)){ @@ -1659,27 +1662,21 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att LeftCorpse = true; } - -// if(!IsLD())//Todo: make it so an LDed client leaves corpse if its enabled -// MakeCorpse(exploss); } else { BuffFadeDetrimental(); } - // - // Finally, send em home - // + /* + Finally, send em home - // we change the mob variables, not pp directly, because Save() will copy - // from these and overwrite what we set in pp anyway - // + We change the mob variables, not pp directly, because Save() will copy + from these and overwrite what we set in pp anyway + */ if(LeftCorpse && (GetClientVersionBit() & BIT_SoFAndLater) && RuleB(Character, RespawnFromHover)) { - ClearDraggedCorpses(); - - RespawnFromHoverTimer.Start(RuleI(Character, RespawnFromHoverTimer) * 1000); - + ClearDraggedCorpses(); + RespawnFromHoverTimer.Start(RuleI(Character, RespawnFromHoverTimer) * 1000); SendRespawnBinds(); } else @@ -1696,17 +1693,22 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att if(r) r->MemberZoned(this); - dead_timer.Start(5000, true); - + dead_timer.Start(5000, true); m_pp.zone_id = m_pp.binds[0].zoneId; m_pp.zoneInstance = 0; - database.MoveCharacterToZone(this->CharacterID(), database.GetZoneName(m_pp.zone_id)); - - Save(); - + database.MoveCharacterToZone(this->CharacterID(), database.GetZoneName(m_pp.zone_id)); + Save(); GoToDeath(); } + /* QS: PlayerLogDeaths */ + if (RuleB(QueryServ, PlayerLogDeaths)){ + const char * killer_name = ""; + if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); } + std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage); + QServ->PlayerLogEvent(Player_Log_Deaths, this->CharacterID(), event_desc); + } + parse->EventPlayer(EVENT_DEATH_COMPLETE, this, buffer, 0); return true; } diff --git a/zone/client.cpp b/zone/client.cpp index d986dbe22..a263cd3cc 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -62,8 +62,9 @@ extern volatile bool RunLoops; #include "client_logs.h" #include "guild_mgr.h" #include "quest_parser_collection.h" +#include "queryserv.h" - +extern QueryServ* QServ; extern EntityList entity_list; extern Zone* zone; extern volatile bool ZoneLoaded; @@ -805,8 +806,8 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } } - - if(RuleB(QueryServ, PlayerChatLogging)) { + /* Logs Player Chat */ + if (RuleB(QueryServ, PlayerLogChat)) { ServerPacket* pack = new ServerPacket(ServerOP_Speech, sizeof(Server_Speech_Struct) + strlen(message) + 1); Server_Speech_Struct* sem = (Server_Speech_Struct*) pack->pBuffer; @@ -841,7 +842,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s switch(chan_num) { - case 0: { // GuildChat + case 0: { /* Guild Chat */ if (!IsInAGuild()) Message_StringID(MT_DefaultText, GUILD_NOT_MEMBER2); //You are not a member of any guild. else if (!guild_mgr.CheckPermission(GuildID(), GuildRank(), GUILD_SPEAK)) @@ -850,7 +851,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s Message(0, "Error: World server disconnected"); break; } - case 2: { // GroupChat + case 2: { /* Group Chat */ Raid* raid = entity_list.GetRaidByClient(this); if(raid) { raid->RaidGroupSay((const char*) message, this); @@ -863,14 +864,14 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } break; } - case 15: { //raid say + case 15: { /* Raid Say */ Raid* raid = entity_list.GetRaidByClient(this); if(raid){ raid->RaidSay((const char*) message, this); } break; } - case 3: { // Shout + case 3: { /* Shout */ Mob *sender = this; if (GetPet() && GetPet()->FindType(SE_VoiceGraft)) sender = GetPet(); @@ -878,7 +879,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s entity_list.ChannelMessage(sender, chan_num, language, lang_skill, message); break; } - case 4: { // Auction + case 4: { /* Auction */ if(RuleB(Chat, ServerWideAuction)) { if(!global_channel_timer.Check()) @@ -917,7 +918,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } break; } - case 5: { // OOC + case 5: { /* OOC */ if(RuleB(Chat, ServerWideOOC)) { if(!global_channel_timer.Check()) @@ -964,15 +965,15 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s } break; } - case 6: // Broadcast - case 11: { // GMSay + case 6: /* Broadcast */ + case 11: { /* GM Say */ if (!(admin >= 80)) Message(0, "Error: Only GMs can use this channel"); else if (!worldserver.SendChannelMessage(this, targetname, chan_num, 0, language, message)) Message(0, "Error: World server disconnected"); break; } - case 7: { // Tell + case 7: { /* Tell */ if(!global_channel_timer.Check()) { if(strlen(targetname) == 0) @@ -1020,7 +1021,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s Message(0, "Error: World server disconnected"); break; } - case 8: { // /say + case 8: { /* Say */ if(message[0] == COMMAND_CHAR) { if(command_dispatch(this, message) == -2) { if(parse->PlayerHasQuestSub(EVENT_COMMAND)) { @@ -4029,13 +4030,17 @@ void Client::KeyRingAdd(uint32 item_id) bool bFound = KeyRingCheck(item_id); if(!bFound){ sprintf(query, "INSERT INTO keyring(char_id,item_id) VALUES(%i,%i)",character_id,item_id); - if(database.RunQuery(query, strlen(query), errbuf, 0, &affected_rows)) - { + if(database.RunQuery(query, strlen(query), errbuf, 0, &affected_rows)) { Message(4,"Added to keyring."); + + /* QS: PlayerLogKeyringAddition */ + if (RuleB(QueryServ, PlayerLogKeyringAddition)){ + std::string event_desc = StringFormat("itemid:%i in zoneid:%i instid:%i", item_id, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Keyring_Addition, this->CharacterID(), event_desc); + } safe_delete_array(query); } - else - { + else { std::cerr << "Error in Doors::HandleClick query '" << query << "' " << errbuf << std::endl; safe_delete_array(query); return; @@ -6933,8 +6938,18 @@ void Client::SetAlternateCurrencyValue(uint32 currency_id, uint32 new_amount) SendAlternateCurrencyValue(currency_id); } -void Client::AddAlternateCurrencyValue(uint32 currency_id, int32 amount) +void Client::AddAlternateCurrencyValue(uint32 currency_id, int32 amount, int8 method) { + + /* Added via Quest, rest of the logging methods may be done inline due to information available in that area of the code */ + if (method == 1){ + /* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + std::string event_desc = StringFormat("Added via Quest :: Cursor to Item :: alt_currency_id:%i amount:%i in zoneid:%i instid:%i", currency_id, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } + } + if(amount == 0) { return; } diff --git a/zone/client.h b/zone/client.h index b78530ae1..f2d16ea0f 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1097,7 +1097,7 @@ public: inline void ClearDraggedCorpses() { DraggedCorpses.clear(); } void SendAltCurrencies(); void SetAlternateCurrencyValue(uint32 currency_id, uint32 new_amount); - void AddAlternateCurrencyValue(uint32 currency_id, int32 amount); + void AddAlternateCurrencyValue(uint32 currency_id, int32 amount, int8 method = 0); void SendAlternateCurrencyValues(); void SendAlternateCurrencyValue(uint32 currency_id, bool send_if_null = true); uint32 GetAlternateCurrencyValue(uint32 currency_id) const; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ce6b1a323..659765ba8 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -16,16 +16,16 @@ */ #include "../common/debug.h" -#include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include #include +#include +#include +#include +#include +#include #ifdef _WINDOWS #define snprintf _snprintf @@ -38,8 +38,6 @@ #include #endif -#include "masterentity.h" -#include "zonedb.h" #include "../common/packet_functions.h" #include "../common/packet_dump.h" #include "worldserver.h" @@ -59,17 +57,21 @@ #include "../common/faction.h" #include "../common/crc32.h" #include "string_ids.h" -#include "map.h" #include "titles.h" -#include "pets.h" +#include "water_map.h" +#include "worldserver.h" +#include "zone.h" #include "zone_config.h" #include "guild_mgr.h" #include "pathing.h" #include "water_map.h" #include "merc.h" +#include "pets.h" #include "../common/zone_numbers.h" #include "quest_parser_collection.h" +#include "queryserv.h" +extern QueryServ* QServ; extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; @@ -5687,8 +5689,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) safe_delete(outapp); // start QS code - if(RuleB(QueryServ, MerchantLogTransactions)) { - ServerPacket* qspack = new ServerPacket(ServerOP_QSMerchantLogTransactions, sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); + if(RuleB(QueryServ, PlayerLogMerchantTransactions)) { + ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer; qsaudit->zone_id = zone->GetZoneID(); @@ -5823,8 +5825,8 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) } // start QS code - if(RuleB(QueryServ, MerchantLogTransactions)) { - ServerPacket* qspack = new ServerPacket(ServerOP_QSMerchantLogTransactions, sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); + if(RuleB(QueryServ, PlayerLogMerchantTransactions)) { + ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer; qsaudit->zone_id = zone->GetZoneID(); @@ -9180,8 +9182,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { if(!GetAA(aaPersistentMinion)) memset(&m_suspendedminion, 0, sizeof(PetInfo)); - //////////////////////////////////////////////////////////// - // Server Zone Entry Packet + /* Server Zone Entry Packet */ outapp = new EQApplicationPacket(OP_ZoneEntry, sizeof(ServerZoneEntry_Struct)); ServerZoneEntry_Struct* sze = (ServerZoneEntry_Struct*)outapp->pBuffer; @@ -9191,43 +9192,31 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { sze->player.spawn.z += 6; //arbitrary lift, seems to help spawning under zone. outapp->priority = 6; FastQueuePacket(&outapp); - //safe_delete(outapp); - //////////////////////////////////////////////////////////// - // Zone Spawns Packet + /* Zone Spawns Packet */ entity_list.SendZoneSpawnsBulk(this); entity_list.SendZoneCorpsesBulk(this); entity_list.SendZonePVPUpdates(this); //hack until spawn struct is fixed. - - - //////////////////////////////////////////////////////////// - // Time of Day packet + /* Time of Day packet */ outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct)); TimeOfDay_Struct* tod = (TimeOfDay_Struct*)outapp->pBuffer; zone->zone_time.getEQTimeOfDay(time(0), tod); outapp->priority = 6; FastQueuePacket(&outapp); - //safe_delete(outapp); - //I think this should happen earlier, not sure - /* if(GetHideMe()) - SetHideMe(true); */ - // Moved to Handle_Connect_OP_SendExpZonein(); - - - //////////////////////////////////////////////////////////// - // Tribute Packets + /* Tribute Packets */ DoTributeUpdate(); if(m_pp.tribute_active) { //restart the tribute timer where we left off tribute_timer.Start(m_pp.tribute_time_remaining); } - //////////////////////////////////////////////////////////// - // Character Inventory Packet - //this is not quite where live sends inventory, they do it after tribute - if (loaditems) {//dont load if a length error occurs + /* + Character Inventory Packet + this is not quite where live sends inventory, they do it after tribute + */ + if (loaditems) { //dont load if a length error occurs BulkSendInventoryItems(); // Send stuff on the cursor which isnt sent in bulk @@ -9241,9 +9230,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { } } - - //////////////////////////////////////////////////////////// - // Task Packets + /* Task Packets */ LoadClientTaskState(); if (GetClientVersion() >= EQClientRoF) @@ -9261,10 +9248,11 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { FastQueuePacket(&outapp); } - ////////////////////////////////////// - // Weather Packet - // This shouldent be moved, this seems to be what the client - // uses to advance to the next state (sending ReqNewZone) + /* + Weather Packet + This shouldent be moved, this seems to be what the client + uses to advance to the next state (sending ReqNewZone) + */ outapp = new EQApplicationPacket(OP_Weather, 12); Weather_Struct *ws = (Weather_Struct *) outapp->pBuffer; ws->val1 = 0x000000FF; @@ -9279,16 +9267,6 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { QueuePacket(outapp); safe_delete(outapp); - ////////////////////////////////////// - // Group Roles - // - ////////////////////////////////////// - /*if(group){ - group->NotifyMainTank(this, 1); - group->NotifyMainAssist(this, 1); - group->NotifyPuller(this, 1); - }*/ - SetAttackTimer(); conn_state = ZoneInfoSent; @@ -9296,9 +9274,8 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { return true; } -// Finish client connecting state -void Client::CompleteConnect() -{ +/* Finish client connecting state */ +void Client::CompleteConnect() { UpdateWho(); client_state = CLIENT_CONNECTED; @@ -9311,14 +9288,14 @@ void Client::CompleteConnect() EnteringMessages(this); LoadZoneFlags(); - // Sets GM Flag if needed & Sends Petition Queue + /* Sets GM Flag if needed & Sends Petition Queue */ UpdateAdmin(false); - if(IsInAGuild()){ + if (IsInAGuild()){ SendAppearancePacket(AT_GuildID, GuildID(), false); SendAppearancePacket(AT_GuildRank, GuildRank(), false); } - for(uint32 spellInt= 0; spellInt < MAX_PP_SPELLBOOK; spellInt++) + for (uint32 spellInt = 0; spellInt < MAX_PP_SPELLBOOK; spellInt++) { if (m_pp.spell_book[spellInt] < 3 || m_pp.spell_book[spellInt] > 50000) m_pp.spell_book[spellInt] = 0xFFFFFFFF; @@ -9329,35 +9306,37 @@ void Client::CompleteConnect() uint32 raidid = database.GetRaidID(GetName()); Raid *raid = nullptr; - if(raidid > 0){ + if (raidid > 0){ raid = entity_list.GetRaidByID(raidid); - if(!raid){ + if (!raid){ raid = new Raid(raidid); - if(raid->GetID() != 0){ + if (raid->GetID() != 0){ entity_list.AddRaid(raid, raidid); } else raid = nullptr; } - if(raid){ + if (raid){ SetRaidGrouped(true); raid->LearnMembers(); raid->VerifyRaid(); raid->GetRaidDetails(); - //only leader should get this; send to all for now till - //I figure out correct creation; can probably also send a no longer leader packet for non leaders - //but not important for now. + /* + Only leader should get this; send to all for now till + I figure out correct creation; can probably also send a no longer leader packet for non leaders + but not important for now. + */ raid->SendRaidCreate(this); raid->SendMakeLeaderPacketTo(raid->leadername, this); raid->SendRaidAdd(GetName(), this); raid->SendBulkRaid(this); raid->SendGroupUpdate(this); uint32 grpID = raid->GetGroup(GetName()); - if(grpID < 12){ + if (grpID < 12){ raid->SendRaidGroupRemove(GetName(), grpID); raid->SendRaidGroupAdd(GetName(), grpID); } - if(raid->IsLocked()) + if (raid->IsLocked()) raid->SendRaidLockTo(this); } } @@ -9366,154 +9345,155 @@ void Client::CompleteConnect() //reapply some buffs uint32 buff_count = GetMaxTotalSlots(); - for (uint32 j1=0; j1 < buff_count; j1++) { - if (buffs[j1].spellid > (uint32)SPDAT_RECORDS) + for (uint32 j1 = 0; j1 < buff_count; j1++) { + if (buffs[j1].spellid >(uint32)SPDAT_RECORDS) continue; const SPDat_Spell_Struct &spell = spells[buffs[j1].spellid]; - for (int x1=0; x1 < EFFECT_COUNT; x1++) { + for (int x1 = 0; x1 < EFFECT_COUNT; x1++) { switch (spell.effectid[x1]) { - case SE_IllusionCopy: - case SE_Illusion: { - if (spell.base[x1] == -1) { - if (gender == 1) - gender = 0; - else if (gender == 0) - gender = 1; - SendIllusionPacket(GetRace(), gender, 0xFF, 0xFF); - } - else if (spell.base[x1] == -2) - { - if (GetRace() == 128 || GetRace() == 130 || GetRace() <= 12) - SendIllusionPacket(GetRace(), GetGender(), spell.max[x1], spell.max[x1]); - } - else if (spell.max[x1] > 0) - { - SendIllusionPacket(spell.base[x1], 0xFF, spell.max[x1], spell.max[x1]); - } - else - { - SendIllusionPacket(spell.base[x1], 0xFF, 0xFF, 0xFF); - } - switch(spell.base[x1]){ - case OGRE: - SendAppearancePacket(AT_Size, 9); - break; - case TROLL: - SendAppearancePacket(AT_Size, 8); - break; - case VAHSHIR: - case BARBARIAN: - SendAppearancePacket(AT_Size, 7); - break; - case HALF_ELF: - case WOOD_ELF: - case DARK_ELF: - case FROGLOK: - SendAppearancePacket(AT_Size, 5); - break; - case DWARF: - SendAppearancePacket(AT_Size, 4); - break; - case HALFLING: - case GNOME: - SendAppearancePacket(AT_Size, 3); - break; - default: - SendAppearancePacket(AT_Size, 6); - break; - } + case SE_IllusionCopy: + case SE_Illusion: { + if (spell.base[x1] == -1) { + if (gender == 1) + gender = 0; + else if (gender == 0) + gender = 1; + SendIllusionPacket(GetRace(), gender, 0xFF, 0xFF); + } + else if (spell.base[x1] == -2) + { + if (GetRace() == 128 || GetRace() == 130 || GetRace() <= 12) + SendIllusionPacket(GetRace(), GetGender(), spell.max[x1], spell.max[x1]); + } + else if (spell.max[x1] > 0) + { + SendIllusionPacket(spell.base[x1], 0xFF, spell.max[x1], spell.max[x1]); + } + else + { + SendIllusionPacket(spell.base[x1], 0xFF, 0xFF, 0xFF); + } + switch (spell.base[x1]){ + case OGRE: + SendAppearancePacket(AT_Size, 9); + break; + case TROLL: + SendAppearancePacket(AT_Size, 8); + break; + case VAHSHIR: + case BARBARIAN: + SendAppearancePacket(AT_Size, 7); + break; + case HALF_ELF: + case WOOD_ELF: + case DARK_ELF: + case FROGLOK: + SendAppearancePacket(AT_Size, 5); + break; + case DWARF: + SendAppearancePacket(AT_Size, 4); + break; + case HALFLING: + case GNOME: + SendAppearancePacket(AT_Size, 3); + break; + default: + SendAppearancePacket(AT_Size, 6); break; } - case SE_SummonHorse: { - SummonHorse(buffs[j1].spellid); - //hasmount = true; //this was false, is that the correct thing? - break; + break; + } + case SE_SummonHorse: { + SummonHorse(buffs[j1].spellid); + //hasmount = true; //this was false, is that the correct thing? + break; + } + case SE_Silence: + { + Silence(true); + break; + } + case SE_Amnesia: + { + Amnesia(true); + break; + } + case SE_DivineAura: + { + invulnerable = true; + break; + } + case SE_Invisibility2: + case SE_Invisibility: + { + invisible = true; + SendAppearancePacket(AT_Invis, 1); + break; + } + case SE_Levitate: + { + if (!zone->CanLevitate()) + { + if (!GetGM()) + { + SendAppearancePacket(AT_Levitate, 0); + BuffFadeByEffect(SE_Levitate); + Message(13, "You can't levitate in this zone."); + } } - case SE_Silence: - { - Silence(true); - break; - } - case SE_Amnesia: - { - Amnesia(true); - break; - } - case SE_DivineAura: - { - invulnerable = true; - break; - } - case SE_Invisibility2: - case SE_Invisibility: - { - invisible = true; - SendAppearancePacket(AT_Invis, 1); - break; - } - case SE_Levitate: - { - if( !zone->CanLevitate() ) - { - if(!GetGM()) - { - SendAppearancePacket(AT_Levitate, 0); - BuffFadeByEffect(SE_Levitate); - Message(13, "You can't levitate in this zone."); - } - }else{ - SendAppearancePacket(AT_Levitate, 2); - } - break; - } - case SE_InvisVsUndead2: - case SE_InvisVsUndead: - { - invisible_undead = true; - break; - } - case SE_InvisVsAnimals: - { - invisible_animals = true; - break; - } - case SE_AddMeleeProc: - case SE_WeaponProc: - { - AddProcToWeapon(GetProcID(buffs[j1].spellid, x1), false, 100+spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid); - break; - } - case SE_DefensiveProc: - { - AddDefensiveProc(GetProcID(buffs[j1].spellid, x1), 100+spells[buffs[j1].spellid].base2[x1],buffs[j1].spellid); - break; - } - case SE_RangedProc: - { - AddRangedProc(GetProcID(buffs[j1].spellid, x1), 100+spells[buffs[j1].spellid].base2[x1],buffs[j1].spellid); - break; - } + else{ + SendAppearancePacket(AT_Levitate, 2); + } + break; + } + case SE_InvisVsUndead2: + case SE_InvisVsUndead: + { + invisible_undead = true; + break; + } + case SE_InvisVsAnimals: + { + invisible_animals = true; + break; + } + case SE_AddMeleeProc: + case SE_WeaponProc: + { + AddProcToWeapon(GetProcID(buffs[j1].spellid, x1), false, 100 + spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid); + break; + } + case SE_DefensiveProc: + { + AddDefensiveProc(GetProcID(buffs[j1].spellid, x1), 100 + spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid); + break; + } + case SE_RangedProc: + { + AddRangedProc(GetProcID(buffs[j1].spellid, x1), 100 + spells[buffs[j1].spellid].base2[x1], buffs[j1].spellid); + break; + } } } } - //sends appearances for all mobs not doing anim_stand aka sitting, looting, playing dead + /* Sends appearances for all mobs not doing anim_stand aka sitting, looting, playing dead */ entity_list.SendZoneAppearance(this); - //sends the Nimbus particle effects (up to 3) for any mob using them + /* Sends the Nimbus particle effects (up to 3) for any mob using them */ entity_list.SendNimbusEffects(this); entity_list.SendUntargetable(this); client_data_loaded = true; int x; - for(x=0;x<8;x++) + for (x = 0; x < 8; x++) SendWearChange(x); Mob *pet = GetPet(); - if(pet != nullptr) { - for(x=0;x<8;x++) + if (pet != nullptr) { + for (x = 0; x < 8; x++) pet->SendWearChange(x); } @@ -9521,14 +9501,14 @@ void Client::CompleteConnect() zoneinpacket_timer.Start(); - if(GetPet()){ + if (GetPet()){ GetPet()->SendPetBuffsToClient(); } - if(GetGroup()) + if (GetGroup()) database.RefreshGroupFromDB(this); - if(RuleB(TaskSystem, EnableTaskSystem)) + if (RuleB(TaskSystem, EnableTaskSystem)) TaskPeriodic_Timer.Start(); else TaskPeriodic_Timer.Disable(); @@ -9536,51 +9516,50 @@ void Client::CompleteConnect() conn_state = ClientConnectFinished; //enforce some rules.. - if(!CanBeInZone()) { + if (!CanBeInZone()) { _log(CLIENT__ERROR, "Kicking char from zone, not allowed here"); GoToSafeCoords(database.GetZoneID("arena"), 0); return; } - if(zone) + if (zone) zone->weatherSend(); TotalKarma = database.GetKarma(AccountID()); - SendDisciplineTimers(); parse->EventPlayer(EVENT_ENTER_ZONE, this, "", 0); - //This sub event is for if a player logs in for the first time since entering world. - if(firstlogon == 1) - parse->EventPlayer(EVENT_CONNECT, this, "", 0); + /* This sub event is for if a player logs in for the first time since entering world. */ + if (firstlogon == 1){ + parse->EventPlayer(EVENT_CONNECT, this, "", 0); + /* QS: PlayerLogConnectDisconnect */ + if (RuleB(QueryServ, PlayerLogConnectDisconnect)){ + std::string event_desc = StringFormat("Connect :: Logged into zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc); + } + } - if(zone) - { - if(zone->GetInstanceTimer()) - { + if(zone) { + if(zone->GetInstanceTimer()) { uint32 ttime = zone->GetInstanceTimer()->GetRemainingTime(); uint32 day = (ttime/86400000); uint32 hour = (ttime/3600000)%24; uint32 minute = (ttime/60000)%60; uint32 second = (ttime/1000)%60; - if(day) - { + if(day) { Message(15, "%s(%u) will expire in %u days, %u hours, %u minutes, and %u seconds.", zone->GetLongName(), zone->GetInstanceID(), day, hour, minute, second); } - else if(hour) - { + else if(hour) { Message(15, "%s(%u) will expire in %u hours, %u minutes, and %u seconds.", zone->GetLongName(), zone->GetInstanceID(), hour, minute, second); } - else if(minute) - { + else if(minute) { Message(15, "%s(%u) will expire in %u minutes, and %u seconds.", zone->GetLongName(), zone->GetInstanceID(), minute, second); } - else - { + else { Message(15, "%s(%u) will expire in in %u seconds.", zone->GetLongName(), zone->GetInstanceID(), second); } @@ -9603,8 +9582,7 @@ void Client::CompleteConnect() if(GetClientVersion() >= EQClientSoD) entity_list.SendFindableNPCList(this); - if(IsInAGuild()) - { + if(IsInAGuild()) { SendGuildRanks(); guild_mgr.SendGuildMemberUpdateToWorld(GetName(), GuildID(), zone->GetZoneID(), time(nullptr)); guild_mgr.RequestOnlineGuildMembers(this->CharacterID(), this->GuildID()); @@ -9616,8 +9594,7 @@ void Client::CompleteConnect() worldserver.SendPacket(pack); delete pack; - if(IsClient() && CastToClient()->GetClientVersionBit() & BIT_UnderfootAndLater) - { + if(IsClient() && CastToClient()->GetClientVersionBit() & BIT_UnderfootAndLater) { EQApplicationPacket *outapp = MakeBuffsPacket(false); CastToClient()->FastQueuePacket(&outapp); } @@ -12749,6 +12726,12 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app) { return; } + /* QS: PlayerLogAlternateCurrencyTransactions :: Merchant Purchase */ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + std::string event_desc = StringFormat("Merchant Purchase :: Spent alt_currency_id:%i cost:%i for itemid:%i in zoneid:%i instid:%i", alt_cur_id, cost, item->ID, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } + AddAlternateCurrencyValue(alt_cur_id, -((int32)cost)); int16 charges = 1; if(item->MaxCharges != 0) @@ -12780,20 +12763,37 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { return; } - if(reclaim->reclaim_flag == 1) { //item -> altcur + /* Item to Currency Storage */ + if(reclaim->reclaim_flag == 1) { uint32 removed = NukeItem(item_id, invWhereWorn | invWherePersonal | invWhereCursor); if(removed > 0) { AddAlternateCurrencyValue(reclaim->currency_id, removed); + + /* QS: PlayerLogAlternateCurrencyTransactions :: Item to Currency */ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + std::string event_desc = StringFormat("Reclaim :: Item to Currency :: alt_currency_id:%i amount:%i to currency tab in zoneid:%i instid:%i", reclaim->currency_id, removed, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } } - } else { + } + /* Cursor to Item storage */ + else { uint32 max_currency = GetAlternateCurrencyValue(reclaim->currency_id); + + /* If you input more than you have currency wise, just give the max of the currency you currently have */ if(reclaim->count > max_currency) { SummonItem(item_id, max_currency); SetAlternateCurrencyValue(reclaim->currency_id, 0); - } else { + } + else { SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, false, MainCursor); AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count)); } + /* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + std::string event_desc = StringFormat("Reclaim :: Cursor to Item :: alt_currency_id:%i amount:-%i in zoneid:%i instid:%i", reclaim->currency_id, reclaim->count, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } } } @@ -12829,6 +12829,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) { uint32 cost = 0; uint32 current_currency = GetAlternateCurrencyValue(alt_cur_id); uint32 merchant_id = tar->MerchantType; + uint32 npc_id = tar->GetNPCTypeID(); bool found = false; std::list merlist = zone->merchanttable[merchant_id]; std::list::const_iterator itr; @@ -12881,6 +12882,12 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) { sell->cost = cost; + /* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + std::string event_desc = StringFormat("Sold to Merchant :: itemid:%i npcid:%i alt_currency_id:%i cost:%i in zoneid:%i instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } + FastQueuePacket(&outapp); AddAlternateCurrencyValue(alt_cur_id, cost); Save(1); @@ -12940,7 +12947,7 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) switch(Command) { case 0: - { + { VERIFY_PACKET_LENGTH(OP_LFGuild, app, LFGuild_PlayerToggle_Struct); LFGuild_PlayerToggle_Struct *pts = (LFGuild_PlayerToggle_Struct *)app->pBuffer; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 3fea686ab..e39cef0bd 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -63,7 +63,9 @@ #include "guild_mgr.h" #include #include "quest_parser_collection.h" +#include "queryserv.h" +extern QueryServ* QServ; extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; @@ -770,38 +772,40 @@ bool Client::Process() { return ret; } -//just a set of actions preformed all over in Client::Process +/* Just a set of actions preformed all over in Client::Process */ void Client::OnDisconnect(bool hard_disconnect) { if(hard_disconnect) { - LeaveGroup(); - + LeaveGroup(); Raid *MyRaid = entity_list.GetRaidByClient(this); if (MyRaid) MyRaid->MemberZoned(this); - parse->EventPlayer(EVENT_DISCONNECT, this, "", 0); + parse->EventPlayer(EVENT_DISCONNECT, this, "", 0); + + /* QS: PlayerLogConnectDisconnect */ + if (RuleB(QueryServ, PlayerLogConnectDisconnect)){ + std::string event_desc = StringFormat("Disconnect :: in zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc); + } } - Mob *Other = trade->With(); - - if(Other) - { - mlog(TRADING__CLIENT, "Client disconnected during a trade. Returning their items."); - + Mob *Other = trade->With(); + if(Other) { + mlog(TRADING__CLIENT, "Client disconnected during a trade. Returning their items."); FinishTrade(this); if(Other->IsClient()) Other->CastToClient()->FinishTrade(Other); - trade->Reset(); - + /* Reset both sides of the trade */ + trade->Reset(); Other->trade->Reset(); } database.SetFirstLogon(CharacterID(), 0); //We change firstlogon status regardless of if a player logs out to zone or not, because we only want to trigger it on their first login from world. - //remove ourself from all proximities + /* Remove ourself from all proximities */ ClearAllProximities(); EQApplicationPacket *outapp = new EQApplicationPacket(OP_LogoutReply); diff --git a/zone/command.cpp b/zone/command.cpp index 555804cfa..b14a173bc 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -62,8 +62,9 @@ #include "guild_mgr.h" #include "titles.h" #include "../common/patches/patches.h" +#include "queryserv.h" -// these should be in the headers... +extern QueryServ* QServ; extern WorldServer worldserver; extern TaskManager *taskmanager; void CatchSignal(int sig_num); @@ -588,6 +589,12 @@ int command_realdispatch(Client *c, const char *message) return(-1); } + /* QS: Player_Log_Issued_Commands */ + if (RuleB(QueryServ, PlayerLogIssuedCommandes)){ + std::string event_desc = StringFormat("Issued command :: '%s' in zoneid:%i instid:%i", message, c->GetZoneID(), c->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Issued_Commands, c->CharacterID(), event_desc); + } + #ifdef COMMANDS_LOGGING if(cur->access >= COMMANDS_LOGGING_MIN_STATUS) { LogFile->write(EQEMuLog::Commands, "%s (%s) used command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE"); diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index b2c4b02ad..5adbdedbd 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -28,8 +28,10 @@ #include "embxs.h" #include "entity.h" #include "zone.h" +#include "queryserv.h" extern Zone* zone; +extern QueryServ* QServ; /* @@ -3370,6 +3372,36 @@ XS(XS__clear_npctype_cache) XSRETURN_EMPTY; } +XS(XS__qs_send_query); +XS(XS__qs_send_query) +{ + dXSARGS; + if (items != 1){ + Perl_croak(aTHX_ "Usage: qs_send_query(query)"); + } + else{ + // char *Query = (char *)SvPV_nolen(ST(0)); + std::string Query = (std::string)SvPV_nolen(ST(0)); + QServ->SendQuery(Query); + } + XSRETURN_EMPTY; +} + +XS(XS__qs_player_event); +XS(XS__qs_player_event) +{ + dXSARGS; + if (items != 2){ + Perl_croak(aTHX_ "Usage: qs_player_event(char_id, event_desc)"); + } + else{ + int char_id = (int)SvIV(ST(0)); + std::string event_desc = (std::string)SvPV_nolen(ST(1)); + QServ->PlayerLogEvent(Player_Log_Quest, char_id, event_desc); + } + XSRETURN_EMPTY; +} + /* This is the callback perl will look for to setup the quest package's XSUBs @@ -3591,6 +3623,8 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "enablerecipe"), XS__enablerecipe, file); newXS(strcpy(buf, "disablerecipe"), XS__disablerecipe, file); newXS(strcpy(buf, "clear_npctype_cache"), XS__clear_npctype_cache, file); + newXS(strcpy(buf, "qs_send_query"), XS__qs_send_query, file); + newXS(strcpy(buf, "qs_player_event"), XS__qs_player_event, file); XSRETURN_YES; } diff --git a/zone/entity.cpp b/zone/entity.cpp index 469bf8111..45c203dc5 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -4170,6 +4170,20 @@ void EntityList::SignalAllClients(uint32 data) } } +uint16 EntityList::GetClientCount(){ + uint16 ClientCount = 0; + std::list client_list; + entity_list.GetClientList(client_list); + std::list::iterator iter = client_list.begin(); + while (iter != client_list.end()) { + Client *entry = (*iter); + entry->GetCleanName(); + ClientCount++; + iter++; + } + return ClientCount; +} + void EntityList::GetMobList(std::list &m_list) { m_list.clear(); diff --git a/zone/entity.h b/zone/entity.h index d61298b0a..5caab8a30 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -398,6 +398,7 @@ public: void UpdateFindableNPCState(NPC *n, bool Remove); void HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode); + uint16 EntityList::GetClientCount(); void GetMobList(std::list &m_list); void GetNPCList(std::list &n_list); void GetMercList(std::list &n_list); diff --git a/zone/exp.cpp b/zone/exp.cpp index 73d339af6..9415022ca 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -22,6 +22,9 @@ #include "../common/string_util.h" #include "../common/rulesys.h" #include "quest_parser_collection.h" +#include "queryserv.h" + +extern QueryServ* QServ; static uint32 MaxBankedGroupLeadershipPoints(int Level) @@ -212,7 +215,6 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { return; // Must be invalid class/race } - if ((set_exp + set_aaxp) > (m_pp.exp+m_pp.expAA)) { if (isrezzexp) this->Message_StringID(MT_Experience, REZ_REGAIN); @@ -288,6 +290,14 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { //Message(15, "You have gained %d skill points!!", m_pp.aapoints - last_unspentAA); char val1[20]={0}; Message_StringID(MT_Experience, GAIN_ABILITY_POINT,ConvertArray(m_pp.aapoints, val1),m_pp.aapoints == 1 ? "" : "(s)"); //You have gained an ability point! You now have %1 ability point%2. + + /* QS: PlayerLogAARate */ + if (RuleB(QueryServ, PlayerLogAARate)){ + int add_points = (m_pp.aapoints - last_unspentAA); + std::string query = StringFormat("INSERT INTO `qs_player_aa_rate_hourly` (char_id, aa_count, hour_time) VALUES (%i, %i, UNIX_TIMESTAMP() - MOD(UNIX_TIMESTAMP(), 3600)) ON DUPLICATE KEY UPDATE `aa_count` = `aa_count` + %i", this->CharacterID(), add_points, add_points); + QServ->SendQuery(query.c_str()); + } + //Message(15, "You now have %d skill points available to spend.", m_pp.aapoints); } @@ -299,12 +309,10 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { if(check_level > maxlevel) { check_level = maxlevel; - if(RuleB(Character, KeepLevelOverMax)) - { + if(RuleB(Character, KeepLevelOverMax)) { set_exp = GetEXPForLevel(GetLevel()+1); } - else - { + else { set_exp = GetEXPForLevel(maxlevel); } } @@ -314,8 +322,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { if(MaxLevel){ if(GetLevel() >= MaxLevel){ uint32 expneeded = GetEXPForLevel(MaxLevel); - if(set_exp > expneeded) - { + if(set_exp > expneeded) { set_exp = expneeded; } } @@ -327,11 +334,11 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { if (GetLevel() == check_level-1){ Message_StringID(MT_Experience, GAIN_LEVEL,ConvertArray(check_level,val1)); SendLevelAppearance(); - //Message(15, "You have gained a level! Welcome to level %i!", check_level); + /* Message(15, "You have gained a level! Welcome to level %i!", check_level); */ } if (GetLevel() == check_level){ Message_StringID(MT_Experience, LOSE_LEVEL,ConvertArray(check_level,val1)); - //Message(15, "You lost a level! You are now level %i!", check_level); + /* Message(15, "You lost a level! You are now level %i!", check_level); */ } else Message(15, "Welcome to level %i!", check_level); @@ -352,8 +359,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { //If were at max level then stop gaining experience if we make it to the cap if(GetLevel() == maxlevel - 1){ uint32 expneeded = GetEXPForLevel(maxlevel); - if(set_exp > expneeded) - { + if(set_exp > expneeded) { set_exp = expneeded; } } @@ -405,15 +411,13 @@ void Client::SetLevel(uint8 set_level, bool command) level = set_level; - if(IsRaidGrouped()) - { + if(IsRaidGrouped()) { Raid *r = this->GetRaid(); if(r){ r->UpdateLevel(GetName(), set_level); } } - if(set_level > m_pp.level2) - { + if(set_level > m_pp.level2) { if(m_pp.level2 == 0) m_pp.points += 5; else @@ -423,6 +427,18 @@ void Client::SetLevel(uint8 set_level, bool command) } if(set_level > m_pp.level) { parse->EventPlayer(EVENT_LEVEL_UP, this, "", 0); + /* QS: PlayerLogLevels */ + if (RuleB(QueryServ, PlayerLogLevels)){ + std::string event_desc = StringFormat("Leveled UP :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc); + } + } + else if (set_level < m_pp.level){ + /* QS: PlayerLogLevels */ + if (RuleB(QueryServ, PlayerLogLevels)){ + std::string event_desc = StringFormat("Leveled DOWN :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc); + } } m_pp.level = set_level; @@ -432,34 +448,34 @@ void Client::SetLevel(uint8 set_level, bool command) lu->exp = 0; } else { - float tmpxp = (float) ( (float) m_pp.exp - GetEXPForLevel( GetLevel() )) / - ( (float) GetEXPForLevel(GetLevel()+1) - GetEXPForLevel(GetLevel())); + float tmpxp = (float) ( (float) m_pp.exp - GetEXPForLevel( GetLevel() )) / ( (float) GetEXPForLevel(GetLevel()+1) - GetEXPForLevel(GetLevel())); lu->exp = (uint32)(330.0f * tmpxp); } QueuePacket(outapp); safe_delete(outapp); this->SendAppearancePacket(AT_WhoLevel, set_level); // who level change - LogFile->write(EQEMuLog::Normal,"Setting Level for %s to %i", GetName(), set_level); + LogFile->write(EQEMuLog::Normal,"Setting Level for %s to %i", GetName(), set_level); CalcBonuses(); - if(!RuleB(Character, HealOnLevel)) - { + + if(!RuleB(Character, HealOnLevel)) { int mhp = CalcMaxHP(); if(GetHP() > mhp) SetHP(mhp); } - else - { + else { SetHP(CalcMaxHP()); // Why not, lets give them a free heal } - DoTributeUpdate(); + DoTributeUpdate(); SendHPUpdate(); SetMana(CalcMaxMana()); UpdateWho(); - if(GetMerc()) - UpdateMercLevel(); + + if(GetMerc()) + UpdateMercLevel(); + Save(); } @@ -508,23 +524,13 @@ uint32 Client::GetEXPForLevel(uint16 check_level) uint32 finalxp = uint32(base * mod); finalxp = mod_client_xp_for_level(finalxp, check_level); - return(finalxp); + return finalxp; } -void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level) { - - if (exp_percentage > 100) - { - exp_percentage = 100; - } - - if (!max_level || GetLevel() < max_level) - { - max_level = GetLevel(); - } - - uint32 newexp = GetEXP() + ((GetEXPForLevel(max_level + 1) - GetEXPForLevel(max_level)) * exp_percentage / 100); - +void Client::AddLevelBasedExp(uint8 exp_percentage, uint8 max_level) { + if (exp_percentage > 100) { exp_percentage = 100; } + if (!max_level || GetLevel() < max_level) { max_level = GetLevel(); } + uint32 newexp = GetEXP() + ((GetEXPForLevel(max_level + 1) - GetEXPForLevel(max_level)) * exp_percentage / 100); SetEXP(newexp, GetAAXP()); } @@ -666,28 +672,25 @@ void Client::SendLeadershipEXPUpdate() { } uint32 Client::GetCharMaxLevelFromQGlobal() { + QGlobalCache *char_c = nullptr; + char_c = this->GetQGlobals(); - QGlobalCache *char_c = nullptr; - char_c = this->GetQGlobals(); + std::list globalMap; + uint32 ntype = 0; - std::list globalMap; - uint32 ntype = 0; + if(char_c) { + QGlobalCache::Combine(globalMap, char_c->GetBucket(), ntype, this->CharacterID(), zone->GetZoneID()); + } - if(char_c) - { - QGlobalCache::Combine(globalMap, char_c->GetBucket(), ntype, this->CharacterID(), zone->GetZoneID()); - } + std::list::iterator iter = globalMap.begin(); + uint32 gcount = 0; + while(iter != globalMap.end()) { + if((*iter).name.compare("CharMaxLevel") == 0){ + return atoi((*iter).value.c_str()); + } + ++iter; + ++gcount; + } - std::list::iterator iter = globalMap.begin(); - uint32 gcount = 0; - while(iter != globalMap.end()) - { - if((*iter).name.compare("CharMaxLevel") == 0){ - return atoi((*iter).value.c_str()); - } - ++iter; - ++gcount; - } - - return false; // Default is false + return false; } diff --git a/zone/groups.cpp b/zone/groups.cpp index 598fa4989..5c34cf359 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -193,11 +193,10 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu for (i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] != nullptr && members[i]->IsClient()) { // If Group Member is Client - Client *c = members[i]->CastToClient(); - //I could not get MoneyOnCorpse to work, so we use this - c->AddMoneyToPP(cpsplit, spsplit, gpsplit, ppsplit, true); - - c->Message(2, msg.c_str()); + Client *c = members[i]->CastToClient(); + //I could not get MoneyOnCorpse to work, so we use this + c->AddMoneyToPP(cpsplit, spsplit, gpsplit, ppsplit, true); + c->Message(2, msg.c_str()); } } } diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index c7f44e6ba..86b20d313 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -311,7 +311,7 @@ Mob *HateList::GetTop(Mob *center) } } - if (cur->ent->Sanctuary()) { + if (cur->ent->Sanctuary()) { if(hate == -1) { top = cur->ent; diff --git a/zone/lua_client.cpp b/zone/lua_client.cpp index a1af1b499..32affc06e 100644 --- a/zone/lua_client.cpp +++ b/zone/lua_client.cpp @@ -1134,7 +1134,7 @@ void Lua_Client::Signal(uint32 id) { void Lua_Client::AddAlternateCurrencyValue(uint32 currency, int amount) { Lua_Safe_Call_Void(); - self->AddAlternateCurrencyValue(currency, amount); + self->AddAlternateCurrencyValue(currency, amount, 1); } void Lua_Client::SendWebLink(const char *site) { diff --git a/zone/net.cpp b/zone/net.cpp index d81ea71e3..8a8421786 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -48,6 +48,7 @@ #include "worldserver.h" #include "net.h" #include "zone.h" +#include "queryserv.h" #include "command.h" #include "zone_config.h" #include "titles.h" @@ -98,6 +99,7 @@ npcDecayTimes_Struct npcCorpseDecayTimes[100]; TitleManager title_manager; DBAsyncFinishedQueue MTdbafq; DBAsync *dbasync = nullptr; +QueryServ *QServ = 0; TaskManager *taskmanager = 0; QuestParserCollection *parse = 0; @@ -114,6 +116,8 @@ int main(int argc, char** argv) { const char *zone_name; + QServ = new QueryServ; + if(argc == 3) { worldserver.SetLauncherName(argv[2]); worldserver.SetLaunchedName(argv[1]); @@ -622,7 +626,7 @@ void LoadSpells(EQEmu::MemoryMappedFile **mmf) { SPDAT_RECORDS = records; } - +/* Update Window Title with relevant information */ void UpdateWindowTitle(char* iNewTitle) { #ifdef _WINDOWS char tmp[500]; @@ -634,7 +638,7 @@ void UpdateWindowTitle(char* iNewTitle) { #if defined(GOTFRAGS) || defined(_EQDEBUG) snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); #else - snprintf(tmp, sizeof(tmp), "%i: %s, %i clients", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients); + snprintf(tmp, sizeof(tmp), "%s :: clients: %i inst_id: %i inst_ver: %i :: port: %i", zone->GetShortName(), numclients, zone->GetInstanceID(), zone->GetInstanceVersion(), ZoneConfig::get()->ZonePort); #endif } else { diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 476c47599..22d26f174 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1312,13 +1312,15 @@ XS(XS_Client_MovePCInstance) if (THIS->IsMerc()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); else if (THIS->IsNPC()) - _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); + _log(CLIENT__ERROR, "Perl(XS_MovePCInstance) attempted to process a type NPC reference"); #ifdef BOTS else if (THIS->IsBot()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); #endif else - _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); + _log(CLIENT__ERROR, "Perl(XS_MovePCInstance) attempted to process an Unknown type reference"); + + Perl_croak(aTHX_ "THIS is not of type Client"); Perl_croak(aTHX_ "THIS is not of type Client"); } diff --git a/zone/petitions.cpp b/zone/petitions.cpp index 4dce685ea..ba57fe7f2 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -300,8 +300,6 @@ void ZoneDatabase::RefreshPetitionsFromDB() newpet->SetSentTime2(atol(row[13])); newpet->SetGMText(row[14]); - std::cout << "Petition " << row[0] << " pettime = " << newpet->GetSentTime() << std::endl; - if (atoi(row[12]) == 1) newpet->SetCheckedOut(true); else diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp new file mode 100644 index 000000000..8ccf38899 --- /dev/null +++ b/zone/queryserv.cpp @@ -0,0 +1,48 @@ +/* EQEMu: Everquest Server Emulator +Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../common/debug.h" +#include "../common/servertalk.h" +#include "../common/string_util.h" +#include "queryserv.h" +#include "worldserver.h" +#include "net.h" + +#include + +extern WorldServer worldserver; +extern QueryServ* QServ; + +QueryServ::QueryServ(){ +} + +QueryServ::~QueryServ(){ +} + +void QueryServ::SendQuery(std::string Query){ + ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, strlen(Query.c_str()) + 5); + pack->WriteUInt32(strlen(Query.c_str())); /* Pack Query String Size so it can be dynamically broken out at queryserv */ + pack->WriteString(Query.c_str()); /* Query */ + worldserver.SendPacket(pack); + safe_delete(pack); +} + +void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc){ + std::string query = StringFormat("INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", Event_Type, Character_ID, EscapeString(Event_Desc.c_str())); + SendQuery(query); +} \ No newline at end of file diff --git a/zone/queryserv.h b/zone/queryserv.h new file mode 100644 index 000000000..657dc0b30 --- /dev/null +++ b/zone/queryserv.h @@ -0,0 +1,35 @@ +#ifndef QUERYSERV_ZONE_H +#define QUERYSERV_ZONE_H + + +/* + enum PlayerGenericLogEventTypes + These Enums are for the generic logging table that are not complex and require more advanced logic +*/ + +enum PlayerGenericLogEventTypes { + Player_Log_Quest = 1, + Player_Log_Zoning, + Player_Log_Deaths, + Player_Log_Connect_State, + Player_Log_Levels, + Player_Log_Keyring_Addition, + Player_Log_QGlobal_Update, + Player_Log_Task_Updates, + Player_Log_AA_Purchases, + Player_Log_Trade_Skill_Events, + Player_Log_Issued_Commands, + Player_Log_Money_Transactions, + Player_Log_Alternate_Currency_Transactions, +}; + + +class QueryServ{ + public: + QueryServ(); + ~QueryServ(); + void QueryServ::SendQuery(std::string Query); + void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc); +}; + +#endif /* QUERYSERV_ZONE_H */ \ No newline at end of file diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index d8b9094be..fc31178ae 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -75,12 +75,12 @@ And then at then end of embparser.cpp, add: #include "../common/rulesys.h" #include "qglobals.h" #include "quest_parser_collection.h" - +#include "queryserv.h" #ifdef BOTS #include "bot.h" #endif - +extern QueryServ* QServ; extern Zone* zone; extern WorldServer worldserver; extern EntityList entity_list; @@ -172,8 +172,7 @@ void QuestManager::EndQuest() { cur = QTimerList.erase(cur); else ++cur; - } - + } run.owner->Depop(); } quests_running_.pop(); @@ -1294,33 +1293,29 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti int qgNpcid = owner->GetNPCTypeID(); /* options value determines the availability of global variables to NPCs when a quest begins - ------------------------------------------------------------------ - value npcid player zone - ------------------------------------------------------------------ - 0 this this this - 1 all this this - 2 this all this - 3 all all this - 4 this this all - 5 all this all - 6 this all all - 7 all all all + ------------------------------------------------------------------ + value npcid player zone + ------------------------------------------------------------------ + 0 this this this + 1 all this this + 2 this all this + 3 all all this + 4 this this all + 5 all this all + 6 this all all + 7 all all all */ - if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved - { - qgCharid=initiator->CharacterID(); - } - else - { + if (initiator && initiator->IsClient()){ // some events like waypoint and spawn don't have a player involved + qgCharid=initiator->CharacterID(); + } + else { qgCharid=-qgNpcid; // make char id negative npc id as a fudge } - if (options < 0 || options > 7) - { + if (options < 0 || options > 7) { std::cerr << "Invalid options for global var " << varname << " using defaults" << std::endl; } // default = 0 (only this npcid,player and zone) - else - { + else { if (options & 1) qgNpcid=0; if (options & 2) @@ -1330,30 +1325,32 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti } InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, newvalue, QGVarDuration(duration)); + + /* QS: PlayerLogQGlobalUpdate */ + if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){ + std::string event_desc = StringFormat("Update :: qglobal:%s to qvalue:%s zoneid:%i instid:%i", varname, newvalue, initiator->GetZoneID(), initiator->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc); + } } /* Inserts global variable into quest_globals table */ -int QuestManager::InsertQuestGlobal( - int charid, int npcid, int zoneid, - const char *varname, const char *varvalue, - int duration) -{ +int QuestManager::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varname, const char *varvalue, int duration) { char *query = 0; char errbuf[MYSQL_ERRMSG_SIZE]; // Make duration string either "unix_timestamp(now()) + xxx" or "NULL" - std::stringstream duration_ss; - if (duration == INT_MAX) - { + std::stringstream duration_ss; + if (duration == INT_MAX) { duration_ss << "NULL"; } - else - { + else { duration_ss << "unix_timestamp(now()) + " << duration; } - //NOTE: this should be escaping the contents of arglist - //npcwise a malicious script can arbitrarily alter the DB + /* + NOTE: this should be escaping the contents of arglist + npcwise a malicious script can arbitrarily alter the DB + */ uint32 last_id = 0; if (!database.RunQuery(query, MakeAnyLenString(&query, "REPLACE INTO quest_globals (charid, npcid, zoneid, name, value, expdate)" @@ -1365,9 +1362,8 @@ int QuestManager::InsertQuestGlobal( } safe_delete_array(query); - if(zone) - { - //first delete our global + if(zone) { + /* Delete existing qglobal data and update zone processes */ ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct)); ServerQGlobalDelete_Struct *qgd = (ServerQGlobalDelete_Struct*)pack->pBuffer; qgd->npc_id = npcid; @@ -1383,18 +1379,16 @@ int QuestManager::InsertQuestGlobal( worldserver.SendPacket(pack); safe_delete(pack); - //then create a new one with the new id + /* Create new qglobal data and update zone processes */ pack = new ServerPacket(ServerOP_QGlobalUpdate, sizeof(ServerQGlobalUpdate_Struct)); ServerQGlobalUpdate_Struct *qgu = (ServerQGlobalUpdate_Struct*)pack->pBuffer; qgu->npc_id = npcid; qgu->char_id = charid; qgu->zone_id = zoneid; - if(duration == INT_MAX) - { + if(duration == INT_MAX) { qgu->expdate = 0xFFFFFFFF; } - else - { + else { qgu->expdate = Timer::GetTimeSeconds() + duration; } strcpy((char*)qgu->name, varname); @@ -1420,8 +1414,7 @@ int QuestManager::InsertQuestGlobal( return 0; } -void QuestManager::targlobal(const char *varname, const char *value, const char *duration, int qgNpcid, int qgCharid, int qgZoneid) -{ +void QuestManager::targlobal(const char *varname, const char *value, const char *duration, int qgNpcid, int qgCharid, int qgZoneid) { InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, value, QGVarDuration(duration)); } @@ -1432,15 +1425,24 @@ void QuestManager::delglobal(const char *varname) { int qgZoneid=zone->GetZoneID(); int qgCharid=0; int qgNpcid=owner->GetNPCTypeID(); + + + if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved { qgCharid=initiator->CharacterID(); } - else - { + else { qgCharid=-qgNpcid; // make char id negative npc id as a fudge } + + /* QS: PlayerLogQGlobalUpdate */ + if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){ + std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc); + } + if (!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM quest_globals WHERE name='%s'" @@ -1451,8 +1453,7 @@ void QuestManager::delglobal(const char *varname) { } safe_delete_array(query); - if(zone) - { + if(zone) { ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct)); ServerQGlobalDelete_Struct *qgu = (ServerQGlobalDelete_Struct*)pack->pBuffer; @@ -1701,17 +1702,14 @@ void QuestManager::showgrid(int grid) { pts.push_back(pt); // Retrieve all waypoints for this grid - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `x`,`y`,`z` FROM grid_entries WHERE `gridid`=%i AND `zoneid`=%i ORDER BY `number`",grid,zone->GetZoneID()),errbuf,&result)) - { - while((row = mysql_fetch_row(result))) - { + if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `x`,`y`,`z` FROM grid_entries WHERE `gridid`=%i AND `zoneid`=%i ORDER BY `number`",grid,zone->GetZoneID()),errbuf,&result)) { + while((row = mysql_fetch_row(result))) { pt.x = atof(row[0]); pt.y = atof(row[1]); pt.z = atof(row[2]); pts.push_back(pt); } - mysql_free_result(result); - + mysql_free_result(result); initiator->SendPathPacket(pts); } else // DB query error! diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index 04e37cd59..fc0360aee 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -28,8 +28,7 @@ extern EntityList entity_list; -SpawnEntry::SpawnEntry( uint32 in_NPCType, int in_chance, uint8 in_npc_spawn_limit ) -{ +SpawnEntry::SpawnEntry( uint32 in_NPCType, int in_chance, uint8 in_npc_spawn_limit ) { NPCType = in_NPCType; chance = in_chance; npc_spawn_limit = in_npc_spawn_limit; @@ -57,7 +56,6 @@ uint32 SpawnGroup::GetNPCType() { int npcType = 0; int totalchance = 0; - //check limits on this spawn group and npc type if(!entity_list.LimitCheckGroup(id, group_spawn_limit)) return(0); @@ -68,7 +66,6 @@ uint32 SpawnGroup::GetNPCType() { for(; cur != end; ++cur) { SpawnEntry *se = *cur; - //check limits on this spawn group and npc type if(!entity_list.LimitCheckType(se->NPCType, se->npc_spawn_limit)) continue; @@ -93,7 +90,6 @@ uint32 SpawnGroup::GetNPCType() { roll -= se->chance; } } - //CODER implement random table return npcType; } @@ -149,7 +145,6 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG MYSQL_RES *result; MYSQL_ROW row; - // CODER new spawn code query = 0; if (RunQuery(query, MakeAnyLenString(&query, "SELECT DISTINCT(spawngroupID), spawngroup.name, spawngroup.spawn_limit, spawngroup.dist, spawngroup.max_x, spawngroup.min_x, spawngroup.max_y, spawngroup.min_y, spawngroup.delay, spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay FROM spawn2,spawngroup WHERE spawn2.spawngroupID=spawngroup.ID and spawn2.version=%u and zone='%s'", version, zone_name), errbuf, &result)) { @@ -162,7 +157,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG } else { - std::cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%s' ", query); safe_delete_array(query); return false; } @@ -182,18 +177,17 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG if (sg) sg->AddSpawnEntry(newSpawnEntry); else - std::cout << "Error in SpawngroupID: " << row[0] << std::endl; + _log(ZONE__SPAWNS, "Error in LoadSpawnGroups %s ", query); } mysql_free_result(result); } else { - std::cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%'", query); safe_delete_array(query); return false; } - // CODER end new spawn code return true; } @@ -203,8 +197,6 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g MYSQL_RES *result; MYSQL_ROW row; - - // CODER new spawn code query = 0; if (RunQuery(query, MakeAnyLenString(&query, "SELECT DISTINCT spawngroup.id, spawngroup.name, spawngroup.spawn_limit, spawngroup.dist, spawngroup.max_x, spawngroup.min_x, spawngroup.max_y, spawngroup.min_y, spawngroup.delay, spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay FROM spawngroup WHERE spawngroup.ID='%i'", spawngroupid), errbuf, &result)) { @@ -217,7 +209,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g } else { - std::cerr << "Error2 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query %s", query); safe_delete_array(query); return false; } @@ -233,17 +225,16 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g if (sg) sg->AddSpawnEntry(newSpawnEntry); else - std::cout << "Error in SpawngroupID: " << row[0] << std::endl; + _log(ZONE__SPAWNS, "Error in SpawngroupID: %s ", row[0]); } mysql_free_result(result); } else { - std::cerr << "Error3 in PopulateZoneLists query '" << query << "' " << errbuf << std::endl; + _log(ZONE__SPAWNS, "Error3 in PopulateZoneLists query '%s'", row[0]); safe_delete_array(query); return false; } - // CODER end new spawn code return true; } diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index abc94f8f5..02dab08c5 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -28,8 +28,6 @@ #include "../common/rulesys.h" - - int Mob::GetKickDamage() { int multiple=(GetLevel()*100/5); multiple += 100; @@ -64,11 +62,9 @@ int Mob::GetBashDamage() { } void Mob::ApplySpecialAttackMod(SkillUseTypes skill, int32 &dmg, int32 &mindmg) { - int item_slot = -1; //1: Apply bonus from AC (BOOT/SHIELD/HANDS) est. 40AC=6dmg if (IsClient()){ - switch (skill){ case SkillFlyingKick: @@ -112,10 +108,8 @@ void Mob::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage, if(hate_override > -1) hate = hate_override; - if(skill == SkillBash) - { - if(IsClient()) - { + if(skill == SkillBash){ + if(IsClient()){ ItemInst *item = CastToClient()->GetInv().GetItem(MainSecondary); if(item) { @@ -186,6 +180,10 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { CombatAbility_Struct* ca_atk = (CombatAbility_Struct*) app->pBuffer; + /* Check to see if actually have skill */ + if (!MaxSkill(static_cast(ca_atk->m_skill))) + return; + if(GetTarget()->GetID() != ca_atk->m_target) return; //invalid packet. @@ -274,8 +272,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { return; } - if ((ca_atk->m_atk == 100) && (ca_atk->m_skill == SkillFrenzy)) - { + if ((ca_atk->m_atk == 100) && (ca_atk->m_skill == SkillFrenzy)){ CheckIncreaseSkill(SkillFrenzy, GetTarget(), 10); int AtkRounds = 3; int skillmod = 100*GetSkill(SkillFrenzy)/MaxSkill(SkillFrenzy); @@ -311,8 +308,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { return; } - switch(GetClass()) - { + switch(GetClass()){ case BERSERKER: case WARRIOR: case RANGER: @@ -384,8 +380,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) { } ReuseTime = (ReuseTime*HasteMod)/100; - if(ReuseTime > 0) - { + if(ReuseTime > 0){ p_timers.Start(pTimerCombatAbility, ReuseTime); } } @@ -403,8 +398,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) SkillUseTypes skill_type; //to avoid casting... even though it "would work" uint8 itemslot = MainFeet; - switch(unchecked_type) - { + switch(unchecked_type){ case SkillFlyingKick:{ skill_type = SkillFlyingKick; max_dmg = ((GetSTR()+GetSkill(skill_type)) * RuleI(Combat, FlyingKickBonus) / 100) + 35; @@ -484,8 +478,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type) else ht = ndamage = MakeRandomInt(min_dmg, max_dmg); } - else - { + else{ ht = max_dmg; } } @@ -535,7 +528,6 @@ void Mob::TryBackstab(Mob *other, int ReuseTime) { RogueBackstab(other,false,ReuseTime); if (level > 54) { - if(IsClient() && CastToClient()->CheckDoubleAttack(false)) { if(other->GetHP() > 0) @@ -619,12 +611,10 @@ void Mob::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) } // determine minimum hits - if (level < 51) - { + if (level < 51) { min_hit = (level*15/10); } - else - { + else { // Trumpcard: Replaced switch statement with formula calc. This will give minhit increases all the way to 65. min_hit = (level * ( level*5 - 105)) / 100; } @@ -636,8 +626,7 @@ void Mob::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) if(min_damage){ ndamage = min_hit; } - else - { + else { if (max_hit < min_hit) max_hit = min_hit; @@ -645,7 +634,6 @@ void Mob::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) ndamage = max_hit; else ndamage = MakeRandomInt(min_hit, max_hit); - } } } @@ -792,28 +780,24 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { return; } - SendItemAnimation(GetTarget(), AmmoItem, SkillArchery); - + SendItemAnimation(GetTarget(), AmmoItem, SkillArchery); DoArcheryAttackDmg(GetTarget(), RangeWeapon, Ammo); //EndlessQuiver AA base1 = 100% Chance to avoid consumption arrow. int ChanceAvoidConsume = aabonuses.ConsumeProjectile + itembonuses.ConsumeProjectile + spellbonuses.ConsumeProjectile; - if (!ChanceAvoidConsume || (ChanceAvoidConsume < 100 && MakeRandomInt(0,99) > ChanceAvoidConsume)){ - + if (!ChanceAvoidConsume || (ChanceAvoidConsume < 100 && MakeRandomInt(0,99) > ChanceAvoidConsume)){ DeleteItemInInventory(ammo_slot, 1, true); mlog(COMBAT__RANGED, "Consumed one arrow from slot %d", ammo_slot); } else { mlog(COMBAT__RANGED, "Endless Quiver prevented ammo consumption."); } - CheckIncreaseSkill(SkillArchery, GetTarget(), -15); - + CheckIncreaseSkill(SkillArchery, GetTarget(), -15); CommonBreakInvisible(); } -void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const ItemInst* Ammo, uint16 weapon_damage, int16 chance_mod, int16 focus, int ReuseTime) -{ +void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const ItemInst* Ammo, uint16 weapon_damage, int16 chance_mod, int16 focus, int ReuseTime) { if (!CanDoSpecialAttack(other)) return; @@ -842,8 +826,7 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Item if (focus) //From FcBaseEffects WDmg += WDmg*focus/100; - if((WDmg > 0) || (ADmg > 0)) - { + if((WDmg > 0) || (ADmg > 0)) { if(WDmg < 0) WDmg = 0; if(ADmg < 0) @@ -944,8 +927,7 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Item } //try proc on hits and misses - if((RangeWeapon != nullptr) && GetTarget() && other && !other->HasDied()) - { + if((RangeWeapon != nullptr) && GetTarget() && other && !other->HasDied()){ TryWeaponProc(RangeWeapon, other, MainRange); } @@ -967,8 +949,7 @@ void NPC::RangedAttack(Mob* other) { //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow - if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())) - { + if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())){ mlog(COMBAT__RANGED, "Archery canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; } @@ -1087,9 +1068,7 @@ void NPC::RangedAttack(Mob* other) } } -uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) -{ - +uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) { uint16 MaxDmg = (((2 * wDmg) * GetDamageTable(SkillThrowing)) / 100); if (MaxDmg == 0) @@ -1101,8 +1080,7 @@ uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) TotalDmg = MakeRandomInt(1, MaxDmg); minDmg = 1; - if(GetLevel() > 25) - { + if(GetLevel() > 25){ TotalDmg += ((GetLevel()-25)/3); minDmg += ((GetLevel()-25)/3); minDmg += minDmg * GetMeleeMinDamageMod_SE(SkillThrowing) / 100; @@ -1195,9 +1173,8 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 //consume ammo DeleteItemInInventory(ammo_slot, 1, true); - CheckIncreaseSkill(SkillThrowing, GetTarget()); - - CommonBreakInvisible(); + CheckIncreaseSkill(SkillThrowing, GetTarget()); + CommonBreakInvisible(); } void Mob::DoThrowingAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Item_Struct* item, uint16 weapon_damage, int16 chance_mod,int16 focus, int ReuseTime) @@ -1227,8 +1204,7 @@ void Mob::DoThrowingAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Ite if (GetClass() == ROGUE && (BehindMob(other, GetX(), GetY()))) Assassinate_Dmg = TryAssassinate(other, SkillThrowing, ranged_timer.GetDuration()); - if(WDmg > 0) - { + if(WDmg > 0){ int minDmg = 1; uint16 MaxDmg = GetThrownDamage(WDmg, TotalDmg, minDmg); @@ -1318,8 +1294,7 @@ void Mob::SendItemAnimation(Mob *to, const Item_Struct *item, SkillUseTypes skil safe_delete(outapp); } -void Mob::ProjectileAnimation(Mob* to, int item_id, bool IsArrow, float speed, float angle, float tilt, float arc, const char *IDFile, SkillUseTypes skillInUse) { - +void Mob::ProjectileAnimation(Mob* to, int item_id, bool IsArrow, float speed, float angle, float tilt, float arc, const char *IDFile, SkillUseTypes skillInUse) { if (!to) return; @@ -1453,17 +1428,11 @@ void NPC::DoClassAttacks(Mob *target) { break; case MONK: case MONKGM: { uint8 satype = SkillKick; - if(level > 29) { - satype = SkillFlyingKick; - } else if(level > 24) { - satype = SkillDragonPunch; - } else if(level > 19) { - satype = SkillEagleStrike; - } else if(level > 9) { - satype = SkillTigerClaw; - } else if(level > 4) { - satype = SkillRoundKick; - } + if(level > 29) { satype = SkillFlyingKick; } + else if(level > 24) { satype = SkillDragonPunch; } + else if(level > 19) { satype = SkillEagleStrike; } + else if(level > 9) { satype = SkillTigerClaw; } + else if(level > 4) { satype = SkillRoundKick; } reuse = MonkSpecialAttack(target, satype); reuse *= 1000; @@ -1472,8 +1441,7 @@ void NPC::DoClassAttacks(Mob *target) { } case WARRIOR: case WARRIORGM:{ if(level >= RuleI(Combat, NPCBashKickLevel)){ - if(MakeRandomInt(0, 100) > 25) //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference. - { + if(MakeRandomInt(0, 100) > 25){ //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference. DoAnim(animKick); int32 dmg = 0; @@ -1494,8 +1462,7 @@ void NPC::DoClassAttacks(Mob *target) { DoSpecialAttackDamage(target, SkillKick, dmg, 1, -1, reuse); did_attack = true; } - else - { + else { DoAnim(animTailRake); int32 dmg = 0; @@ -1518,8 +1485,7 @@ void NPC::DoClassAttacks(Mob *target) { } break; } - case BERSERKER: case BERSERKERGM: - { + case BERSERKER: case BERSERKERGM:{ int AtkRounds = 3; int32 max_dmg = 26 + ((GetLevel()-6) * 2); int32 min_dmg = 0; @@ -1535,8 +1501,7 @@ void NPC::DoClassAttacks(Mob *target) { reuse = FrenzyReuseTime * 1000; - while(AtkRounds > 0) { - + while(AtkRounds > 0) { if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){ DoSpecialAttackDamage(GetTarget(), SkillFrenzy, max_dmg, min_dmg, -1 , reuse, true); } @@ -1574,8 +1539,7 @@ void NPC::DoClassAttacks(Mob *target) { } case CLERIC: case CLERICGM: //clerics can bash too. case SHADOWKNIGHT: case SHADOWKNIGHTGM: - case PALADIN: case PALADINGM: - { + case PALADIN: case PALADINGM:{ if(level >= RuleI(Combat, NPCBashKickLevel)){ DoAnim(animTailRake); int32 dmg = 0; @@ -1615,8 +1579,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) return; //check range for all these abilities, they are all close combat stuff - if(!CombatRange(ca_target)) - { + if(!CombatRange(ca_target)){ return; } @@ -1638,10 +1601,8 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) uint16 skill_to_use = -1; - if (skill == -1){ - - switch(GetClass()) - { + if (skill == -1){ + switch(GetClass()){ case WARRIOR: case RANGER: case BEASTLORD: @@ -1692,14 +1653,11 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) if(skill_to_use == -1) return; - if(skill_to_use == SkillBash) - { - if (ca_target!=this) - { + if(skill_to_use == SkillBash) { + if (ca_target!=this) { DoAnim(animTailRake); - if(GetWeaponDamage(ca_target, GetInv().GetItem(MainSecondary)) <= 0 && - GetWeaponDamage(ca_target, GetInv().GetItem(MainShoulders)) <= 0){ + if(GetWeaponDamage(ca_target, GetInv().GetItem(MainSecondary)) <= 0 && GetWeaponDamage(ca_target, GetInv().GetItem(MainShoulders)) <= 0){ dmg = -5; } else{ @@ -1720,16 +1678,14 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) DoSpecialAttackDamage(ca_target, SkillBash, dmg, 1,-1,ReuseTime); - if(ReuseTime > 0 && !IsRiposte) - { + if(ReuseTime > 0 && !IsRiposte) { p_timers.Start(pTimerCombatAbility, ReuseTime); } } return; } - if(skill_to_use == SkillFrenzy) - { + if(skill_to_use == SkillFrenzy){ CheckIncreaseSkill(SkillFrenzy, GetTarget(), 10); int AtkRounds = 3; int skillmod = 100*GetSkill(SkillFrenzy)/MaxSkill(SkillFrenzy); @@ -1763,10 +1719,8 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) return; } - if(skill_to_use == SkillKick) - { - if(ca_target!=this) - { + if(skill_to_use == SkillKick){ + if(ca_target!=this){ DoAnim(animKick); if(GetWeaponDamage(ca_target, GetInv().GetItem(MainFeet)) <= 0){ @@ -1790,12 +1744,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) } } - if(skill_to_use == SkillFlyingKick || - skill_to_use == SkillDragonPunch || - skill_to_use == SkillEagleStrike || - skill_to_use == SkillTigerClaw || - skill_to_use == SkillRoundKick) - { + if(skill_to_use == SkillFlyingKick || skill_to_use == SkillDragonPunch || skill_to_use == SkillEagleStrike || skill_to_use == SkillTigerClaw || skill_to_use == SkillRoundKick) { ReuseTime = MonkSpecialAttack(ca_target, skill_to_use) - 1; MonkSpecialAttack(ca_target, skill_to_use); @@ -1809,8 +1758,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) int MonkSPA [5] = { SkillFlyingKick, SkillDragonPunch, SkillEagleStrike, SkillTigerClaw, SkillRoundKick }; MonkSpecialAttack(ca_target, MonkSPA[MakeRandomInt(0,4)]); - int TripleChance = 25; - + int TripleChance = 25; if (bDoubleSpecialAttack > 100) TripleChance += TripleChance*(100-bDoubleSpecialAttack)/100; @@ -1820,8 +1768,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) } } - if(skill_to_use == SkillBackstab) - { + if(skill_to_use == SkillBackstab){ ReuseTime = BackstabReuseTime-1; if (IsRiposte) @@ -1831,8 +1778,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte) } ReuseTime = (ReuseTime*HasteMod)/100; - if(ReuseTime > 0 && !IsRiposte) - { + if(ReuseTime > 0 && !IsRiposte){ p_timers.Start(pTimerCombatAbility, ReuseTime); } } @@ -1899,8 +1845,7 @@ void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus) { tauntchance /= 100.0f; - if (tauntchance > MakeRandomFloat(0, 1)) { - + if (tauntchance > MakeRandomFloat(0, 1)) { if (hate_top && hate_top != this){ newhate = (who->GetNPCHate(hate_top) - who->GetNPCHate(this)) + 1; who->CastToNPC()->AddToHateList(this, newhate); @@ -1922,8 +1867,7 @@ void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus) { if (HasSkillProcs()) TrySkillProc(who, SkillTaunt, TauntReuseTime*1000); - - + if (Success && HasSkillProcSuccess()) TrySkillProc(who, SkillTaunt, TauntReuseTime*1000, true); } @@ -1944,8 +1888,7 @@ void Mob::InstillDoubt(Mob *who) { if(!CombatRange(who)) return; - if(IsClient()) - { + if(IsClient()) { CastToClient()->CheckIncreaseSkill(SkillIntimidation, who, 10); } @@ -1975,14 +1918,12 @@ void Mob::InstillDoubt(Mob *who) { } } -uint32 Mob::TryHeadShot(Mob* defender, SkillUseTypes skillInUse) { - +uint32 Mob::TryHeadShot(Mob* defender, SkillUseTypes skillInUse) { //Only works on YOUR target. if(defender && (defender->GetBodyType() == BT_Humanoid) && !defender->IsClient() && (skillInUse == SkillArchery) && (GetTarget() == defender)) { - uint32 HeadShot_Dmg = aabonuses.HeadShot[1] + spellbonuses.HeadShot[1] + itembonuses.HeadShot[1]; - + uint32 HeadShot_Dmg = aabonuses.HeadShot[1] + spellbonuses.HeadShot[1] + itembonuses.HeadShot[1]; uint8 HeadShot_Level = 0; //Get Highest Headshot Level HeadShot_Level = aabonuses.HSLevel; if (HeadShot_Level < spellbonuses.HSLevel) @@ -1990,8 +1931,7 @@ uint32 Mob::TryHeadShot(Mob* defender, SkillUseTypes skillInUse) { else if (HeadShot_Level < itembonuses.HSLevel) HeadShot_Level = itembonuses.HSLevel; - if(HeadShot_Dmg && HeadShot_Level && (defender->GetLevel() <= HeadShot_Level)){ - + if(HeadShot_Dmg && HeadShot_Level && (defender->GetLevel() <= HeadShot_Level)){ float ProcChance = GetSpecialProcChances(MainRange); if(ProcChance > MakeRandomFloat(0,1)) return HeadShot_Dmg; @@ -2084,7 +2024,7 @@ float Mob::GetAssassinateProcChances(uint16 ReuseTime) ProcChance += ProcChance * ProcBonus / 100.0f; } else { - /*Kayen: Unable to find data on old proc rate of assassinate, no idea if our formula is real or made up.*/ + /* Kayen: Unable to find data on old proc rate of assassinate, no idea if our formula is real or made up. */ ProcChance = (10 + (static_cast(mydex/10) + static_cast(itembonuses.HeroicDEX /10)))/100.0f; } @@ -2097,8 +2037,10 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes if (!CanDoSpecialAttack(other)) return; - //For spells using skill value 98 (feral swipe ect) server sets this to 67 automatically. - //Kayen: This is unlikely to be completely accurate but use OFFENSE skill value for these effects. + /* + For spells using skill value 98 (feral swipe ect) server sets this to 67 automatically. + Kayen: This is unlikely to be completely accurate but use OFFENSE skill value for these effects. + */ if (skillinuse == SkillBegging) skillinuse = SkillOffense; @@ -2107,8 +2049,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes int Hand = MainPrimary; if (hate == 0 && weapon_damage > 1) hate = weapon_damage; - if(weapon_damage > 0){ - + if(weapon_damage > 0){ if (focus) //From FcBaseEffects weapon_damage += weapon_damage*focus/100; @@ -2118,12 +2059,10 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes } int32 min_hit = 1; - int32 max_hit = (2*weapon_damage*GetDamageTable(skillinuse)) / 100; - - if(GetLevel() >= 28 && IsWarriorClass() ) - { - int ucDamageBonus = GetWeaponDamageBonus((const Item_Struct*) nullptr ); + int32 max_hit = (2 * weapon_damage*GetDamageTable(skillinuse)) / 100; + if(GetLevel() >= 28 && IsWarriorClass() ) { + int ucDamageBonus = GetWeaponDamageBonus((const Item_Struct*) nullptr ); min_hit += (int) ucDamageBonus; max_hit += (int) ucDamageBonus; hate += ucDamageBonus; @@ -2142,8 +2081,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes } } - ApplySpecialAttackMod(skillinuse, max_hit, min_hit); - + ApplySpecialAttackMod(skillinuse, max_hit, min_hit); min_hit += min_hit * GetMeleeMinDamageMod_SE(skillinuse) / 100; if(max_hit < min_hit) @@ -2204,8 +2142,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes TrySkillProc(other, skillinuse, ReuseTime, true); } -bool Mob::CanDoSpecialAttack(Mob *other) -{ +bool Mob::CanDoSpecialAttack(Mob *other) { //Make sure everything is valid before doing any attacks. if (!other) { SetTarget(nullptr); @@ -2215,8 +2152,7 @@ bool Mob::CanDoSpecialAttack(Mob *other) if(!GetTarget()) SetTarget(other); - if ((other == nullptr || ((IsClient() && CastToClient()->dead) || (other->IsClient() && other->CastToClient()->dead)) - || HasDied() || (!IsAttackAllowed(other)))) { + if ((other == nullptr || ((IsClient() && CastToClient()->dead) || (other->IsClient() && other->CastToClient()->dead)) || HasDied() || (!IsAttackAllowed(other)))) { return false; } diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 994ebdc5d..3da32c03c 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -34,18 +34,16 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) #include "../common/features.h" #include "quest_parser_collection.h" #include "mob.h" +#include "queryserv.h" +extern QueryServ* QServ; TaskManager::TaskManager() { - for(int i=0; iActivityCount; j++) { @@ -62,11 +60,8 @@ TaskManager::~TaskManager() { } bool TaskManager::LoadTaskSets() { - - const char *TaskSetQuery = "SELECT `id`, `taskid` from `tasksets` WHERE `id` > 0 AND `id` < %i " "AND `taskid` >= 0 AND `taskid` < %i ORDER BY `id`, `taskid` ASC"; - const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTaskSets: %s"; char errbuf[MYSQL_ERRMSG_SIZE]; @@ -1985,12 +1980,17 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T // Inform the client the task has been updated, both by a chat message c->Message(0, "Your task '%s' has been updated.", Task->Title); - if(Task->Activity[ActivityID].GoalMethod != METHODQUEST) - { + if(Task->Activity[ActivityID].GoalMethod != METHODQUEST) { char buf[24]; snprintf(buf, 23, "%d %d", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID); buf[23] = '\0'; parse->EventPlayer(EVENT_TASK_STAGE_COMPLETE, c, buf, 0); + + /* QS: PlayerLogTaskUpdates :: Update */ + if (RuleB(QueryServ, PlayerLogTaskUpdates)){ + std::string event_desc = StringFormat("Task Stage Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc); + } } // If this task is now complete, the Completed tasks will have been @@ -2002,6 +2002,12 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T buf[23] = '\0'; parse->EventPlayer(EVENT_TASK_COMPLETE, c, buf, 0); + /* QS: PlayerLogTaskUpdates :: Complete */ + if (RuleB(QueryServ, PlayerLogTaskUpdates)){ + std::string event_desc = StringFormat("Task Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc); + } + taskmanager->SendCompletedTasksToClient(c, this); c->SendTaskActivityComplete(ActiveTasks[TaskIndex].TaskID, 0, TaskIndex, false); taskmanager->SaveClientState(c, this); @@ -2011,6 +2017,7 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T // If Experience and/or cash rewards are set, reward them from the task even if RewardMethod is METHODQUEST RewardTask(c, Task); //RemoveTask(c, TaskIndex); + } } diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 4d4edb344..e8e787de0 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -34,6 +34,9 @@ #include "../common/string_util.h" #include "../common/rulesys.h" #include "quest_parser_collection.h" +#include "queryserv.h" + +extern QueryServ* QServ; static const SkillUseTypes TradeskillUnknown = Skill1HBlunt; /* an arbitrary non-tradeskill */ @@ -1067,7 +1070,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if(over_trivial < 0) CheckIncreaseTradeskill(bonusstat, stat_modifier, skillup_modifier, success_modifier, spec->tradeskill); - Message_StringID(4,TRADESKILL_SUCCEED,spec->name.c_str()); + Message_StringID(4, TRADESKILL_SUCCEED, spec->name.c_str()); _log(TRADESKILLS__TRACE, "Tradeskill success"); @@ -1076,16 +1079,24 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { //should we check this crap? SummonItem(itr->first, itr->second); item = database.GetItem(itr->first); - if (this->GetGroup()) - { - entity_list.MessageGroup(this,true,MT_Skills,"%s has successfully fashioned %s!",GetName(),item->Name); + if (this->GetGroup()) { + entity_list.MessageGroup(this, true, MT_Skills, "%s has successfully fashioned %s!", GetName(), item->Name); } + + /* QS: Player_Log_Trade_Skill_Events */ + if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){ + std::string event_desc = StringFormat("Success :: fashioned recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc); + } + if(RuleB(TaskSystem, EnableTaskSystem)) UpdateTasksForItem(ActivityTradeSkill, itr->first, itr->second); ++itr; } return(true); - } else { + } + /* Tradeskill Fail */ + else { success_modifier = 2; // Halves the chance if(over_trivial < 0) @@ -1097,6 +1108,13 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { if (this->GetGroup()) { entity_list.MessageGroup(this,true,MT_Skills,"%s was unsuccessful in %s tradeskill attempt.",GetName(),this->GetGender() == 0 ? "his" : this->GetGender() == 1 ? "her" : "its"); + + } + + /* QS: Player_Log_Trade_Skill_Events */ + if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){ + std::string event_desc = StringFormat("Failed :: recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc); } itr = spec->onfail.begin(); @@ -1106,6 +1124,8 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { ++itr; } + /* Salvage Item rolls */ + // Rolls on each item, is possible to return everything int SalvageChance = aabonuses.SalvageChance + itembonuses.SalvageChance + spellbonuses.SalvageChance; // Skip check if not a normal TS or if a quest recipe these should be nofail, but check amyways diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 75b7bddf6..b50e43d33 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -25,7 +25,9 @@ #include "../common/string_util.h" #include "string_ids.h" #include "quest_parser_collection.h" +#include "queryserv.h" +extern QueryServ* QServ; extern WorldServer worldserver; extern Zone* zone; @@ -147,7 +149,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { } } - //make sure its a valid zone. + /* Check for Valid Zone */ const char *target_zone_name = database.GetZoneName(target_zone_id); if(target_zone_name == nullptr) { //invalid zone... @@ -157,7 +159,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { return; } - //load up the safe coords, restrictions, and verify the zone name + /* Load up the Safe Coordinates, restrictions and verify the zone name*/ float safe_x, safe_y, safe_z; int16 minstatus = 0; uint8 minlevel = 0; @@ -327,15 +329,19 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc SendLogoutPackets(); - //dont clear aggro until the zone is successful + /* QS: PlayerLogZone */ + if (RuleB(QueryServ, PlayerLogZone)){ + std::string event_desc = StringFormat("Zoning :: zoneid:%u instid:%u x:%4.2f y:%4.2f z:%4.2f h:%4.2f zonemode:%d from zoneid:%u instid:%i", zone_id, instance_id, dest_x, dest_y, dest_z, dest_h, zone_mode, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Zoning, this->CharacterID(), event_desc); + } + + /* Dont clear aggro until the zone is successful */ entity_list.RemoveFromHateLists(this); if(this->GetPet()) entity_list.RemoveFromHateLists(this->GetPet()); - LogFile->write(EQEMuLog::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f", - m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id, - dest_x, dest_y, dest_z); + LogFile->write(EQEMuLog::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f", m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id, dest_x, dest_y, dest_z); //set the player's coordinates in the new zone so they have them //when they zone into it From 8529384b009a56214fc8a888374d811b62319f08 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:00:40 -0700 Subject: [PATCH 173/217] SendMail converted to QueryDatabase --- ucs/database.cpp | 78 +++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index b704a271b..6bdf2b1e8 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -425,72 +425,62 @@ void Database::SendBody(Client *client, int messageNumber) { safe_delete(outapp); } -bool Database::SendMail(std::string Recipient, std::string From, std::string Subject, std::string Body, std::string RecipientsString) { +bool Database::SendMail(std::string recipient, std::string from, std::string subject, std::string body, std::string recipientsString) { - int CharacterID; + int characterID; - std::string CharacterName; + std::string characterName; //printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str()); - std::string::size_type LastPeriod = Recipient.find_last_of("."); + auto lastPeriod = recipient.find_last_of("."); - if(LastPeriod == std::string::npos) - CharacterName = Recipient; + if(lastPeriod == std::string::npos) + characterName = recipient; else - CharacterName = Recipient.substr(LastPeriod+1); + characterName = recipient.substr(lastPeriod+1); - CharacterName[0] = toupper(CharacterName[0]); + characterName[0] = toupper(characterName[0]); - for(unsigned int i = 1; i < CharacterName.length(); i++) - CharacterName[i] = tolower(CharacterName[i]); + for(unsigned int i = 1; i < characterName.length(); i++) + characterName[i] = tolower(characterName[i]); - CharacterID = FindCharacter(CharacterName.c_str()); + characterID = FindCharacter(characterName.c_str()); - _log(UCS__TRACE, "SendMail: CharacterID for recipient %s is %i", CharacterName.c_str(), CharacterID); + _log(UCS__TRACE, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID); - if(CharacterID <= 0) return false; + if(characterID <= 0) + return false; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; + char *escSubject = new char[subject.length() * 2 + 1]; + char *escBody = new char[body.length() * 2 + 1]; - char *EscSubject = new char[Subject.length() * 2 + 1]; - char *EscBody = new char[Body.length() * 2 + 1]; + DoEscapeString(escSubject, subject.c_str(), subject.length()); + DoEscapeString(escBody, body.c_str(), body.length()); - DoEscapeString(EscSubject, Subject.c_str(), Subject.length()); - DoEscapeString(EscBody, Body.c_str(), Body.length()); - - const char *MailQuery="INSERT INTO `mail` (`charid`, `timestamp`, `from`, `subject`, `body`, `to`, `status`) " - "VALUES ('%i', %i, '%s', '%s', '%s', '%s', %i)"; - - uint32 LastMsgID; - - int Now = time(nullptr); // time returns a 64 bit int on Windows at least, which vsnprintf doesn't like. - - if(!RunQuery(query, MakeAnyLenString(&query, MailQuery, CharacterID, Now, From.c_str(), EscSubject, EscBody, - RecipientsString.c_str(), 1), errbuf, 0, 0, &LastMsgID)) { - - _log(UCS__ERROR, "SendMail: Query %s failed with error %s", query, errbuf); - - safe_delete_array(EscSubject); - safe_delete_array(EscBody); - safe_delete_array(query); + int now = time(nullptr); // time returns a 64 bit int on Windows at least, which vsnprintf doesn't like. + std::string query = StringFormat("INSERT INTO `mail` " + "(`charid`, `timestamp`, `from`, `subject`, `body`, `to`, `status`) " + "VALUES ('%i', %i, '%s', '%s', '%s', '%s', %i)", + characterID, now, from.c_str(), escSubject, escBody, + recipientsString.c_str(), 1); + safe_delete_array(escSubject); + safe_delete_array(escBody); + auto results = QueryDatabase(query); + if(!results.Success()) { + _log(UCS__ERROR, "SendMail: Query %s failed with error %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - _log(UCS__TRACE, "MessageID %i generated, from %s, to %s", LastMsgID, From.c_str(), Recipient.c_str()); + _log(UCS__TRACE, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str()); - safe_delete_array(EscSubject); - safe_delete_array(EscBody); - safe_delete_array(query); - Client *c = CL->IsCharacterOnline(CharacterName); + Client *client = CL->IsCharacterOnline(characterName); - if(c) { - std::string FQN = GetMailPrefix() + From; - - c->SendNotification(c->GetMailBoxNumber(CharacterName), Subject, FQN, LastMsgID); + if(client) { + std::string FQN = GetMailPrefix() + from; + client->SendNotification(client->GetMailBoxNumber(characterName), subject, FQN, results.LastInsertedID()); } MailMessagesSent++; From c9bd662b57cfb01d62b8070ac4cd5b6aac6373f6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:07:04 -0700 Subject: [PATCH 174/217] SetMessageStatus converted to QueryDatabase --- ucs/database.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 6bdf2b1e8..4e47b27ed 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -428,11 +428,8 @@ void Database::SendBody(Client *client, int messageNumber) { bool Database::SendMail(std::string recipient, std::string from, std::string subject, std::string body, std::string recipientsString) { int characterID; - std::string characterName; - //printf("Database::SendMail(%s, %s, %s)\n", Recipient.c_str(), From.c_str(), Subject.c_str()); - auto lastPeriod = recipient.find_last_of("."); if(lastPeriod == std::string::npos) @@ -488,22 +485,21 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub return true; } -void Database::SetMessageStatus(int MessageNumber, int Status) { +void Database::SetMessageStatus(int messageNumber, int status) { - _log(UCS__TRACE, "SetMessageStatus %i %i", MessageNumber, Status); + _log(UCS__TRACE, "SetMessageStatus %i %i", messageNumber, status); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + if(status == 0) { + std::string query = StringFormat("DELETE FROM `mail` WHERE `msgid` = %i", messageNumber); + auto results = QueryDatabase(query); + return; + } - if(Status == 0) - RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `msgid`=%i", MessageNumber), errbuf); - else if (!RunQuery(query, MakeAnyLenString(&query, "update `mail` set `status`=%i where `msgid`=%i", Status, MessageNumber), errbuf)) { + std::string query = StringFormat("UPDATE `mail` SET `status` = %i WHERE `msgid`=%i", status, messageNumber); + auto results = QueryDatabase(query); + if (!results.Success()) + _log(UCS__ERROR, "Error updating status %s, %s", query.c_str(), results.ErrorMessage().c_str()); - _log(UCS__ERROR, "Error updating status %s, %s", query, errbuf); - - } - - safe_delete_array(query); } void Database::ExpireMail() { From 163906e0f029618e62192724b5138a794adc6d92 Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 00:09:09 -0500 Subject: [PATCH 175/217] Nix fix --- zone/entity.h | 2 +- zone/queryserv.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/entity.h b/zone/entity.h index 5caab8a30..cc302fe75 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -398,7 +398,7 @@ public: void UpdateFindableNPCState(NPC *n, bool Remove); void HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode); - uint16 EntityList::GetClientCount(); + uint16 GetClientCount(); void GetMobList(std::list &m_list); void GetNPCList(std::list &n_list); void GetMercList(std::list &n_list); diff --git a/zone/queryserv.h b/zone/queryserv.h index 657dc0b30..e0c7d4e56 100644 --- a/zone/queryserv.h +++ b/zone/queryserv.h @@ -28,8 +28,8 @@ class QueryServ{ public: QueryServ(); ~QueryServ(); - void QueryServ::SendQuery(std::string Query); - void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc); + void SendQuery(std::string Query); + void PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc); }; #endif /* QUERYSERV_ZONE_H */ \ No newline at end of file From 20e978b6769f6096775fac3bdcff9e2a56356d4a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:16:37 -0700 Subject: [PATCH 176/217] ExpiredMail converted to QueryDatabase --- ucs/database.cpp | 68 +++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 4e47b27ed..d66b41418 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -506,58 +506,48 @@ void Database::ExpireMail() { _log(UCS__INIT, "Expiring mail..."); - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - uint32 AffectedRows; - - if (!RunQuery(query,MakeAnyLenString(&query, "select COUNT(*) from `mail` "),errbuf,&result)){ - _log(UCS__ERROR, "Unable to get message count from database. %s %s", query, errbuf); - safe_delete_array(query); - return ; + std::string query = "SELECT COUNT(*) FROM `mail`"; + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(query); - row = mysql_fetch_row(result); + auto row = results.begin(); _log(UCS__INIT, "There are %s messages in the database.", row[0]); - mysql_free_result(result); - // Expire Trash if(RuleI(Mail, ExpireTrash) >= 0) { - if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=4 and `timestamp` < %i", - time(nullptr) - RuleI(Mail, ExpireTrash)), errbuf, 0, &AffectedRows)) { - _log(UCS__INIT, "Expired %i trash messages.", AffectedRows); - } - else { - _log(UCS__ERROR, "Error expiring trash messages, %s %s", query, errbuf); - } - safe_delete_array(query); + query = StringFormat("DELETE FROM `mail` WHERE `status`=4 AND `timestamp` < %i", + time(nullptr) - RuleI(Mail, ExpireTrash)); + results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__INIT, "Expired %i trash messages.", results.RowsAffected()); + else + _log(UCS__ERROR, "Error expiring trash messages, %s %s", query.c_str(), results.ErrorMessage().c_str()); } + // Expire Read if(RuleI(Mail, ExpireRead) >= 0) { - if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=3 and `timestamp` < %i", - time(nullptr) - RuleI(Mail, ExpireRead)), errbuf, 0, &AffectedRows)) { - _log(UCS__INIT, "Expired %i read messages.", AffectedRows); - } - else { - _log(UCS__ERROR, "Error expiring read messages, %s %s", query, errbuf); - } - safe_delete_array(query); + query = StringFormat("DELETE FROM `mail` WHERE `status` = 3 AND `timestamp` < %i", + time(nullptr) - RuleI(Mail, ExpireRead)); + results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__INIT, "Expired %i read messages.", results.RowsAffected()); + else + _log(UCS__ERROR, "Error expiring read messages, %s %s", query.c_str(), results.ErrorMessage().c_str()); } + // Expire Unread if(RuleI(Mail, ExpireUnread) >= 0) { - if(RunQuery(query, MakeAnyLenString(&query, "delete from `mail` where `status`=1 and `timestamp` < %i", - time(nullptr) - RuleI(Mail, ExpireUnread)), errbuf, 0, &AffectedRows)) { - _log(UCS__INIT, "Expired %i unread messages.", AffectedRows); - } - else { - _log(UCS__ERROR, "Error expiring unread messages, %s %s", query, errbuf); - } - safe_delete_array(query); + query = StringFormat("DELETE FROM `mail` WHERE `status`=1 AND `timestamp` < %i", + time(nullptr) - RuleI(Mail, ExpireUnread)); + results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__INIT, "Expired %i unread messages.", results.RowsAffected()); + else + _log(UCS__ERROR, "Error expiring unread messages, %s %s", query.c_str(), results.ErrorMessage().c_str()); } } From cdd1e173483e975e236a2888bdd5435394c7f1c9 Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 00:17:31 -0500 Subject: [PATCH 177/217] Cosmetic log fix from merge --- zone/perl_client.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 22d26f174..72e2865c9 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1312,15 +1312,15 @@ XS(XS_Client_MovePCInstance) if (THIS->IsMerc()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); else if (THIS->IsNPC()) - _log(CLIENT__ERROR, "Perl(XS_MovePCInstance) attempted to process a type NPC reference"); + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); #ifdef BOTS else if (THIS->IsBot()) _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); #endif else - _log(CLIENT__ERROR, "Perl(XS_MovePCInstance) attempted to process an Unknown type reference"); + _log(CLIENT__ERROR, "Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); - Perl_croak(aTHX_ "THIS is not of type Client"); + Perl_croak(aTHX_ "THIS is not of type Client"); Perl_croak(aTHX_ "THIS is not of type Client"); } From 9d5f427f5738d1e17538a8e9cd28c98f5e01f8b9 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:20:16 -0700 Subject: [PATCH 178/217] AddFriendOrIgnore converted to QueryDatabase --- ucs/database.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index d66b41418..36e2b1251 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -551,22 +551,17 @@ void Database::ExpireMail() { } } -void Database::AddFriendOrIgnore(int CharID, int Type, std::string Name) { +void Database::AddFriendOrIgnore(int charID, int type, std::string name) { - const char *FriendsQuery="INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')"; - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - - if(!RunQuery(query, MakeAnyLenString(&query, FriendsQuery, CharID, Type, CapitaliseName(Name).c_str()), errbuf, 0, 0)) - _log(UCS__ERROR, "Error adding friend/ignore, query was %s : %s", query, errbuf); + std::string query = StringFormat("INSERT INTO `friends` (`charid`, `type`, `name`) " + "VALUES('%i', %i, '%s')", + charID, type, CapitaliseName(name).c_str()); + auto results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__ERROR, "Error adding friend/ignore, query was %s : %s", query.c_str(), results.ErrorMessage().c_str()); else - _log(UCS__TRACE, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", - CharID, Type, Name.c_str()); + _log(UCS__TRACE, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str()); - - safe_delete_array(query); } void Database::RemoveFriendOrIgnore(int CharID, int Type, std::string Name) { From c1469a3a8e1a4f592aa70bd1ef9e380153d5289e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:22:49 -0700 Subject: [PATCH 179/217] RemoveFriendOrIgnore converted to QueryDatabase --- ucs/database.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 36e2b1251..880972152 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -564,21 +564,17 @@ void Database::AddFriendOrIgnore(int charID, int type, std::string name) { } -void Database::RemoveFriendOrIgnore(int CharID, int Type, std::string Name) { +void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) { - const char *FriendsQuery="DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'"; - - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - - if(!RunQuery(query, MakeAnyLenString(&query, FriendsQuery, CharID, Type, CapitaliseName(Name).c_str()), errbuf, 0, 0)) - _log(UCS__ERROR, "Error removing friend/ignore, query was %s", query); + std::string query = StringFormat("DELETE FROM `friends` WHERE `charid` = %i " + "AND `type` = %i AND `name` = '%s'", + charID, type, CapitaliseName(name).c_str()); + auto results = QueryDatabase(query); + if(!results.Success()) + _log(UCS__ERROR, "Error removing friend/ignore, query was %s", query.c_str()); else - _log(UCS__TRACE, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", - CharID, Type, Name.c_str()); + _log(UCS__TRACE, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str()); - - safe_delete_array(query); } void Database::GetFriendsAndIgnore(int CharID, std::vector &Friends, std::vector &Ignorees) { From 4e10b77980c32a3e943d2daff4559113b4c4613f Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 00:28:45 -0500 Subject: [PATCH 180/217] 2nd Nix fix --- zone/queryserv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index 8ccf38899..ae414a7ca 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -43,6 +43,6 @@ void QueryServ::SendQuery(std::string Query){ } void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc){ - std::string query = StringFormat("INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", Event_Type, Character_ID, EscapeString(Event_Desc.c_str())); + std::string query = StringFormat("INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", Event_Type, Character_ID, EscapeString(Event_Desc)); SendQuery(query); } \ No newline at end of file From 232d61b98394cbe9a46babc22b14b2747cd64c85 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 22:33:05 -0700 Subject: [PATCH 181/217] GetFriendAndIgnore converted to QueryDatabase --- ucs/database.cpp | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/ucs/database.cpp b/ucs/database.cpp index 880972152..d3c44174c 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -577,44 +577,29 @@ void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) { } -void Database::GetFriendsAndIgnore(int CharID, std::vector &Friends, std::vector &Ignorees) { +void Database::GetFriendsAndIgnore(int charID, std::vector &friends, std::vector &ignorees) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - const char *FriendsQuery="select `type`, `name` from `friends` WHERE `charid`=%i"; - - if (!RunQuery(query,MakeAnyLenString(&query, FriendsQuery, CharID),errbuf,&result)){ - - _log(UCS__ERROR, "GetFriendsAndIgnore query error %s, %s", query, errbuf); - - safe_delete_array(query); - - return ; + std::string query = StringFormat("select `type`, `name` FROM `friends` WHERE `charid`=%i", charID); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(UCS__ERROR, "GetFriendsAndIgnore query error %s, %s", query.c_str(), results.ErrorMessage().c_str()); + return; } - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - - std::string Name = row[1]; + for (auto row = results.begin(); row != results.end(); ++row) { + std::string name = row[1]; if(atoi(row[0]) == 0) { - Ignorees.push_back(Name); - _log(UCS__TRACE, "Added Ignoree from DB %s", Name.c_str()); - } - else - { - Friends.push_back(Name); - _log(UCS__TRACE, "Added Friend from DB %s", Name.c_str()); + ignorees.push_back(name); + _log(UCS__TRACE, "Added Ignoree from DB %s", name.c_str()); + continue; } + + friends.push_back(name); + _log(UCS__TRACE, "Added Friend from DB %s", name.c_str()); } - mysql_free_result(result); - - return; } From b112dfe860ee5a14010881879a899638d2769450 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 24 Aug 2014 01:48:29 -0400 Subject: [PATCH 182/217] Fix gcc compile error --- zone/queryserv.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index ae414a7ca..a7f4127d5 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -34,15 +34,18 @@ QueryServ::QueryServ(){ QueryServ::~QueryServ(){ } -void QueryServ::SendQuery(std::string Query){ - ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, strlen(Query.c_str()) + 5); +void QueryServ::SendQuery(std::string Query) +{ + ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, strlen(Query.c_str()) + 5); pack->WriteUInt32(strlen(Query.c_str())); /* Pack Query String Size so it can be dynamically broken out at queryserv */ pack->WriteString(Query.c_str()); /* Query */ - worldserver.SendPacket(pack); - safe_delete(pack); + worldserver.SendPacket(pack); + safe_delete(pack); } void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc){ - std::string query = StringFormat("INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", Event_Type, Character_ID, EscapeString(Event_Desc)); - SendQuery(query); -} \ No newline at end of file + std::string query = StringFormat( + "INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", + Event_Type, Character_ID, EscapeString(Event_Desc).c_str()); + SendQuery(query); +} From 0b486b3f763f5cd342e6936de0a1ccd2605fa948 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 24 Aug 2014 02:02:42 -0400 Subject: [PATCH 183/217] strlen to std::string::length Minor style nits! --- zone/queryserv.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index a7f4127d5..ad7de0424 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -36,14 +36,15 @@ QueryServ::~QueryServ(){ void QueryServ::SendQuery(std::string Query) { - ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, strlen(Query.c_str()) + 5); - pack->WriteUInt32(strlen(Query.c_str())); /* Pack Query String Size so it can be dynamically broken out at queryserv */ + ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, Query.length() + 5); + pack->WriteUInt32(Query.length()); /* Pack Query String Size so it can be dynamically broken out at queryserv */ pack->WriteString(Query.c_str()); /* Query */ worldserver.SendPacket(pack); safe_delete(pack); } -void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc){ +void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc) +{ std::string query = StringFormat( "INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", Event_Type, Character_ID, EscapeString(Event_Desc).c_str()); From cef1dfd0c02a063b541dd7370f3d93c24c974cea Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 02:50:39 -0500 Subject: [PATCH 184/217] Query Fix for SendQuery (Temporary) --- zone/client_packet.cpp | 4 ++-- zone/queryserv.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 659765ba8..f35ec0565 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12884,8 +12884,8 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) { /* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/ if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ - std::string event_desc = StringFormat("Sold to Merchant :: itemid:%i npcid:%i alt_currency_id:%i cost:%i in zoneid:%i instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID()); - QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + std::string event_desc = StringFormat("Sold to Merchant :: itemid:%u npcid:%u alt_currency_id:%u cost:%u in zoneid:%u instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID()); + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } FastQueuePacket(&outapp); diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index ad7de0424..2b02d193c 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -47,6 +47,6 @@ void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Eve { std::string query = StringFormat( "INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", - Event_Type, Character_ID, EscapeString(Event_Desc).c_str()); + Event_Type, Character_ID, EscapeString(Event_Desc.c_str()).c_str()); SendQuery(query); -} +} \ No newline at end of file From 52ae78709b207463f6299cd9d6a36b141358be6d Mon Sep 17 00:00:00 2001 From: Uleat Date: Sun, 24 Aug 2014 05:42:43 -0400 Subject: [PATCH 185/217] First attempt at fixing zone shutdown crashes. (Mob timer processing accessing released resources.) --- changelog.txt | 4 ++++ zone/entity.cpp | 2 +- zone/mob_ai.cpp | 29 ++++++++++++++++++++++++++++- zone/quest_parser_collection.cpp | 5 ++--- zone/zone.cpp | 13 +++++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index bf2ea97f0..082463fe9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/24/2014 == +Uleat: Fix (attempted) for zone crashes related to zone shut-down. This change disables all Mob AI and disables/deletes all Mob timers once Zone::ShutDown() is called. More areas will be addressed as reports come in. +Note: Perl and Lua quests tested to work..please post any aberrant behavior. (I finally set my spell-check to US English...) + == 08/20/2014 == Uleat: Rework of Trade::AddEntity() - function used to move items into the trade window. Now accepts argument for 'stack_size' and updates client properly. Note: I tested trade with Titanium:{SoF,SoD,UF,RoF} in both directions and no client generated an OP_MoveItem event for attempting to place a stackable diff --git a/zone/entity.cpp b/zone/entity.cpp index 469bf8111..242d1a6b6 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1598,7 +1598,7 @@ Corpse *EntityList::GetCorpseByName(const char *name) Spawn2 *EntityList::GetSpawnByID(uint32 id) { - if (!zone) + if (!zone || !zone->IsLoaded()) return nullptr; LinkedListIterator iterator(zone->spawn2_list); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 87fc2ea79..10d41c78e 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -541,13 +541,40 @@ void NPC::AI_Start(uint32 iMoveDelay) { void Mob::AI_Stop() { if (!IsAIControlled()) return; + pAIControlled = false; + safe_delete(AIthink_timer); safe_delete(AIwalking_timer); safe_delete(AImovement_timer); - safe_delete(AItarget_check_timer) + safe_delete(AItarget_check_timer); safe_delete(AIscanarea_timer); safe_delete(AIfeignremember_timer); + safe_delete(PathingLOSCheckTimer); + safe_delete(PathingRouteUpdateTimerShort); + safe_delete(PathingRouteUpdateTimerLong); + + attack_timer.Disable(); + attack_dw_timer.Disable(); + ranged_timer.Disable(); + tic_timer.Disable(); + mana_timer.Disable(); + spellend_timer.Disable(); + projectile_timer.Disable(); + rewind_timer.Disable(); + bindwound_timer.Disable(); + stunned_timer.Disable(); + spun_timer.Disable(); + bardsong_timer.Disable(); + gravity_timer.Disable(); + viral_timer.Disable(); + flee_timer.Disable(); + + for (int sat = 0; sat < MAX_SPECIAL_ATTACK; ++sat) { + if (SpecialAbilities[sat].timer) + SpecialAbilities[sat].timer->Disable(); + } + hate_list.Wipe(); } diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index 376c121d3..8fc0f9c43 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -600,9 +600,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string } QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) { - - if(!zone) - return nullptr; + if(!zone || !zone->IsLoaded()) + return nullptr; //first look for /quests/zone/player_v[instance_version].ext (precedence) filename = "quests/"; diff --git a/zone/zone.cpp b/zone/zone.cpp index a3026425c..77ac4401b 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -718,11 +718,24 @@ void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) { } } +bool Zone::IsLoaded() { + return ZoneLoaded; +} + void Zone::Shutdown(bool quite) { if (!ZoneLoaded) return; + std::list mob_list; + entity_list.GetMobList(mob_list); + std::list::iterator mob_itr = mob_list.begin(); + while (mob_itr != mob_list.end()) { + Mob* mob_inst = *mob_itr; + mob_inst->AI_Stop(); + ++mob_itr; + } + std::map::iterator itr; while(zone->npctable.size()) { itr=zone->npctable.begin(); From 3b048ee8a2fa35315833fa09245a82989e0aaa8c Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 07:13:15 -0500 Subject: [PATCH 186/217] Character creation process crash fix (world) and query cleanup --- changelog.txt | 3 +++ common/database.cpp | 7 ++++--- zone/queryserv.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 3836b437e..7b485913e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/24/2014 == +Akkadius: Character creation process crash fix and query cleanup + == 08/23/2014 == Akkadius: Changed zone process window title format, example: 'crushbone :: clients: 6 inst_id: 1 inst_ver: 0 :: port: 7015' Akkadius: Most of the following changes are QueryServ related, fully implemented its original functionality to be able to offload diff --git a/common/database.cpp b/common/database.cpp index e82f350b1..8d27d5b46 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -608,10 +608,11 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven for (int16 i=EmuConstants::EQUIPMENT_BEGIN; i<=EmuConstants::BANK_BAGS_END;) { const ItemInst* newinv = inv->GetItem(i); - if (!newinv) + if (newinv) { - invquery = StringFormat("INSERT INTO inventory SET charid=%0u, slotid=%0d, itemid=%0u, charges=%0d, color=%0u", - charid, i, newinv->GetItem()->ID,newinv->GetCharges(), newinv->GetColor()); + invquery = StringFormat("INSERT INTO `inventory` (charid, slotid, itemid, charges, color) VALUES (%u, %i, %u, %i, %u)", + charid, i, newinv->GetItem()->ID, newinv->GetCharges(), newinv->GetColor()); + auto results = QueryDatabase(invquery); if (!results.RowsAffected()) diff --git a/zone/queryserv.h b/zone/queryserv.h index e0c7d4e56..8aafcafda 100644 --- a/zone/queryserv.h +++ b/zone/queryserv.h @@ -21,7 +21,7 @@ enum PlayerGenericLogEventTypes { Player_Log_Issued_Commands, Player_Log_Money_Transactions, Player_Log_Alternate_Currency_Transactions, -}; +}; class QueryServ{ From 633583c266f987afcbfd2194b7abd7001bb66841 Mon Sep 17 00:00:00 2001 From: akkadius Date: Sun, 24 Aug 2014 08:52:14 -0500 Subject: [PATCH 187/217] Created `character_lookup` table for applications that mirrors all `character_` table fields minus blob fields for application lookups - A 2.4GB character_ table will take 7 seconds to query on a SSD versus .1s on the character_lookup table - This also causes applications like Magelo to burst reads of the entire character table because of the blob fields that come with the reads, as much as 500-600MB/s even if a indexed id filter is provided - This field is synchronized on player save and has 0.001s DB hit - When we split out from the blob, ideally this table can be removed, but it really does no harm in mirroring data when a 2.6GB character table mirrors everything subtracting blob data down to 8MB - Required SQL: utils\sql\git\required\2014_08_24_character_lookup.sql --- changelog.txt | 6 ++++ .../required/2014_08_24_character_lookup.sql | 33 +++++++++++++++++++ zone/client.cpp | 3 ++ zone/zonedb.cpp | 8 +++++ zone/zonedb.h | 1 + 5 files changed, 51 insertions(+) create mode 100644 utils/sql/git/required/2014_08_24_character_lookup.sql diff --git a/changelog.txt b/changelog.txt index 7b485913e..a5fe6bf4f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,12 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- == 08/24/2014 == Akkadius: Character creation process crash fix and query cleanup +Akkadius: Created `character_lookup` table for applications that mirrors all `character_` table fields minus blob fields for application lookups + - A 2.4GB character_ table will take 7 seconds to query on a SSD versus .1s on the character_lookup table + - This also causes applications like Magelo to burst reads of the entire character table because of the blob fields that come with the reads, as much as 500-600MB/s even if a indexed id filter is provided + - This field is synchronized on player save and has 0.001s DB hit + - When we split out from the blob, ideally this table can be removed + - Required SQL: utils\sql\git\required\2014_08_24_character_lookup.sql == 08/23/2014 == Akkadius: Changed zone process window title format, example: 'crushbone :: clients: 6 inst_id: 1 inst_ver: 0 :: port: 7015' diff --git a/utils/sql/git/required/2014_08_24_character_lookup.sql b/utils/sql/git/required/2014_08_24_character_lookup.sql new file mode 100644 index 000000000..414dbbdcb --- /dev/null +++ b/utils/sql/git/required/2014_08_24_character_lookup.sql @@ -0,0 +1,33 @@ +-- chracter_lookup table structure -- + +CREATE TABLE `character_lookup` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `account_id` int(11) NOT NULL DEFAULT '0', + `name` varchar(64) NOT NULL DEFAULT '', + `timelaston` int(11) unsigned DEFAULT '0', + `x` float NOT NULL DEFAULT '0', + `y` float NOT NULL DEFAULT '0', + `z` float NOT NULL DEFAULT '0', + `zonename` varchar(30) NOT NULL DEFAULT '', + `zoneid` smallint(6) NOT NULL DEFAULT '0', + `instanceid` smallint(5) unsigned NOT NULL DEFAULT '0', + `pktime` int(8) NOT NULL DEFAULT '0', + `groupid` int(10) unsigned NOT NULL DEFAULT '0', + `class` tinyint(4) NOT NULL DEFAULT '0', + `level` mediumint(8) unsigned NOT NULL DEFAULT '0', + `lfp` tinyint(1) unsigned NOT NULL DEFAULT '0', + `lfg` tinyint(1) unsigned NOT NULL DEFAULT '0', + `mailkey` char(16) NOT NULL, + `xtargets` tinyint(3) unsigned NOT NULL DEFAULT '5', + `firstlogon` tinyint(3) NOT NULL DEFAULT '0', + `inspectmessage` varchar(256) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + KEY `account_id` (`account_id`) +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; + +-- Initial population of the character_lookup table -- + +INSERT INTO `character_lookup` (id, account_id, `name`, timelaston, x, y, z, zonename, zoneid, instanceid, pktime, groupid, class, `level`, lfp, lfg, mailkey, xtargets, firstlogon, inspectmessage) +SELECT id, account_id, `name`, timelaston, x, y, z, zonename, zoneid, instanceid, pktime, groupid, class, `level`, lfp, lfg, mailkey, xtargets, firstlogon, inspectmessage +FROM `character_`; \ No newline at end of file diff --git a/zone/client.cpp b/zone/client.cpp index a263cd3cc..37740b472 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -630,6 +630,9 @@ bool Client::Save(uint8 iCommitNow) { return false; } + /* Mirror Character Data */ + database.StoreCharacterLookup(this->CharacterID()); + return true; } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 92bf3cc22..787e3a94e 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3226,3 +3226,11 @@ bool ZoneDatabase::GetFactionIdsForNPC(uint32 nfl_id, std::list Date: Sun, 24 Aug 2014 11:53:28 -0700 Subject: [PATCH 188/217] GetDoorsCount converted to QueryDatabase --- zone/doors.cpp | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index c353ce568..d3b9ec6ec 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -568,36 +568,31 @@ void Doors::DumpDoor(){ } int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - query = new char[256]; - sprintf(query, "SELECT MAX(id), count(*) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)", zone_name, version); - if (RunQuery(query, strlen(query), errbuf, &result)) { - safe_delete_array(query); - row = mysql_fetch_row(result); - if (row != nullptr && row[1] != 0) { - int32 ret = atoi(row[1]); - if (oMaxID) { - if (row[0]) - *oMaxID = atoi(row[0]); - else - *oMaxID = 0; - } - mysql_free_result(result); - return ret; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in GetDoorsCount query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT MAX(id), count(*) FROM doors " + "WHERE zone = '%s' AND (version = %u OR version = -1)", + zone_name, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in GetDoorsCount query '" << query << "' " << results.ErrorMessage() << std::endl; return -1; - } + } + + if (results.RowCount() != 1) + return -1; + + auto row = results.begin(); + + if (!oMaxID) + return atoi(row[1]); + + if (row[0]) + *oMaxID = atoi(row[0]); + else + *oMaxID = 0; + + return atoi(row[1]); - return -1; } int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) { From 8f4e2e99db454a124a6ccaf9b31a476fbce41d21 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:00:45 -0700 Subject: [PATCH 189/217] GetDoorsCountPlusOne converted to QueryDatabase --- zone/doors.cpp | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index d3b9ec6ec..375b59be5 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -596,34 +596,24 @@ int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 v } int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 oMaxID = 0; - MYSQL_RES *result; - MYSQL_ROW row; - query = new char[256]; - sprintf(query, "SELECT MAX(id) FROM doors WHERE zone='%s' AND version=%u", zone_name, version); - if (RunQuery(query, strlen(query), errbuf, &result)) { - safe_delete_array(query); - row = mysql_fetch_row(result); - if (row != nullptr && row[1] != 0) { - if (row[0]) - oMaxID = atoi(row[0]) + 1; - else - oMaxID = 0; - mysql_free_result(result); - return oMaxID; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT MAX(id) FROM doors " + "WHERE zone = '%s' AND version = %u", zone_name, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << results.ErrorMessage() << std::endl; return -1; - } + } - return -1; + if (results.RowCount() != 1) + return -1; + + auto row = results.begin(); + + if (!row[0]) + return 0; + + return atoi(row[0]) + 1; } int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) { From 5d6d48988964f46063dfb786c345ae1ccbe4b944 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:08:39 -0700 Subject: [PATCH 190/217] GetDoorsDBCountPlusOne converted to QueryDatabase --- zone/doors.cpp | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index 375b59be5..f01c4dbc0 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -617,34 +617,27 @@ int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) { } int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + uint32 oMaxID = 0; - MYSQL_RES *result; - MYSQL_ROW row; - query = new char[256]; - sprintf(query, "SELECT MAX(doorid) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)", zone_name, version); - if (RunQuery(query, strlen(query), errbuf, &result)) { - safe_delete_array(query); - row = mysql_fetch_row(result); - if (row != nullptr && row[1] != 0) { - if (row[0]) - oMaxID = atoi(row[0]) + 1; - else - oMaxID = 0; - mysql_free_result(result); - return oMaxID; - } - mysql_free_result(result); - } - else { - std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT MAX(doorid) FROM doors " + "WHERE zone = '%s' AND (version = %u OR version = -1)", + zone_name, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error in GetDoorsCountPlusOne query '" << query << "' " << results.ErrorMessage() << std::endl; return -1; } - return -1; + if (results.RowCount() != 1) + return -1; + + auto row = results.begin(); + + if (!row[0]) + return 0; + + return atoi(row[0]) + 1; } bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name, int16 version) { From 9707b53df26b68a3938c43bca7bd17d3ee5de51c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:14:16 -0700 Subject: [PATCH 191/217] LoadDoors converted to QueryDatabase --- zone/doors.cpp | 104 +++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/zone/doors.cpp b/zone/doors.cpp index f01c4dbc0..5ff7eae26 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -642,61 +642,63 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name, int16 version) { LogFile->write(EQEMuLog::Status, "Loading Doors from database..."); - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + // Door tmpDoor; - MakeAnyLenString(&query, "SELECT id,doorid,zone,name,pos_x,pos_y,pos_z,heading," - "opentype,guild,lockpick,keyitem,nokeyring,triggerdoor,triggertype,dest_zone,dest_instance,dest_x," - "dest_y,dest_z,dest_heading,door_param,invert_state,incline,size,is_ldon_door,client_version_mask " - "FROM doors WHERE zone='%s' AND (version=%u OR version=-1) ORDER BY doorid asc", zone_name, version); - if (RunQuery(query, strlen(query), errbuf, &result)) { - safe_delete_array(query); - int32 r; - for(r = 0; (row = mysql_fetch_row(result)); r++) { - if(r >= iDoorCount) { - std::cerr << "Error, Door Count of " << iDoorCount << " exceeded." << std::endl; - break; - } - memset(&into[r], 0, sizeof(Door)); - into[r].db_id = atoi(row[0]); - into[r].door_id = atoi(row[1]); - strn0cpy(into[r].zone_name,row[2],32); - strn0cpy(into[r].door_name,row[3],32); - into[r].pos_x = (float)atof(row[4]); - into[r].pos_y = (float)atof(row[5]); - into[r].pos_z = (float)atof(row[6]); - into[r].heading = (float)atof(row[7]); - into[r].opentype = atoi(row[8]); - into[r].guild_id = atoi(row[9]); - into[r].lockpick = atoi(row[10]); - into[r].keyitem = atoi(row[11]); - into[r].nokeyring = atoi(row[12]); - into[r].trigger_door = atoi(row[13]); - into[r].trigger_type = atoi(row[14]); - strn0cpy(into[r].dest_zone, row[15], 32); - into[r].dest_instance_id = atoi(row[16]); - into[r].dest_x = (float) atof(row[17]); - into[r].dest_y = (float) atof(row[18]); - into[r].dest_z = (float) atof(row[19]); - into[r].dest_heading = (float) atof(row[20]); - into[r].door_param=atoi(row[21]); - into[r].invert_state=atoi(row[22]); - into[r].incline=atoi(row[23]); - into[r].size=atoi(row[24]); - into[r].is_ldon_door=atoi(row[25]); - into[r].client_version_mask = (uint32)strtoul(row[26], nullptr, 10); - } - mysql_free_result(result); - } - else - { - std::cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT id, doorid, zone, name, pos_x, pos_y, pos_z, heading, " + "opentype, guild, lockpick, keyitem, nokeyring, triggerdoor, triggertype, " + "dest_zone, dest_instance, dest_x, dest_y, dest_z, dest_heading, " + "door_param, invert_state, incline, size, is_ldon_door, client_version_mask " + "FROM doors WHERE zone = '%s' AND (version = %u OR version = -1) " + "ORDER BY doorid asc", zone_name, version); + auto results = QueryDatabase(query); + if (!results.Success()){ + std::cerr << "Error in DBLoadDoors query '" << query << "' " << results.ErrorMessage() << std::endl; return false; } + + int32 rowIndex = 0; + for(auto row = results.begin(); row != results.end(); ++row, ++rowIndex) { + if(rowIndex >= iDoorCount) { + std::cerr << "Error, Door Count of " << iDoorCount << " exceeded." << std::endl; + break; + } + + memset(&into[rowIndex], 0, sizeof(Door)); + + into[rowIndex].db_id = atoi(row[0]); + into[rowIndex].door_id = atoi(row[1]); + + strn0cpy(into[rowIndex].zone_name,row[2],32); + strn0cpy(into[rowIndex].door_name,row[3],32); + + into[rowIndex].pos_x = (float)atof(row[4]); + into[rowIndex].pos_y = (float)atof(row[5]); + into[rowIndex].pos_z = (float)atof(row[6]); + into[rowIndex].heading = (float)atof(row[7]); + into[rowIndex].opentype = atoi(row[8]); + into[rowIndex].guild_id = atoi(row[9]); + into[rowIndex].lockpick = atoi(row[10]); + into[rowIndex].keyitem = atoi(row[11]); + into[rowIndex].nokeyring = atoi(row[12]); + into[rowIndex].trigger_door = atoi(row[13]); + into[rowIndex].trigger_type = atoi(row[14]); + + strn0cpy(into[rowIndex].dest_zone, row[15], 32); + + into[rowIndex].dest_instance_id = atoi(row[16]); + into[rowIndex].dest_x = (float) atof(row[17]); + into[rowIndex].dest_y = (float) atof(row[18]); + into[rowIndex].dest_z = (float) atof(row[19]); + into[rowIndex].dest_heading = (float) atof(row[20]); + into[rowIndex].door_param=atoi(row[21]); + into[rowIndex].invert_state=atoi(row[22]); + into[rowIndex].incline=atoi(row[23]); + into[rowIndex].size=atoi(row[24]); + into[rowIndex].is_ldon_door=atoi(row[25]); + into[rowIndex].client_version_mask = (uint32)strtoul(row[26], nullptr, 10); + } + return true; } From 3d1521857ea7a1077a8c3b45265d874014f3a1d6 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:21:16 -0700 Subject: [PATCH 192/217] LoadStaticZonePoints converted to QueryDatabase --- zone/zone.cpp | 66 ++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/zone/zone.cpp b/zone/zone.cpp index a3026425c..a85b2d9ff 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1678,45 +1678,41 @@ ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Clien bool ZoneDatabase::LoadStaticZonePoints(LinkedList* zone_point_list, const char* zonename, uint32 version) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + zone_point_list->Clear(); zone->numzonepoints = 0; - MakeAnyLenString(&query, "SELECT x, y, z, target_x, target_y, " - "target_z, target_zone_id, heading, target_heading, number, " - "target_instance, client_version_mask FROM zone_points " - "WHERE zone='%s' AND (version=%i OR version=-1) order by number", zonename, version); - if (RunQuery(query, strlen(query), errbuf, &result)) - { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) - { - ZonePoint* zp = new ZonePoint; - zp->x = atof(row[0]); - zp->y = atof(row[1]); - zp->z = atof(row[2]); - zp->target_x = atof(row[3]); - zp->target_y = atof(row[4]); - zp->target_z = atof(row[5]); - zp->target_zone_id = atoi(row[6]); - zp->heading = atof(row[7]); - zp->target_heading = atof(row[8]); - zp->number = atoi(row[9]); - zp->target_zone_instance = atoi(row[10]); - zp->client_version_mask = (uint32)strtoul(row[11], nullptr, 0); - zone_point_list->Insert(zp); - zone->numzonepoints++; - } - mysql_free_result(result); - } - else - { - std::cerr << "Error1 in LoadStaticZonePoints query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + std::string query = StringFormat("SELECT x, y, z, target_x, target_y, " + "target_z, target_zone_id, heading, target_heading, " + "number, target_instance, client_version_mask " + "FROM zone_points WHERE zone='%s' AND (version=%i OR version=-1) " + "ORDER BY number", zonename, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + std::cerr << "Error1 in LoadStaticZonePoints query '" << query << "' " << results.ErrorMessage() << std::endl; return false; } + + for (auto row = results.begin(); row != results.end(); ++row) { + ZonePoint* zp = new ZonePoint; + + zp->x = atof(row[0]); + zp->y = atof(row[1]); + zp->z = atof(row[2]); + zp->target_x = atof(row[3]); + zp->target_y = atof(row[4]); + zp->target_z = atof(row[5]); + zp->target_zone_id = atoi(row[6]); + zp->heading = atof(row[7]); + zp->target_heading = atof(row[8]); + zp->number = atoi(row[9]); + zp->target_zone_instance = atoi(row[10]); + zp->client_version_mask = (uint32)strtoul(row[11], nullptr, 0); + + zone_point_list->Insert(zp); + + zone->numzonepoints++; + } + return true; } From e7ef4b5484fe3df0fa0e78eff5ac415aa7ddf7ea Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:37:44 -0700 Subject: [PATCH 193/217] SpellGlobalCheck converted to QueryDatabase --- zone/spells.cpp | 160 ++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 86 deletions(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index 4eddf5883..357fafbd4 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -1252,7 +1252,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot, } } - if(IsClient()) { + if(IsClient()) { CheckNumHitsRemaining(NUMHIT_MatchingSpells); TrySympatheticProc(target, spell_id); } @@ -1378,7 +1378,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce mlog(AA__MESSAGE, "Project Illusion overwrote target caster: %s spell id: %d was ON", GetName(), spell_id); targetType = ST_GroupClientAndPet; } - + if (spell_target && !spell_target->PassCastRestriction(true, spells[spell_id].CastRestriction)){ Message_StringID(13,SPELL_NEED_TAR); return false; @@ -1386,16 +1386,16 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce //Must be out of combat. (If Beneficial checks casters combat state, Deterimental checks targets) if (!spells[spell_id].InCombat && spells[spell_id].OutofCombat){ - if (IsDetrimentalSpell(spell_id)) { - if ( (spell_target->IsNPC() && spell_target->IsEngaged()) || + if (IsDetrimentalSpell(spell_id)) { + if ( (spell_target->IsNPC() && spell_target->IsEngaged()) || (spell_target->IsClient() && spell_target->CastToClient()->GetAggroCount())){ Message_StringID(13,SPELL_NO_EFFECT); //Unsure correct string return false; } } - else if (IsBeneficialSpell(spell_id)) { - if ( (IsNPC() && IsEngaged()) || + else if (IsBeneficialSpell(spell_id)) { + if ( (IsNPC() && IsEngaged()) || (IsClient() && CastToClient()->GetAggroCount())){ if (IsDiscipline(spell_id)) Message_StringID(13,NO_ABILITY_IN_COMBAT); @@ -1409,16 +1409,16 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce //Must be in combat. (If Beneficial checks casters combat state, Deterimental checks targets) else if (spells[spell_id].InCombat && !spells[spell_id].OutofCombat){ - if (IsDetrimentalSpell(spell_id)) { - if ( (spell_target->IsNPC() && !spell_target->IsEngaged()) || + if (IsDetrimentalSpell(spell_id)) { + if ( (spell_target->IsNPC() && !spell_target->IsEngaged()) || (spell_target->IsClient() && !spell_target->CastToClient()->GetAggroCount())){ Message_StringID(13,SPELL_NO_EFFECT); //Unsure correct string return false; } } - else if (IsBeneficialSpell(spell_id)) { - if ( (IsNPC() && !IsEngaged()) || + else if (IsBeneficialSpell(spell_id)) { + if ( (IsNPC() && !IsEngaged()) || (IsClient() && !CastToClient()->GetAggroCount())){ if (IsDiscipline(spell_id)) Message_StringID(13,NO_ABILITY_OUT_OF_COMBAT); @@ -1782,10 +1782,10 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce case ST_PetMaster: { - + Mob *owner = nullptr; - - if (IsPet()) + + if (IsPet()) owner = GetOwner(); else if ((IsNPC() && CastToNPC()->GetSwarmOwner())) owner = entity_list.GetMobID(CastToNPC()->GetSwarmOwner()); @@ -1975,7 +1975,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 if (!TrySpellProjectile(spell_target, spell_id)) return false; } - + else if(!SpellOnTarget(spell_id, spell_target, false, true, resist_adjust, false)) { if(IsBuffSpell(spell_id) && IsBeneficialSpell(spell_id)) { // Prevent mana usage/timers being set for beneficial buffs @@ -2723,7 +2723,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, if ((effect2 == SE_BStacker) && (!IsCastonFadeDurationSpell(spellid1) && buffs[buffslot].ticsremaining != 1 && IsEffectInSpell(spellid1, SE_CStacker))) return -1; } - + if (spellbonuses.DStacker[0]) { if ((effect2 == SE_DStacker) && (sp2.effectid[i] <= spellbonuses.DStacker[1])) return -1; @@ -2775,7 +2775,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, mlog(SPELLS__STACKING, "%s (%d) blocks effect %d on slot %d below %d, but we do not have that effect on that slot. Ignored.", sp1.name, spellid1, blocked_effect, blocked_slot, blocked_below_value); } - } + } } } else { mlog(SPELLS__STACKING, "%s (%d) and %s (%d) appear to be in the same line, skipping Stacking Overwrite/Blocking checks", @@ -3564,7 +3564,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r if(spell_effectiveness == 0 || !IsPartialCapableSpell(spell_id) ) { mlog(SPELLS__RESISTS, "Spell %d was completely resisted by %s", spell_id, spelltar->GetName()); - + if (spells[spell_id].resisttype == RESIST_PHYSICAL){ Message_StringID(MT_SpellFailure, PHYSICAL_RESIST_FAIL,spells[spell_id].name); spelltar->Message_StringID(MT_SpellFailure, YOU_RESIST, spells[spell_id].name); @@ -3707,7 +3707,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r TrySpellTrigger(spelltar, spell_id); TryApplyEffect(spelltar, spell_id); - + if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) { int32 aggro_amount = CheckAggroAmount(spell_id, isproc); mlog(SPELLS__CASTING, "Spell %d cast on %s generated %d hate", spell_id, spelltar->GetName(), aggro_amount); @@ -3733,7 +3733,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r safe_delete(action_packet); return false; } - + // cause the effects to the target if(!spelltar->SpellEffect(this, spell_id, spell_effectiveness)) { @@ -3746,11 +3746,11 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r return false; } - + if (IsDetrimentalSpell(spell_id)) { - + CheckNumHitsRemaining(NUMHIT_OutgoingSpells); - + if (spelltar) spelltar->CheckNumHitsRemaining(NUMHIT_IncomingSpells); } @@ -4408,7 +4408,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if (CharismaCheck) { - /* + /* Charisma ONLY effects the initial resist check when charm is cast with 10 CHA = -1 Resist mod up to 255 CHA (min ~ 75 cha) Charisma less than ~ 75 gives a postive modifier to resist checks at approximate ratio of -10 CHA = +6 Resist. Mez spells do same initial resist check as a above. @@ -4470,7 +4470,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if (CharmTick) { int min_charmbreakchance = ((100/RuleI(Spells, CharmBreakCheckChance))/66 * 100)*2; - + if (resist_chance < min_charmbreakchance) resist_chance = min_charmbreakchance; } @@ -4965,68 +4965,56 @@ int Client::FindSpellBookSlotBySpellID(uint16 spellid) { return -1; //default } -bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) { +bool Client::SpellGlobalCheck(uint16 spell_ID, uint16 char_ID) { - std::string Spell_Global_Name; - int Spell_Global_Value; - int Global_Value; + std::string spell_Global_Name; + int spell_Global_Value; + int global_Value; - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - - if (database.RunQuery(query,MakeAnyLenString(&query, "SELECT qglobal, value FROM spell_globals WHERE spellid=%i", Spell_ID), errbuf, &result)) { - safe_delete_array(query); - - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - Spell_Global_Name = row[0]; - Spell_Global_Value = atoi(row[1]); - - mysql_free_result(result); - - if (Spell_Global_Name.empty()) { // If the entry in the spell_globals table has nothing set for the qglobal name - return true; - } - else if (database.RunQuery(query,MakeAnyLenString(&query, "SELECT value FROM quest_globals WHERE charid=%i AND name='%s'", Char_ID, Spell_Global_Name.c_str()), errbuf, &result)) { - safe_delete_array(query); - - if (mysql_num_rows(result) == 1) { - row = mysql_fetch_row(result); - - Global_Value = atoi(row[0]); - mysql_free_result(result); - if (Global_Value == Spell_Global_Value) { // If the values match from both tables, allow the spell to be scribed - return true; - } - else if (Global_Value > Spell_Global_Value) { // Check if the qglobal value is greater than the require spellglobal value - return true; - } - else // If no matching result found in qglobals, don't scribe this spell - { - LogFile->write(EQEMuLog::Error, "Char ID: %i Spell_globals Name: '%s' Value: '%i' did not match QGlobal Value: '%i' for Spell ID %i", Char_ID, Spell_Global_Name.c_str(), Spell_Global_Value, Global_Value, Spell_ID); - return false; - } - } - else - LogFile->write(EQEMuLog::Error, "Char ID: %i does not have the Qglobal Name: '%s' for Spell ID %i", Char_ID, Spell_Global_Name.c_str(), Spell_ID); - safe_delete_array(query); - } - else - LogFile->write(EQEMuLog::Error, "Spell ID %i query of spell_globals with Name: '%s' Value: '%i' failed", Spell_ID, Spell_Global_Name.c_str(), Spell_Global_Value); - } - else { - return true; // Spell ID isn't listed in the spells_global table, so it is not restricted from scribing - } - mysql_free_result(result); - } - else { - LogFile->write(EQEMuLog::Error, "Error while querying Spell ID %i spell_globals table query '%s': %s", Spell_ID, query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT qglobal, value FROM spell_globals " + "WHERE spellid = %i", spell_ID); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error while querying Spell ID %i spell_globals table query '%s': %s", spell_ID, query.c_str(), results.ErrorMessage().c_str()); return false; // Query failed, so prevent spell from scribing just in case - } - return false; // Default is false + } + + if (results.RowCount() != 1) + return true; // Spell ID isn't listed in the spells_global table, so it is not restricted from scribing + + auto row = results.begin(); + spell_Global_Name = row[0]; + spell_Global_Value = atoi(row[1]); + + if (spell_Global_Name.empty()) + return true; // If the entry in the spell_globals table has nothing set for the qglobal name + + query = StringFormat("SELECT value FROM quest_globals " + "WHERE charid = %i AND name = '%s'", + char_ID, spell_Global_Name.c_str()); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Spell ID %i query of spell_globals with Name: '%s' Value: '%i' failed", spell_ID, spell_Global_Name.c_str(), spell_Global_Value); + return false; + } + + if (results.RowCount() != 1) { + LogFile->write(EQEMuLog::Error, "Char ID: %i does not have the Qglobal Name: '%s' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_ID); + return false; + } + + row = results.begin(); + + global_Value = atoi(row[0]); + + if (global_Value == spell_Global_Value) + return true; // If the values match from both tables, allow the spell to be scribed + else if (global_Value > spell_Global_Value) + return true; // Check if the qglobal value is greater than the require spellglobal value + + // If no matching result found in qglobals, don't scribe this spell + LogFile->write(EQEMuLog::Error, "Char ID: %i Spell_globals Name: '%s' Value: '%i' did not match QGlobal Value: '%i' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_Global_Value, global_Value, spell_ID); + return false; } // TODO get rid of this @@ -5081,7 +5069,7 @@ bool Mob::FindType(uint16 type, bool bOffensive, uint16 threshold) { } bool Mob::IsCombatProc(uint16 spell_id) { - + if (RuleB(Spells, FocusCombatProcs)) return false; @@ -5092,7 +5080,7 @@ bool Mob::IsCombatProc(uint16 spell_id) { { for (int i = 0; i < MAX_PROCS; i++){ - if (PermaProcs[i].spellID == spell_id || SpellProcs[i].spellID == spell_id + if (PermaProcs[i].spellID == spell_id || SpellProcs[i].spellID == spell_id || RangedProcs[i].spellID == spell_id){ return true; } @@ -5150,7 +5138,7 @@ bool Mob::AddDefensiveProc(uint16 spell_id, uint16 iChance, uint16 base_spell_id { if(spell_id == SPELL_UNKNOWN) return(false); - + int i; for (i = 0; i < MAX_PROCS; i++) { if (DefensiveProcs[i].spellID == SPELL_UNKNOWN) { From adf36bf912d10440cde2d928e71939dab03c0a4d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:46:02 -0700 Subject: [PATCH 194/217] LoadSpawnGroups converted to QueryDatabase --- zone/spawngroup.cpp | 82 +++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index fc0360aee..ef0a0882a 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -140,53 +140,49 @@ bool SpawnGroupList::RemoveSpawnGroup(uint32 in_id) { } bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - query = 0; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT DISTINCT(spawngroupID), spawngroup.name, spawngroup.spawn_limit, spawngroup.dist, spawngroup.max_x, spawngroup.min_x, spawngroup.max_y, spawngroup.min_y, spawngroup.delay, spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay FROM spawn2,spawngroup WHERE spawn2.spawngroupID=spawngroup.ID and spawn2.version=%u and zone='%s'", version, zone_name), errbuf, &result)) - { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - SpawnGroup* newSpawnGroup = new SpawnGroup( atoi(row[0]), row[1], atoi(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11])); - spawn_group_list->AddSpawnGroup(newSpawnGroup); - } - mysql_free_result(result); - } - else - { - _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%s' ", query); - safe_delete_array(query); + std::string query = StringFormat("SELECT DISTINCT(spawngroupID), spawngroup.name, spawngroup.spawn_limit, " + "spawngroup.dist, spawngroup.max_x, spawngroup.min_x, " + "spawngroup.max_y, spawngroup.min_y, spawngroup.delay, " + "spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay " + "FROM spawn2, spawngroup WHERE spawn2.spawngroupID = spawngroup.ID " + "AND spawn2.version = %u and zone = '%s'", version, zone_name); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%s' ", query.c_str()); return false; - } + } - query = 0; - if (RunQuery(query, MakeAnyLenString(&query, - "SELECT DISTINCT spawnentry.spawngroupID, npcid, chance, " - "npc_types.spawn_limit AS sl " - "FROM spawnentry, spawn2, npc_types " - "WHERE spawnentry.npcID=npc_types.id AND spawnentry.spawngroupID=spawn2.spawngroupID " - "AND zone='%s'", zone_name), errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) - { - SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0); - SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0])); - if (sg) - sg->AddSpawnEntry(newSpawnEntry); - else - _log(ZONE__SPAWNS, "Error in LoadSpawnGroups %s ", query); - } - mysql_free_result(result); - } - else - { - _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%'", query); - safe_delete_array(query); + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnGroup* newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]), + atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), + atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11])); + spawn_group_list->AddSpawnGroup(newSpawnGroup); + } + + query = StringFormat("SELECT DISTINCT spawnentry.spawngroupID, npcid, chance, " + "npc_types.spawn_limit AS sl " + "FROM spawnentry, spawn2, npc_types " + "WHERE spawnentry.npcID=npc_types.id " + "AND spawnentry.spawngroupID = spawn2.spawngroupID " + "AND zone = '%s'", zone_name); + results = QueryDatabase(query); + if (!results.Success()) { + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query '%'", query.c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0); + SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0])); + + if (!sg) { + _log(ZONE__SPAWNS, "Error in LoadSpawnGroups %s ", query.c_str()); + continue; + } + + sg->AddSpawnEntry(newSpawnEntry); + } return true; } From 932dd836d0f706d6de579919fc49bb34a4675cb2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 12:54:06 -0700 Subject: [PATCH 195/217] LoadSpawnGroupsByID converted to QueryDatabase --- zone/spawngroup.cpp | 73 +++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index ef0a0882a..81d6c5d51 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -188,49 +188,44 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG } bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - query = 0; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT DISTINCT spawngroup.id, spawngroup.name, spawngroup.spawn_limit, spawngroup.dist, spawngroup.max_x, spawngroup.min_x, spawngroup.max_y, spawngroup.min_y, spawngroup.delay, spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay FROM spawngroup WHERE spawngroup.ID='%i'", spawngroupid), errbuf, &result)) - { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - SpawnGroup* newSpawnGroup = new SpawnGroup( atoi(row[0]), row[1], atoi(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11])); - spawn_group_list->AddSpawnGroup(newSpawnGroup); - } - mysql_free_result(result); - } - else - { - _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query %s", query); - safe_delete_array(query); + + std::string query = StringFormat("SELECT DISTINCT(spawngroup.id), spawngroup.name, spawngroup.spawn_limit, " + "spawngroup.dist, spawngroup.max_x, spawngroup.min_x, " + "spawngroup.max_y, spawngroup.min_y, spawngroup.delay, " + "spawngroup.despawn, spawngroup.despawn_timer, spawngroup.mindelay " + "FROM spawngroup WHERE spawngroup.ID = '%i'", spawngroupid); + auto results = QueryDatabase(query); + if (!results.Success()) { + _log(ZONE__SPAWNS, "Error2 in PopulateZoneLists query %s", query.c_str()); + return false; + } + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnGroup* newSpawnGroup = new SpawnGroup(atoi(row[0]), row[1], atoi(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6]), atof(row[7]), atoi(row[8]), atoi(row[9]), atoi(row[10]), atoi(row[11])); + spawn_group_list->AddSpawnGroup(newSpawnGroup); + } + + query = StringFormat("SELECT DISTINCT(spawnentry.spawngroupID), spawnentry.npcid, " + "spawnentry.chance, spawngroup.spawn_limit FROM spawnentry, spawngroup " + "WHERE spawnentry.spawngroupID = '%i' AND spawngroup.spawn_limit = '0' " + "ORDER BY chance", spawngroupid); + results = QueryDatabase(query); + if (!results.Success()) { + _log(ZONE__SPAWNS, "Error3 in PopulateZoneLists query '%s'", query.c_str()); return false; } - query = 0; - if (RunQuery(query, MakeAnyLenString(&query, - "SELECT DISTINCT spawnentry.spawngroupID, spawnentry.npcid, spawnentry.chance, spawngroup.spawn_limit FROM spawnentry,spawngroup WHERE spawnentry.spawngroupID='%i' AND spawngroup.spawn_limit='0' ORDER by chance", spawngroupid), errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) - { - SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0); - SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0])); - if (sg) - sg->AddSpawnEntry(newSpawnEntry); - else - _log(ZONE__SPAWNS, "Error in SpawngroupID: %s ", row[0]); - } - mysql_free_result(result); - } - else - { - _log(ZONE__SPAWNS, "Error3 in PopulateZoneLists query '%s'", row[0]); - safe_delete_array(query); - return false; - } + for(auto row = results.begin(); row != results.end(); ++row) { + SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0); + SpawnGroup *sg = spawn_group_list->GetSpawnGroup(atoi(row[0])); + if (!sg) { + _log(ZONE__SPAWNS, "Error in SpawngroupID: %s ", row[0]); + continue; + } + + sg->AddSpawnEntry(newSpawnEntry); + } return true; } From 42a51eb37341cdec85275526bff8eca5d8f31311 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:00:39 -0700 Subject: [PATCH 196/217] PopulateZoneSpawnList converted to QueryDatabase --- zone/spawn2.cpp | 58 +++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index dd541e0a2..53656489c 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -354,34 +354,30 @@ void Spawn2::DeathReset(bool realdeath) } bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spawn2_list, int16 version, uint32 repopdelay) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; const char *zone_name = database.GetZoneName(zoneid); - - MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, _condition, cond_value, enabled, animation FROM spawn2 WHERE zone='%s' AND version=%u", zone_name, version); - if (RunQuery(query, strlen(query), errbuf, &result)) - { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) - { - Spawn2* newSpawn = 0; - - bool perl_enabled = atoi(row[11]) == 1 ? true : false; - uint32 spawnLeft = (GetSpawnTimeLeft(atoi(row[0]), zone->GetInstanceID()) * 1000); - newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), spawnLeft, atoi(row[8]), atoi(row[9]), atoi(row[10]), perl_enabled, (EmuAppearance)atoi(row[12])); - spawn2_list.Insert( newSpawn ); - } - mysql_free_result(result); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in PopulateZoneLists query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT id, spawngroupID, x, y, z, heading, " + "respawntime, variance, pathgrid, _condition, " + "cond_value, enabled, animation FROM spawn2 " + "WHERE zone = '%s' AND version = %u", + zone_name, version); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in PopulateZoneLists query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + Spawn2* newSpawn = 0; + + bool perl_enabled = atoi(row[11]) == 1? true: false; + uint32 spawnLeft = (GetSpawnTimeLeft(atoi(row[0]), zone->GetInstanceID()) * 1000); + newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), + atof(row[5]), atoi(row[6]), atoi(row[7]), spawnLeft, atoi(row[8]), + atoi(row[9]), atoi(row[10]), perl_enabled, (EmuAppearance)atoi(row[12])); + + spawn2_list.Insert(newSpawn); + } return true; } @@ -863,10 +859,10 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in SpawnEvent &cevent = *cur; bool StrictCheck = false; - if(cevent.strict && - cevent.next.hour == tod.hour && - cevent.next.day == tod.day && - cevent.next.month == tod.month && + if(cevent.strict && + cevent.next.hour == tod.hour && + cevent.next.day == tod.day && + cevent.next.month == tod.month && cevent.next.year == tod.year) StrictCheck = true; @@ -894,7 +890,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in //execute the event if(!cevent.strict || StrictCheck) ExecEvent(cevent, false); - + //add the period of the event to the trigger time EQTime::AddMinutes(cevent.period, &cevent.next); ran = true; @@ -926,7 +922,7 @@ void SpawnConditionManager::FindNearestEvent() { if(cevent.enabled) { //see if this event is before our last nearest - if(EQTime::IsTimeBefore(&next_event, &cevent.next)) + if(EQTime::IsTimeBefore(&next_event, &cevent.next)) { memcpy(&next_event, &cevent.next, sizeof(next_event)); next_id = cevent.id; From 9980dfe80e8ac3682ed803bd04400e60c0ef66c7 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:03:45 -0700 Subject: [PATCH 197/217] LoadSpawn2 converted to QueryDatabase --- zone/spawn2.cpp | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 53656489c..e7e5e9e81 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -384,28 +384,33 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2id, uint32 timeleft) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - if (RunQuery(query, MakeAnyLenString(&query, "SELECT id, spawngroupID, x, y, z, heading, respawntime, variance, pathgrid, _condition, cond_value, enabled, animation FROM spawn2 WHERE id=%i", spawn2id), errbuf, &result)) { - if (mysql_num_rows(result) == 1) - { - row = mysql_fetch_row(result); - bool perl_enabled = atoi(row[11]) == 1 ? true : false; - Spawn2* newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), timeleft, atoi(row[8]), atoi(row[9]), atoi(row[10]), perl_enabled, (EmuAppearance)atoi(row[12])); - spawn2_list.Insert( newSpawn ); - mysql_free_result(result); - safe_delete_array(query); - return newSpawn; - } - mysql_free_result(result); - } + std::string query = StringFormat("SELECT id, spawngroupID, x, y, z, heading, " + "respawntime, variance, pathgrid, _condition, " + "cond_value, enabled, animation FROM spawn2 " + "WHERE id = %i", spawn2id); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return nullptr; + } - LogFile->write(EQEMuLog::Error, "Error in LoadSpawn2 query '%s': %s", query, errbuf); - safe_delete_array(query); - return 0; + if (results.RowCount() != 1) { + LogFile->write(EQEMuLog::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return nullptr; + } + + auto row = results.begin(); + + bool perl_enabled = atoi(row[11]) == 1 ? true : false; + + Spawn2* newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), atof(row[3]), atof(row[4]), + atof(row[5]), atoi(row[6]), atoi(row[7]), timeleft, atoi(row[8]), + atoi(row[9]), atoi(row[10]), perl_enabled, (EmuAppearance)atoi(row[12])); + + spawn2_list.Insert(newSpawn); + + return newSpawn; } bool ZoneDatabase::CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, float heading, float x, float y, float z, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) From c70c7e13ec9510b09d33603b47ab14f5b6278b45 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:07:15 -0700 Subject: [PATCH 198/217] CreateSpawn2 converted to QueryDatabase --- zone/spawn2.cpp | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index e7e5e9e81..36ca4b3d6 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -413,38 +413,27 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2 return newSpawn; } -bool ZoneDatabase::CreateSpawn2(Client *c, uint32 spawngroup, const char* zone, float heading, float x, float y, float z, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) +bool ZoneDatabase::CreateSpawn2(Client *client, uint32 spawngroup, const char* zone, float heading, float x, float y, float z, uint32 respawn, uint32 variance, uint16 condition, int16 cond_value) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - uint32 affected_rows = 0; - - // if(GetInverseXY()==1) { - // float temp=x; - // x=y; - // y=temp; - // } - if (RunQuery(query, MakeAnyLenString(&query, - "INSERT INTO spawn2 (spawngroupID,zone,x,y,z,heading,respawntime,variance,_condition,cond_value) Values (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)", - spawngroup, zone, x, y, z, heading, respawn, variance, condition, cond_value - ), errbuf, 0, &affected_rows)) { - safe_delete_array(query); - if (affected_rows == 1) { - if(c) c->LogSQL(query); - return true; - } - else { - return false; - } - } - else { - LogFile->write(EQEMuLog::Error, "Error in CreateSpawn2 query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("INSERT INTO spawn2 (spawngroupID, zone, x, y, z, heading, " + "respawntime, variance, _condition, cond_value) " + "VALUES (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)", + spawngroup, zone, x, y, z, heading, + respawn, variance, condition, cond_value); + auto results = QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in CreateSpawn2 query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } - return false; + if (results.RowsAffected() != 1) + return false; + + if(client) + client->LogSQL(query.c_str()); + + return true; } uint32 Zone::CountSpawn2() { From 3cf4d4af1ba052d8cab8693ed3ad62ad02f8f5ed Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:10:15 -0700 Subject: [PATCH 199/217] UpdateDBEvent converted to QueryDatabase --- zone/spawn2.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 36ca4b3d6..f4cbe64a7 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -661,23 +661,20 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { } void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - int len; - SpawnCondition cond; - len = MakeAnyLenString(&query, - "UPDATE spawn_events SET " - "next_minute=%d, next_hour=%d, next_day=%d, next_month=%d, " - "next_year=%d, enabled=%d, strict=%d " - "WHERE id=%d", - event.next.minute, event.next.hour, event.next.day, event.next.month, - event.next.year, event.enabled?1:0, event.strict?1:0,event.id - ); - if(!database.RunQuery(query, len, errbuf)) { - LogFile->write(EQEMuLog::Error, "Unable to update spawn event '%s': %s\n", query, errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("UPDATE spawn_events SET " + "next_minute = %d, next_hour = %d, " + "next_day = %d, next_month = %d, " + "next_year = %d, enabled = %d, " + "strict = %d WHERE id = %d", + event.next.minute, event.next.hour, + event.next.day, event.next.month, + event.next.year, event.enabled? 1: 0, + event.strict? 1: 0, event.id); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Unable to update spawn event '%s': %s\n", query.c_str(), results.ErrorMessage().c_str()); + } void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) { From 538921701c42252531987da8ecc12477068a9b79 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:13:11 -0700 Subject: [PATCH 200/217] UpdatedDBCondition converted to QueryDatabase --- zone/spawn2.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index f4cbe64a7..7440f07af 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -678,19 +678,15 @@ void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) { } void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - int len; - SpawnCondition cond; - len = MakeAnyLenString(&query, - "REPLACE INTO spawn_condition_values (id, value, zone, instance_id) VALUES(%u, %u, '%s', %u)", - cond_id, value, zone_name, instance_id - ); - if(!database.RunQuery(query, len, errbuf)) { - LogFile->write(EQEMuLog::Error, "Unable to update spawn condition '%s': %s\n", query, errbuf); - } - safe_delete_array(query); + std::string query = StringFormat("REPLACE INTO spawn_condition_values " + "(id, value, zone, instance_id) " + "VALUES( %u, %u, '%s', %u)", + cond_id, value, zone_name, instance_id); + auto results = database.QueryDatabase(query); + if(!results.Success()) + LogFile->write(EQEMuLog::Error, "Unable to update spawn condition '%s': %s\n", query.c_str(), results.ErrorMessage().c_str()); + } bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) { From 7864a5285de41f05315ce06803fe22a47e35a2ec Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:18:51 -0700 Subject: [PATCH 201/217] LoadDBEvent converted to QueryDatabase --- zone/spawn2.cpp | 78 +++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 7440f07af..752052f2c 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -690,49 +690,45 @@ void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 inst } bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int len; - bool ret = false; - - len = MakeAnyLenString(&query, - "SELECT id,cond_id,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument,strict,zone " - "FROM spawn_events WHERE id=%d", event_id); - if (database.RunQuery(query, len, errbuf, &result)) { - safe_delete_array(query); - if((row = mysql_fetch_row(result))) { - event.id = atoi(row[0]); - event.condition_id = atoi(row[1]); - event.period = atoi(row[2]); - - event.next.minute = atoi(row[3]); - event.next.hour = atoi(row[4]); - event.next.day = atoi(row[5]); - event.next.month = atoi(row[6]); - event.next.year = atoi(row[7]); - - event.enabled = atoi(row[8])==0?false:true; - event.action = (SpawnEvent::Action) atoi(row[9]); - event.argument = atoi(row[10]); - event.strict = atoi(row[11])==0?false:true; - zone_name = row[12]; - - std::string t; - EQTime::ToString(&event.next, t); - _log(SPAWNS__CONDITIONS, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", - event.enabled?"enabled":"disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, t.c_str()); - - ret = true; - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadDBEvent query '%s': %s", query, errbuf); - safe_delete_array(query); + std::string query = StringFormat("SELECT id, cond_id, period, " + "next_minute, next_hour, next_day, " + "next_month, next_year, enabled, " + "action, argument, strict, zone " + "FROM spawn_events WHERE id = %d", event_id); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadDBEvent query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); + return false; } - return(ret); + + if (results.RowCount() == 0) + return false; + + auto row = results.begin(); + + event.id = atoi(row[0]); + event.condition_id = atoi(row[1]); + event.period = atoi(row[2]); + + event.next.minute = atoi(row[3]); + event.next.hour = atoi(row[4]); + event.next.day = atoi(row[5]); + event.next.month = atoi(row[6]); + event.next.year = atoi(row[7]); + + event.enabled = atoi(row[8]) != 0; + event.action = (SpawnEvent::Action) atoi(row[9]); + event.argument = atoi(row[10]); + event.strict = atoi(row[11]) != 0; + zone_name = row[12]; + + std::string timeAsString; + EQTime::ToString(&event.next, timeAsString); + + _log(SPAWNS__CONDITIONS, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str()); + + return true; } bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id) From 0240c6195252ebd55dbc16cc2dbb063becf6f78c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:31:55 -0700 Subject: [PATCH 202/217] LoadSpawnConditions converted to QueryDatabase --- zone/spawn2.cpp | 210 +++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 111 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 752052f2c..1e233a36f 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -733,94 +733,87 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std: bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int len; - //clear out old stuff.. spawn_conditions.clear(); - //load spawn conditions - SpawnCondition cond; - len = MakeAnyLenString(&query, "SELECT id, onchange, value FROM spawn_conditions WHERE zone='%s'", zone_name); - if (database.RunQuery(query, len, errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - cond.condition_id = atoi(row[0]); - cond.value = atoi(row[2]); - cond.on_change = (SpawnCondition::OnChange) atoi(row[1]); - spawn_conditions[cond.condition_id] = cond; - _log(SPAWNS__CONDITIONS, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query, errbuf); - safe_delete_array(query); + + std::string query = StringFormat("SELECT id, onchange, value " + "FROM spawn_conditions " + "WHERE zone = '%s'", zone_name); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + //load spawn conditions + SpawnCondition cond; + + cond.condition_id = atoi(row[0]); + cond.value = atoi(row[2]); + cond.on_change = (SpawnCondition::OnChange) atoi(row[1]); + spawn_conditions[cond.condition_id] = cond; + + _log(SPAWNS__CONDITIONS, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change); + } //load values - len = MakeAnyLenString(&query, "SELECT id, value FROM spawn_condition_values WHERE zone='%s' and instance_id=%u", zone_name, instance_id); - if (database.RunQuery(query, len, errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) - { - std::map::iterator iter = spawn_conditions.find(atoi(row[0])); - if(iter != spawn_conditions.end()) - { - iter->second.value = atoi(row[1]); - } - } - mysql_free_result(result); - } - else - { - LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query, errbuf); - safe_delete_array(query); + query = StringFormat("SELECT id, value FROM spawn_condition_values " + "WHERE zone = '%s' AND instance_id = %u", + zone_name, instance_id); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); spawn_conditions.clear(); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + auto iter = spawn_conditions.find(atoi(row[0])); + + if(iter != spawn_conditions.end()) + iter->second.value = atoi(row[1]); + } //load spawn events - SpawnEvent event; - len = MakeAnyLenString(&query, - "SELECT id,cond_id,period,next_minute,next_hour,next_day,next_month,next_year,enabled,action,argument,strict " - "FROM spawn_events WHERE zone='%s'", zone_name); - if (database.RunQuery(query, len, errbuf, &result)) { - safe_delete_array(query); - while((row = mysql_fetch_row(result))) { - event.id = atoi(row[0]); - event.condition_id = atoi(row[1]); - event.period = atoi(row[2]); - if(event.period == 0) { - LogFile->write(EQEMuLog::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id); - continue; - } - - event.next.minute = atoi(row[3]); - event.next.hour = atoi(row[4]); - event.next.day = atoi(row[5]); - event.next.month = atoi(row[6]); - event.next.year = atoi(row[7]); - - event.enabled = atoi(row[8])==0?false:true; - event.action = (SpawnEvent::Action) atoi(row[9]); - event.argument = atoi(row[10]); - event.strict = atoi(row[11])==0?false:true; - spawn_events.push_back(event); - - _log(SPAWNS__CONDITIONS, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", - event.enabled?"enabled":"disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict); - } - mysql_free_result(result); - } else { - LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions events query '%s': %s", query, errbuf); - safe_delete_array(query); + query = StringFormat("SELECT id, cond_id, period, next_minute, next_hour, " + "next_day, next_month, next_year, enabled, action, argument, strict " + "FROM spawn_events WHERE zone = '%s'", zone_name); + results = database.QueryDatabase(query); + if (!results.Success()) { + LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions events query '%s': %s", query.c_str(), results.ErrorMessage().c_str()); return false; - } + } + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnEvent event; + + event.id = atoi(row[0]); + event.condition_id = atoi(row[1]); + event.period = atoi(row[2]); + + if(event.period == 0) { + LogFile->write(EQEMuLog::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id); + continue; + } + + event.next.minute = atoi(row[3]); + event.next.hour = atoi(row[4]); + event.next.day = atoi(row[5]); + event.next.month = atoi(row[6]); + event.next.year = atoi(row[7]); + + event.enabled = atoi(row[8])==0?false:true; + event.action = (SpawnEvent::Action) atoi(row[9]); + event.argument = atoi(row[10]); + event.strict = atoi(row[11])==0?false:true; + + spawn_events.push_back(event); + + _log(SPAWNS__CONDITIONS, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict); + } //now we need to catch up on events that happened while we were away //and use them to alter just the condition variables. @@ -834,11 +827,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in TimeOfDay_Struct tod; zone->zone_time.getEQTimeOfDay(&tod); - std::vector::iterator cur,end; - cur = spawn_events.begin(); - end = spawn_events.end(); - bool ran; - for(; cur != end; ++cur) { + for(auto cur = spawn_events.begin(); cur != spawn_events.end(); ++cur) { SpawnEvent &cevent = *cur; bool StrictCheck = false; @@ -853,43 +842,42 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in if(!cevent.enabled || !StrictCheck) SetCondition(zone->GetShortName(), zone->GetInstanceID(),cevent.condition_id,0); - if(cevent.enabled) - { - //watch for special case of all 0s, which means to reset next to now - if(cevent.next.year == 0 && cevent.next.month == 0 && cevent.next.day == 0 && cevent.next.hour == 0 && cevent.next.minute == 0) { - _log(SPAWNS__CONDITIONS, "Initial next trigger time set for spawn event %d", cevent.id); - memcpy(&cevent.next, &tod, sizeof(cevent.next)); - //add one period - EQTime::AddMinutes(cevent.period, &cevent.next); - //save it in the db. - UpdateDBEvent(cevent); - continue; //were done with this event. - } + if(!cevent.enabled) + continue; - ran = false; - while(EQTime::IsTimeBefore(&tod, &cevent.next)) { - _log(SPAWNS__CONDITIONS, "Catch up triggering on event %d", cevent.id); - //this event has been triggered. - //execute the event - if(!cevent.strict || StrictCheck) - ExecEvent(cevent, false); + //watch for special case of all 0s, which means to reset next to now + if(cevent.next.year == 0 && cevent.next.month == 0 && cevent.next.day == 0 && cevent.next.hour == 0 && cevent.next.minute == 0) { + _log(SPAWNS__CONDITIONS, "Initial next trigger time set for spawn event %d", cevent.id); + memcpy(&cevent.next, &tod, sizeof(cevent.next)); + //add one period + EQTime::AddMinutes(cevent.period, &cevent.next); + //save it in the db. + UpdateDBEvent(cevent); + continue; //were done with this event. + } - //add the period of the event to the trigger time - EQTime::AddMinutes(cevent.period, &cevent.next); - ran = true; - } - //only write it out if the event actually ran - if(ran) { - //save the event in the DB - UpdateDBEvent(cevent); - } - } + bool ran = false; + while(EQTime::IsTimeBefore(&tod, &cevent.next)) { + _log(SPAWNS__CONDITIONS, "Catch up triggering on event %d", cevent.id); + //this event has been triggered. + //execute the event + if(!cevent.strict || StrictCheck) + ExecEvent(cevent, false); + + //add the period of the event to the trigger time + EQTime::AddMinutes(cevent.period, &cevent.next); + ran = true; + } + + //only write it out if the event actually ran + if(ran) + UpdateDBEvent(cevent); //save the event in the DB } //now our event timers are all up to date, find our closest event. FindNearestEvent(); - return(true); + return true; } void SpawnConditionManager::FindNearestEvent() { From b6875564d41c5c7bce10cab252a69b244bad663a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 13:47:18 -0700 Subject: [PATCH 203/217] GetCondition converted to QueryDatabase --- zone/spawn2.cpp | 51 ++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 1e233a36f..25cbb8ccf 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -1129,37 +1129,28 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc } SpawnCondition &cond = condi->second; - return(cond.value); - } else { - //this is a remote spawn condition, grab it from the DB - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; - int len; - - int16 value; - - //load spawn conditions - SpawnCondition cond; - len = MakeAnyLenString(&query, "SELECT value FROM spawn_condition_values WHERE zone='%s' AND instance_id=%u AND id=%d", - zone_short, instance_id, condition_id); - if (database.RunQuery(query, len, errbuf, &result)) { - safe_delete_array(query); - if((row = mysql_fetch_row(result))) { - value = atoi(row[0]); - } else { - _log(SPAWNS__CONDITIONS, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short); - value = 0; //dunno a better thing to do... - } - mysql_free_result(result); - } else { - _log(SPAWNS__CONDITIONS, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short); - safe_delete_array(query); - value = 0; //dunno a better thing to do... - } - return(value); + return cond.value; } + + //this is a remote spawn condition, grab it from the DB + //load spawn conditions + std::string query = StringFormat("SELECT value FROM spawn_condition_values " + "WHERE zone = '%s' AND instance_id = %u AND id = %d", + zone_short, instance_id, condition_id); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + _log(SPAWNS__CONDITIONS, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short); + return 0; //dunno a better thing to do... + } + + if (results.RowCount() == 0) { + _log(SPAWNS__CONDITIONS, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short); + return 0; //dunno a better thing to do... + } + + auto row = results.begin(); + + return atoi(row[0]); } bool SpawnConditionManager::Check(uint16 condition, int16 min_value) { From c851cd3f120d070996d3d73b238965cf5803a01b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 14:06:52 -0700 Subject: [PATCH 204/217] Handle_OP_ItemLinkClick converted to QueryDatabase --- zone/client_packet.cpp | 55 +++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index f35ec0565..5ec2e9e9e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3137,6 +3137,7 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) DumpPacket(app); return; } + DumpPacket(app); ItemViewRequest_Struct* ivrs = (ItemViewRequest_Struct*)app->pBuffer; @@ -3156,30 +3157,24 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) silentsaylink = true; } - if (sayid && sayid > 0) + if (sayid > 0) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result; - MYSQL_ROW row; + std::string query = StringFormat("SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + Message(13, "Error: The saylink (%s) was not found in the database.", response.c_str()); + return; + } - if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid),errbuf,&result)) - { - if (mysql_num_rows(result) == 1) - { - row = mysql_fetch_row(result); - response = row[0]; - } - mysql_free_result(result); - } - else - { - Message(13, "Error: The saylink (%s) was not found in the database.",response.c_str()); - safe_delete_array(query); + if (results.RowCount() != 1) { + Message(13, "Error: The saylink (%s) was not found in the database.", response.c_str()); return; } - safe_delete_array(query); + + auto row = results.begin(); + response = row[0]; + } if((response).size() > 0) @@ -4628,7 +4623,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) p_timers.Start(pTimerHarmTouch, HarmTouchReuseTime); } - + if (spell_to_cast > 0) // if we've matched LoH or HT, cast now CastSpell(spell_to_cast, castspell->target_id, castspell->slot); } @@ -5864,9 +5859,9 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) else this->DeleteItemInInventory(mp->itemslot,mp->quantity,false); - //This forces the price to show up correctly for charged items. + //This forces the price to show up correctly for charged items. if(inst->IsCharged()) - mp->quantity = 1; + mp->quantity = 1; EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerSell, sizeof(Merchant_Purchase_Struct)); Merchant_Purchase_Struct* mco=(Merchant_Purchase_Struct*)outapp->pBuffer; @@ -7635,7 +7630,7 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app) int mendhp = GetMaxHP() / 4; int currenthp = GetHP(); if (MakeRandomInt(0, 199) < (int)GetSkill(SkillMend)) { - + int criticalchance = spellbonuses.CriticalMend + itembonuses.CriticalMend + aabonuses.CriticalMend; if(MakeRandomInt(0,99) < criticalchance){ @@ -9532,7 +9527,7 @@ void Client::CompleteConnect() { /* This sub event is for if a player logs in for the first time since entering world. */ if (firstlogon == 1){ - parse->EventPlayer(EVENT_CONNECT, this, "", 0); + parse->EventPlayer(EVENT_CONNECT, this, "", 0); /* QS: PlayerLogConnectDisconnect */ if (RuleB(QueryServ, PlayerLogConnectDisconnect)){ std::string event_desc = StringFormat("Connect :: Logged into zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID()); @@ -12775,7 +12770,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } } - } + } /* Cursor to Item storage */ else { uint32 max_currency = GetAlternateCurrencyValue(reclaim->currency_id); @@ -12784,7 +12779,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { if(reclaim->count > max_currency) { SummonItem(item_id, max_currency); SetAlternateCurrencyValue(reclaim->currency_id, 0); - } + } else { SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, false, MainCursor); AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count)); @@ -12793,7 +12788,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) { if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ std::string event_desc = StringFormat("Reclaim :: Cursor to Item :: alt_currency_id:%i amount:-%i in zoneid:%i instid:%i", reclaim->currency_id, reclaim->count, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); - } + } } } @@ -12885,8 +12880,8 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) { /* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/ if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ std::string event_desc = StringFormat("Sold to Merchant :: itemid:%u npcid:%u alt_currency_id:%u cost:%u in zoneid:%u instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID()); - QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); - } + QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); + } FastQueuePacket(&outapp); AddAlternateCurrencyValue(alt_cur_id, cost); @@ -12947,7 +12942,7 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) switch(Command) { case 0: - { + { VERIFY_PACKET_LENGTH(OP_LFGuild, app, LFGuild_PlayerToggle_Struct); LFGuild_PlayerToggle_Struct *pts = (LFGuild_PlayerToggle_Struct *)app->pBuffer; From 4d0179d525633175548a71b9b0182fd16c6e8588 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 14:13:06 -0700 Subject: [PATCH 205/217] Handle_OP_SetStartCity converted to QueryDatabase --- zone/client_packet.cpp | 102 ++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 63 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 5ec2e9e9e..3ab2338c7 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11405,92 +11405,68 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) Message(15,"Your home city has already been set.", m_pp.binds[4].zoneId, database.GetZoneName(m_pp.binds[4].zoneId)); return; } + if (app->size < 1) { LogFile->write(EQEMuLog::Error, "Wrong size: OP_SetStartCity, size=%i, expected %i", app->size, 1); DumpPacket(app); return; } - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; - MYSQL_RES *result = nullptr; - MYSQL_ROW row = 0; float x(0),y(0),z(0); uint32 zoneid = 0; + uint32 startCity = (uint32)strtol((const char*)app->pBuffer, nullptr, 10); - uint32 StartCity = (uint32)strtol((const char*)app->pBuffer, nullptr, 10); - bool ValidCity = false; - database.RunQuery - ( - query, - MakeAnyLenString - ( - &query, - "SELECT zone_id, bind_id, x, y, z FROM start_zones " - "WHERE player_class=%i AND player_deity=%i AND player_race=%i", - m_pp.class_, - m_pp.deity, - m_pp.race - ), - errbuf, - &result - ); - safe_delete_array(query); - - if(!result) { + std::string query = StringFormat("SELECT zone_id, bind_id, x, y, z FROM start_zones " + "WHERE player_class=%i AND player_deity=%i AND player_race=%i", + m_pp.class_, m_pp.deity, m_pp.race); + auto results = database.QueryDatabase(query); + if(!results.Success()) { LogFile->write(EQEMuLog::Error, "No valid start zones found for /setstartcity"); return; } - while(row = mysql_fetch_row(result)) { + bool validCity = false; + for (auto row = results.begin(); row != results.end(); ++row) { if(atoi(row[1]) != 0) zoneid = atoi(row[1]); else zoneid = atoi(row[0]); - if(zoneid == StartCity) { - ValidCity = true; - x = atof(row[2]); - y = atof(row[3]); - z = atof(row[4]); - } + if(zoneid != startCity) + continue; + + validCity = true; + x = atof(row[2]); + y = atof(row[3]); + z = atof(row[4]); } - if(ValidCity) { + if(validCity) { Message(15,"Your home city has been set"); - SetStartZone(StartCity, x, y, z); - } - else { - database.RunQuery - ( - query, - MakeAnyLenString - ( - &query, - "SELECT zone_id, bind_id FROM start_zones " - "WHERE player_class=%i AND player_deity=%i AND player_race=%i", - m_pp.class_, - m_pp.deity, - m_pp.race - ), - errbuf, - &result - ); - safe_delete_array(query); - Message(15,"Use \"/startcity #\" to choose a home city from the following list:"); - char* name; - while(row = mysql_fetch_row(result)) { - if(atoi(row[1]) != 0) - zoneid = atoi(row[1]); - else - zoneid = atoi(row[0]); - database.GetZoneLongName(database.GetZoneName(zoneid),&name); - Message(15,"%d - %s", zoneid, name); - safe_delete_array(name); - } + SetStartZone(startCity, x, y, z); + return; } - mysql_free_result(result); + query = StringFormat("SELECT zone_id, bind_id FROM start_zones " + "WHERE player_class=%i AND player_deity=%i AND player_race=%i", + m_pp.class_, m_pp.deity, m_pp.race); + results = database.QueryDatabase(query); + if (!results.Success()) + return; + + Message(15,"Use \"/startcity #\" to choose a home city from the following list:"); + + for (auto row = results.begin(); row != results.end(); ++row) { + if(atoi(row[1]) != 0) + zoneid = atoi(row[1]); + else + zoneid = atoi(row[0]); + + char* name; + database.GetZoneLongName(database.GetZoneName(zoneid), &name); + Message(15,"%d - %s", zoneid, name); + } + } void Client::Handle_OP_Report(const EQApplicationPacket *app) From f948786f6a22b16abc76bc13ceb3874fc7d557ac Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 14:21:33 -0700 Subject: [PATCH 206/217] Handle_OP_GMSearchCorpse converted to QueryDatabase --- zone/client_packet.cpp | 101 ++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 62 deletions(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 3ab2338c7..7cc3ebe85 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11573,7 +11573,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) // Could make this into a rule, although there is a hard limit since we are using a popup, of 4096 bytes that can // be displayed in the window, including all the HTML formatting tags. // - const int MaxResults = 10; + const int maxResults = 10; if(app->size < sizeof(GMSearchCorpse_Struct)) { @@ -11586,85 +11586,62 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) GMSearchCorpse_Struct *gmscs = (GMSearchCorpse_Struct *)app->pBuffer; gmscs->Name[63] = '\0'; - char errbuf[MYSQL_ERRMSG_SIZE]; - char* Query = 0; - MYSQL_RES *Result; - MYSQL_ROW Row; + char *escSearchString = new char[129]; + database.DoEscapeString(escSearchString, gmscs->Name, strlen(gmscs->Name)); - char *EscSearchString = new char[129]; + std::string query = StringFormat("SELECT charname, zoneid, x, y, z, timeofdeath, rezzed, IsBurried " + "FROM player_corpses WheRE charname LIKE '%%%s%%' ORDER BY charname LIMIT %i", + escSearchString, maxResults); + safe_delete_array(escSearchString); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + Message(0, "Query failed: %s.", results.ErrorMessage().c_str()); + return; + } - database.DoEscapeString(EscSearchString, gmscs->Name, strlen(gmscs->Name)); + if (results.RowCount() == 0) + return; - if (database.RunQuery(Query, MakeAnyLenString(&Query, "select charname, zoneid, x, y, z, timeofdeath, rezzed, IsBurried from " - "player_corpses where charname like '%%%s%%' order by charname limit %i", - EscSearchString, MaxResults), errbuf, &Result)) - { + if(results.RowCount() == maxResults) + Message(clientMessageError, "Your search found too many results; some are not displayed."); + else + Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", results.RowCount(), gmscs->Name); - int NumberOfRows = mysql_num_rows(Result); + char charName[64], timeOfDeath[20]; - if(NumberOfRows == MaxResults) - Message(clientMessageError, "Your search found too many results; some are not displayed."); - else { - Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", - NumberOfRows, gmscs->Name); - } - - if(NumberOfRows == 0) - { - mysql_free_result(Result); - safe_delete_array(Query); - return; - } - - char CharName[64], TimeOfDeath[20], Buffer[512]; - - std::string PopupText = "
NameZoneXYZDate" + std::string popupText = ""; + for (auto row = results.begin(); row != results.end(); ++row) { - while ((Row = mysql_fetch_row(Result))) - { + strn0cpy(charName, row[0], sizeof(charName)); - strn0cpy(CharName, Row[0], sizeof(CharName)); + uint32 ZoneID = atoi(row[1]); + float CorpseX = atof(row[2]); + float CorpseY = atof(row[3]); + float CorpseZ = atof(row[4]); - uint32 ZoneID = atoi(Row[1]); + strn0cpy(timeOfDeath, row[5], sizeof(timeOfDeath)); - float CorpseX = atof(Row[2]); - float CorpseY = atof(Row[3]); - float CorpseZ = atof(Row[4]); + bool corpseRezzed = atoi(row[6]); + bool corpseBuried = atoi(row[7]); - strn0cpy(TimeOfDeath, Row[5], sizeof(TimeOfDeath)); + popupText += StringFormat("", + charName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, timeOfDeath, + corpseRezzed ? "Yes" : "No", corpseBuried ? "Yes" : "No"); - bool CorpseRezzed = atoi(Row[6]); - bool CorpseBuried = atoi(Row[7]); + if(popupText.size() > 4000) { + Message(clientMessageError, "Unable to display all the results."); + break; + } - sprintf(Buffer, "", - CharName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, TimeOfDeath, - CorpseRezzed ? "Yes" : "No", CorpseBuried ? "Yes" : "No"); + } - PopupText += Buffer; + popupText += "
NameZoneXYZDate" "RezzedBuried
 " "
%s%s%8.0f%8.0f%8.0f%s%s%s
%s%s%8.0f%8.0f%8.0f%s%s%s
"; - if(PopupText.size() > 4000) - { - Message(clientMessageError, "Unable to display all the results."); - break; - } + SendPopupToClient("Corpses", popupText.c_str()); - } - - PopupText += "
"; - - mysql_free_result(Result); - - SendPopupToClient("Corpses", PopupText.c_str()); - } - else{ - Message(0, "Query failed: %s.", errbuf); - - } - safe_delete_array(Query); - safe_delete_array(EscSearchString); } void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) From 50e6d0d256a62ca06d52142bf50eb3f4f6dc9087 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 24 Aug 2014 16:02:21 -0700 Subject: [PATCH 207/217] Load converted to QueryDatabase --- zone/guild_mgr.cpp | 146 +++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 92 deletions(-) diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 087878ffc..876feb4bd 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -644,104 +644,66 @@ GuildBankManager::~GuildBankManager() } } -bool GuildBankManager::Load(uint32 GuildID) +bool GuildBankManager::Load(uint32 guildID) { - const char *LoadQuery = "SELECT `area`, `slot`, `itemid`, `qty`, `donator`, `permissions`, `whofor` from `guild_bank` " - "WHERE `guildid` = %i"; - - char errbuf[MYSQL_ERRMSG_SIZE]; - - char* query = 0; - - MYSQL_RES *result; - - MYSQL_ROW row; - - if(database.RunQuery(query, MakeAnyLenString(&query, LoadQuery, GuildID), errbuf, &result)) - { - GuildBank *Bank = new GuildBank; - - Bank->GuildID = GuildID; - - for(int i = 0; i < GUILD_BANK_MAIN_AREA_SIZE; ++i) - Bank->Items.MainArea[i].ItemID = 0; - - for(int i = 0; i < GUILD_BANK_DEPOSIT_AREA_SIZE; ++i) - Bank->Items.DepositArea[i].ItemID = 0; - - char Donator[64], WhoFor[64]; - - while((row = mysql_fetch_row(result))) - { - int Area = atoi(row[0]); - - int Slot = atoi(row[1]); - - int ItemID = atoi(row[2]); - - int Qty = atoi(row[3]); - - if(row[4]) - strn0cpy(Donator, row[4], sizeof(Donator)); - else - Donator[0] = '\0'; - - int Permissions = atoi(row[5]); - - if(row[6]) - strn0cpy(WhoFor, row[6], sizeof(WhoFor)); - else - WhoFor[0] = '\0'; - - if(Area == GuildBankMainArea) - { - if((Slot >= 0) && (Slot < GUILD_BANK_MAIN_AREA_SIZE)) - { - Bank->Items.MainArea[Slot].ItemID = ItemID; - - Bank->Items.MainArea[Slot].Quantity = Qty; - - strn0cpy(Bank->Items.MainArea[Slot].Donator, Donator, sizeof(Donator)); - - Bank->Items.MainArea[Slot].Permissions = Permissions; - - strn0cpy(Bank->Items.MainArea[Slot].WhoFor, WhoFor, sizeof(WhoFor)); - } - } - else - { - if((Slot >= 0 ) && (Slot < GUILD_BANK_DEPOSIT_AREA_SIZE)) - { - Bank->Items.DepositArea[Slot].ItemID = ItemID; - - Bank->Items.DepositArea[Slot].Quantity = Qty; - - strn0cpy(Bank->Items.DepositArea[Slot].Donator, Donator, sizeof(Donator)); - - Bank->Items.DepositArea[Slot].Permissions = Permissions; - - strn0cpy(Bank->Items.DepositArea[Slot].WhoFor, WhoFor, sizeof(WhoFor)); - } - } - - } - mysql_free_result(result); - - safe_delete_array(query); - - Banks.push_back(Bank); - } - else - { - _log(GUILDS__BANK_ERROR, "Error Loading guild bank: %s, %s", query, errbuf); - - safe_delete_array(query); + std::string query = StringFormat("SELECT `area`, `slot`, `itemid`, `qty`, `donator`, `permissions`, `whofor` " + "FROM `guild_bank` WHERE `guildid` = %i", guildID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + _log(GUILDS__BANK_ERROR, "Error Loading guild bank: %s, %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - return true; + GuildBank *bank = new GuildBank; + bank->GuildID = guildID; + + for(int i = 0; i < GUILD_BANK_MAIN_AREA_SIZE; ++i) + bank->Items.MainArea[i].ItemID = 0; + + for(int i = 0; i < GUILD_BANK_DEPOSIT_AREA_SIZE; ++i) + bank->Items.DepositArea[i].ItemID = 0; + + char donator[64], whoFor[64]; + + for (auto row = results.begin(); row != results.end(); ++row) + { + int area = atoi(row[0]); + int slot = atoi(row[1]); + int itemID = atoi(row[2]); + int qty = atoi(row[3]); + + if(row[4]) + strn0cpy(donator, row[4], sizeof(donator)); + else + donator[0] = '\0'; + + int permissions = atoi(row[5]); + + if(row[6]) + strn0cpy(whoFor, row[6], sizeof(whoFor)); + else + whoFor[0] = '\0'; + + if(slot < 0 || + ((area != GuildBankMainArea || slot >= GUILD_BANK_MAIN_AREA_SIZE) || + (area == GuildBankMainArea || slot >= GUILD_BANK_DEPOSIT_AREA_SIZE))) + continue; + + bank->Items.MainArea[slot].ItemID = itemID; + bank->Items.MainArea[slot].Quantity = qty; + + strn0cpy(bank->Items.MainArea[slot].Donator, donator, sizeof(donator)); + + bank->Items.MainArea[slot].Permissions = permissions; + + strn0cpy(bank->Items.MainArea[slot].WhoFor, whoFor, sizeof(whoFor)); + } + + Banks.push_back(bank); + + return true; } bool GuildBankManager::IsLoaded(uint32 GuildID) From b3ea7ecd0d8f8ed01f24226ef95f817689f85d29 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Sun, 24 Aug 2014 19:11:41 -0400 Subject: [PATCH 208/217] Added param to special attack NPC_NO_CHASE Param 2 = If set will disable LOS check --- zone/aggro.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zone/aggro.cpp b/zone/aggro.cpp index 109720e47..30ef4087d 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -877,8 +877,12 @@ bool Mob::CombatRange(Mob* other) if (GetSpecialAbility(NPC_CHASE_DISTANCE)){ + bool DoLoSCheck = true; float max_dist = static_cast(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 0)); float min_dist = static_cast(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 1)); + + if (GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 2)); + DoLoSCheck = false; //Ignore line of sight check if (max_dist == 1) max_dist = 250.0f; //Default it to 250 if you forget to put a value @@ -890,7 +894,7 @@ bool Mob::CombatRange(Mob* other) else min_dist = min_dist * min_dist; - if (CheckLastLosState() && (_DistNoRoot >= min_dist && _DistNoRoot <= max_dist)) + if ((DoLoSCheck && CheckLastLosState()) && (_DistNoRoot >= min_dist && _DistNoRoot <= max_dist)) SetPseudoRoot(true); else SetPseudoRoot(false); From 412835d7fac699a7224dcdbb5aba971ece8de2fc Mon Sep 17 00:00:00 2001 From: KimLS Date: Sun, 24 Aug 2014 16:26:51 -0700 Subject: [PATCH 209/217] Basic string tests, plus fix for StringFormat returning a std::string that was just very subtley malformed. --- common/string_util.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- common/string_util.h | 1 + tests/CMakeLists.txt | 5 +++-- tests/main.cpp | 2 ++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/common/string_util.cpp b/common/string_util.cpp index 0ccd0e4ef..2fcb59e05 100644 --- a/common/string_util.cpp +++ b/common/string_util.cpp @@ -53,10 +53,11 @@ const std::string vStringFormat(const char* format, va_list args) return ""; } else if ((unsigned int)characters_used > output.capacity()) { - output.resize(characters_used+1); + output.resize(characters_used + 1); va_copy(tmpargs,args); characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs); va_end(tmpargs); + output.resize(characters_used); if (characters_used < 0) { // We shouldn't have a format error by this point, but I can't imagine what error we @@ -72,6 +73,8 @@ const std::string vStringFormat(const char* format, va_list args) characters_used = vsnprintf(&output[0], output.capacity(), format, tmpargs); va_end(tmpargs); + output.resize(characters_used); + if (characters_used < 0) { // We shouldn't have a format error by this point, but I can't imagine what error we // could have by this point. Still, return empty string; @@ -380,6 +383,42 @@ std::string EscapeString(const std::string &s) { return ret; } +std::string EscapeString(const char *src, size_t sz) { + std::string ret; + + for(size_t i = 0; i < sz; ++i) { + char c = src[i]; + switch(c) { + case '\x00': + ret += "\\x00"; + break; + case '\n': + ret += "\\n"; + break; + case '\r': + ret += "\\r"; + break; + case '\\': + ret += "\\\\"; + break; + case '\'': + ret += "\\'"; + break; + case '\"': + ret += "\\\""; + break; + case '\x1a': + ret += "\\x1a"; + break; + default: + ret.push_back(c); + break; + } + } + + return ret; +} + bool isAlphaNumeric(const char *text) { for (unsigned int charIndex=0; charIndex Date: Sun, 24 Aug 2014 16:30:02 -0700 Subject: [PATCH 210/217] Idiot kls missed a file --- tests/string_util_test.h | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/string_util_test.h diff --git a/tests/string_util_test.h b/tests/string_util_test.h new file mode 100644 index 000000000..374878065 --- /dev/null +++ b/tests/string_util_test.h @@ -0,0 +1,85 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __EQEMU_TESTS_STRING_UTIL_H +#define __EQEMU_TESTS_STRING_UTIL_H + +#include "cppunit/cpptest.h" +#include "../common/string_util.h" + +class StringUtilTest : public Test::Suite { + typedef void(IPCMutexTest::*TestFunction)(void); +public: + StringUtilTest() { + TEST_ADD(StringUtilTest::StringFormatTest); + TEST_ADD(StringUtilTest::EscapeStringTest); + TEST_ADD(StringUtilTest::EscapeStringMemoryTest); + } + + ~StringUtilTest() { + } + + private: + void StringFormatTest() { + const char* fmt = "Test: %c %d %4.2f"; + char c = 'a'; + int i = 2014; + float f = 3.1416; + + auto s = StringFormat(fmt, c, i, f); + TEST_ASSERT(s.length() == 17); + TEST_ASSERT(s.compare("Test: a 2014 3.14") == 0); + } + + void EscapeStringTest() { + std::string t; + t.resize(10); + t[0] = 'a'; + t[1] = 'b'; + t[2] = 'c'; + t[3] = '\x00'; + t[4] = '\n'; + t[5] = '\r'; + t[6] = '\\'; + t[7] = '\''; + t[8] = '\"'; + t[9] = '\x1a'; + + auto s = EscapeString(t); + TEST_ASSERT(s.compare("abc\\x00\\n\\r\\\\\\'\\\"\\x1a") == 0); + } + + void EscapeStringMemoryTest() { + char t[10] = { 0 }; + t[0] = 'a'; + t[1] = 'b'; + t[2] = 'c'; + t[3] = '\x00'; + t[4] = '\n'; + t[5] = '\r'; + t[6] = '\\'; + t[7] = '\''; + t[8] = '\"'; + t[9] = '\x1a'; + + auto s = EscapeString(t, 10); + TEST_ASSERT(s.compare("abc\\x00\\n\\r\\\\\\'\\\"\\x1a") == 0); + } +}; + +#endif From 67a774dd9b4b8a3ecabe868d1456f6cff114877d Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 24 Aug 2014 22:28:37 -0400 Subject: [PATCH 211/217] Remove extra c_str() non-sense now that the bug is fixed --- zone/queryserv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index 2b02d193c..ad7de0424 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -47,6 +47,6 @@ void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Eve { std::string query = StringFormat( "INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))", - Event_Type, Character_ID, EscapeString(Event_Desc.c_str()).c_str()); + Event_Type, Character_ID, EscapeString(Event_Desc).c_str()); SendQuery(query); -} \ No newline at end of file +} From 00852063c2990fce2dcef0d01e203ec3b301ebb0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 25 Aug 2014 12:15:06 -0700 Subject: [PATCH 212/217] Promote converted to QueryDatabase --- zone/guild_mgr.cpp | 81 ++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 876feb4bd..316ec6409 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -935,90 +935,73 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32 return true; } -int GuildBankManager::Promote(uint32 GuildID, int SlotID) +int GuildBankManager::Promote(uint32 guildID, int slotID) { - if((SlotID < 0) || (SlotID > (GUILD_BANK_DEPOSIT_AREA_SIZE - 1))) + if((slotID < 0) || (slotID > (GUILD_BANK_DEPOSIT_AREA_SIZE - 1))) return -1; - std::list::iterator Iterator = GetGuildBank(GuildID); + auto iter = GetGuildBank(guildID); - if(Iterator == Banks.end()) - { + if(iter == Banks.end()) return -1; - } - if((*Iterator)->Items.DepositArea[SlotID].ItemID == 0) - { + if((*iter)->Items.DepositArea[slotID].ItemID == 0) return -1; - } - int MainSlot = -1; + int mainSlot = -1; for(int i = 0; i < GUILD_BANK_MAIN_AREA_SIZE; ++i) - if((*Iterator)->Items.MainArea[i].ItemID == 0) - { - MainSlot = i; - + if((*iter)->Items.MainArea[i].ItemID == 0) { + mainSlot = i; break; } - if(MainSlot == -1) + if(mainSlot == -1) return -1; + (*iter)->Items.MainArea[mainSlot].ItemID = (*iter)->Items.DepositArea[slotID].ItemID; + (*iter)->Items.MainArea[mainSlot].Quantity = (*iter)->Items.DepositArea[slotID].Quantity; + (*iter)->Items.MainArea[mainSlot].Permissions = (*iter)->Items.DepositArea[slotID].Permissions; - (*Iterator)->Items.MainArea[MainSlot].ItemID = (*Iterator)->Items.DepositArea[SlotID].ItemID; - - (*Iterator)->Items.MainArea[MainSlot].Quantity = (*Iterator)->Items.DepositArea[SlotID].Quantity; - - strn0cpy((*Iterator)->Items.MainArea[MainSlot].Donator, (*Iterator)->Items.DepositArea[SlotID].Donator, sizeof((*Iterator)->Items.MainArea[MainSlot].Donator)); - (*Iterator)->Items.MainArea[MainSlot].Permissions = (*Iterator)->Items.DepositArea[SlotID].Permissions; - - strn0cpy((*Iterator)->Items.MainArea[MainSlot].WhoFor, (*Iterator)->Items.DepositArea[SlotID].WhoFor, sizeof((*Iterator)->Items.MainArea[MainSlot].WhoFor)); - - const char *Query="UPDATE `guild_bank` SET `area` = 1, `slot` = %i WHERE `guildid` = %i AND `area` = 0 AND `slot` = %i LIMIT 1"; - - char errbuf[MYSQL_ERRMSG_SIZE]; - - char* query = 0; - - if(!database.RunQuery(query, MakeAnyLenString(&query, Query, MainSlot, GuildID, SlotID), errbuf)) - { - _log(GUILDS__BANK_ERROR, "error promoting item: %s : %s", query, errbuf); - - safe_delete_array(query); + strn0cpy((*iter)->Items.MainArea[mainSlot].Donator, (*iter)->Items.DepositArea[slotID].Donator, sizeof((*iter)->Items.MainArea[mainSlot].Donator)); + strn0cpy((*iter)->Items.MainArea[mainSlot].WhoFor, (*iter)->Items.DepositArea[slotID].WhoFor, sizeof((*iter)->Items.MainArea[mainSlot].WhoFor)); + std::string query = StringFormat("UPDATE `guild_bank` SET `area` = 1, `slot` = %i " + "WHERE `guildid` = %i AND `area` = 0 AND `slot` = %i " + "LIMIT 1", mainSlot, guildID, slotID); + auto results = database.QueryDatabase(query); + if (!results.Success()) { + _log(GUILDS__BANK_ERROR, "error promoting item: %s : %s", query.c_str(), results.ErrorMessage().c_str()); return -1; } - safe_delete_array(query); + (*iter)->Items.DepositArea[slotID].ItemID = 0; - (*Iterator)->Items.DepositArea[SlotID].ItemID = 0; - - const Item_Struct *Item = database.GetItem((*Iterator)->Items.MainArea[MainSlot].ItemID); + const Item_Struct *Item = database.GetItem((*iter)->Items.MainArea[mainSlot].ItemID); GuildBankItemUpdate_Struct gbius; if(!Item->Stackable) - gbius.Init(GuildBankItemUpdate, 1, MainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, 1, 0, 0, 0); + gbius.Init(GuildBankItemUpdate, 1, mainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, 1, 0, 0, 0); else { - if((*Iterator)->Items.MainArea[MainSlot].Quantity == Item->StackSize) - gbius.Init(GuildBankItemUpdate, 1, MainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, - (*Iterator)->Items.MainArea[MainSlot].Quantity, 0, 0, 0); + if((*iter)->Items.MainArea[mainSlot].Quantity == Item->StackSize) + gbius.Init(GuildBankItemUpdate, 1, mainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, + (*iter)->Items.MainArea[mainSlot].Quantity, 0, 0, 0); else - gbius.Init(GuildBankItemUpdate, 1, MainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, - (*Iterator)->Items.MainArea[MainSlot].Quantity, 0, 1, 0); + gbius.Init(GuildBankItemUpdate, 1, mainSlot, GuildBankMainArea, 1, Item->ID, Item->Icon, + (*iter)->Items.MainArea[mainSlot].Quantity, 0, 1, 0); } strn0cpy(gbius.ItemName, Item->Name, sizeof(gbius.ItemName)); - entity_list.QueueClientsGuildBankItemUpdate(&gbius, GuildID); + entity_list.QueueClientsGuildBankItemUpdate(&gbius, guildID); - gbius.Init(GuildBankItemUpdate, 1, SlotID, GuildBankDepositArea, 0, 0, 0, 0, 0, 0, 0); + gbius.Init(GuildBankItemUpdate, 1, slotID, GuildBankDepositArea, 0, 0, 0, 0, 0, 0, 0); - entity_list.QueueClientsGuildBankItemUpdate(&gbius, GuildID); + entity_list.QueueClientsGuildBankItemUpdate(&gbius, guildID); - return MainSlot; + return mainSlot; } void GuildBankManager::SetPermissions(uint32 GuildID, uint16 SlotID, uint32 Permissions, const char *MemberName) From c3fdbfe90469f4f46aef164c279fa1387675191d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 25 Aug 2014 12:33:09 -0700 Subject: [PATCH 213/217] SetPermissions converted to QueryDatabase --- zone/guild_mgr.cpp | 68 +++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 316ec6409..3f477df6f 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -1004,70 +1004,58 @@ int GuildBankManager::Promote(uint32 guildID, int slotID) return mainSlot; } -void GuildBankManager::SetPermissions(uint32 GuildID, uint16 SlotID, uint32 Permissions, const char *MemberName) +void GuildBankManager::SetPermissions(uint32 guildID, uint16 slotID, uint32 permissions, const char *memberName) { - if((SlotID > (GUILD_BANK_MAIN_AREA_SIZE - 1))) + if((slotID > (GUILD_BANK_MAIN_AREA_SIZE - 1))) return; - std::list::iterator Iterator = GetGuildBank(GuildID); + auto iter = GetGuildBank(guildID); - if(Iterator == Banks.end()) + if(iter == Banks.end()) + return; + + if((*iter)->Items.MainArea[slotID].ItemID == 0) + return; + + std::string query = StringFormat("UPDATE `guild_bank` SET `permissions` = %i, `whofor` = '%s' " + "WHERE `guildid` = %i AND `area` = 1 AND `slot` = %i LIMIT 1", + permissions, memberName, guildID, slotID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + _log(GUILDS__BANK_ERROR, "error changing permissions: %s : %s", query.c_str(), results.ErrorMessage().c_str()); return; } - if((*Iterator)->Items.MainArea[SlotID].ItemID == 0) - { - return; - } + (*iter)->Items.MainArea[slotID].Permissions = permissions; - const char *Query="UPDATE `guild_bank` SET `permissions` = %i, `whofor` = '%s' WHERE `guildid` = %i AND `area` = 1 AND `slot` = %i LIMIT 1"; - - char errbuf[MYSQL_ERRMSG_SIZE]; - - char* query = 0; - - if(!database.RunQuery(query, MakeAnyLenString(&query, Query, Permissions, MemberName, GuildID, SlotID), errbuf)) - { - _log(GUILDS__BANK_ERROR, "error changing permissions: %s : %s", query, errbuf); - - safe_delete_array(query); - - return; - } - - safe_delete_array(query); - - (*Iterator)->Items.MainArea[SlotID].Permissions = Permissions; - - if(Permissions == GuildBankSingleMember) - strn0cpy((*Iterator)->Items.MainArea[SlotID].WhoFor, MemberName, sizeof((*Iterator)->Items.MainArea[SlotID].WhoFor)); + if(permissions == GuildBankSingleMember) + strn0cpy((*iter)->Items.MainArea[slotID].WhoFor, memberName, sizeof((*iter)->Items.MainArea[slotID].WhoFor)); else - (*Iterator)->Items.MainArea[SlotID].WhoFor[0] = '\0'; + (*iter)->Items.MainArea[slotID].WhoFor[0] = '\0'; - - const Item_Struct *Item = database.GetItem((*Iterator)->Items.MainArea[SlotID].ItemID); + const Item_Struct *Item = database.GetItem((*iter)->Items.MainArea[slotID].ItemID); GuildBankItemUpdate_Struct gbius; if(!Item->Stackable) - gbius.Init(GuildBankItemUpdate, 1, SlotID, GuildBankMainArea, 1, Item->ID, Item->Icon, 1, (*Iterator)->Items.MainArea[SlotID].Permissions, 0, 0); + gbius.Init(GuildBankItemUpdate, 1, slotID, GuildBankMainArea, 1, Item->ID, Item->Icon, 1, (*iter)->Items.MainArea[slotID].Permissions, 0, 0); else { - if((*Iterator)->Items.MainArea[SlotID].Quantity == Item->StackSize) - gbius.Init(GuildBankItemUpdate, 1, SlotID, GuildBankMainArea, 1, Item->ID, Item->Icon, - (*Iterator)->Items.MainArea[SlotID].Quantity, (*Iterator)->Items.MainArea[SlotID].Permissions, 0, 0); + if((*iter)->Items.MainArea[slotID].Quantity == Item->StackSize) + gbius.Init(GuildBankItemUpdate, 1, slotID, GuildBankMainArea, 1, Item->ID, Item->Icon, + (*iter)->Items.MainArea[slotID].Quantity, (*iter)->Items.MainArea[slotID].Permissions, 0, 0); else - gbius.Init(GuildBankItemUpdate, 1, SlotID, GuildBankMainArea, 1, Item->ID, Item->Icon, - (*Iterator)->Items.MainArea[SlotID].Quantity, (*Iterator)->Items.MainArea[SlotID].Permissions, 1, 0); + gbius.Init(GuildBankItemUpdate, 1, slotID, GuildBankMainArea, 1, Item->ID, Item->Icon, + (*iter)->Items.MainArea[slotID].Quantity, (*iter)->Items.MainArea[slotID].Permissions, 1, 0); } strn0cpy(gbius.ItemName, Item->Name, sizeof(gbius.ItemName)); - strn0cpy(gbius.WhoFor, (*Iterator)->Items.MainArea[SlotID].WhoFor, sizeof(gbius.WhoFor)); + strn0cpy(gbius.WhoFor, (*iter)->Items.MainArea[slotID].WhoFor, sizeof(gbius.WhoFor)); - entity_list.QueueClientsGuildBankItemUpdate(&gbius, GuildID); + entity_list.QueueClientsGuildBankItemUpdate(&gbius, guildID); } ItemInst* GuildBankManager::GetItem(uint32 GuildID, uint16 Area, uint16 SlotID, uint32 Quantity) From 1e870864716ff9b7da32323cc94c7941cd944e60 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 25 Aug 2014 12:43:14 -0700 Subject: [PATCH 214/217] DeleteItem converted to QueryDatabase --- zone/guild_mgr.cpp | 85 +++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 51 deletions(-) diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 3f477df6f..e1fbf0db5 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -1141,90 +1141,73 @@ std::list::iterator GuildBankManager::GetGuildBank(uint32 GuildID) return Iterator; } -bool GuildBankManager::DeleteItem(uint32 GuildID, uint16 Area, uint16 SlotID, uint32 Quantity) +bool GuildBankManager::DeleteItem(uint32 guildID, uint16 area, uint16 slotID, uint32 quantity) { - std::list::iterator Iterator = GetGuildBank(GuildID); + auto iter = GetGuildBank(guildID); - if(Iterator == Banks.end()) + if(iter == Banks.end()) return false; - char errbuf[MYSQL_ERRMSG_SIZE]; - - char* query = 0; - GuildBankItem* BankArea = nullptr; - if(Area == GuildBankMainArea) + if(area == GuildBankMainArea) { - if(SlotID > (GUILD_BANK_MAIN_AREA_SIZE - 1)) + if(slotID > (GUILD_BANK_MAIN_AREA_SIZE - 1)) return false; - BankArea = &(*Iterator)->Items.MainArea[0]; - } - else - { - if(SlotID > (GUILD_BANK_DEPOSIT_AREA_SIZE - 1)) + BankArea = &(*iter)->Items.MainArea[0]; + } else { + if(slotID > (GUILD_BANK_DEPOSIT_AREA_SIZE - 1)) return false; - BankArea = &(*Iterator)->Items.DepositArea[0]; + BankArea = &(*iter)->Items.DepositArea[0]; } + bool deleted = true; - bool Deleted = true; - - const Item_Struct *Item = database.GetItem(BankArea[SlotID].ItemID); - - if(!Item->Stackable || (Quantity >= BankArea[SlotID].Quantity)) - { - const char *Query = "DELETE from `guild_bank` where `guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1"; - - if(!database.RunQuery(query, MakeAnyLenString(&query, Query, GuildID, Area, SlotID), errbuf)) - { - _log(GUILDS__BANK_ERROR, "Delete item failed. %s : %s", query, errbuf); - - safe_delete_array(query); + const Item_Struct *Item = database.GetItem(BankArea[slotID].ItemID); + if(!Item->Stackable || (quantity >= BankArea[slotID].Quantity)) { + std::string query = StringFormat("DELETE FROM `guild_bank` WHERE `guildid` = %i " + "AND `area` = %i AND `slot` = %i LIMIT 1", + guildID, area, slotID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + _log(GUILDS__BANK_ERROR, "Delete item failed. %s : %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); - - BankArea[SlotID].ItemID = 0; - } - else - { - const char *Query = "UPDATE `guild_bank` SET `qty` = %i where `guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1"; - - if(!database.RunQuery(query, MakeAnyLenString(&query, Query, BankArea[SlotID].Quantity - Quantity, - GuildID, Area, SlotID), errbuf)) - { - _log(GUILDS__BANK_ERROR, "Update item failed. %s : %s", query, errbuf); - - safe_delete_array(query); + BankArea[slotID].ItemID = 0; + } else { + std::string query = StringFormat("UPDATE `guild_bank` SET `qty` = %i WHERE `guildid` = %i " + "AND `area` = %i AND `slot` = %i LIMIT 1", + BankArea[slotID].Quantity - quantity, guildID, area, slotID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + _log(GUILDS__BANK_ERROR, "Update item failed. %s : %s", query.c_str(), results.ErrorMessage().c_str()); return false; } - safe_delete_array(query); + BankArea[slotID].Quantity -= quantity; - BankArea[SlotID].Quantity -= Quantity; - - Deleted = false; + deleted = false; } + GuildBankItemUpdate_Struct gbius; - if(!Deleted) + if(!deleted) { - gbius.Init(GuildBankItemUpdate, 1, SlotID, Area, 1, Item->ID, Item->Icon, BankArea[SlotID].Quantity, BankArea[SlotID].Permissions, 1, 0); + gbius.Init(GuildBankItemUpdate, 1, slotID, area, 1, Item->ID, Item->Icon, BankArea[slotID].Quantity, BankArea[slotID].Permissions, 1, 0); strn0cpy(gbius.ItemName, Item->Name, sizeof(gbius.ItemName)); - strn0cpy(gbius.WhoFor, BankArea[SlotID].WhoFor, sizeof(gbius.WhoFor)); + strn0cpy(gbius.WhoFor, BankArea[slotID].WhoFor, sizeof(gbius.WhoFor)); } else - gbius.Init(GuildBankItemUpdate, 1, SlotID, Area, 0, 0, 0, 0, 0, 0, 0); + gbius.Init(GuildBankItemUpdate, 1, slotID, area, 0, 0, 0, 0, 0, 0, 0); - entity_list.QueueClientsGuildBankItemUpdate(&gbius, GuildID); + entity_list.QueueClientsGuildBankItemUpdate(&gbius, guildID); return true; From a6b923a22ef19fb610d33b99e9e2f681ecf54379 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 25 Aug 2014 15:10:46 -0700 Subject: [PATCH 215/217] UpdateItemQuantity converted to QueryDatabase --- zone/guild_mgr.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index e1fbf0db5..37cc7a3de 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -1338,26 +1338,20 @@ bool GuildBankManager::SplitStack(uint32 GuildID, uint16 SlotID, uint32 Quantity return true; } -void GuildBankManager::UpdateItemQuantity(uint32 GuildID, uint16 Area, uint16 SlotID, uint32 Quantity) +void GuildBankManager::UpdateItemQuantity(uint32 guildID, uint16 area, uint16 slotID, uint32 quantity) { // Helper method for MergeStacks. Assuming all passed parameters are valid. // - char errbuf[MYSQL_ERRMSG_SIZE]; - - char* query = 0; - - const char *Query = "UPDATE `guild_bank` SET `qty` = %i where `guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1"; - - if(!database.RunQuery(query, MakeAnyLenString(&query, Query, Quantity, GuildID, Area, SlotID), errbuf)) - { - _log(GUILDS__BANK_ERROR, "Update item quantity failed. %s : %s", query, errbuf); - - safe_delete_array(query); - + std::string query = StringFormat("UPDATE `guild_bank` SET `qty` = %i " + "WHERE `guildid` = %i AND `area` = %i " + "AND `slot` = %i LIMIT 1", + quantity, guildID, area, slotID); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + _log(GUILDS__BANK_ERROR, "Update item quantity failed. %s : %s", query.c_str(), results.ErrorMessage().c_str()); return; } - safe_delete_array(query); } bool GuildBankManager::AllowedToWithdraw(uint32 GuildID, uint16 Area, uint16 SlotID, const char *Name) From d4a9fed45eeae224f64dfaa93bb3920af19a6cff Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 25 Aug 2014 22:29:00 -0400 Subject: [PATCH 216/217] Added QS code to Client::FinishTrade() --- zone/client.h | 2 +- zone/client_packet.cpp | 75 +++++++--- zone/trading.cpp | 320 +++++++++++++++++++++++++---------------- 3 files changed, 250 insertions(+), 147 deletions(-) diff --git a/zone/client.h b/zone/client.h index f2d16ea0f..d3aed5540 100644 --- a/zone/client.h +++ b/zone/client.h @@ -268,7 +268,7 @@ public: void TradeRequestFailed(const EQApplicationPacket* app); void BuyTraderItem(TraderBuy_Struct* tbs,Client* trader,const EQApplicationPacket* app); void TraderUpdate(uint16 slot_id,uint32 trader_id); - void FinishTrade(Mob* with, ServerPacket* qspack = nullptr, bool finalizer = false); + void FinishTrade(Mob* with, bool finalizer = false, void* event_entry = nullptr, std::list* event_details = nullptr); void SendZonePoints(); void SendBuyerResults(char *SearchQuery, uint32 SearchID); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index f35ec0565..8d39f815a 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4862,6 +4862,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) { Mob* with = trade->With(); trade->state = TradeAccepted; + if (with && with->IsClient()) { //finish trade... // Have both accepted? @@ -4872,6 +4873,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) other->trade->state = TradeCompleting; trade->state = TradeCompleting; + // should we do this for NoDrop items as well? if (CheckTradeLoreConflict(other) || other->CheckTradeLoreConflict(this)) { Message_StringID(13, TRADE_CANCEL_LORE); other->Message_StringID(13, TRADE_CANCEL_LORE); @@ -4887,23 +4889,37 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) // start QS code if(RuleB(QueryServ, PlayerLogTrades)) { - uint16 trade_count = 0; + QSPlayerLogTrade_Struct event_entry; + std::list event_details; - // Item trade count for packet sizing - for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_END; slot_id++) { - if(other->GetInv().GetItem(slot_id)) { trade_count += other->GetInv().GetItem(slot_id)->GetTotalItemCount(); } - if(m_inv[slot_id]) { trade_count += m_inv[slot_id]->GetTotalItemCount(); } - } - - ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct) + (sizeof(QSTradeItems_Struct) * trade_count)); + memset(&event_entry, 0, sizeof(QSPlayerLogTrade_Struct)); // Perform actual trade - this->FinishTrade(other, qspack, true); - other->FinishTrade(this, qspack, false); + this->FinishTrade(other, true, &event_entry, &event_details); + other->FinishTrade(this, false, &event_entry, &event_details); - qspack->Deflate(); - if(worldserver.Connected()) { worldserver.SendPacket(qspack); } - safe_delete(qspack); + ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct)+(sizeof(QSTradeItems_Struct)* event_details.size())); + + QSPlayerLogTrade_Struct* qs_buf = (QSPlayerLogTrade_Struct*)qs_pack->pBuffer; + + memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogTrade_Struct)); + + int offset = 0; + + for (std::list::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) { + QSTradeItems_Struct* detail = reinterpret_cast(*iter); + qs_buf->items[offset] = *detail; + safe_delete(detail); + } + + event_details.clear(); + + qs_pack->Deflate(); + + if(worldserver.Connected()) + worldserver.SendPacket(qs_pack); + + safe_delete(qs_pack); // end QS code } else { @@ -4928,25 +4944,42 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) if(with->IsNPC()) { // Audit trade to database for player trade stream if(RuleB(QueryServ, PlayerLogHandins)) { - uint16 handin_count = 0; + QSPlayerLogHandin_Struct event_entry; + std::list event_details; - for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_NPC_END; slot_id++) { - if(m_inv[slot_id]) { handin_count += m_inv[slot_id]->GetTotalItemCount(); } + memset(&event_entry, 0, sizeof(QSPlayerLogHandin_Struct)); + + FinishTrade(with->CastToNPC(), false, &event_entry, &event_details); + + ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct)+(sizeof(QSHandinItems_Struct)* event_details.size())); + + QSPlayerLogHandin_Struct* qs_buf = (QSPlayerLogHandin_Struct*)qs_pack->pBuffer; + + memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogHandin_Struct)); + + int offset = 0; + + for (std::list::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) { + QSHandinItems_Struct* detail = reinterpret_cast(*iter); + qs_buf->items[offset] = *detail; + safe_delete(detail); } - ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct) + (sizeof(QSHandinItems_Struct) * handin_count)); + event_details.clear(); - FinishTrade(with->CastToNPC(), qspack); + qs_pack->Deflate(); - qspack->Deflate(); - if(worldserver.Connected()) { worldserver.SendPacket(qspack); } - safe_delete(qspack); + if(worldserver.Connected()) + worldserver.SendPacket(qs_pack); + + safe_delete(qs_pack); } else { FinishTrade(with->CastToNPC()); } } #ifdef BOTS + // TODO: Log Bot trades else if(with->IsBot()) with->CastToBot()->FinishTrade(this, Bot::BotTradeClientNormal); #endif diff --git a/zone/trading.cpp b/zone/trading.cpp index 1ae9596b9..88b277651 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -22,7 +22,10 @@ #include "../common/rulesys.h" #include "quest_parser_collection.h" #include "worldserver.h" +#include "queryserv.h" + extern WorldServer worldserver; +extern QueryServ* QServ; // The maximum amount of a single bazaar/barter transaction expressed in copper. // Equivalent to 2 Million plat @@ -438,92 +441,38 @@ void Client::ResetTrade() { } } -void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) { +void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, std::list* event_details) { if(tradingWith && tradingWith->IsClient()) { Client* other = tradingWith->CastToClient(); + QSPlayerLogTrade_Struct* qs_audit = nullptr; + bool qs_log = false; if(other) { mlog(TRADING__CLIENT, "Finishing trade with client %s", other->GetName()); this->AddMoneyToPP(other->trade->cp, other->trade->sp, other->trade->gp, other->trade->pp, true); - + // step 0: pre-processing // QS code - if (qspack && RuleB(QueryServ, PlayerLogTrades)) { - QSPlayerLogTrade_Struct* qsaudit = (QSPlayerLogTrade_Struct*)qspack->pBuffer; - + if (RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) { + qs_audit = (QSPlayerLogTrade_Struct*)event_entry; + qs_log = true; + if (finalizer) { - qsaudit->char2_id = this->character_id; + qs_audit->char2_id = this->character_id; - qsaudit->char2_money.platinum = this->trade->pp; - qsaudit->char2_money.gold = this->trade->gp; - qsaudit->char2_money.silver = this->trade->sp; - qsaudit->char2_money.copper = this->trade->cp; + qs_audit->char2_money.platinum = this->trade->pp; + qs_audit->char2_money.gold = this->trade->gp; + qs_audit->char2_money.silver = this->trade->sp; + qs_audit->char2_money.copper = this->trade->cp; } else { - qsaudit->char1_id = this->character_id; + qs_audit->char1_id = this->character_id; - qsaudit->char1_money.platinum = this->trade->pp; - qsaudit->char1_money.gold = this->trade->gp; - qsaudit->char1_money.silver = this->trade->sp; - qsaudit->char1_money.copper = this->trade->cp; - } - - // qsaudit->items[x].to_slot is disabled until QueryServ:PlayerLogTrades code is updated - for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) { - const ItemInst* inst = m_inv[trade_slot]; - - if (!inst) - continue; - - uint16 item_offset = qsaudit->char1_count + qsaudit->char2_count; - - qsaudit->items[item_offset].from_id = this->character_id; - qsaudit->items[item_offset].from_slot = trade_slot; - qsaudit->items[item_offset].to_id = other->CharacterID(); - qsaudit->items[item_offset].to_slot = 0; // disabled - qsaudit->items[item_offset].item_id = inst->GetID(); - qsaudit->items[item_offset].charges = inst->GetCharges(); - qsaudit->items[item_offset].aug_1 = inst->GetAugmentItemID(1); - qsaudit->items[item_offset].aug_2 = inst->GetAugmentItemID(2); - qsaudit->items[item_offset].aug_3 = inst->GetAugmentItemID(3); - qsaudit->items[item_offset].aug_4 = inst->GetAugmentItemID(4); - qsaudit->items[item_offset].aug_5 = inst->GetAugmentItemID(5); - - if (finalizer) - ++qsaudit->char2_count; - else - ++qsaudit->char1_count; - - if (inst->IsType(ItemClassContainer)) { - // Pseudo-Slot ID's are generated based on how the db saves bag items... - for (uint8 sub_slot = SUB_BEGIN; sub_slot < inst->GetItem()->BagSlots; ++sub_slot) { - const ItemInst* sub_inst = inst->GetItem(sub_slot); - - if (!sub_inst) - continue; - - int16 from_slot = Inventory::CalcSlotId(trade_slot, sub_slot); - item_offset = qsaudit->char1_count + qsaudit->char2_count; - - qsaudit->items[item_offset].from_id = this->character_id; - qsaudit->items[item_offset].from_slot = from_slot; - qsaudit->items[item_offset].to_id = other->CharacterID(); - qsaudit->items[item_offset].to_slot = 0; // disabled - qsaudit->items[item_offset].item_id = sub_inst->GetID(); - qsaudit->items[item_offset].charges = sub_inst->GetCharges(); - qsaudit->items[item_offset].aug_1 = sub_inst->GetAugmentItemID(1); - qsaudit->items[item_offset].aug_2 = sub_inst->GetAugmentItemID(2); - qsaudit->items[item_offset].aug_3 = sub_inst->GetAugmentItemID(3); - qsaudit->items[item_offset].aug_4 = sub_inst->GetAugmentItemID(4); - qsaudit->items[item_offset].aug_5 = sub_inst->GetAugmentItemID(5); - - if (finalizer) - ++qsaudit->char2_count; - else - ++qsaudit->char1_count; - } - } + qs_audit->char1_money.platinum = this->trade->pp; + qs_audit->char1_money.gold = this->trade->gp; + qs_audit->char1_money.silver = this->trade->sp; + qs_audit->char1_money.copper = this->trade->cp; } } @@ -541,22 +490,69 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if (free_slot != INVALID_INDEX) { if (other->PutItemInInventory(free_slot, *inst, true)) { mlog(TRADING__CLIENT, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + if (qs_log) { + QSTradeItems_Struct* detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = trade_slot; + detail->to_id = other->CharacterID(); + detail->to_slot = free_slot; + detail->item_id = inst->GetID(); + detail->charges = 1; + detail->aug_1 = inst->GetAugmentItemID(1); + detail->aug_2 = inst->GetAugmentItemID(2); + detail->aug_3 = inst->GetAugmentItemID(3); + detail->aug_4 = inst->GetAugmentItemID(4); + detail->aug_5 = inst->GetAugmentItemID(5); + + event_details->push_back(detail); + + if (finalizer) + qs_audit->char2_count += detail->charges; + else + qs_audit->char1_count += detail->charges; + + //for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) { + for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items + const ItemInst* bag_inst = inst->GetItem(sub_slot); + + if (bag_inst) { + detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = Inventory::CalcSlotId(trade_slot, sub_slot); + detail->to_id = other->CharacterID(); + detail->to_slot = Inventory::CalcSlotId(free_slot, sub_slot); + detail->item_id = bag_inst->GetID(); + detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges()); + detail->aug_1 = bag_inst->GetAugmentItemID(1); + detail->aug_2 = bag_inst->GetAugmentItemID(2); + detail->aug_3 = bag_inst->GetAugmentItemID(3); + detail->aug_4 = bag_inst->GetAugmentItemID(4); + detail->aug_5 = bag_inst->GetAugmentItemID(5); + + event_details->push_back(detail); + + if (finalizer) + qs_audit->char2_count += detail->charges; + else + qs_audit->char1_count += detail->charges; + } + } + } } else { mlog(TRADING__ERROR, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); - PushItemOnCursor(*inst, true); } } else { mlog(TRADING__ERROR, "%s's inventory is full, returning container %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); - PushItemOnCursor(*inst, true); } } else { mlog(TRADING__ERROR, "Container %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); - PushItemOnCursor(*inst, true); } @@ -583,7 +579,6 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if (partial_inst->GetID() != inst->GetID()) { _log(TRADING__ERROR, "Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); - break; } @@ -606,6 +601,28 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if (other->PutItemInInventory(partial_slot, *partial_inst, true)) { mlog(TRADING__CLIENT, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID, (old_charges - inst->GetCharges())); + if (qs_log) { + QSTradeItems_Struct* detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = trade_slot; + detail->to_id = other->CharacterID(); + detail->to_slot = partial_slot; + detail->item_id = inst->GetID(); + detail->charges = (old_charges - inst->GetCharges()); + detail->aug_1 = 0; + detail->aug_2 = 0; + detail->aug_3 = 0; + detail->aug_4 = 0; + detail->aug_5 = 0; + + event_details->push_back(detail); + + if (finalizer) + qs_audit->char2_count += detail->charges; + else + qs_audit->char1_count += detail->charges; + } } else { mlog(TRADING__ERROR, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.", @@ -613,13 +630,11 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) inst->SetCharges(old_charges); partial_inst->SetCharges(partial_charges); - break; } if (inst->GetCharges() == 0) { DeleteItemInInventory(trade_slot); - break; } } @@ -654,7 +669,6 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if (inst->GetCharges() == 0) { DeleteItemInInventory(trade_slot); - break; } } @@ -675,22 +689,70 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) if (free_slot != INVALID_INDEX) { if (other->PutItemInInventory(free_slot, *inst, true)) { mlog(TRADING__CLIENT, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + if (qs_log) { + QSTradeItems_Struct* detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = trade_slot; + detail->to_id = other->CharacterID(); + detail->to_slot = free_slot; + detail->item_id = inst->GetID(); + detail->charges = (!inst->IsStackable() ? 1 : inst->GetCharges()); + detail->aug_1 = inst->GetAugmentItemID(1); + detail->aug_2 = inst->GetAugmentItemID(2); + detail->aug_3 = inst->GetAugmentItemID(3); + detail->aug_4 = inst->GetAugmentItemID(4); + detail->aug_5 = inst->GetAugmentItemID(5); + + event_details->push_back(detail); + + if (finalizer) + qs_audit->char2_count += detail->charges; + else + qs_audit->char1_count += detail->charges; + + // 'step 3' should never really see containers..but, just in case... + //for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) { + for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items + const ItemInst* bag_inst = inst->GetItem(sub_slot); + + if (bag_inst) { + detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = trade_slot; + detail->to_id = other->CharacterID(); + detail->to_slot = free_slot; + detail->item_id = bag_inst->GetID(); + detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges()); + detail->aug_1 = bag_inst->GetAugmentItemID(1); + detail->aug_2 = bag_inst->GetAugmentItemID(2); + detail->aug_3 = bag_inst->GetAugmentItemID(3); + detail->aug_4 = bag_inst->GetAugmentItemID(4); + detail->aug_5 = bag_inst->GetAugmentItemID(5); + + event_details->push_back(detail); + + if (finalizer) + qs_audit->char2_count += detail->charges; + else + qs_audit->char1_count += detail->charges; + } + } + } } else { mlog(TRADING__ERROR, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); - PushItemOnCursor(*inst, true); } } else { mlog(TRADING__ERROR, "%s's inventory is full, returning item %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); - PushItemOnCursor(*inst, true); } } else { mlog(TRADING__ERROR, "Item %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); - PushItemOnCursor(*inst, true); } @@ -701,65 +763,73 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer) //Do not reset the trade here, done by the caller. } } - - // trading with npc doesn't require Inventory::FindFreeSlotForTradeItem() rework else if(tradingWith && tradingWith->IsNPC()) { - QSPlayerLogHandin_Struct* qsaudit = nullptr; - bool QSPLH = false; + QSPlayerLogHandin_Struct* qs_audit = nullptr; + bool qs_log = false; // QS code - if(qspack && RuleB(QueryServ, PlayerLogTrades)) { + if(RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) { // Currently provides only basic functionality. Calling method will also // need to be modified before item returns and rewards can be logged. -U - qsaudit = (QSPlayerLogHandin_Struct*) qspack->pBuffer; - QSPLH = true; + qs_audit = (QSPlayerLogHandin_Struct*)event_entry; + qs_log = true; - qsaudit->quest_id = 0; - qsaudit->char_id = character_id; - qsaudit->char_money.platinum = trade->pp; - qsaudit->char_money.gold = trade->gp; - qsaudit->char_money.silver = trade->sp; - qsaudit->char_money.copper = trade->cp; - qsaudit->char_count = 0; - qsaudit->npc_id = tradingWith->GetNPCTypeID(); - qsaudit->npc_money.platinum = 0; - qsaudit->npc_money.gold = 0; - qsaudit->npc_money.silver = 0; - qsaudit->npc_money.copper = 0; - qsaudit->npc_count = 0; + qs_audit->quest_id = 0; + qs_audit->char_id = character_id; + qs_audit->char_money.platinum = trade->pp; + qs_audit->char_money.gold = trade->gp; + qs_audit->char_money.silver = trade->sp; + qs_audit->char_money.copper = trade->cp; + qs_audit->char_count = 0; + qs_audit->npc_id = tradingWith->GetNPCTypeID(); + qs_audit->npc_money.platinum = 0; + qs_audit->npc_money.gold = 0; + qs_audit->npc_money.silver = 0; + qs_audit->npc_money.copper = 0; + qs_audit->npc_count = 0; } - if(QSPLH) { // This can be incoporated below when revisions are made -U - for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_NPC_END; slot_id++) { - const ItemInst* trade_inst = m_inv[slot_id]; + if(qs_log) { // This can be incorporated below when revisions are made -U + for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_NPC_END; ++trade_slot) { + const ItemInst* trade_inst = m_inv[trade_slot]; if(trade_inst) { - strcpy(qsaudit->items[qsaudit->char_count].action_type, "HANDIN"); + QSHandinItems_Struct* detail = new QSHandinItems_Struct; - qsaudit->items[qsaudit->char_count].char_slot = slot_id; - qsaudit->items[qsaudit->char_count].item_id = trade_inst->GetID(); - qsaudit->items[qsaudit->char_count].charges = trade_inst->GetCharges(); - qsaudit->items[qsaudit->char_count].aug_1 = trade_inst->GetAugmentItemID(1); - qsaudit->items[qsaudit->char_count].aug_2 = trade_inst->GetAugmentItemID(2); - qsaudit->items[qsaudit->char_count].aug_3 = trade_inst->GetAugmentItemID(3); - qsaudit->items[qsaudit->char_count].aug_4 = trade_inst->GetAugmentItemID(4); - qsaudit->items[qsaudit->char_count++].aug_5 = trade_inst->GetAugmentItemID(5); + strcpy(detail->action_type, "HANDIN"); + + detail->char_slot = trade_slot; + detail->item_id = trade_inst->GetID(); + detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges()); + detail->aug_1 = trade_inst->GetAugmentItemID(1); + detail->aug_2 = trade_inst->GetAugmentItemID(2); + detail->aug_3 = trade_inst->GetAugmentItemID(3); + detail->aug_4 = trade_inst->GetAugmentItemID(4); + detail->aug_5 = trade_inst->GetAugmentItemID(5); + + event_details->push_back(detail); + qs_audit->char_count += detail->charges; if(trade_inst->IsType(ItemClassContainer)) { - for(uint8 bag_idx = SUB_BEGIN; bag_idx < trade_inst->GetItem()->BagSlots; bag_idx++) { - const ItemInst* trade_baginst = trade_inst->GetItem(bag_idx); + for (uint8 sub_slot = SUB_BEGIN; sub_slot < trade_inst->GetItem()->BagSlots; ++sub_slot) { + const ItemInst* trade_baginst = trade_inst->GetItem(sub_slot); if(trade_baginst) { - strcpy(qsaudit->items[qsaudit->char_count].action_type, "HANDIN"); + detail = new QSHandinItems_Struct; - qsaudit->items[qsaudit->char_count].char_slot = Inventory::CalcSlotId(slot_id, bag_idx); - qsaudit->items[qsaudit->char_count].item_id = trade_baginst->GetID(); - qsaudit->items[qsaudit->char_count].charges = trade_baginst->GetCharges(); - qsaudit->items[qsaudit->char_count].aug_1 = trade_baginst->GetAugmentItemID(1); - qsaudit->items[qsaudit->char_count].aug_2 = trade_baginst->GetAugmentItemID(2); - qsaudit->items[qsaudit->char_count].aug_3 = trade_baginst->GetAugmentItemID(3); - qsaudit->items[qsaudit->char_count].aug_4 = trade_baginst->GetAugmentItemID(4); - qsaudit->items[qsaudit->char_count++].aug_5 = trade_baginst->GetAugmentItemID(5); + strcpy(detail->action_type, "HANDIN"); + + detail->char_slot = Inventory::CalcSlotId(trade_slot, sub_slot); + detail->item_id = trade_baginst->GetID(); + detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges()); + detail->aug_1 = trade_baginst->GetAugmentItemID(1); + detail->aug_2 = trade_baginst->GetAugmentItemID(2); + detail->aug_3 = trade_baginst->GetAugmentItemID(3); + detail->aug_4 = trade_baginst->GetAugmentItemID(4); + detail->aug_5 = trade_baginst->GetAugmentItemID(5); + + event_details->push_back(detail); + qs_audit->char_count += detail->charges; } } } From 18a4f831be630adca360763dfbc302f5d3d07767 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 26 Aug 2014 06:37:40 -0400 Subject: [PATCH 217/217] Tweaked QS code for Client::FinishTrade() and QueryServ handlers. --- changelog.txt | 6 ++++++ common/servertalk.h | 2 ++ queryserv/database.cpp | 12 ++++++------ queryserv/database.h | 4 ++-- queryserv/worldserver.cpp | 6 ++---- zone/client_packet.cpp | 6 ++++-- zone/trading.cpp | 20 ++++++++++++++++++++ 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9172332d9..98e1f0606 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,11 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 08/26/2014 == +Uleat: Implemented 'Smart' Player Trade transfers. Trades are processed by containers, stackables and then all remaining. QueryServ logs have been updated to match these transactions. +Note: QueryServ logs previously listed 'Items' on the main entry table. This indicated the number of slots affected and not the actual number of items. +This field now indicates the actual number of items transferred. For non-stackable, the value is '1' and stackable is the number of charges. A _detail_count +property has been added to both 'Trade' and 'Handin' structs to indicate the number of details recorded..though, not tracked..it could be added. + == 08/24/2014 == Uleat: Fix (attempted) for zone crashes related to zone shut-down. This change disables all Mob AI and disables/deletes all Mob timers once Zone::ShutDown() is called. More areas will be addressed as reports come in. Note: Perl and Lua quests tested to work..please post any aberrant behavior. (I finally set my spell-check to US English...) diff --git a/common/servertalk.h b/common/servertalk.h index 6d1a83a84..5337b6b1d 100644 --- a/common/servertalk.h +++ b/common/servertalk.h @@ -1118,6 +1118,7 @@ struct QSPlayerLogTrade_Struct { uint32 char2_id; MoneyUpdate_Struct char2_money; uint16 char2_count; + uint16 _detail_count; QSTradeItems_Struct items[0]; }; @@ -1141,6 +1142,7 @@ struct QSPlayerLogHandin_Struct { uint32 npc_id; MoneyUpdate_Struct npc_money; uint16 npc_count; + uint16 _detail_count; QSHandinItems_Struct items[0]; }; diff --git a/queryserv/database.cpp b/queryserv/database.cpp index 4b94f215b..cfc4a8892 100644 --- a/queryserv/database.cpp +++ b/queryserv/database.cpp @@ -119,7 +119,7 @@ void Database::AddSpeech(const char* from, const char* to, const char* message, safe_delete_array(S3); } -void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) { +void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 DetailCount) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; @@ -134,8 +134,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) { _log(QUERYSERV__ERROR, "%s", query); } - if(Items > 0) { - for(int i = 0; i < Items; i++) { + if(DetailCount > 0) { + for(int i = 0; i < DetailCount; i++) { if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_trade_record_entries` SET `event_id`='%i', " "`from_id`='%i', `from_slot`='%i', `to_id`='%i', `to_slot`='%i', `item_id`='%i', " "`charges`='%i', `aug_1`='%i', `aug_2`='%i', `aug_3`='%i', `aug_4`='%i', `aug_5`='%i'", @@ -149,7 +149,7 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) { } } -void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { +void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 DetailCount) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; uint32 lastid = 0; @@ -163,8 +163,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) { _log(QUERYSERV__ERROR, "%s", query); } - if(Items > 0) { - for(int i = 0; i < Items; i++) { + if(DetailCount > 0) { + for(int i = 0; i < DetailCount; i++) { if(!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `qs_player_handin_record_entries` SET `event_id`='%i', " "`action_type`='%s', `char_slot`='%i', `item_id`='%i', `charges`='%i', " "`aug_1`='%i', `aug_2`='%i', `aug_3`='%i', `aug_4`='%i', `aug_5`='%i'", diff --git a/queryserv/database.h b/queryserv/database.h index ac002a0b5..a25d91611 100644 --- a/queryserv/database.h +++ b/queryserv/database.h @@ -43,8 +43,8 @@ public: ~Database(); void AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type); - void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items); - void LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items); + void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 DetailCount); + void LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 DetailCount); void LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members); void LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items); void LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items); diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index 154db3a07..fc87929ca 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -80,14 +80,12 @@ void WorldServer::Process() } case ServerOP_QSPlayerLogTrades: { QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)pack->pBuffer; - uint32 Items = QS->char1_count + QS->char2_count; - database.LogPlayerTrade(QS, Items); + database.LogPlayerTrade(QS, QS->_detail_count); break; } case ServerOP_QSPlayerLogHandins: { QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)pack->pBuffer; - uint32 Items = QS->char_count + QS->npc_count; - database.LogPlayerHandin(QS, Items); + database.LogPlayerHandin(QS, QS->_detail_count); break; } case ServerOP_QSPlayerLogNPCKills: { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 8d39f815a..76c873711 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4898,8 +4898,9 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) this->FinishTrade(other, true, &event_entry, &event_details); other->FinishTrade(this, false, &event_entry, &event_details); - ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct)+(sizeof(QSTradeItems_Struct)* event_details.size())); + event_entry._detail_count = event_details.size(); + ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct)+(sizeof(QSTradeItems_Struct)* event_entry._detail_count)); QSPlayerLogTrade_Struct* qs_buf = (QSPlayerLogTrade_Struct*)qs_pack->pBuffer; memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogTrade_Struct)); @@ -4951,8 +4952,9 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) FinishTrade(with->CastToNPC(), false, &event_entry, &event_details); - ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct)+(sizeof(QSHandinItems_Struct)* event_details.size())); + event_entry._detail_count = event_details.size(); + ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct)+(sizeof(QSHandinItems_Struct)* event_entry._detail_count)); QSPlayerLogHandin_Struct* qs_buf = (QSPlayerLogHandin_Struct*)qs_pack->pBuffer; memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogHandin_Struct)); diff --git a/zone/trading.cpp b/zone/trading.cpp index 88b277651..23d8d77af 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -656,6 +656,8 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st if (!bias_inst || (bias_inst->GetID() != inst->GetID()) || (bias_inst->GetCharges() >= bias_inst->GetItem()->StackSize)) continue; + int16 old_charges = inst->GetCharges(); + if ((bias_inst->GetCharges() + inst->GetCharges()) > bias_inst->GetItem()->StackSize) { int16 new_charges = (bias_inst->GetCharges() + inst->GetCharges()) - bias_inst->GetItem()->StackSize; @@ -667,6 +669,24 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st inst->SetCharges(0); } + if (qs_log) { + QSTradeItems_Struct* detail = new QSTradeItems_Struct; + + detail->from_id = this->character_id; + detail->from_slot = trade_slot; + detail->to_id = this->character_id; + detail->to_slot = bias_slot; + detail->item_id = inst->GetID(); + detail->charges = (old_charges - inst->GetCharges()); + detail->aug_1 = 0; + detail->aug_2 = 0; + detail->aug_3 = 0; + detail->aug_4 = 0; + detail->aug_5 = 0; + + event_details->push_back(detail); + } + if (inst->GetCharges() == 0) { DeleteItemInInventory(trade_slot); break;