mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 23:28:21 +00:00
RunQuery now uses a string instead of a char* for the error buffer.
This commit is contained in:
+246
-246
File diff suppressed because it is too large
Load Diff
+17
-8
@@ -18,10 +18,10 @@
|
||||
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
|
||||
|
||||
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES* result = 0;
|
||||
DBAsyncQuery* dbaq = iWork->PopAnswer();
|
||||
if (dbaq->GetAnswer(errbuf, &result))
|
||||
if (dbaq->GetAnswer(&errbuf, &result))
|
||||
iWork->GetDB()->LoadVariables_result(result);
|
||||
else
|
||||
std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
|
||||
@@ -615,10 +615,13 @@ DBAsyncQuery::~DBAsyncQuery() {
|
||||
mysql_free_result(presult);
|
||||
}
|
||||
|
||||
bool DBAsyncQuery::GetAnswer(char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum) {
|
||||
bool DBAsyncQuery::GetAnswer(std::string* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum) {
|
||||
if (pstatus != DBAsync::Finished) {
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "Error: Query not finished.");
|
||||
{
|
||||
errbuf->assign("Error: Query not finished.");
|
||||
}
|
||||
|
||||
if (errnum)
|
||||
*errnum = UINT_MAX;
|
||||
return false;
|
||||
@@ -626,12 +629,16 @@ bool DBAsyncQuery::GetAnswer(char* errbuf, MYSQL_RES** result, uint32* affected_
|
||||
if (errbuf) {
|
||||
if (pGetErrbuf) {
|
||||
if (perrbuf)
|
||||
strn0cpy(errbuf, perrbuf, MYSQL_ERRMSG_SIZE);
|
||||
{
|
||||
errbuf->assign(*perrbuf);
|
||||
}
|
||||
else
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "Error message should've been saved, but hasnt. errno: %u", perrnum);
|
||||
{
|
||||
StringFormat(*errbuf, "Error message should've been saved, but hasnt. errno: %u", perrnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "Error message not saved. errno: %u", perrnum);
|
||||
StringFormat(*errbuf, "Error message not saved. errno: %u", perrnum);
|
||||
}
|
||||
if (errnum)
|
||||
*errnum = perrnum;
|
||||
@@ -647,7 +654,9 @@ bool DBAsyncQuery::GetAnswer(char* errbuf, MYSQL_RES** result, uint32* affected_
|
||||
void DBAsyncQuery::Process(DBcore* iDBC) {
|
||||
pstatus = DBAsync::Executing;
|
||||
if (pGetErrbuf)
|
||||
perrbuf = new char[MYSQL_ERRMSG_SIZE];
|
||||
{
|
||||
std::string perrbuf = "";
|
||||
}
|
||||
MYSQL_RES** resultPP = 0;
|
||||
if (pGetResultSet)
|
||||
resultPP = &presult;
|
||||
|
||||
+9
-9
@@ -143,7 +143,7 @@ public:
|
||||
DBAsyncQuery(uint32 iQPT, std::string iQuery, bool iGetResultSet = true, bool iGetErrbuf = true);
|
||||
~DBAsyncQuery();
|
||||
|
||||
bool GetAnswer(char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0);
|
||||
bool GetAnswer(std::string* errbuf = nullptr, MYSQL_RES** result = nullptr, uint32* affected_rows = nullptr, uint32* last_insert_id = nullptr, uint32* errnum = nullptr);
|
||||
inline uint32 QPT() { return pQPT; }
|
||||
protected:
|
||||
friend class DBAsyncWork;
|
||||
@@ -155,15 +155,15 @@ protected:
|
||||
void Init(uint32 iQPT, bool iGetResultSet, bool iGetErrbuf);
|
||||
DBAsync::Status pstatus;
|
||||
std::string pQuery;
|
||||
bool pGetResultSet;
|
||||
bool pGetErrbuf;
|
||||
bool pGetResultSet;
|
||||
bool pGetErrbuf;
|
||||
|
||||
bool pmysqlsuccess;
|
||||
char* perrbuf;
|
||||
uint32 perrnum;
|
||||
uint32 paffected_rows;
|
||||
uint32 plast_insert_id;
|
||||
MYSQL_RES* presult;
|
||||
bool pmysqlsuccess;
|
||||
std::string* perrbuf;
|
||||
uint32 perrnum;
|
||||
uint32 paffected_rows;
|
||||
uint32 plast_insert_id;
|
||||
MYSQL_RES* presult;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+17
-14
@@ -11,13 +11,11 @@
|
||||
#include "dbcore.h"
|
||||
#include <string.h>
|
||||
#include "../common/MiscFunctions.h"
|
||||
#include "../common/StringUtil.h"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "unix.h"
|
||||
@@ -59,12 +57,10 @@ void DBcore::ping() {
|
||||
MDatabase.unlock();
|
||||
}
|
||||
|
||||
bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
|
||||
bool DBcore::RunQuery(const std::string& query, std::string* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
|
||||
_CP(DBcore_RunQuery);
|
||||
if (errnum)
|
||||
*errnum = 0;
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
bool ret = false;
|
||||
LockMutex lock(&MDatabase);
|
||||
if (pStatus != Connected)
|
||||
@@ -89,7 +85,10 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
{
|
||||
StringFormat(*errbuf,"#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
}
|
||||
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
ret = false;
|
||||
}
|
||||
@@ -98,7 +97,10 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
{
|
||||
StringFormat(*errbuf, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
}
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
@@ -129,7 +131,7 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
||||
if (errnum)
|
||||
*errnum = UINT_MAX;
|
||||
if (errbuf)
|
||||
strcpy(errbuf, "DBcore::RunQuery: No Result");
|
||||
errbuf->assign("DBcore::RunQuery: No Result");
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +164,7 @@ void DBcore::DoEscapeString(std::string& outString, const char* frombuf, uint32
|
||||
safe_delete_array(tobuf);
|
||||
}
|
||||
|
||||
bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase,uint32 iPort, uint32* errnum, char* errbuf, bool iCompress, bool iSSL) {
|
||||
bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase,uint32 iPort, uint32* errnum, std::string* errbuf, bool iCompress, bool iSSL) {
|
||||
LockMutex lock(&MDatabase);
|
||||
safe_delete(pHost);
|
||||
safe_delete(pUser);
|
||||
@@ -178,9 +180,7 @@ bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, c
|
||||
return Open(errnum, errbuf);
|
||||
}
|
||||
|
||||
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
bool DBcore::Open(uint32* errnum, std::string* errbuf) {
|
||||
LockMutex lock(&MDatabase);
|
||||
if (GetStatus() == Connected)
|
||||
return true;
|
||||
@@ -208,7 +208,10 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
{
|
||||
StringFormat(*errbuf, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
}
|
||||
|
||||
pStatus = Error;
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-3
@@ -22,15 +22,15 @@ public:
|
||||
DBcore();
|
||||
~DBcore();
|
||||
eStatus GetStatus() { return pStatus; }
|
||||
bool RunQuery(const std::string& query, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0, bool retry = true);
|
||||
bool RunQuery(const std::string& query, std::string* errbuf = nullptr, MYSQL_RES** result = nullptr, uint32* affected_rows = nullptr, uint32* last_insert_id = nullptr, uint32* errnum = nullptr, bool retry = true);
|
||||
void DoEscapeString(std::string& outString, const char* frombuf, uint32 fromlen);
|
||||
void ping();
|
||||
MYSQL* getMySQL(){ return &mysql; }
|
||||
|
||||
protected:
|
||||
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
|
||||
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, std::string* errbuf = nullptr, bool iCompress = false, bool iSSL = false);
|
||||
private:
|
||||
bool Open(uint32* errnum = 0, char* errbuf = 0);
|
||||
bool Open(uint32* errnum = 0, std::string* errbuf = nullptr);
|
||||
|
||||
MYSQL mysql;
|
||||
Mutex MDatabase;
|
||||
|
||||
+71
-71
@@ -49,7 +49,7 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
return(false);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -58,8 +58,8 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
StringFormat(query, "SELECT id, name, leader, minstatus, motd, motd_setter,channel, url FROM guilds");
|
||||
|
||||
// load up all the guilds
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
@@ -71,8 +71,8 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
"can_demote, can_motd, can_warpeace FROM guild_ranks");
|
||||
|
||||
//load up the rank info for each guild.
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -124,8 +124,8 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
StringFormat(query,"SELECT name, leader, minstatus, motd, motd_setter, channel, url"
|
||||
" FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -142,8 +142,8 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
StringFormat(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);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -231,19 +231,19 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
}
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//clear out old `guilds` entry
|
||||
StringFormat(query, "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
}
|
||||
|
||||
//clear out old `guild_ranks` entries
|
||||
StringFormat(query, "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
}
|
||||
|
||||
//escape our strings.
|
||||
@@ -258,9 +258,9 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
StringFormat(query, "INSERT INTO guilds (id,name,leader,minstatus,motd,motd_setter) VALUES(%lu,'%s',%lu,%d,'%s', '%s')",
|
||||
(unsigned long)guild_id, name_esc.c_str(), (unsigned long)info->leader_char_id, info->minstatus, motd_esc.c_str(), motd_set_esc.c_str());
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf))
|
||||
if (!m_db->RunQuery(query, &errbuf))
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
_log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -284,8 +284,8 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
r.permissions[GUILD_MOTD],
|
||||
r.permissions[GUILD_WARPEACE]);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||
return(GUILD_NONE);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
|
||||
@@ -312,7 +312,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||
for (x = 1; x < MAX_NUMBER_GUILDS; x++) {
|
||||
StringFormat(query,"SELECT id FROM guilds where id=%i;", x);
|
||||
|
||||
if (m_db->RunQuery(query, errbuf, &result)) {
|
||||
if (m_db->RunQuery(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);
|
||||
@@ -321,7 +321,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in _GetFreeGuildID query '%s': %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in _GetFreeGuildID query '%s': %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
||||
return(false);
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//escape our strings.
|
||||
@@ -561,9 +561,9 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
||||
StringFormat(query, "UPDATE guilds SET name='%s' WHERE id=%d",
|
||||
esc.c_str(), guild_id);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf))
|
||||
if (!m_db->RunQuery(query, &errbuf))
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
_log(GUILDS__ERROR, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -586,15 +586,15 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
||||
return(false);
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//insert the new `guilds` entry
|
||||
StringFormat(query, "UPDATE guilds SET leader='%d' WHERE id=%d",
|
||||
leader, guild_id);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
||||
return(false);
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//escape our strings.
|
||||
@@ -639,8 +639,8 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
||||
StringFormat(query,"UPDATE guilds SET motd='%s',motd_setter='%s' WHERE id=%d",
|
||||
esc.c_str(), esc_set.c_str(), guild_id);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
||||
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//escape our strings.
|
||||
@@ -679,9 +679,9 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
||||
StringFormat(query, "UPDATE guilds SET url='%s' WHERE id=%d",
|
||||
esc.c_str(), GuildID);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf))
|
||||
if (!m_db->RunQuery(query, &errbuf))
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error setting URL for guild %d '%s': %s", GuildID, query.c_str(), errbuf);
|
||||
_log(GUILDS__ERROR, "Error setting URL for guild %d '%s': %s", GuildID, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
||||
|
||||
GuildInfo *info = res->second;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//escape our strings.
|
||||
@@ -718,8 +718,8 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
||||
|
||||
StringFormat(query,"UPDATE guilds SET channel='%s' WHERE id=%d", esc.c_str(), GuildID);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -736,23 +736,23 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
if(guild_id != GUILD_NONE) {
|
||||
StringFormat(query, "REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)",
|
||||
charid, guild_id, rank);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
StringFormat(query, "DELETE FROM guild_members WHERE char_id=%d", charid);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
@@ -778,7 +778,7 @@ bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) {
|
||||
|
||||
bool BaseGuildManager::GetBankerFlag(uint32 CharID)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -788,9 +788,9 @@ bool BaseGuildManager::GetBankerFlag(uint32 CharID)
|
||||
|
||||
StringFormat(query,"select `banker` from `guild_members` where char_id=%i LIMIT 1", CharID);
|
||||
|
||||
if(!m_db->RunQuery(query, errbuf, &result))
|
||||
if(!m_db->RunQuery(query, &errbuf, &result))
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error retrieving banker flag '%s': %s", query.c_str(), errbuf);
|
||||
_log(GUILDS__ERROR, "Error retrieving banker flag '%s': %s", query.c_str(), errbuf.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -818,7 +818,7 @@ bool BaseGuildManager::DBSetAltFlag(uint32 charid, bool is_alt)
|
||||
|
||||
bool BaseGuildManager::GetAltFlag(uint32 CharID)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -828,8 +828,8 @@ bool BaseGuildManager::GetAltFlag(uint32 CharID)
|
||||
|
||||
StringFormat(query, "select `alt` from `guild_members` where char_id=%i LIMIT 1", CharID);
|
||||
|
||||
if(!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query.c_str(), errbuf);
|
||||
if(!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query.c_str(), errbuf.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -858,7 +858,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
|
||||
if(m_db == nullptr)
|
||||
return(false);
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
//escape our strings.
|
||||
@@ -870,8 +870,8 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
|
||||
StringFormat(query,"UPDATE guild_members SET public_note='%s' WHERE char_id=%d",
|
||||
esc.c_str(), charid);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf)) {
|
||||
_log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -884,11 +884,11 @@ bool BaseGuildManager::_RunQuery(const std::string query, const char *errmsg) {
|
||||
if(m_db == nullptr)
|
||||
return(false);
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf))
|
||||
if (!m_db->RunQuery(query, &errbuf))
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error %s: '%s': %s", errmsg, query.c_str(), errbuf);
|
||||
_log(GUILDS__ERROR, "Error %s: '%s': %s", errmsg, query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
||||
if(m_db == nullptr)
|
||||
return(false);
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -950,8 +950,8 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
||||
//load up the rank info for each guild.
|
||||
StringFormat(query,GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -986,8 +986,8 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
StringFormat(query, GuildMemberBaseQuery " WHERE c.name='%s'", esc.c_str());
|
||||
|
||||
//load up the rank info for each guild.
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -1011,7 +1011,7 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1023,8 +1023,8 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||
#else
|
||||
StringFormat(query, GuildMemberBaseQuery " WHERE c.id=%d", char_id);
|
||||
#endif
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -1265,7 +1265,7 @@ BaseGuildManager::GuildInfo::GuildInfo() {
|
||||
|
||||
uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
|
||||
@@ -1273,8 +1273,8 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||
"(SELECT id FROM character_ WHERE account_id = %i) AND rank = 2",
|
||||
AccountID);
|
||||
|
||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), errbuf);
|
||||
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||
_log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), errbuf.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1288,7 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||
/*
|
||||
|
||||
bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
// int i;
|
||||
MYSQL_RES *result;
|
||||
@@ -1327,7 +1327,7 @@ bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
|
||||
StringFormat(query, "SELECT id, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, "
|
||||
"rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title FROM guilds");
|
||||
|
||||
if (RunQuery(query,errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
uint32 guildeqid = 0xFFFFFFFF;
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
@@ -1392,12 +1392,12 @@ bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
|
||||
|
||||
|
||||
void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
char* notebuf = new char[(strlen(note)*2)+3];
|
||||
DoEscapeString(notebuf, note, strlen(note)) ;
|
||||
StringFormat(query,"update character_ set publicnote='%s' where name='%s' and guild=%i", notebuf,charname,guild_id);
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
cerr << "Error running SetPublicNote query: " << errbuf << endl;
|
||||
}
|
||||
safe_delete_array(notebuf);
|
||||
@@ -1406,7 +1406,7 @@ void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){
|
||||
|
||||
|
||||
bool Database::GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
+24
-24
@@ -28,7 +28,7 @@
|
||||
|
||||
/*
|
||||
void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -51,7 +51,7 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildMembers query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildMembers query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
gms->count=count;
|
||||
@@ -59,7 +59,7 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
||||
}
|
||||
|
||||
uint32 Database::NumberInGuild(uint32 guild_id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -75,14 +75,14 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in NumberInGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in NumberInGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
@@ -94,7 +94,7 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
||||
}
|
||||
|
||||
bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
@@ -115,7 +115,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||
|
||||
bool Database::DeleteGuild(uint32 guild_id)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
char *query2 = 0;
|
||||
uint32 affected_rows = 0;
|
||||
@@ -142,7 +142,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in DeleteGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in DeleteGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
||||
}
|
||||
|
||||
bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
char buf[65];
|
||||
@@ -165,7 +165,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in RenameGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in RenameGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||
|
||||
bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
int chars = 0;
|
||||
uint32 affected_rows = 0;
|
||||
@@ -206,7 +206,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in EditGuild query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in EditGuild query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
||||
|
||||
bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||
if (!name || !guild_id) return false;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -230,7 +230,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildNameByID query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildNameByID query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||
|
||||
uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -257,7 +257,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in Getguild_idbyLeader query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in Getguild_idbyLeader query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||
|
||||
bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
@@ -278,7 +278,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuildLeader query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuildLeader query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||
}
|
||||
|
||||
bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
char* motdbuf = 0;
|
||||
uint32 affected_rows = 0;
|
||||
@@ -306,7 +306,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuildMOTD query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetGuildMOTD query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
delete motdbuf;
|
||||
return false;
|
||||
@@ -317,7 +317,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||
|
||||
string Database::GetGuildMOTD(uint32 guild_id)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -332,7 +332,7 @@ string Database::GetGuildMOTD(uint32 guild_id)
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildMOTD query '%s': %s", query, errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetGuildMOTD query '%s': %s", query, &errbuf);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
return motd_str;
|
||||
|
||||
+14
-14
@@ -127,7 +127,7 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_star
|
||||
}
|
||||
|
||||
bool PersistentTimer::Load(Database *db) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
std::string query;
|
||||
@@ -142,9 +142,9 @@ bool PersistentTimer::Load(Database *db) {
|
||||
printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf, &result)) {
|
||||
if (!db->RunQuery(query, &errbuf, &result)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf.c_str());
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ bool PersistentTimer::Store(Database *db) {
|
||||
if(Expired(db, false)) //dont need to store expired timers.
|
||||
return(true);
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 qlen = 0;
|
||||
|
||||
@@ -182,7 +182,7 @@ bool PersistentTimer::Store(Database *db) {
|
||||
printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf)) {
|
||||
if (!db->RunQuery(query, &errbuf)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", errbuf);
|
||||
#endif
|
||||
@@ -193,7 +193,7 @@ bool PersistentTimer::Store(Database *db) {
|
||||
}
|
||||
|
||||
bool PersistentTimer::Clear(Database *db) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 qlen = 0;
|
||||
|
||||
@@ -205,7 +205,7 @@ bool PersistentTimer::Clear(Database *db) {
|
||||
printf("Clearing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf)) {
|
||||
if (!db->RunQuery(query, &errbuf)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
||||
#endif
|
||||
@@ -304,7 +304,7 @@ bool PTimerList::Load(Database *db) {
|
||||
}
|
||||
_list.clear();
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
std::string query;
|
||||
@@ -319,9 +319,9 @@ bool PTimerList::Load(Database *db) {
|
||||
printf("Loading all timers for char %lu\n", (unsigned long)_char_id);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf, &result)) {
|
||||
if (!db->RunQuery(query, &errbuf, &result)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf.c_str());
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
@@ -375,7 +375,7 @@ bool PTimerList::Store(Database *db) {
|
||||
bool PTimerList::Clear(Database *db) {
|
||||
_list.clear();
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 qlen = 0;
|
||||
|
||||
@@ -387,7 +387,7 @@ bool PTimerList::Clear(Database *db) {
|
||||
printf("Storing all timers for char %lu: '%s'\n", (unsigned long)_char_id, query);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf)) {
|
||||
if (!db->RunQuery(query, &errbuf)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
||||
#endif
|
||||
@@ -472,7 +472,7 @@ void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *>
|
||||
}
|
||||
|
||||
bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query, "DELETE FROM timers WHERE char_id=%lu AND type=%u ",
|
||||
@@ -482,7 +482,7 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
||||
printf("Clearing timer (offline): char %lu of type %u: '%s'\n", (unsigned long)char_id, type, query);
|
||||
#endif
|
||||
|
||||
if (!db->RunQuery(query, errbuf)) {
|
||||
if (!db->RunQuery(query, &errbuf)) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEMuLog::Error, "Error in PTimerList::ClearOffline, error: %s", errbuf);
|
||||
#endif
|
||||
|
||||
+18
-18
@@ -266,7 +266,7 @@ void RuleManager::SaveRules(Database *db, const char *ruleset) {
|
||||
|
||||
|
||||
bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -287,7 +287,7 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||
" FROM rule_values"
|
||||
" WHERE ruleset_id=%d", rsid);
|
||||
|
||||
if (db->RunQuery(query, errbuf, &result))
|
||||
if (db->RunQuery(query, &errbuf, &result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
if(!SetRule(row[0], row[1], nullptr, false))
|
||||
@@ -295,7 +295,7 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -317,22 +317,22 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) {
|
||||
break;
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query,"REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) "
|
||||
" VALUES(%d, '%s', '%s')",
|
||||
m_activeRuleset, _GetRuleName(type, index), vstr);
|
||||
|
||||
if (!db->RunQuery(query, errbuf))
|
||||
if (!db->RunQuery(query, &errbuf))
|
||||
{
|
||||
_log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query.c_str(),errbuf);
|
||||
_log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query.c_str(),errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int RuleManager::GetRulesetID(Database *db, const char *rulesetname) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -347,14 +347,14 @@ int RuleManager::GetRulesetID(Database *db, const char *rulesetname) {
|
||||
" FROM rule_sets"
|
||||
" WHERE name='%s'", rst.c_str());
|
||||
|
||||
if (db->RunQuery(query, errbuf, &result))
|
||||
if (db->RunQuery(query, &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.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
|
||||
return(res);
|
||||
@@ -372,15 +372,15 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
|
||||
db->DoEscapeString(rst, ruleset, len);
|
||||
|
||||
uint32 new_id;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
|
||||
std::string query;
|
||||
StringFormat(query,"INSERT INTO rule_sets (ruleset_id, name) "
|
||||
" VALUES(0, '%s')",rst.c_str());
|
||||
|
||||
if (!db->RunQuery(query,errbuf,nullptr,nullptr,&new_id))
|
||||
if (!db->RunQuery(query,&errbuf,nullptr,nullptr,&new_id))
|
||||
{
|
||||
_log(RULES__ERROR, "Failed to create rule set in the database: %s: %s", query.c_str(),errbuf);
|
||||
_log(RULES__ERROR, "Failed to create rule set in the database: %s: %s", query.c_str(),errbuf.c_str());
|
||||
res = -1;
|
||||
} else {
|
||||
res = new_id;
|
||||
@@ -390,7 +390,7 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
|
||||
}
|
||||
|
||||
std::string RuleManager::GetRulesetName(Database *db, int id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -400,21 +400,21 @@ std::string RuleManager::GetRulesetName(Database *db, int id) {
|
||||
StringFormat(query,"SELECT name"
|
||||
" FROM rule_sets"
|
||||
" WHERE ruleset_id=%d", id);
|
||||
if (db->RunQuery(query, errbuf, &result)){
|
||||
if (db->RunQuery(query, &errbuf, &result)){
|
||||
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.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
|
||||
return(res);
|
||||
}
|
||||
|
||||
bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -423,14 +423,14 @@ bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
||||
into[0] = "default";
|
||||
StringFormat(query,"SELECT ruleset_id , name FROM rule_sets");
|
||||
|
||||
if (db->RunQuery(query, errbuf, &result)) {
|
||||
if (db->RunQuery(query, &errbuf, &result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
into[ atoi(row[0]) ] = row[1];
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in ListRulesets query %s: %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in ListRulesets query %s: %s", query.c_str(), errbuf.c_str());
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
|
||||
+95
-95
@@ -46,12 +46,12 @@ SharedDatabase::~SharedDatabase() {
|
||||
|
||||
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id);
|
||||
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -61,14 +61,14 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
||||
|
||||
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
StringFormat(query,"SELECT gmspeed FROM account where id='%i'", account_id);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
if (mysql_num_rows(result) == 1)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
@@ -95,12 +95,12 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
||||
|
||||
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id);
|
||||
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
||||
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
||||
|
||||
uint32 EntitledTime = 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
@@ -122,7 +122,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
||||
"(ascii(substring(profile, 239, 1)) * 65536) + (ascii(substring(profile, 240, 1)) * 16777216))"
|
||||
"from character_ where account_id = %i", AccountID);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
|
||||
@@ -142,7 +142,7 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
||||
iter_queue it;
|
||||
int i;
|
||||
bool ret=true;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
||||
StringFormat(query,"DELETE FROM inventory WHERE charid=%i AND ( (slotid >=8000 and slotid<=8999) "
|
||||
"or slotid=30 or (slotid>=331 and slotid<=340))", char_id);
|
||||
|
||||
if ((ret = RunQuery(query, errbuf))) {
|
||||
if ((ret = RunQuery(query, &errbuf))) {
|
||||
for(it=start,i=8000;it!=end;it++,i++) {
|
||||
ItemInst *inst=*it;
|
||||
if (!(ret=SaveInventory(char_id,inst,(i==8000) ? 30 : i)))
|
||||
@@ -165,7 +165,7 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
||||
|
||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -175,8 +175,8 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
|
||||
"WHERE acctid=%d AND slotid=%d",
|
||||
account_id, slot_id);
|
||||
|
||||
if (!RunQuery(query, errbuf, &result)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error runing inventory verification query '%s': %s", query.c_str(), errbuf);
|
||||
if (!RunQuery(query, &errbuf, &result)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error runing inventory verification query '%s': %s", query.c_str(), errbuf.c_str());
|
||||
//returning true is less harmful in the face of a query error
|
||||
return(true);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
|
||||
|
||||
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||
_CP(Database_SaveInventory);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
bool ret = false;
|
||||
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
|
||||
@@ -225,7 +225,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
StringFormat(query, "DELETE FROM sharedbank WHERE acctid=%i AND slotid=%i",
|
||||
account_id, slot_id);
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (ret && Inventory::SupportsContainers(slot_id)) {
|
||||
@@ -234,7 +234,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
StringFormat(query, "DELETE FROM sharedbank WHERE acctid=%i AND slotid>=%i AND slotid<%i",
|
||||
account_id, base_slot_id, (base_slot_id+10));
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
}
|
||||
|
||||
// @merth: need to delete augments here
|
||||
@@ -261,7 +261,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
(unsigned long)augslot[4]);
|
||||
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
}
|
||||
}
|
||||
else { // All other inventory
|
||||
@@ -271,7 +271,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
StringFormat(query, "DELETE FROM inventory WHERE charid=%i AND slotid=%i",
|
||||
char_id, slot_id);
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (ret && Inventory::SupportsContainers(slot_id)) {
|
||||
@@ -280,7 +280,7 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
StringFormat(query, "DELETE FROM inventory WHERE charid=%i AND slotid>=%i AND slotid<%i",
|
||||
char_id, base_slot_id, (base_slot_id+10));
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
}
|
||||
|
||||
// @merth: need to delete augments here
|
||||
@@ -305,12 +305,12 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
(unsigned long)augslot[2],(unsigned long)augslot[3],
|
||||
(unsigned long)augslot[4]);
|
||||
|
||||
ret = RunQuery(query, errbuf);
|
||||
ret = RunQuery(query, &errbuf);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
LogFile->write(EQEMuLog::Error, "SaveInventory query '%s': %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "SaveInventory query '%s': %s", query.c_str(), errbuf.c_str());
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst && inst->IsType(ItemClassContainer) && Inventory::SupportsContainers(slot_id)) {
|
||||
@@ -327,14 +327,14 @@ bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 s
|
||||
|
||||
int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
StringFormat(query, "SELECT sharedplat FROM account WHERE id='%i'", account_id);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
if (mysql_num_rows(result) == 1)
|
||||
{
|
||||
row = mysql_fetch_row(result);
|
||||
@@ -359,13 +359,13 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
||||
|
||||
bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query,"UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i",
|
||||
amount_to_add, account_id);
|
||||
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
|
||||
|
||||
bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin_level)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -386,7 +386,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
|
||||
"gm <= %i ORDER BY id",
|
||||
si_race, si_class, si_deity, si_current_zone, admin_level);
|
||||
|
||||
RunQuery(query, errbuf, &result);
|
||||
RunQuery(query, &errbuf, &result);
|
||||
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
int itemid = atoi(row[0]);
|
||||
@@ -410,7 +410,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
|
||||
|
||||
// Retrieve shared bank inventory based on either account or character
|
||||
bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 len_query = 0;
|
||||
MYSQL_RES *result;
|
||||
@@ -433,7 +433,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
|
||||
}
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
int16 slot_id = (int16)atoi(row[0]);
|
||||
uint32 item_id = (uint32)atoi(row[1]);
|
||||
@@ -507,7 +507,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Database::GetSharedBank(uint32 account_id): %s", errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Database::GetSharedBank(uint32 account_id): %s", errbuf.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
// Overloaded: Retrieve character inventory based on character id
|
||||
bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
_CP(Database_GetInventory);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES* result;
|
||||
MYSQL_ROW row;
|
||||
@@ -527,7 +527,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
"instnodrop, custom_data FROM inventory WHERE "
|
||||
"charid=%i ORDER BY slotid", char_id);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
int16 slot_id = atoi(row[0]);
|
||||
@@ -617,7 +617,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
return GetSharedBank(char_id, inv, true);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "GetInventory query '%s' %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "GetInventory query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
LogFile->write(EQEMuLog::Error, "If you got an error related to the 'instnodrop' field, run the following SQL Queries:\nalter table inventory add instnodrop tinyint(1) unsigned default 0 not null;\n");
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
// Overloaded: Retrieve character inventory based on account_id and character name
|
||||
bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) {
|
||||
_CP(Database_GetInventory_name);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES* result;
|
||||
MYSQL_ROW row;
|
||||
@@ -640,7 +640,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
"AND ch.account_id=%i ORDER BY slotid",
|
||||
name, account_id);
|
||||
|
||||
if (RunQuery(query, errbuf, &result))
|
||||
if (RunQuery(query, &errbuf, &result))
|
||||
{
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
int16 slot_id = atoi(row[0]);
|
||||
@@ -718,7 +718,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
return GetSharedBank(account_id, inv, false);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "GetInventory query '%s' %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "GetInventory query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
LogFile->write(EQEMuLog::Error, "If you got an error related to the 'instnodrop' field, run the following SQL Queries:\nalter table inventory add instnodrop tinyint(1) unsigned default 0 not null;\n");
|
||||
}
|
||||
return false;
|
||||
@@ -726,14 +726,14 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
|
||||
|
||||
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
item_count = -1;
|
||||
max_id = 0;
|
||||
|
||||
std::string query = "SELECT MAX(id), count(*) FROM items";
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
row = mysql_fetch_row(result);
|
||||
if (row != nullptr && row[1] != 0) {
|
||||
item_count = atoi(row[1]);
|
||||
@@ -743,7 +743,7 @@ void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetItemsCount '%s': '%s'", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetItemsCount '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,7 +780,7 @@ bool SharedDatabase::LoadItems() {
|
||||
|
||||
void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_item_id) {
|
||||
EQEmu::FixedMemoryHashSet<Item_Struct> hash(reinterpret_cast<uint8*>(data), size, items, max_item_id);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
@@ -817,7 +817,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
"updated"
|
||||
" from items order by id";
|
||||
Item_Struct item;
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
memset(&item, 0, sizeof(Item_Struct));
|
||||
|
||||
@@ -1022,7 +1022,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "LoadItems '%s', %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "LoadItems '%s', %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,7 +1060,7 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
|
||||
|
||||
std::string SharedDatabase::GetBook(const char *txtfile)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1070,7 +1070,7 @@ std::string SharedDatabase::GetBook(const char *txtfile)
|
||||
|
||||
StringFormat(query,"SELECT txtfile FROM books where name='%s'", txtfile2);
|
||||
|
||||
if (!RunQuery(query,errbuf, &result)) {
|
||||
if (!RunQuery(query, &errbuf, &result)) {
|
||||
std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl;
|
||||
txtout.assign(" ",1);
|
||||
return txtout;
|
||||
@@ -1094,20 +1094,20 @@ std::string SharedDatabase::GetBook(const char *txtfile)
|
||||
void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
||||
list_count = 0;
|
||||
max_lists = 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
std::string query = "SELECT COUNT(*), MAX(id) FROM npc_faction";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
if(row = mysql_fetch_row(result)) {
|
||||
list_count = static_cast<uint32>(atoul(row[0]));
|
||||
max_lists = static_cast<uint32>(atoul(row[1]));
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1134,12 +1134,12 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co
|
||||
"npc_faction.id = npc_faction_entries.npc_faction_id "
|
||||
"ORDER BY npc_faction.id;";
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
NPCFactionList faction;
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
uint32 current_id = 0;
|
||||
uint32 current_entry = 0;
|
||||
while(row = mysql_fetch_row(result)) {
|
||||
@@ -1178,7 +1178,7 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co
|
||||
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,7 +1220,7 @@ bool SharedDatabase::LoadNPCFactionLists() {
|
||||
// False will also be returned if there is a database error.
|
||||
bool SharedDatabase::GetPlayerProfile(uint32 account_id, char* name, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, char* current_zone, uint32 *current_instance) {
|
||||
_CP(Database_GetPlayerProfile);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES* result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1231,7 +1231,7 @@ bool SharedDatabase::GetPlayerProfile(uint32 account_id, char* name, PlayerProfi
|
||||
"character_ WHERE account_id=%i AND name='%s'",
|
||||
account_id, name);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
row = mysql_fetch_row(result);
|
||||
lengths = mysql_fetch_lengths(result);
|
||||
@@ -1268,26 +1268,26 @@ bool SharedDatabase::GetPlayerProfile(uint32 account_id, char* name, PlayerProfi
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "GetPlayerProfile query '%s' %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "GetPlayerProfile query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SetPlayerProfile(uint32 account_id, uint32 charid, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, uint32 current_zone, uint32 current_instance, uint8 MaxXTargets) {
|
||||
_CP(Database_SetPlayerProfile);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 affected_rows = 0;
|
||||
bool ret = false;
|
||||
|
||||
SetPlayerProfile_MQ(query, account_id, charid, pp, inv, ext, current_zone, current_instance, MaxXTargets);
|
||||
|
||||
if (RunQuery(query, errbuf, 0, &affected_rows)) {
|
||||
if (RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||
ret = (affected_rows != 0);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
LogFile->write(EQEMuLog::Error, "SetPlayerProfile query '%s' %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "SetPlayerProfile query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1387,7 +1387,7 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges)
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
@@ -1398,7 +1398,7 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
"not timeofdeath=0",
|
||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
|
||||
if (!RunQuery(query, errbuf, 0, &affected_rows))
|
||||
if (!RunQuery(query, &errbuf, 0, &affected_rows))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -1409,7 +1409,7 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
"UNIX_TIMESTAMP(timeofdeath)) > %d and not timeofdeath=0",
|
||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
|
||||
if (!RunQuery(query, errbuf, 0, &affected_rows))
|
||||
if (!RunQuery(query, &errbuf, 0, &affected_rows))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -1418,14 +1418,14 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerBackups() {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
uint32 affected_rows = 0;
|
||||
|
||||
// 1209600 seconds = 2 weeks
|
||||
query = "Delete from player_corpses_backup where (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > 1209600";
|
||||
|
||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
||||
if (!RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1433,7 +1433,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() {
|
||||
}
|
||||
|
||||
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1441,7 +1441,7 @@ bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||
query = "SELECT command,access from commands";
|
||||
commands.clear();
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
commands[row[0]]=atoi(row[1]);
|
||||
}
|
||||
@@ -1487,13 +1487,13 @@ void SharedDatabase::LoadSkillCaps(void *data) {
|
||||
uint32 level_count = HARD_LEVEL_CAP + 1;
|
||||
uint16 *skill_caps_table = reinterpret_cast<uint16*>(data);
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
query = "SELECT skillID, class, level, cap FROM skill_caps ORDER BY skillID, class, level";
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
uint8 skillID = atoi(row[0]);
|
||||
@@ -1508,7 +1508,7 @@ void SharedDatabase::LoadSkillCaps(void *data) {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error loading skill caps from database: %s", errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error loading skill caps from database: %s", errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1592,7 +1592,7 @@ uint8 SharedDatabase::GetTrainLevel(uint8 Class_, SkillType Skill, uint8 Level)
|
||||
|
||||
void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1601,7 +1601,7 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
|
||||
"WHERE `spellid` > 0 AND `spellid` <= %i", iMaxSpellID);
|
||||
|
||||
|
||||
if(RunQuery(query,errbuf,&result)) {
|
||||
if(RunQuery(query,&errbuf,&result)) {
|
||||
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
|
||||
@@ -1613,7 +1613,7 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadDamageShieldTypes: %s %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error in LoadDamageShieldTypes: %s %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1622,7 +1622,7 @@ const EvolveInfo* SharedDatabase::GetEvolveInfo(uint32 loregroup) {
|
||||
}
|
||||
|
||||
int SharedDatabase::GetMaxSpellID() {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
@@ -1630,12 +1630,12 @@ int SharedDatabase::GetMaxSpellID() {
|
||||
|
||||
query = "SELECT MAX(id) FROM spells_new";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
row = mysql_fetch_row(result);
|
||||
ret = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
_log(SPELLS__LOAD_ERR, "Error in GetMaxSpellID query '%s' %s", query.c_str(), errbuf);
|
||||
_log(SPELLS__LOAD_ERR, "Error in GetMaxSpellID query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
@@ -1643,14 +1643,14 @@ int SharedDatabase::GetMaxSpellID() {
|
||||
|
||||
void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
||||
SPDat_Spell_Struct *sp = reinterpret_cast<SPDat_Spell_Struct*>(data);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
query = "SELECT * FROM spells_new ORDER BY id ASC";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
int tempid = 0;
|
||||
int counter = 0;
|
||||
@@ -1769,7 +1769,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
||||
|
||||
LoadDamageShieldTypes(sp, max_spells);
|
||||
} else {
|
||||
_log(SPELLS__LOAD_ERR, "Error in LoadSpells query '%s' %s", query.c_str(), errbuf);
|
||||
_log(SPELLS__LOAD_ERR, "Error in LoadSpells query '%s' %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1778,11 +1778,11 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
|
||||
max_loot_table = 0;
|
||||
loot_table_entries = 0;
|
||||
std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable";
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
if(row = mysql_fetch_row(result)) {
|
||||
loot_table_count = static_cast<uint32>(atoul(row[0]));
|
||||
max_loot_table = static_cast<uint32>(atoul(row[1]));
|
||||
@@ -1790,7 +1790,7 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1798,13 +1798,13 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d
|
||||
loot_drop_count = 0;
|
||||
max_loot_drop = 0;
|
||||
loot_drop_entries = 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
if(row = mysql_fetch_row(result)) {
|
||||
loot_drop_count = static_cast<uint32>(atoul(row[0]));
|
||||
max_loot_drop = static_cast<uint32>(atoul(row[1]));
|
||||
@@ -1812,13 +1812,13 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
||||
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
uint8 loot_table[sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128)];
|
||||
@@ -1830,7 +1830,7 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
||||
"loottable_entries.probability FROM loottable LEFT JOIN loottable_entries"
|
||||
" ON loottable.id = loottable_entries.loottable_id ORDER BY id";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
uint32 current_id = 0;
|
||||
uint32 current_entry = 0;
|
||||
while(row = mysql_fetch_row(result)) {
|
||||
@@ -1873,13 +1873,13 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
||||
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
||||
@@ -1892,7 +1892,7 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||
"lootdrop JOIN lootdrop_entries "
|
||||
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
if(RunQuery(query, &errbuf, &result)) {
|
||||
uint32 current_id = 0;
|
||||
uint32 current_entry = 0;
|
||||
while(row = mysql_fetch_row(result)) {
|
||||
@@ -1930,7 +1930,7 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot drop info from database: %s, %s", query.c_str(), errbuf);
|
||||
LogFile->write(EQEMuLog::Error, "Error getting loot drop info from database: %s, %s", query.c_str(), errbuf.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1988,13 +1988,13 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
|
||||
|
||||
void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
StringFormat(query,"SELECT inspectmessage FROM character_ WHERE name='%s'", playername);
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
row = mysql_fetch_row(result);
|
||||
@@ -2010,27 +2010,27 @@ void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_St
|
||||
|
||||
void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'",
|
||||
message->text, playername);
|
||||
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
StringFormat(query, "SELECT BotInspectMessage FROM bots WHERE BotID=%i", botid);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
if (RunQuery(query, &errbuf, &result)) {
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
row = mysql_fetch_row(result);
|
||||
memcpy(message, row[0], sizeof(InspectMessage_Struct));
|
||||
@@ -2045,13 +2045,13 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
|
||||
|
||||
void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
std::string errbuf;
|
||||
std::string query;
|
||||
|
||||
StringFormat(query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i",
|
||||
message->text, botid);
|
||||
|
||||
if (!RunQuery(query, errbuf)) {
|
||||
if (!RunQuery(query, &errbuf)) {
|
||||
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user