mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-25 10:22:26 +00:00
RunQuery now uses a string instead of a char* for the error buffer.
This commit is contained in:
parent
46918cdbec
commit
f8dc6f7730
File diff suppressed because it is too large
Load Diff
@ -18,10 +18,10 @@
|
|||||||
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
|
#define ASYNC_LOOP_GRANULARITY 4 //# of ms between checking our work
|
||||||
|
|
||||||
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
bool DBAsyncCB_LoadVariables(DBAsyncWork* iWork) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES* result = 0;
|
MYSQL_RES* result = 0;
|
||||||
DBAsyncQuery* dbaq = iWork->PopAnswer();
|
DBAsyncQuery* dbaq = iWork->PopAnswer();
|
||||||
if (dbaq->GetAnswer(errbuf, &result))
|
if (dbaq->GetAnswer(&errbuf, &result))
|
||||||
iWork->GetDB()->LoadVariables_result(result);
|
iWork->GetDB()->LoadVariables_result(result);
|
||||||
else
|
else
|
||||||
std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
|
std::cout << "Error: DBAsyncCB_LoadVariables failed: !GetAnswer: '" << errbuf << "'" << std::endl;
|
||||||
@ -615,10 +615,13 @@ DBAsyncQuery::~DBAsyncQuery() {
|
|||||||
mysql_free_result(presult);
|
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 (pstatus != DBAsync::Finished) {
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "Error: Query not finished.");
|
{
|
||||||
|
errbuf->assign("Error: Query not finished.");
|
||||||
|
}
|
||||||
|
|
||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = UINT_MAX;
|
*errnum = UINT_MAX;
|
||||||
return false;
|
return false;
|
||||||
@ -626,12 +629,16 @@ bool DBAsyncQuery::GetAnswer(char* errbuf, MYSQL_RES** result, uint32* affected_
|
|||||||
if (errbuf) {
|
if (errbuf) {
|
||||||
if (pGetErrbuf) {
|
if (pGetErrbuf) {
|
||||||
if (perrbuf)
|
if (perrbuf)
|
||||||
strn0cpy(errbuf, perrbuf, MYSQL_ERRMSG_SIZE);
|
{
|
||||||
|
errbuf->assign(*perrbuf);
|
||||||
|
}
|
||||||
else
|
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
|
else
|
||||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "Error message not saved. errno: %u", perrnum);
|
StringFormat(*errbuf, "Error message not saved. errno: %u", perrnum);
|
||||||
}
|
}
|
||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = perrnum;
|
*errnum = perrnum;
|
||||||
@ -647,7 +654,9 @@ bool DBAsyncQuery::GetAnswer(char* errbuf, MYSQL_RES** result, uint32* affected_
|
|||||||
void DBAsyncQuery::Process(DBcore* iDBC) {
|
void DBAsyncQuery::Process(DBcore* iDBC) {
|
||||||
pstatus = DBAsync::Executing;
|
pstatus = DBAsync::Executing;
|
||||||
if (pGetErrbuf)
|
if (pGetErrbuf)
|
||||||
perrbuf = new char[MYSQL_ERRMSG_SIZE];
|
{
|
||||||
|
std::string perrbuf = "";
|
||||||
|
}
|
||||||
MYSQL_RES** resultPP = 0;
|
MYSQL_RES** resultPP = 0;
|
||||||
if (pGetResultSet)
|
if (pGetResultSet)
|
||||||
resultPP = &presult;
|
resultPP = &presult;
|
||||||
|
|||||||
@ -143,7 +143,7 @@ public:
|
|||||||
DBAsyncQuery(uint32 iQPT, std::string iQuery, bool iGetResultSet = true, bool iGetErrbuf = true);
|
DBAsyncQuery(uint32 iQPT, std::string iQuery, bool iGetResultSet = true, bool iGetErrbuf = true);
|
||||||
~DBAsyncQuery();
|
~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; }
|
inline uint32 QPT() { return pQPT; }
|
||||||
protected:
|
protected:
|
||||||
friend class DBAsyncWork;
|
friend class DBAsyncWork;
|
||||||
@ -155,15 +155,15 @@ protected:
|
|||||||
void Init(uint32 iQPT, bool iGetResultSet, bool iGetErrbuf);
|
void Init(uint32 iQPT, bool iGetResultSet, bool iGetErrbuf);
|
||||||
DBAsync::Status pstatus;
|
DBAsync::Status pstatus;
|
||||||
std::string pQuery;
|
std::string pQuery;
|
||||||
bool pGetResultSet;
|
bool pGetResultSet;
|
||||||
bool pGetErrbuf;
|
bool pGetErrbuf;
|
||||||
|
|
||||||
bool pmysqlsuccess;
|
bool pmysqlsuccess;
|
||||||
char* perrbuf;
|
std::string* perrbuf;
|
||||||
uint32 perrnum;
|
uint32 perrnum;
|
||||||
uint32 paffected_rows;
|
uint32 paffected_rows;
|
||||||
uint32 plast_insert_id;
|
uint32 plast_insert_id;
|
||||||
MYSQL_RES* presult;
|
MYSQL_RES* presult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,11 @@
|
|||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../common/MiscFunctions.h"
|
#include "../common/MiscFunctions.h"
|
||||||
|
#include "../common/StringUtil.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
|
||||||
#define strncasecmp _strnicmp
|
|
||||||
#define strcasecmp _stricmp
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#else
|
#else
|
||||||
#include "unix.h"
|
#include "unix.h"
|
||||||
@ -59,12 +57,10 @@ void DBcore::ping() {
|
|||||||
MDatabase.unlock();
|
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);
|
_CP(DBcore_RunQuery);
|
||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = 0;
|
*errnum = 0;
|
||||||
if (errbuf)
|
|
||||||
errbuf[0] = 0;
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
LockMutex lock(&MDatabase);
|
LockMutex lock(&MDatabase);
|
||||||
if (pStatus != Connected)
|
if (pStatus != Connected)
|
||||||
@ -89,7 +85,10 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
|||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = mysql_errno(&mysql);
|
*errnum = mysql_errno(&mysql);
|
||||||
if (errbuf)
|
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;
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@ -98,7 +97,10 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
|||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = mysql_errno(&mysql);
|
*errnum = mysql_errno(&mysql);
|
||||||
if (errbuf)
|
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
|
#ifdef _EQDEBUG
|
||||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -129,7 +131,7 @@ bool DBcore::RunQuery(const std::string& query, char* errbuf, MYSQL_RES** result
|
|||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = UINT_MAX;
|
*errnum = UINT_MAX;
|
||||||
if (errbuf)
|
if (errbuf)
|
||||||
strcpy(errbuf, "DBcore::RunQuery: No Result");
|
errbuf->assign("DBcore::RunQuery: No Result");
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +164,7 @@ void DBcore::DoEscapeString(std::string& outString, const char* frombuf, uint32
|
|||||||
safe_delete_array(tobuf);
|
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);
|
LockMutex lock(&MDatabase);
|
||||||
safe_delete(pHost);
|
safe_delete(pHost);
|
||||||
safe_delete(pUser);
|
safe_delete(pUser);
|
||||||
@ -178,9 +180,7 @@ bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, c
|
|||||||
return Open(errnum, errbuf);
|
return Open(errnum, errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
bool DBcore::Open(uint32* errnum, std::string* errbuf) {
|
||||||
if (errbuf)
|
|
||||||
errbuf[0] = 0;
|
|
||||||
LockMutex lock(&MDatabase);
|
LockMutex lock(&MDatabase);
|
||||||
if (GetStatus() == Connected)
|
if (GetStatus() == Connected)
|
||||||
return true;
|
return true;
|
||||||
@ -208,7 +208,10 @@ bool DBcore::Open(uint32* errnum, char* errbuf) {
|
|||||||
if (errnum)
|
if (errnum)
|
||||||
*errnum = mysql_errno(&mysql);
|
*errnum = mysql_errno(&mysql);
|
||||||
if (errbuf)
|
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;
|
pStatus = Error;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,15 +22,15 @@ public:
|
|||||||
DBcore();
|
DBcore();
|
||||||
~DBcore();
|
~DBcore();
|
||||||
eStatus GetStatus() { return pStatus; }
|
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 DoEscapeString(std::string& outString, const char* frombuf, uint32 fromlen);
|
||||||
void ping();
|
void ping();
|
||||||
MYSQL* getMySQL(){ return &mysql; }
|
MYSQL* getMySQL(){ return &mysql; }
|
||||||
|
|
||||||
protected:
|
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:
|
private:
|
||||||
bool Open(uint32* errnum = 0, char* errbuf = 0);
|
bool Open(uint32* errnum = 0, std::string* errbuf = nullptr);
|
||||||
|
|
||||||
MYSQL mysql;
|
MYSQL mysql;
|
||||||
Mutex MDatabase;
|
Mutex MDatabase;
|
||||||
|
|||||||
@ -49,7 +49,7 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -58,8 +58,8 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
StringFormat(query, "SELECT id, name, leader, minstatus, motd, motd_setter,channel, url FROM guilds");
|
StringFormat(query, "SELECT id, name, leader, minstatus, motd, motd_setter,channel, url FROM guilds");
|
||||||
|
|
||||||
// load up all the guilds
|
// load up all the guilds
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
@ -71,8 +71,8 @@ bool BaseGuildManager::LoadGuilds() {
|
|||||||
"can_demote, can_motd, can_warpeace FROM guild_ranks");
|
"can_demote, can_motd, can_warpeace FROM guild_ranks");
|
||||||
|
|
||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -124,8 +124,8 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
|||||||
StringFormat(query,"SELECT name, leader, minstatus, motd, motd_setter, channel, url"
|
StringFormat(query,"SELECT name, leader, minstatus, motd, motd_setter, channel, url"
|
||||||
" FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
" FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
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 "
|
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);
|
"FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,19 +231,19 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
|||||||
}
|
}
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//clear out old `guilds` entry
|
//clear out old `guilds` entry
|
||||||
StringFormat(query, "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
StringFormat(query, "DELETE FROM guilds WHERE id=%lu", (unsigned long)guild_id);
|
||||||
if (!m_db->RunQuery(query, 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);
|
_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
|
//clear out old `guild_ranks` entries
|
||||||
StringFormat(query, "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
|
StringFormat(query, "DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
|
||||||
if (!m_db->RunQuery(query, 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);
|
_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.
|
//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')",
|
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());
|
(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);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,8 +284,8 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
|||||||
r.permissions[GUILD_MOTD],
|
r.permissions[GUILD_MOTD],
|
||||||
r.permissions[GUILD_WARPEACE]);
|
r.permissions[GUILD_WARPEACE]);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, 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);
|
_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);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
|||||||
return(GUILD_NONE);
|
return(GUILD_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
|||||||
for (x = 1; x < MAX_NUMBER_GUILDS; x++) {
|
for (x = 1; x < MAX_NUMBER_GUILDS; x++) {
|
||||||
StringFormat(query,"SELECT id FROM guilds where id=%i;", 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) {
|
if (mysql_num_rows(result) == 0) {
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
_log(GUILDS__DB, "Located free guild ID %d in the database", x);
|
_log(GUILDS__DB, "Located free guild ID %d in the database", x);
|
||||||
@ -321,7 +321,7 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
return(false);
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//escape our strings.
|
//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",
|
StringFormat(query, "UPDATE guilds SET name='%s' WHERE id=%d",
|
||||||
esc.c_str(), guild_id);
|
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);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,15 +586,15 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
|||||||
return(false);
|
return(false);
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//insert the new `guilds` entry
|
//insert the new `guilds` entry
|
||||||
StringFormat(query, "UPDATE guilds SET leader='%d' WHERE id=%d",
|
StringFormat(query, "UPDATE guilds SET leader='%d' WHERE id=%d",
|
||||||
leader, guild_id);
|
leader, guild_id);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf)) {
|
if (!m_db->RunQuery(query, &errbuf)) {
|
||||||
_log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
|||||||
return(false);
|
return(false);
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//escape our strings.
|
//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",
|
StringFormat(query,"UPDATE guilds SET motd='%s',motd_setter='%s' WHERE id=%d",
|
||||||
esc.c_str(), esc_set.c_str(), guild_id);
|
esc.c_str(), esc_set.c_str(), guild_id);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf)) {
|
if (!m_db->RunQuery(query, &errbuf)) {
|
||||||
_log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
|||||||
|
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//escape our strings.
|
//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",
|
StringFormat(query, "UPDATE guilds SET url='%s' WHERE id=%d",
|
||||||
esc.c_str(), GuildID);
|
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);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
|||||||
|
|
||||||
GuildInfo *info = res->second;
|
GuildInfo *info = res->second;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//escape our strings.
|
//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);
|
StringFormat(query,"UPDATE guilds SET channel='%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 Channel for guild %d '%s': %s", GuildID, query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,23 +736,23 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(guild_id != GUILD_NONE) {
|
if(guild_id != GUILD_NONE) {
|
||||||
StringFormat(query, "REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)",
|
StringFormat(query, "REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)",
|
||||||
charid, guild_id, rank);
|
charid, guild_id, rank);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, 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);
|
_log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
StringFormat(query, "DELETE FROM guild_members WHERE char_id=%d", charid);
|
StringFormat(query, "DELETE FROM guild_members WHERE char_id=%d", charid);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, 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);
|
_log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -778,7 +778,7 @@ bool BaseGuildManager::DBSetBankerFlag(uint32 charid, bool is_banker) {
|
|||||||
|
|
||||||
bool BaseGuildManager::GetBankerFlag(uint32 CharID)
|
bool BaseGuildManager::GetBankerFlag(uint32 CharID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ bool BaseGuildManager::DBSetAltFlag(uint32 charid, bool is_alt)
|
|||||||
|
|
||||||
bool BaseGuildManager::GetAltFlag(uint32 CharID)
|
bool BaseGuildManager::GetAltFlag(uint32 CharID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
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);
|
StringFormat(query, "select `alt` 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 alt flag '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -858,7 +858,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
|
|||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
//escape our strings.
|
//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",
|
StringFormat(query,"UPDATE guild_members SET public_note='%s' WHERE char_id=%d",
|
||||||
esc.c_str(), charid);
|
esc.c_str(), charid);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf)) {
|
if (!m_db->RunQuery(query, &errbuf)) {
|
||||||
_log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,11 +884,11 @@ bool BaseGuildManager::_RunQuery(const std::string query, const char *errmsg) {
|
|||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
return(false);
|
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);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,7 +942,7 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
|||||||
if(m_db == nullptr)
|
if(m_db == nullptr)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -950,8 +950,8 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
|||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
StringFormat(query,GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
|
StringFormat(query,GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
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());
|
StringFormat(query, GuildMemberBaseQuery " WHERE c.name='%s'", esc.c_str());
|
||||||
|
|
||||||
//load up the rank info for each guild.
|
//load up the rank info for each guild.
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1011,7 +1011,7 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1023,8 +1023,8 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
|||||||
#else
|
#else
|
||||||
StringFormat(query, GuildMemberBaseQuery " WHERE c.id=%d", char_id);
|
StringFormat(query, GuildMemberBaseQuery " WHERE c.id=%d", char_id);
|
||||||
#endif
|
#endif
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,7 +1265,7 @@ BaseGuildManager::GuildInfo::GuildInfo() {
|
|||||||
|
|
||||||
uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -1273,8 +1273,8 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
|||||||
"(SELECT id FROM character_ WHERE account_id = %i) AND rank = 2",
|
"(SELECT id FROM character_ WHERE account_id = %i) AND rank = 2",
|
||||||
AccountID);
|
AccountID);
|
||||||
|
|
||||||
if (!m_db->RunQuery(query, errbuf, &result)) {
|
if (!m_db->RunQuery(query, &errbuf, &result)) {
|
||||||
_log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), errbuf);
|
_log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1288,7 +1288,7 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
|
bool Database::LoadGuilds(GuildRanks_Struct* guilds) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
// int i;
|
// int i;
|
||||||
MYSQL_RES *result;
|
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, "
|
StringFormat(query, "SELECT id, eqid, name, leader, minstatus, rank0title, rank1, rank1title, rank2, "
|
||||||
"rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title FROM guilds");
|
"rank2title, rank3, rank3title, rank4, rank4title, rank5, rank5title FROM guilds");
|
||||||
|
|
||||||
if (RunQuery(query,errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
uint32 guildeqid = 0xFFFFFFFF;
|
uint32 guildeqid = 0xFFFFFFFF;
|
||||||
while ((row = mysql_fetch_row(result))) {
|
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){
|
void Database::SetPublicNote(uint32 guild_id,char* charname, char* note){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
char* notebuf = new char[(strlen(note)*2)+3];
|
char* notebuf = new char[(strlen(note)*2)+3];
|
||||||
DoEscapeString(notebuf, note, strlen(note)) ;
|
DoEscapeString(notebuf, note, strlen(note)) ;
|
||||||
StringFormat(query,"update character_ set publicnote='%s' where name='%s' and guild=%i", notebuf,charname,guild_id);
|
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;
|
cerr << "Error running SetPublicNote query: " << errbuf << endl;
|
||||||
}
|
}
|
||||||
safe_delete_array(notebuf);
|
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) {
|
bool Database::GetGuildRanks(uint32 guildeqid, GuildRanks_Struct* gr) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -51,7 +51,7 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
gms->count=count;
|
gms->count=count;
|
||||||
@ -59,7 +59,7 @@ void Database::GetGuildMembers(uint32 guild_id, GuildMember_Struct* gms){
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 Database::NumberInGuild(uint32 guild_id) {
|
uint32 Database::NumberInGuild(uint32 guild_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -75,14 +75,14 @@ uint32 Database::NumberInGuild(uint32 guild_id) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ bool Database::SetGuild(char* name, uint32 guild_id, uint8 guildrank) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
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) {
|
bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ bool Database::SetGuild(uint32 charid, uint32 guild_id, uint8 guildrank) {
|
|||||||
|
|
||||||
bool Database::DeleteGuild(uint32 guild_id)
|
bool Database::DeleteGuild(uint32 guild_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
char *query2 = 0;
|
char *query2 = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
@ -142,7 +142,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ bool Database::DeleteGuild(uint32 guild_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
char buf[65];
|
char buf[65];
|
||||||
@ -165,7 +165,7 @@ bool Database::RenameGuild(uint32 guild_id, const char* name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
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)
|
bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct* grl)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
int chars = 0;
|
int chars = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
@ -206,7 +206,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ bool Database::EditGuild(uint32 guild_id, uint8 ranknum, GuildRankLevel_Struct*
|
|||||||
|
|
||||||
bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
||||||
if (!name || !guild_id) return false;
|
if (!name || !guild_id) return false;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -230,7 +230,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ bool Database::GetGuildNameByID(uint32 guild_id, char * name) {
|
|||||||
|
|
||||||
uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -257,7 +257,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ uint32 Database::GetGuildIDbyLeader(uint32 leader)
|
|||||||
|
|
||||||
bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ bool Database::SetGuildLeader(uint32 guild_id, uint32 leader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
char* motdbuf = 0;
|
char* motdbuf = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
@ -306,7 +306,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
|||||||
}
|
}
|
||||||
else
|
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);
|
safe_delete_array(query);
|
||||||
delete motdbuf;
|
delete motdbuf;
|
||||||
return false;
|
return false;
|
||||||
@ -317,7 +317,7 @@ bool Database::SetGuildMOTD(uint32 guild_id, const char* motd) {
|
|||||||
|
|
||||||
string Database::GetGuildMOTD(uint32 guild_id)
|
string Database::GetGuildMOTD(uint32 guild_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char *query = 0;
|
char *query = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -332,7 +332,7 @@ string Database::GetGuildMOTD(uint32 guild_id)
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
return motd_str;
|
return motd_str;
|
||||||
|
|||||||
@ -127,7 +127,7 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_star
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PersistentTimer::Load(Database *db) {
|
bool PersistentTimer::Load(Database *db) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
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);
|
printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf, &result)) {
|
if (!db->RunQuery(query, &errbuf, &result)) {
|
||||||
#if EQDEBUG > 5
|
#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
|
#endif
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ bool PersistentTimer::Store(Database *db) {
|
|||||||
if(Expired(db, false)) //dont need to store expired timers.
|
if(Expired(db, false)) //dont need to store expired timers.
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 qlen = 0;
|
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);
|
printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf)) {
|
if (!db->RunQuery(query, &errbuf)) {
|
||||||
#if EQDEBUG > 5
|
#if EQDEBUG > 5
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Store, error: %s", errbuf);
|
||||||
#endif
|
#endif
|
||||||
@ -193,7 +193,7 @@ bool PersistentTimer::Store(Database *db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PersistentTimer::Clear(Database *db) {
|
bool PersistentTimer::Clear(Database *db) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 qlen = 0;
|
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);
|
printf("Clearing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf)) {
|
if (!db->RunQuery(query, &errbuf)) {
|
||||||
#if EQDEBUG > 5
|
#if EQDEBUG > 5
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
||||||
#endif
|
#endif
|
||||||
@ -304,7 +304,7 @@ bool PTimerList::Load(Database *db) {
|
|||||||
}
|
}
|
||||||
_list.clear();
|
_list.clear();
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -319,9 +319,9 @@ bool PTimerList::Load(Database *db) {
|
|||||||
printf("Loading all timers for char %lu\n", (unsigned long)_char_id);
|
printf("Loading all timers for char %lu\n", (unsigned long)_char_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf, &result)) {
|
if (!db->RunQuery(query, &errbuf, &result)) {
|
||||||
#if EQDEBUG > 5
|
#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
|
#endif
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ bool PTimerList::Store(Database *db) {
|
|||||||
bool PTimerList::Clear(Database *db) {
|
bool PTimerList::Clear(Database *db) {
|
||||||
_list.clear();
|
_list.clear();
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 qlen = 0;
|
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);
|
printf("Storing all timers for char %lu: '%s'\n", (unsigned long)_char_id, query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf)) {
|
if (!db->RunQuery(query, &errbuf)) {
|
||||||
#if EQDEBUG > 5
|
#if EQDEBUG > 5
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Clear, error: %s", errbuf);
|
||||||
#endif
|
#endif
|
||||||
@ -472,7 +472,7 @@ void PTimerList::ToVector(std::vector< std::pair<pTimerType, PersistentTimer *>
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM timers WHERE char_id=%lu AND type=%u ",
|
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);
|
printf("Clearing timer (offline): char %lu of type %u: '%s'\n", (unsigned long)char_id, type, query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!db->RunQuery(query, errbuf)) {
|
if (!db->RunQuery(query, &errbuf)) {
|
||||||
#if EQDEBUG > 5
|
#if EQDEBUG > 5
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PTimerList::ClearOffline, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PTimerList::ClearOffline, error: %s", errbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -266,7 +266,7 @@ void RuleManager::SaveRules(Database *db, const char *ruleset) {
|
|||||||
|
|
||||||
|
|
||||||
bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -287,7 +287,7 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
|||||||
" FROM rule_values"
|
" FROM rule_values"
|
||||||
" WHERE ruleset_id=%d", rsid);
|
" WHERE ruleset_id=%d", rsid);
|
||||||
|
|
||||||
if (db->RunQuery(query, errbuf, &result))
|
if (db->RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
if(!SetRule(row[0], row[1], nullptr, false))
|
if(!SetRule(row[0], row[1], nullptr, false))
|
||||||
@ -295,7 +295,7 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,22 +317,22 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) "
|
StringFormat(query,"REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) "
|
||||||
" VALUES(%d, '%s', '%s')",
|
" VALUES(%d, '%s', '%s')",
|
||||||
m_activeRuleset, _GetRuleName(type, index), vstr);
|
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) {
|
int RuleManager::GetRulesetID(Database *db, const char *rulesetname) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -347,14 +347,14 @@ int RuleManager::GetRulesetID(Database *db, const char *rulesetname) {
|
|||||||
" FROM rule_sets"
|
" FROM rule_sets"
|
||||||
" WHERE name='%s'", rst.c_str());
|
" WHERE name='%s'", rst.c_str());
|
||||||
|
|
||||||
if (db->RunQuery(query, errbuf, &result))
|
if (db->RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if((row = mysql_fetch_row(result))) {
|
if((row = mysql_fetch_row(result))) {
|
||||||
res = atoi(row[0]);
|
res = atoi(row[0]);
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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);
|
return(res);
|
||||||
@ -372,15 +372,15 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
|
|||||||
db->DoEscapeString(rst, ruleset, len);
|
db->DoEscapeString(rst, ruleset, len);
|
||||||
|
|
||||||
uint32 new_id;
|
uint32 new_id;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
StringFormat(query,"INSERT INTO rule_sets (ruleset_id, name) "
|
StringFormat(query,"INSERT INTO rule_sets (ruleset_id, name) "
|
||||||
" VALUES(0, '%s')",rst.c_str());
|
" 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;
|
res = -1;
|
||||||
} else {
|
} else {
|
||||||
res = new_id;
|
res = new_id;
|
||||||
@ -390,7 +390,7 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string RuleManager::GetRulesetName(Database *db, int id) {
|
std::string RuleManager::GetRulesetName(Database *db, int id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -400,21 +400,21 @@ std::string RuleManager::GetRulesetName(Database *db, int id) {
|
|||||||
StringFormat(query,"SELECT name"
|
StringFormat(query,"SELECT name"
|
||||||
" FROM rule_sets"
|
" FROM rule_sets"
|
||||||
" WHERE ruleset_id=%d", id);
|
" WHERE ruleset_id=%d", id);
|
||||||
if (db->RunQuery(query, errbuf, &result)){
|
if (db->RunQuery(query, &errbuf, &result)){
|
||||||
if((row = mysql_fetch_row(result))) {
|
if((row = mysql_fetch_row(result))) {
|
||||||
res = row[0];
|
res = row[0];
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
return(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -423,14 +423,14 @@ bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
|||||||
into[0] = "default";
|
into[0] = "default";
|
||||||
StringFormat(query,"SELECT ruleset_id , name FROM rule_sets");
|
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))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
into[ atoi(row[0]) ] = row[1];
|
into[ atoi(row[0]) ] = row[1];
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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(false);
|
||||||
}
|
}
|
||||||
return(true);
|
return(true);
|
||||||
|
|||||||
@ -46,12 +46,12 @@ SharedDatabase::~SharedDatabase() {
|
|||||||
|
|
||||||
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE account SET hideme = %i where id = %i", hideme, account_id);
|
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;
|
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -61,14 +61,14 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
|||||||
|
|
||||||
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"SELECT gmspeed FROM account where id='%i'", account_id);
|
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)
|
if (mysql_num_rows(result) == 1)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -95,12 +95,12 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
|||||||
|
|
||||||
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE account SET gmspeed = %i where id = %i", gmspeed, account_id);
|
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;
|
std::cerr << "Error in SetGMSpeed query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
|||||||
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
||||||
|
|
||||||
uint32 EntitledTime = 0;
|
uint32 EntitledTime = 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
|
|||||||
"(ascii(substring(profile, 239, 1)) * 65536) + (ascii(substring(profile, 240, 1)) * 16777216))"
|
"(ascii(substring(profile, 239, 1)) * 65536) + (ascii(substring(profile, 240, 1)) * 16777216))"
|
||||||
"from character_ where account_id = %i", AccountID);
|
"from character_ where account_id = %i", AccountID);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ bool SharedDatabase::SaveCursor(uint32 char_id, std::list<ItemInst*>::const_iter
|
|||||||
iter_queue it;
|
iter_queue it;
|
||||||
int i;
|
int i;
|
||||||
bool ret=true;
|
bool ret=true;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
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) "
|
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);
|
"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++) {
|
for(it=start,i=8000;it!=end;it++,i++) {
|
||||||
ItemInst *inst=*it;
|
ItemInst *inst=*it;
|
||||||
if (!(ret=SaveInventory(char_id,inst,(i==8000) ? 30 : i)))
|
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)
|
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const ItemInst* inst)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -175,8 +175,8 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
|
|||||||
"WHERE acctid=%d AND slotid=%d",
|
"WHERE acctid=%d AND slotid=%d",
|
||||||
account_id, slot_id);
|
account_id, slot_id);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error runing inventory verification query '%s': %s", query.c_str(), errbuf);
|
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
|
//returning true is less harmful in the face of a query error
|
||||||
return(true);
|
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) {
|
bool SharedDatabase::SaveInventory(uint32 char_id, const ItemInst* inst, int16 slot_id) {
|
||||||
_CP(Database_SaveInventory);
|
_CP(Database_SaveInventory);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
|
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",
|
StringFormat(query, "DELETE FROM sharedbank WHERE acctid=%i AND slotid=%i",
|
||||||
account_id, slot_id);
|
account_id, slot_id);
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
|
|
||||||
// Delete bag slots, if need be
|
// Delete bag slots, if need be
|
||||||
if (ret && Inventory::SupportsContainers(slot_id)) {
|
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",
|
StringFormat(query, "DELETE FROM sharedbank WHERE acctid=%i AND slotid>=%i AND slotid<%i",
|
||||||
account_id, base_slot_id, (base_slot_id+10));
|
account_id, base_slot_id, (base_slot_id+10));
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @merth: need to delete augments here
|
// @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]);
|
(unsigned long)augslot[4]);
|
||||||
|
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // All other inventory
|
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",
|
StringFormat(query, "DELETE FROM inventory WHERE charid=%i AND slotid=%i",
|
||||||
char_id, slot_id);
|
char_id, slot_id);
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
|
|
||||||
// Delete bag slots, if need be
|
// Delete bag slots, if need be
|
||||||
if (ret && Inventory::SupportsContainers(slot_id)) {
|
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",
|
StringFormat(query, "DELETE FROM inventory WHERE charid=%i AND slotid>=%i AND slotid<%i",
|
||||||
char_id, base_slot_id, (base_slot_id+10));
|
char_id, base_slot_id, (base_slot_id+10));
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @merth: need to delete augments here
|
// @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[2],(unsigned long)augslot[3],
|
||||||
(unsigned long)augslot[4]);
|
(unsigned long)augslot[4]);
|
||||||
|
|
||||||
ret = RunQuery(query, errbuf);
|
ret = RunQuery(query, &errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret)
|
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
|
// Save bag contents, if slot supports bag contents
|
||||||
if (inst && inst->IsType(ItemClassContainer) && Inventory::SupportsContainers(slot_id)) {
|
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)
|
int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT sharedplat FROM account WHERE id='%i'", account_id);
|
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)
|
if (mysql_num_rows(result) == 1)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
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)
|
bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i",
|
StringFormat(query,"UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i",
|
||||||
amount_to_add, account_id);
|
amount_to_add, account_id);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
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)
|
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;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -386,7 +386,7 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, Inventory* inv,
|
|||||||
"gm <= %i ORDER BY id",
|
"gm <= %i ORDER BY id",
|
||||||
si_race, si_class, si_deity, si_current_zone, admin_level);
|
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))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int itemid = atoi(row[0]);
|
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
|
// Retrieve shared bank inventory based on either account or character
|
||||||
bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 len_query = 0;
|
uint32 len_query = 0;
|
||||||
MYSQL_RES *result;
|
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))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
int16 slot_id = (int16)atoi(row[0]);
|
int16 slot_id = (int16)atoi(row[0]);
|
||||||
uint32 item_id = (uint32)atoi(row[1]);
|
uint32 item_id = (uint32)atoi(row[1]);
|
||||||
@ -507,7 +507,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
|||||||
// Overloaded: Retrieve character inventory based on character id
|
// Overloaded: Retrieve character inventory based on character id
|
||||||
bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||||
_CP(Database_GetInventory);
|
_CP(Database_GetInventory);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -527,7 +527,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
|||||||
"instnodrop, custom_data FROM inventory WHERE "
|
"instnodrop, custom_data FROM inventory WHERE "
|
||||||
"charid=%i ORDER BY slotid", char_id);
|
"charid=%i ORDER BY slotid", char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
int16 slot_id = atoi(row[0]);
|
int16 slot_id = atoi(row[0]);
|
||||||
@ -617,7 +617,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
|||||||
return GetSharedBank(char_id, inv, true);
|
return GetSharedBank(char_id, inv, true);
|
||||||
}
|
}
|
||||||
else {
|
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");
|
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
|
// Overloaded: Retrieve character inventory based on account_id and character name
|
||||||
bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) {
|
bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv) {
|
||||||
_CP(Database_GetInventory_name);
|
_CP(Database_GetInventory_name);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
MYSQL_ROW row;
|
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",
|
"AND ch.account_id=%i ORDER BY slotid",
|
||||||
name, account_id);
|
name, account_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
int16 slot_id = atoi(row[0]);
|
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);
|
return GetSharedBank(account_id, inv, false);
|
||||||
}
|
}
|
||||||
else {
|
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");
|
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;
|
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) {
|
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
item_count = -1;
|
item_count = -1;
|
||||||
max_id = 0;
|
max_id = 0;
|
||||||
|
|
||||||
std::string query = "SELECT MAX(id), count(*) FROM items";
|
std::string query = "SELECT MAX(id), count(*) FROM items";
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (row != nullptr && row[1] != 0) {
|
if (row != nullptr && row[1] != 0) {
|
||||||
item_count = atoi(row[1]);
|
item_count = atoi(row[1]);
|
||||||
@ -743,7 +743,7 @@ void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
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);
|
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_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -817,7 +817,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
|||||||
"updated"
|
"updated"
|
||||||
" from items order by id";
|
" from items order by id";
|
||||||
Item_Struct item;
|
Item_Struct item;
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
memset(&item, 0, sizeof(Item_Struct));
|
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);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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)
|
std::string SharedDatabase::GetBook(const char *txtfile)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1070,7 +1070,7 @@ std::string SharedDatabase::GetBook(const char *txtfile)
|
|||||||
|
|
||||||
StringFormat(query,"SELECT txtfile FROM books where name='%s'", txtfile2);
|
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;
|
std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl;
|
||||||
txtout.assign(" ",1);
|
txtout.assign(" ",1);
|
||||||
return txtout;
|
return txtout;
|
||||||
@ -1094,20 +1094,20 @@ std::string SharedDatabase::GetBook(const char *txtfile)
|
|||||||
void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
||||||
list_count = 0;
|
list_count = 0;
|
||||||
max_lists = 0;
|
max_lists = 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT COUNT(*), MAX(id) FROM npc_faction";
|
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)) {
|
if(row = mysql_fetch_row(result)) {
|
||||||
list_count = static_cast<uint32>(atoul(row[0]));
|
list_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_lists = static_cast<uint32>(atoul(row[1]));
|
max_lists = static_cast<uint32>(atoul(row[1]));
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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 "
|
"npc_faction.id = npc_faction_entries.npc_faction_id "
|
||||||
"ORDER BY npc_faction.id;";
|
"ORDER BY npc_faction.id;";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
NPCFactionList faction;
|
NPCFactionList faction;
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
uint32 current_id = 0;
|
uint32 current_id = 0;
|
||||||
uint32 current_entry = 0;
|
uint32 current_entry = 0;
|
||||||
while(row = mysql_fetch_row(result)) {
|
while(row = mysql_fetch_row(result)) {
|
||||||
@ -1178,7 +1178,7 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co
|
|||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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.
|
// 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) {
|
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);
|
_CP(Database_GetPlayerProfile);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1231,7 +1231,7 @@ bool SharedDatabase::GetPlayerProfile(uint32 account_id, char* name, PlayerProfi
|
|||||||
"character_ WHERE account_id=%i AND name='%s'",
|
"character_ WHERE account_id=%i AND name='%s'",
|
||||||
account_id, name);
|
account_id, name);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
@ -1268,26 +1268,26 @@ bool SharedDatabase::GetPlayerProfile(uint32 account_id, char* name, PlayerProfi
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
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) {
|
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);
|
_CP(Database_SetPlayerProfile);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
SetPlayerProfile_MQ(query, account_id, charid, pp, inv, ext, current_zone, current_instance, MaxXTargets);
|
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);
|
ret = (affected_rows != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
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;
|
return ret;
|
||||||
@ -1387,7 +1387,7 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -1398,7 +1398,7 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
|||||||
"not timeofdeath=0",
|
"not timeofdeath=0",
|
||||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows))
|
if (!RunQuery(query, &errbuf, 0, &affected_rows))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1409,7 +1409,7 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
|||||||
"UNIX_TIMESTAMP(timeofdeath)) > %d and not timeofdeath=0",
|
"UNIX_TIMESTAMP(timeofdeath)) > %d and not timeofdeath=0",
|
||||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows))
|
if (!RunQuery(query, &errbuf, 0, &affected_rows))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1418,14 +1418,14 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 SharedDatabase::DeleteStalePlayerBackups() {
|
int32 SharedDatabase::DeleteStalePlayerBackups() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
// 1209600 seconds = 2 weeks
|
// 1209600 seconds = 2 weeks
|
||||||
query = "Delete from player_corpses_backup where (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > 1209600";
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1433,7 +1433,7 @@ int32 SharedDatabase::DeleteStalePlayerBackups() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1441,7 +1441,7 @@ bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
|||||||
query = "SELECT command,access from commands";
|
query = "SELECT command,access from commands";
|
||||||
commands.clear();
|
commands.clear();
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
commands[row[0]]=atoi(row[1]);
|
commands[row[0]]=atoi(row[1]);
|
||||||
}
|
}
|
||||||
@ -1487,13 +1487,13 @@ void SharedDatabase::LoadSkillCaps(void *data) {
|
|||||||
uint32 level_count = HARD_LEVEL_CAP + 1;
|
uint32 level_count = HARD_LEVEL_CAP + 1;
|
||||||
uint16 *skill_caps_table = reinterpret_cast<uint16*>(data);
|
uint16 *skill_caps_table = reinterpret_cast<uint16*>(data);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
query = "SELECT skillID, class, level, cap FROM skill_caps ORDER BY skillID, class, level";
|
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))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
uint8 skillID = atoi(row[0]);
|
uint8 skillID = atoi(row[0]);
|
||||||
@ -1508,7 +1508,7 @@ void SharedDatabase::LoadSkillCaps(void *data) {
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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) {
|
void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1601,7 +1601,7 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
|
|||||||
"WHERE `spellid` > 0 AND `spellid` <= %i", iMaxSpellID);
|
"WHERE `spellid` > 0 AND `spellid` <= %i", iMaxSpellID);
|
||||||
|
|
||||||
|
|
||||||
if(RunQuery(query,errbuf,&result)) {
|
if(RunQuery(query,&errbuf,&result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
|
||||||
@ -1613,7 +1613,7 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
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() {
|
int SharedDatabase::GetMaxSpellID() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1630,12 +1630,12 @@ int SharedDatabase::GetMaxSpellID() {
|
|||||||
|
|
||||||
query = "SELECT MAX(id) FROM spells_new";
|
query = "SELECT MAX(id) FROM spells_new";
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
ret = atoi(row[0]);
|
ret = atoi(row[0]);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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;
|
ret = -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -1643,14 +1643,14 @@ int SharedDatabase::GetMaxSpellID() {
|
|||||||
|
|
||||||
void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
||||||
SPDat_Spell_Struct *sp = reinterpret_cast<SPDat_Spell_Struct*>(data);
|
SPDat_Spell_Struct *sp = reinterpret_cast<SPDat_Spell_Struct*>(data);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
query = "SELECT * FROM spells_new ORDER BY id ASC";
|
query = "SELECT * FROM spells_new ORDER BY id ASC";
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
int tempid = 0;
|
int tempid = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -1769,7 +1769,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
|||||||
|
|
||||||
LoadDamageShieldTypes(sp, max_spells);
|
LoadDamageShieldTypes(sp, max_spells);
|
||||||
} else {
|
} 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;
|
max_loot_table = 0;
|
||||||
loot_table_entries = 0;
|
loot_table_entries = 0;
|
||||||
std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable";
|
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_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
if(row = mysql_fetch_row(result)) {
|
if(row = mysql_fetch_row(result)) {
|
||||||
loot_table_count = static_cast<uint32>(atoul(row[0]));
|
loot_table_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_loot_table = static_cast<uint32>(atoul(row[1]));
|
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);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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;
|
loot_drop_count = 0;
|
||||||
max_loot_drop = 0;
|
max_loot_drop = 0;
|
||||||
loot_drop_entries = 0;
|
loot_drop_entries = 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
|
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)) {
|
if(row = mysql_fetch_row(result)) {
|
||||||
loot_drop_count = static_cast<uint32>(atoul(row[0]));
|
loot_drop_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_loot_drop = static_cast<uint32>(atoul(row[1]));
|
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);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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) {
|
void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
||||||
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
uint8 loot_table[sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128)];
|
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"
|
"loottable_entries.probability FROM loottable LEFT JOIN loottable_entries"
|
||||||
" ON loottable.id = loottable_entries.loottable_id ORDER BY id";
|
" 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_id = 0;
|
||||||
uint32 current_entry = 0;
|
uint32 current_entry = 0;
|
||||||
while(row = mysql_fetch_row(result)) {
|
while(row = mysql_fetch_row(result)) {
|
||||||
@ -1873,13 +1873,13 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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) {
|
void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||||
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
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 "
|
"lootdrop JOIN lootdrop_entries "
|
||||||
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
"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_id = 0;
|
||||||
uint32 current_entry = 0;
|
uint32 current_entry = 0;
|
||||||
while(row = mysql_fetch_row(result)) {
|
while(row = mysql_fetch_row(result)) {
|
||||||
@ -1930,7 +1930,7 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
|||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} 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) {
|
void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"SELECT inspectmessage FROM character_ WHERE name='%s'", playername);
|
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) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
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) {
|
void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'",
|
StringFormat(query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'",
|
||||||
message->text, playername);
|
message->text, playername);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {
|
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT BotInspectMessage FROM bots WHERE BotID=%i", botid);
|
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) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
memcpy(message, row[0], sizeof(InspectMessage_Struct));
|
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) {
|
void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i",
|
StringFormat(query, "UPDATE bots SET BotInspectMessage='%s' WHERE BotID=%i",
|
||||||
message->text, botid);
|
message->text, botid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,10 +64,10 @@ Database::Database(const char* host, const char* user, const char* passwd, const
|
|||||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||||
{
|
{
|
||||||
uint32 errnum= 0;
|
uint32 errnum= 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf))
|
if (!Open(host, user, passwd, database, port, &errnum, &errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Failed to connect to database: Error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Failed to connect to database: Error: %s", errbuf.c_str());
|
||||||
HandleMysqlError(errnum);
|
HandleMysqlError(errnum);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -98,16 +98,16 @@ Database::~Database()
|
|||||||
|
|
||||||
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"select `value` from `variables` where `varname`='%s'", varname);
|
StringFormat(query,"select `value` from `variables` where `varname`='%s'", varname);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
|
|||||||
|
|
||||||
|
|
||||||
void Database::AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type) {
|
void Database::AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query, speechFrom, speechTo, speechMeesage;
|
std::string query, speechFrom, speechTo, speechMeesage;
|
||||||
|
|
||||||
DoEscapeString(speechFrom, from, strlen(from));
|
DoEscapeString(speechFrom, from, strlen(from));
|
||||||
@ -142,15 +142,15 @@ void Database::AddSpeech(const char* from, const char* to, const char* message,
|
|||||||
"`minstatus`='%i', `guilddbid`='%i', `type`='%i'",
|
"`minstatus`='%i', `guilddbid`='%i', `type`='%i'",
|
||||||
speechFrom.c_str(), speechTo.c_str(), speechMeesage.c_str(), minstatus, guilddbid, type);
|
speechFrom.c_str(), speechTo.c_str(), speechMeesage.c_str(), minstatus, guilddbid, type);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0)) {
|
if(!RunQuery(query, &errbuf, 0, 0)) {
|
||||||
_log(NET__WORLD, "Failed Speech Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Speech Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
|||||||
QS->char2_money.silver, QS->char2_money.copper, QS->char2_count);
|
QS->char2_money.silver, QS->char2_money.copper, QS->char2_count);
|
||||||
|
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed Trade Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Trade Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +181,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
|||||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3,
|
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);
|
QS->items[i].aug_4, QS->items[i].aug_5);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
_log(NET__WORLD, "Failed Trade Log Record Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Trade Log Record Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 Items) {
|
|||||||
|
|
||||||
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -204,8 +204,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
|||||||
QS->npc_id, QS->npc_money.platinum, QS->npc_money.gold, QS->npc_money.silver,
|
QS->npc_id, QS->npc_money.platinum, QS->npc_money.gold, QS->npc_money.silver,
|
||||||
QS->npc_money.copper, QS->npc_count);
|
QS->npc_money.copper, QS->npc_count);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed Handin Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Handin Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
|||||||
QS->items[i].item_id, QS->items[i].charges, QS->items[i].aug_1,
|
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);
|
QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0)) {
|
if(!RunQuery(query, &errbuf, 0, 0)) {
|
||||||
_log(NET__WORLD, "Failed Handin Log Record Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Handin Log Record Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 Items) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -236,8 +236,8 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
|||||||
"`type`='%i', `zone_id`='%i', `time`=NOW()",
|
"`type`='%i', `zone_id`='%i', `time`=NOW()",
|
||||||
QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID);
|
QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed NPC Kill Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed NPC Kill Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
|||||||
"`event_id`='%i', `char_id`='%i'",
|
"`event_id`='%i', `char_id`='%i'",
|
||||||
lastid, QS->Chars[i].char_id);
|
lastid, QS->Chars[i].char_id);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr)) {
|
||||||
_log(NET__WORLD, "Failed NPC Kill Log Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed NPC Kill Log Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 Members){
|
|||||||
|
|
||||||
void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -266,8 +266,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
|||||||
"`char_id`='%i', `stack_size`='%i', `char_items`='%i'",
|
"`char_id`='%i', `stack_size`='%i', `char_items`='%i'",
|
||||||
QS->char_id, QS->stack_size, QS->char_count, QS->char_count);
|
QS->char_id, QS->stack_size, QS->char_count, QS->char_count);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed Delete Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Delete Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,8 +281,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
|||||||
QS->items[i].charges, QS->items[i].aug_1,QS->items[i].aug_2,
|
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);
|
QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr)) {
|
||||||
_log(NET__WORLD, "Failed Delete Log Record Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Delete Log Record Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 Items) {
|
|||||||
|
|
||||||
void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -301,8 +301,8 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
|||||||
QS->char_id, QS->from_slot, QS->to_slot, QS->stack_size,
|
QS->char_id, QS->from_slot, QS->to_slot, QS->stack_size,
|
||||||
QS->char_count, QS->postaction);
|
QS->char_count, QS->postaction);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed Move Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Move Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +316,8 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
|||||||
QS->items[i].charges, QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3,
|
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);
|
QS->items[i].aug_4, QS->items[i].aug_5);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr)) {
|
||||||
_log(NET__WORLD, "Failed Move Log Record Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Move Log Record Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 Items) {
|
|||||||
void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint32 Items) {
|
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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 lastid = 0;
|
uint32 lastid = 0;
|
||||||
|
|
||||||
@ -342,8 +342,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3
|
|||||||
QS->char_id, QS->char_money.platinum, QS->char_money.gold,
|
QS->char_id, QS->char_money.platinum, QS->char_money.gold,
|
||||||
QS->char_money.silver, QS->char_money.copper, QS->char_count);
|
QS->char_money.silver, QS->char_money.copper, QS->char_count);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0, &lastid)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &lastid)) {
|
||||||
_log(NET__WORLD, "Failed Transaction Log Record Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Transaction Log Record Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,8 +357,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3
|
|||||||
QS->items[i].aug_1, QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4,
|
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);
|
QS->items[i].aug_5);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
_log(NET__WORLD, "Failed Transaction Log Record Entry Insert: %s", errbuf);
|
_log(NET__WORLD, "Failed Transaction Log Record Entry Insert: %s", errbuf.c_str());
|
||||||
_log(NET__WORLD, "%s", query.c_str());
|
_log(NET__WORLD, "%s", query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ GuildLookingForPlayers::GuildLookingForPlayers(char *Name, char *Comments, uint3
|
|||||||
|
|
||||||
bool LFGuildManager::LoadDatabase()
|
bool LFGuildManager::LoadDatabase()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -42,9 +42,9 @@ bool LFGuildManager::LoadDatabase()
|
|||||||
"`tolevel`, `classes`, `aacount`, `timezone`, "
|
"`tolevel`, `classes`, `aacount`, `timezone`, "
|
||||||
"`timeposted` FROM `lfguild`";
|
"`timeposted` FROM `lfguild`";
|
||||||
|
|
||||||
if (!database.RunQuery(query,errbuf,&result)){
|
if (!database.RunQuery(query, &errbuf, &result)){
|
||||||
|
|
||||||
_log(QUERYSERV__ERROR, "Failed to load LFGuild info from database. %s %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Failed to load LFGuild info from database. %s %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ 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)
|
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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::list<PlayerLookingForGuild>::iterator it;
|
std::list<PlayerLookingForGuild>::iterator it;
|
||||||
@ -260,8 +260,8 @@ void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM `lfguild` WHERE `type` = 0 AND `name` = '%s'", From);
|
StringFormat(query,"DELETE FROM `lfguild` WHERE `type` = 0 AND `name` = '%s'", From);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0))
|
if(!database.RunQuery(query, &errbuf, 0, 0))
|
||||||
_log(QUERYSERV__ERROR, "Error removing player from LFGuild table, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error removing player from LFGuild table, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
uint32 Now = time(nullptr);
|
uint32 Now = time(nullptr);
|
||||||
@ -276,8 +276,8 @@ void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char
|
|||||||
"VALUES(0, '%s', '%s', %u, 0, %u, %u, %u, %u)",
|
"VALUES(0, '%s', '%s', %u, 0, %u, %u, %u, %u)",
|
||||||
From, Comments, Level, Class, AAPoints, TimeZone, Now);
|
From, Comments, Level, Class, AAPoints, TimeZone, Now);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, nullptr, nullptr))
|
if(!database.RunQuery(query, &errbuf, nullptr, nullptr))
|
||||||
_log(QUERYSERV__ERROR, "Error inserting player into LFGuild table, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error inserting player into LFGuild table, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ 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)
|
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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::list<GuildLookingForPlayers>::iterator it;
|
std::list<GuildLookingForPlayers>::iterator it;
|
||||||
@ -316,8 +316,8 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM `lfguild` WHERE `type` = 1 AND `name` = '%s'", GuildName);
|
StringFormat(query,"DELETE FROM `lfguild` WHERE `type` = 1 AND `name` = '%s'", GuildName);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
_log(QUERYSERV__ERROR, "Error removing guild from LFGuild table, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error removing guild from LFGuild table, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
uint32 Now = time(nullptr);
|
uint32 Now = time(nullptr);
|
||||||
@ -333,8 +333,8 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char
|
|||||||
GuildName, Comments, FromLevel, ToLevel, Classes,
|
GuildName, Comments, FromLevel, ToLevel, Classes,
|
||||||
AACount, TimeZone, Now);
|
AACount, TimeZone, Now);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
_log(QUERYSERV__ERROR, "Error inserting guild into LFGuild table, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error inserting guild into LFGuild table, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -356,7 +356,7 @@ void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char
|
|||||||
|
|
||||||
void LFGuildManager::ExpireEntries()
|
void LFGuildManager::ExpireEntries()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::list<PlayerLookingForGuild>::iterator it;
|
std::list<PlayerLookingForGuild>::iterator it;
|
||||||
@ -369,8 +369,8 @@ void LFGuildManager::ExpireEntries()
|
|||||||
|
|
||||||
StringFormat(query, "DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str());
|
StringFormat(query, "DELETE from `lfguild` WHERE `type` = 0 AND `name` = '%s'", (*it).Name.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
_log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error expiring player LFGuild entry, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
it = Players.erase(it);
|
it = Players.erase(it);
|
||||||
@ -383,8 +383,8 @@ void LFGuildManager::ExpireEntries()
|
|||||||
{
|
{
|
||||||
StringFormat(query, "DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str());
|
StringFormat(query, "DELETE from `lfguild` WHERE `type` = 1 AND `name` = '%s'", (*it2).Name.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
_log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query.c_str(), errbuf);
|
_log(QUERYSERV__ERROR, "Error removing guild LFGuild entry, query was %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
it2 = Guilds.erase(it2);
|
it2 = Guilds.erase(it2);
|
||||||
|
|||||||
110
ucs/database.cpp
110
ucs/database.cpp
@ -70,10 +70,10 @@ Database::Database(const char* host, const char* user, const char* passwd, const
|
|||||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||||
{
|
{
|
||||||
uint32 errnum= 0;
|
uint32 errnum= 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf))
|
if (!Open(host, user, passwd, database, port, &errnum, &errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Failed to connect to database: Error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Failed to connect to database: Error: %s", errbuf.c_str());
|
||||||
HandleMysqlError(errnum);
|
HandleMysqlError(errnum);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -104,7 +104,7 @@ Database::~Database()
|
|||||||
|
|
||||||
void Database::GetAccountStatus(Client *c) {
|
void Database::GetAccountStatus(Client *c) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -113,9 +113,9 @@ void Database::GetAccountStatus(Client *c) {
|
|||||||
"where `id`='%i' limit 1",
|
"where `id`='%i' limit 1",
|
||||||
c->GetAccountID());
|
c->GetAccountID());
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query,&errbuf,&result)){
|
||||||
|
|
||||||
_log(UCS__ERROR, "Unable to get account status for character %s, error %s", c->GetName().c_str(), errbuf);
|
_log(UCS__ERROR, "Unable to get account status for character %s, error %s", c->GetName().c_str(), errbuf.c_str());
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -144,7 +144,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
|
|||||||
|
|
||||||
_log(UCS__TRACE, "FindAccount for character %s", CharacterName);
|
_log(UCS__TRACE, "FindAccount for character %s", CharacterName);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -155,7 +155,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
|
|||||||
"`character_` where `name`='%s' limit 1",
|
"`character_` where `name`='%s' limit 1",
|
||||||
CharacterName);
|
CharacterName);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result))
|
if (!RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
_log(UCS__ERROR, "FindAccount query failed: %s", query.c_str());
|
_log(UCS__ERROR, "FindAccount query failed: %s", query.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
@ -180,7 +180,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
|
|||||||
"and `name` !='%s'",
|
"and `name` !='%s'",
|
||||||
AccountID, CharacterName);
|
AccountID, CharacterName);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result))
|
if (!RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
return AccountID;
|
return AccountID;
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ int Database::FindAccount(const char *CharacterName, Client *c) {
|
|||||||
|
|
||||||
bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) {
|
bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::string MailKey) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -204,9 +204,9 @@ bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::stri
|
|||||||
StringFormat(query,"select `mailkey` from `character_` where `name`='%s' limit 1",
|
StringFormat(query,"select `mailkey` from `character_` where `name`='%s' limit 1",
|
||||||
CharacterName.c_str());
|
CharacterName.c_str());
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf,&result)){
|
||||||
|
|
||||||
_log(UCS__ERROR, "Error retrieving mailkey from database: %s", errbuf);
|
_log(UCS__ERROR, "Error retrieving mailkey from database: %s", errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ bool Database::VerifyMailKey(std::string CharacterName, int IPAddress, std::stri
|
|||||||
|
|
||||||
int Database::FindCharacter(const char *CharacterName) {
|
int Database::FindCharacter(const char *CharacterName) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -246,9 +246,9 @@ int Database::FindCharacter(const char *CharacterName) {
|
|||||||
StringFormat(query,"select `id` from `character_` where `name`='%s' limit 1",
|
StringFormat(query,"select `id` from `character_` where `name`='%s' limit 1",
|
||||||
SafeCharName);
|
SafeCharName);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf,&result)){
|
||||||
|
|
||||||
_log(UCS__ERROR, "FindCharacter failed. %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "FindCharacter failed. %s %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
safe_delete_array(SafeCharName);
|
safe_delete_array(SafeCharName);
|
||||||
|
|
||||||
@ -278,16 +278,16 @@ int Database::FindCharacter(const char *CharacterName) {
|
|||||||
|
|
||||||
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"select `value` from `variables` where `varname`='%s'", varname);
|
StringFormat(query,"select `value` from `variables` where `varname`='%s'", varname);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -312,15 +312,15 @@ bool Database::LoadChatChannels() {
|
|||||||
|
|
||||||
_log(UCS__INIT, "Loading chat channels from the database.");
|
_log(UCS__INIT, "Loading chat channels from the database.");
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "select `name`,`owner`,`password`, `minstatus` from `chatchannels`";
|
std::string query = "select `name`,`owner`,`password`, `minstatus` from `chatchannels`";
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf, &result)){
|
||||||
|
|
||||||
_log(UCS__ERROR, "Failed to load channels. %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Failed to load channels. %s %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -344,15 +344,15 @@ 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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE `chatchannels` set `password`='%s' where `name`='%s'",
|
StringFormat(query,"UPDATE `chatchannels` set `password`='%s' where `name`='%s'",
|
||||||
Password.c_str(), ChannelName.c_str());
|
Password.c_str(), ChannelName.c_str());
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
_log(UCS__ERROR, "Error updating password in database: %s, %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error updating password in database: %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,15 +361,15 @@ 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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE `chatchannels` set `owner`='%s' where `name`='%s'",
|
StringFormat(query, "UPDATE `chatchannels` set `owner`='%s' where `name`='%s'",
|
||||||
Owner.c_str(), ChannelName.c_str());
|
Owner.c_str(), ChannelName.c_str());
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
_log(UCS__ERROR, "Error updating Owner in database: %s, %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error updating Owner in database: %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ void Database::SendHeaders(Client *c) {
|
|||||||
if(CharacterID <= 0)
|
if(CharacterID <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -393,7 +393,7 @@ void Database::SendHeaders(Client *c) {
|
|||||||
"from `mail` where `charid`=%i",
|
"from `mail` where `charid`=%i",
|
||||||
CharacterID);
|
CharacterID);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf, &result)){
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ void Database::SendBody(Client *c, int MessageNumber) {
|
|||||||
if(CharacterID <= 0)
|
if(CharacterID <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -496,7 +496,7 @@ void Database::SendBody(Client *c, int MessageNumber) {
|
|||||||
"where `charid`=%i and `msgid`=%i",
|
"where `charid`=%i and `msgid`=%i",
|
||||||
CharacterID, MessageNumber);
|
CharacterID, MessageNumber);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ bool Database::SendMail(std::string Recipient, std::string From, std::string Sub
|
|||||||
|
|
||||||
if(CharacterID <= 0) return false;
|
if(CharacterID <= 0) return false;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query,escSubject,escBody;
|
std::string query,escSubject,escBody;
|
||||||
|
|
||||||
DoEscapeString(escSubject, Subject.c_str(), Subject.length());
|
DoEscapeString(escSubject, Subject.c_str(), Subject.length());
|
||||||
@ -582,9 +582,9 @@ bool Database::SendMail(std::string Recipient, std::string From, std::string Sub
|
|||||||
RecipientsString.c_str(), 1);
|
RecipientsString.c_str(), 1);
|
||||||
|
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, nullptr, nullptr, &LastMsgID)) {
|
if(!RunQuery(query, &errbuf, nullptr, nullptr, &LastMsgID)) {
|
||||||
|
|
||||||
_log(UCS__ERROR, "SendMail: Query %s failed with error %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "SendMail: Query %s failed with error %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -609,22 +609,22 @@ 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];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(Status == 0)
|
if(Status == 0)
|
||||||
{
|
{
|
||||||
StringFormat(query, "delete from `mail` where `msgid`=%i", MessageNumber);
|
StringFormat(query, "delete from `mail` where `msgid`=%i", MessageNumber);
|
||||||
|
|
||||||
RunQuery(query, errbuf);
|
RunQuery(query, &errbuf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringFormat(query, "update `mail` set `status`=%i where `msgid`=%i",
|
StringFormat(query, "update `mail` set `status`=%i where `msgid`=%i",
|
||||||
Status, MessageNumber);
|
Status, MessageNumber);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
_log(UCS__ERROR, "Error updating status %s, %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error updating status %s, %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,15 +634,15 @@ void Database::ExpireMail() {
|
|||||||
|
|
||||||
_log(UCS__INIT, "Expiring mail...");
|
_log(UCS__INIT, "Expiring mail...");
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
uint32 AffectedRows;
|
uint32 AffectedRows;
|
||||||
std::string query ="select COUNT(*) from `mail` ";
|
std::string query ="select COUNT(*) from `mail` ";
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf,&result)){
|
||||||
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Unable to get message count from database. %s %s", query.c_str(), errbuf.c_str());
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,11 +658,11 @@ void Database::ExpireMail() {
|
|||||||
StringFormat(query,"delete from `mail` where `status`=4 and `timestamp` < %i",
|
StringFormat(query,"delete from `mail` where `status`=4 and `timestamp` < %i",
|
||||||
time(nullptr) - RuleI(Mail, ExpireTrash));
|
time(nullptr) - RuleI(Mail, ExpireTrash));
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, 0, &AffectedRows)) {
|
if(RunQuery(query, &errbuf, nullptr, &AffectedRows)) {
|
||||||
_log(UCS__INIT, "Expired %i trash messages.", AffectedRows);
|
_log(UCS__INIT, "Expired %i trash messages.", AffectedRows);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_log(UCS__ERROR, "Error expiring trash messages, %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error expiring trash messages, %s %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Expire Read
|
// Expire Read
|
||||||
@ -671,11 +671,11 @@ void Database::ExpireMail() {
|
|||||||
StringFormat(query,"delete from `mail` where `status`=3 and `timestamp` < %i",
|
StringFormat(query,"delete from `mail` where `status`=3 and `timestamp` < %i",
|
||||||
time(nullptr) - RuleI(Mail, ExpireRead));
|
time(nullptr) - RuleI(Mail, ExpireRead));
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, 0, &AffectedRows)) {
|
if(RunQuery(query, &errbuf, nullptr, &AffectedRows)) {
|
||||||
_log(UCS__INIT, "Expired %i read messages.", AffectedRows);
|
_log(UCS__INIT, "Expired %i read messages.", AffectedRows);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_log(UCS__ERROR, "Error expiring read messages, %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error expiring read messages, %s %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Expire Unread
|
// Expire Unread
|
||||||
@ -684,25 +684,25 @@ void Database::ExpireMail() {
|
|||||||
StringFormat(query, "delete from `mail` where `status`=1 and `timestamp` < %i",
|
StringFormat(query, "delete from `mail` where `status`=1 and `timestamp` < %i",
|
||||||
time(nullptr) - RuleI(Mail, ExpireUnread));
|
time(nullptr) - RuleI(Mail, ExpireUnread));
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, 0, &AffectedRows)) {
|
if(RunQuery(query, &errbuf, nullptr, &AffectedRows)) {
|
||||||
_log(UCS__INIT, "Expired %i unread messages.", AffectedRows);
|
_log(UCS__INIT, "Expired %i unread messages.", AffectedRows);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_log(UCS__ERROR, "Error expiring unread messages, %s %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error expiring unread messages, %s %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::AddFriendOrIgnore(int CharID, int Type, std::string Name) {
|
void Database::AddFriendOrIgnore(int CharID, int Type, std::string Name) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')",
|
StringFormat(query, "INSERT INTO `friends` (`charid`, `type`, `name`) VALUES ('%i', %i, '%s')",
|
||||||
CharID, Type, CapitaliseName(Name).c_str());
|
CharID, Type, CapitaliseName(Name).c_str());
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0))
|
if(!RunQuery(query, &errbuf))
|
||||||
_log(UCS__ERROR, "Error adding friend/ignore, query was %s : %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "Error adding friend/ignore, query was %s : %s", query.c_str(), errbuf.c_str());
|
||||||
else
|
else
|
||||||
_log(UCS__TRACE, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.",
|
_log(UCS__TRACE, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.",
|
||||||
CharID, Type, Name.c_str());
|
CharID, Type, Name.c_str());
|
||||||
@ -711,13 +711,13 @@ 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) {
|
||||||
|
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'",
|
StringFormat(query,"DELETE FROM `friends` WHERE `charid`=%i AND `type`=%i and `name`='%s'",
|
||||||
CharID, Type, CapitaliseName(Name).c_str());
|
CharID, Type, CapitaliseName(Name).c_str());
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, 0, 0))
|
if(!RunQuery(query, &errbuf))
|
||||||
_log(UCS__ERROR, "Error removing friend/ignore, query was %s", query.c_str());
|
_log(UCS__ERROR, "Error removing friend/ignore, query was %s", query.c_str());
|
||||||
else
|
else
|
||||||
_log(UCS__TRACE, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.",
|
_log(UCS__TRACE, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.",
|
||||||
@ -727,16 +727,16 @@ void Database::RemoveFriendOrIgnore(int CharID, int Type, std::string Name) {
|
|||||||
|
|
||||||
void Database::GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees) {
|
void Database::GetFriendsAndIgnore(int CharID, std::vector<std::string> &Friends, std::vector<std::string> &Ignorees) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"select `type`, `name` from `friends` WHERE `charid`=%i", CharID);
|
StringFormat(query,"select `type`, `name` from `friends` WHERE `charid`=%i", CharID);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,&result)){
|
if (!RunQuery(query, &errbuf, &result)){
|
||||||
|
|
||||||
_log(UCS__ERROR, "GetFriendsAndIgnore query error %s, %s", query.c_str(), errbuf);
|
_log(UCS__ERROR, "GetFriendsAndIgnore query error %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -374,14 +374,14 @@ void Adventure::MoveCorpsesToGraveyard()
|
|||||||
|
|
||||||
std::list<uint32> dbid_list;
|
std::list<uint32> dbid_list;
|
||||||
std::list<uint32> charid_list;
|
std::list<uint32> charid_list;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID());
|
StringFormat(query,"SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -392,7 +392,7 @@ void Adventure::MoveCorpsesToGraveyard()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<uint32>::iterator iter = dbid_list.begin();
|
std::list<uint32>::iterator iter = dbid_list.begin();
|
||||||
@ -405,9 +405,9 @@ void Adventure::MoveCorpsesToGraveyard()
|
|||||||
StringFormat(query,"UPDATE player_corpses SET zoneid=%d, instanceid=0, x=%f, y=%f, z=%f WHERE instanceid=%d",
|
StringFormat(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());
|
GetTemplate()->graveyard_zone_id, x, y, z, GetInstanceID());
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf))
|
if(!database.RunQuery(query,&errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -635,7 +635,7 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int id)
|
|||||||
|
|
||||||
bool AdventureManager::LoadAdventureTemplates()
|
bool AdventureManager::LoadAdventureTemplates()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -646,7 +646,7 @@ bool AdventureManager::LoadAdventureTemplates()
|
|||||||
" dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, "
|
" dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, "
|
||||||
"graveyard_radius FROM adventure_template";
|
"graveyard_radius FROM adventure_template";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -691,7 +691,7 @@ bool AdventureManager::LoadAdventureTemplates()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -699,13 +699,13 @@ bool AdventureManager::LoadAdventureTemplates()
|
|||||||
|
|
||||||
bool AdventureManager::LoadAdventureEntries()
|
bool AdventureManager::LoadAdventureEntries()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query= "SELECT id, template_id FROM adventure_template_entry";
|
std::string query= "SELECT id, template_id FROM adventure_template_entry";
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -742,7 +742,7 @@ bool AdventureManager::LoadAdventureEntries()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1090,7 +1090,7 @@ void AdventureManager::LoadLeaderboardInfo()
|
|||||||
leaderboard_info_percentage_ruj.clear();
|
leaderboard_info_percentage_ruj.clear();
|
||||||
leaderboard_info_wins_tak.clear();
|
leaderboard_info_wins_tak.clear();
|
||||||
leaderboard_info_percentage_tak.clear();
|
leaderboard_info_percentage_tak.clear();
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -1098,7 +1098,7 @@ void AdventureManager::LoadLeaderboardInfo()
|
|||||||
"AS adv_stats ""left join character_ AS ch on "
|
"AS adv_stats ""left join character_ AS ch on "
|
||||||
"adv_stats.player_id = ch.id;";
|
"adv_stats.player_id = ch.id;";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -1159,7 +1159,7 @@ void AdventureManager::LoadLeaderboardInfo()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ EQLConfig::EQLConfig(const char *launcher_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EQLConfig::LoadSettings() {
|
void EQLConfig::LoadSettings() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -45,19 +45,19 @@ void EQLConfig::LoadSettings() {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT dynamics FROM launcher WHERE name='%s'",namebuf.c_str());
|
StringFormat(query,"SELECT dynamics FROM launcher WHERE name='%s'",namebuf.c_str());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
m_dynamics = atoi(row[0]);
|
m_dynamics = atoi(row[0]);
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringFormat(query, "SELECT zone,port FROM launcher_zones WHERE launcher='%s'", namebuf.c_str());
|
StringFormat(query, "SELECT zone,port FROM launcher_zones WHERE launcher='%s'", namebuf.c_str());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
LauncherZone zs;
|
LauncherZone zs;
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
@ -67,12 +67,12 @@ void EQLConfig::LoadSettings() {
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
|
EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -82,8 +82,8 @@ EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
|
|||||||
StringFormat(query, "INSERT INTO launcher (name,dynamics) VALUES('%s', %d)",
|
StringFormat(query, "INSERT INTO launcher (name,dynamics) VALUES('%s', %d)",
|
||||||
namebuf.c_str(), dynamic_count);
|
namebuf.c_str(), dynamic_count);
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", errbuf.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void EQLConfig::DeleteLauncher() {
|
|||||||
|
|
||||||
launcher_list.Remove(m_name.c_str());
|
launcher_list.Remove(m_name.c_str());
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -130,16 +130,16 @@ void EQLConfig::DeleteLauncher() {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM launcher WHERE name='%s'",namebuf.c_str());
|
StringFormat(query, "DELETE FROM launcher WHERE name='%s'",namebuf.c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s'",
|
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s'",
|
||||||
namebuf.c_str());
|
namebuf.c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
//database update
|
//database update
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -190,8 +190,8 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
StringFormat(query, "INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)",
|
StringFormat(query, "INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)",
|
||||||
namebuf.c_str(), zonebuf.c_str(), port);
|
namebuf.c_str(), zonebuf.c_str(), port);
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
|
|
||||||
|
|
||||||
//database update
|
//database update
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -240,8 +240,8 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
StringFormat(query, "UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
|
StringFormat(query, "UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
|
||||||
port, namebuf.c_str(), zonebuf.c_str());
|
port, namebuf.c_str(), zonebuf.c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//database update
|
//database update
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -282,8 +282,8 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
|||||||
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'",
|
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'",
|
||||||
namebuf.c_str(), zonebuf.c_str());
|
namebuf.c_str(), zonebuf.c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EQLConfig::SetDynamicCount(int count) {
|
bool EQLConfig::SetDynamicCount(int count) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
std::string namebuf;
|
std::string namebuf;
|
||||||
@ -310,8 +310,8 @@ bool EQLConfig::SetDynamicCount(int count) {
|
|||||||
StringFormat(query, "UPDATE launcher SET dynamics=%d WHERE name='%s'",
|
StringFormat(query, "UPDATE launcher SET dynamics=%d WHERE name='%s'",
|
||||||
count, namebuf.c_str());
|
count, namebuf.c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -384,13 +384,13 @@ bool EQW::SetPublicNote(uint32 charid, const char *note) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int EQW::CountBugs() {
|
int EQW::CountBugs() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT count(*) FROM bugs where status = 0";
|
std::string query = "SELECT count(*) FROM bugs where status = 0";
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
if((row = mysql_fetch_row(result))) {
|
if((row = mysql_fetch_row(result))) {
|
||||||
int count = atoi(row[0]);
|
int count = atoi(row[0]);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@ -403,14 +403,14 @@ int EQW::CountBugs() {
|
|||||||
|
|
||||||
std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset);
|
StringFormat(query,"SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
res.push_back(row[0]);
|
res.push_back(row[0]);
|
||||||
}
|
}
|
||||||
@ -421,14 +421,14 @@ std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
|||||||
|
|
||||||
std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
|
std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
|
||||||
std::map<std::string,std::string> res;
|
std::map<std::string,std::string> res;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"select name, zone, x, y, z, target, bug from bugs where id = %s", id);
|
StringFormat(query,"select name, zone, x, y, z, target, bug from bugs where id = %s", id);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
res["name"] = row[0];
|
res["name"] = row[0];
|
||||||
res["zone"] = row[1];
|
res["zone"] = row[1];
|
||||||
@ -446,12 +446,12 @@ std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
|
|||||||
|
|
||||||
void EQW::ResolveBug(const char *id) {
|
void EQW::ResolveBug(const char *id) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE bugs SET status=1 WHERE id=%s", id);
|
StringFormat(query,"UPDATE bugs SET status=1 WHERE id=%s", id);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
// TODO: log failed statement.
|
// TODO: log failed statement.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ extern std::vector<RaceClassCombos> character_create_race_class_combos;
|
|||||||
|
|
||||||
// solar: the current stuff is at the bottom of this function
|
// solar: the current stuff is at the bottom of this function
|
||||||
void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* cs) {
|
void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* cs) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -58,7 +58,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
|||||||
"order by name limit 10",
|
"order by name limit 10",
|
||||||
account_id);
|
account_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
////////////
|
////////////
|
||||||
@ -128,7 +128,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
|||||||
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
||||||
pp->class_, pp->deity, pp->race);
|
pp->class_, pp->deity, pp->race);
|
||||||
|
|
||||||
RunQuery(query,errbuf,&result2);
|
RunQuery(query,&errbuf,&result2);
|
||||||
|
|
||||||
// if there is only one possible start city, set it
|
// if there is only one possible start city, set it
|
||||||
if(mysql_num_rows(result2) == 1) {
|
if(mysql_num_rows(result2) == 1) {
|
||||||
@ -161,7 +161,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
|||||||
|
|
||||||
StringFormat(query,"SELECT extprofile FROM character_ WHERE id=%i",char_id);
|
StringFormat(query,"SELECT extprofile FROM character_ WHERE id=%i",char_id);
|
||||||
|
|
||||||
RunQuery(query,errbuf, &result2);
|
RunQuery(query, &errbuf, &result2);
|
||||||
if(result2) {
|
if(result2) {
|
||||||
row2 = mysql_fetch_row(result2);
|
row2 = mysql_fetch_row(result2);
|
||||||
ExtendedProfile_Struct* ext = (ExtendedProfile_Struct*)row2[0];
|
ExtendedProfile_Struct* ext = (ExtendedProfile_Struct*)row2[0];
|
||||||
@ -240,7 +240,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
|||||||
if (bindnum > 4)
|
if (bindnum > 4)
|
||||||
bindnum = 0;
|
bindnum = 0;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -251,7 +251,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
|||||||
|
|
||||||
StringFormat(query, "SELECT profile from character_ where id='%i'", CharID);
|
StringFormat(query, "SELECT profile from character_ where id='%i'", CharID);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
unsigned long* lengths = mysql_fetch_lengths(result);
|
unsigned long* lengths = mysql_fetch_lengths(result);
|
||||||
if (lengths[0] == sizeof(PlayerProfile_Struct)) {
|
if (lengths[0] == sizeof(PlayerProfile_Struct)) {
|
||||||
@ -271,7 +271,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
|||||||
BindZoneName, pp.binds[bindnum].zoneId, pp.binds[bindnum].x, pp.binds[bindnum].y, pp.binds[bindnum].z,
|
BindZoneName, pp.binds[bindnum].zoneId, pp.binds[bindnum].x, pp.binds[bindnum].y, pp.binds[bindnum].z,
|
||||||
CharID);
|
CharID);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, nullptr,&affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr,&affected_rows)) {
|
||||||
|
|
||||||
return pp.zone_id;
|
return pp.zone_id;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
|||||||
|
|
||||||
bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row = 0;
|
MYSQL_ROW row = 0;
|
||||||
@ -299,9 +299,9 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct*
|
|||||||
in_cc->start_zone, in_cc->class_,
|
in_cc->start_zone, in_cc->class_,
|
||||||
in_cc->deity, in_cc->race);
|
in_cc->deity, in_cc->race);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, &result))
|
if(!RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Start zone query failed: %s : %s\n", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Start zone query failed: %s : %s\n", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
// For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely
|
// For now, if no row matching row is found, send them to Crescent Reach, as that is probably the most likely
|
||||||
// reason for no match being found.
|
// reason for no match being found.
|
||||||
//
|
//
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row = 0;
|
MYSQL_ROW row = 0;
|
||||||
@ -450,9 +450,9 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
in_cc->start_zone, in_cc->class_,
|
in_cc->start_zone, in_cc->class_,
|
||||||
in_cc->deity, in_cc->race);
|
in_cc->deity, in_cc->race);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf, &result))
|
if(!RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
|||||||
|
|
||||||
std::string query = "SELECT name FROM launcher";
|
std::string query = "SELECT name FROM launcher";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
rl.push_back(row[0]);
|
rl.push_back(row[0]);
|
||||||
@ -513,13 +513,13 @@ void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetLauncherList: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetLauncherList: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) {
|
void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
char MailKeyString[17];
|
char MailKeyString[17];
|
||||||
@ -532,21 +532,21 @@ void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) {
|
|||||||
StringFormat(query, "UPDATE character_ SET mailkey = '%s' WHERE id='%i'",
|
StringFormat(query, "UPDATE character_ SET mailkey = '%s' WHERE id='%i'",
|
||||||
MailKeyString, CharID);
|
MailKeyString, CharID);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf))
|
if (!RunQuery(query, &errbuf))
|
||||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, errbuf);
|
LogFile->write(EQEMuLog::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT level FROM character_ WHERE name='%s'", name);
|
StringFormat(query, "SELECT level FROM character_ WHERE name='%s'", name);
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result))
|
if(RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if(row = mysql_fetch_row(result))
|
if(row = mysql_fetch_row(result))
|
||||||
{
|
{
|
||||||
@ -558,7 +558,7 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetCharacterLevel: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetCharacterLevel: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -566,14 +566,14 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
|||||||
bool WorldDatabase::LoadCharacterCreateAllocations() {
|
bool WorldDatabase::LoadCharacterCreateAllocations() {
|
||||||
character_create_allocations.clear();
|
character_create_allocations.clear();
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT * FROM char_create_point_allocations order by id";
|
std::string query = "SELECT * FROM char_create_point_allocations order by id";
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
while(row = mysql_fetch_row(result)) {
|
while(row = mysql_fetch_row(result)) {
|
||||||
RaceClassAllocation allocate;
|
RaceClassAllocation allocate;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
@ -605,13 +605,13 @@ bool WorldDatabase::LoadCharacterCreateAllocations() {
|
|||||||
bool WorldDatabase::LoadCharacterCreateCombos() {
|
bool WorldDatabase::LoadCharacterCreateCombos() {
|
||||||
character_create_race_class_combos.clear();
|
character_create_race_class_combos.clear();
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query ="select * from char_create_combinations order by race, class, deity, start_zone";
|
std::string query ="select * from char_create_combinations order by race, class, deity, start_zone";
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
while(row = mysql_fetch_row(result)) {
|
while(row = mysql_fetch_row(result)) {
|
||||||
RaceClassCombos combo;
|
RaceClassCombos combo;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|||||||
@ -447,7 +447,7 @@ bool ZoneServer::Process() {
|
|||||||
}
|
}
|
||||||
else if (cle->Online() == CLE_Status_Zoning) {
|
else if (cle->Online() == CLE_Status_Zoning) {
|
||||||
if (!scm->noreply) {
|
if (!scm->noreply) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
//MYSQL_ROW row; Trumpcard - commenting. Currently unused.
|
//MYSQL_ROW row; Trumpcard - commenting. Currently unused.
|
||||||
@ -459,14 +459,14 @@ bool ZoneServer::Process() {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT name from character_ where name='%s'",scm->deliverto);
|
StringFormat(query,"SELECT name from character_ where name='%s'",scm->deliverto);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
if (result!=0) {
|
if (result!=0) {
|
||||||
|
|
||||||
StringFormat(query, "INSERT INTO tellque (Date,Receiver,Sender,Message) "
|
StringFormat(query, "INSERT INTO tellque (Date,Receiver,Sender,Message) "
|
||||||
"values('%s','%s','%s','%s')",
|
"values('%s','%s','%s','%s')",
|
||||||
telldate, scm->deliverto, scm->from,scm->message);
|
telldate, scm->deliverto, scm->from,scm->message);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
|
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
|
||||||
else
|
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);
|
||||||
|
|||||||
56
zone/AA.cpp
56
zone/AA.cpp
@ -1465,13 +1465,13 @@ void Zone::LoadAAs() {
|
|||||||
|
|
||||||
bool ZoneDatabase::LoadAAEffects2() {
|
bool ZoneDatabase::LoadAAEffects2() {
|
||||||
aa_effects.clear(); //start fresh
|
aa_effects.clear(); //start fresh
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT aaid, slot, effectid, base1, base2 FROM aa_effects ORDER BY aaid ASC, slot ASC";
|
std::string query = "SELECT aaid, slot, effectid, base1, base2 FROM aa_effects ORDER BY aaid ASC, slot ASC";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while((row = mysql_fetch_row(result))!= nullptr) {
|
while((row = mysql_fetch_row(result))!= nullptr) {
|
||||||
int aaid = atoi(row[0]);
|
int aaid = atoi(row[0]);
|
||||||
@ -1489,7 +1489,7 @@ bool ZoneDatabase::LoadAAEffects2() {
|
|||||||
if (count < 1) //no results
|
if (count < 1) //no results
|
||||||
LogFile->write(EQEMuLog::Error, "Error loading AA Effects, none found in the database.");
|
LogFile->write(EQEMuLog::Error, "Error loading AA Effects, none found in the database.");
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAEffects2 query: '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1633,7 +1633,7 @@ void Client::InspectBuffs(Client* Inspector, int Rank)
|
|||||||
|
|
||||||
//this really need to be renamed to LoadAAActions()
|
//this really need to be renamed to LoadAAActions()
|
||||||
bool ZoneDatabase::LoadAAEffects() {
|
bool ZoneDatabase::LoadAAEffects() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -1642,7 +1642,7 @@ bool ZoneDatabase::LoadAAEffects() {
|
|||||||
std::string query = "SELECT aaid,rank,reuse_time,spell_id,target,nonspell_action,nonspell_mana,nonspell_duration,"
|
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";
|
"redux_aa,redux_rate,redux_aa2,redux_rate2 FROM aa_actions";
|
||||||
|
|
||||||
if(RunQuery(query, errbuf, &result)) {
|
if(RunQuery(query, &errbuf, &result)) {
|
||||||
int r;
|
int r;
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -1667,7 +1667,7 @@ bool ZoneDatabase::LoadAAEffects() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadAAEffects query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadAAEffects query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1681,7 +1681,7 @@ bool ZoneDatabase::LoadAAEffects() {
|
|||||||
|
|
||||||
//AndMetal: this may now be obsolete since we have Zone::GetTotalAALevels()
|
//AndMetal: this may now be obsolete since we have Zone::GetTotalAALevels()
|
||||||
uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) {
|
uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1689,14 +1689,14 @@ uint8 ZoneDatabase::GetTotalAALevels(uint32 skill_id) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT count(slot) from aa_effects where aaid=%i", skill_id);
|
StringFormat(query,"SELECT count(slot) from aa_effects where aaid=%i", skill_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
total=atoi(row[0]);
|
total=atoi(row[0]);
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTotalAALevels '%s: %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTotalAALevels '%s: %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@ -1726,7 +1726,7 @@ void ZoneDatabase::FillAAEffects(SendAA_Struct* aa_struct){
|
|||||||
if(!aa_struct)
|
if(!aa_struct)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1734,7 +1734,7 @@ void ZoneDatabase::FillAAEffects(SendAA_Struct* aa_struct){
|
|||||||
StringFormat(query,"SELECT effectid, base1, base2, slot from aa_effects "
|
StringFormat(query,"SELECT effectid, base1, base2, slot from aa_effects "
|
||||||
"where aaid=%i order by slot asc", aa_struct->id);
|
"where aaid=%i order by slot asc", aa_struct->id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
int ndx=0;
|
int ndx=0;
|
||||||
while((row = mysql_fetch_row(result))!=nullptr) {
|
while((row = mysql_fetch_row(result))!=nullptr) {
|
||||||
aa_struct->abilities[ndx].skill_id=atoi(row[0]);
|
aa_struct->abilities[ndx].skill_id=atoi(row[0]);
|
||||||
@ -1745,43 +1745,43 @@ void ZoneDatabase::FillAAEffects(SendAA_Struct* aa_struct){
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::FillAAEffects query: '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::FillAAEffects query: '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::CountAAs(){
|
uint32 ZoneDatabase::CountAAs(){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int count=0;
|
int count=0;
|
||||||
|
|
||||||
std::string query = "SELECT count(title_sid) from altadv_vars";
|
std::string query = "SELECT count(title_sid) from altadv_vars";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if((row = mysql_fetch_row(result))!=nullptr)
|
if((row = mysql_fetch_row(result))!=nullptr)
|
||||||
count = atoi(row[0]);
|
count = atoi(row[0]);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAAs query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::CountAAEffects(){
|
uint32 ZoneDatabase::CountAAEffects(){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int count=0;
|
int count=0;
|
||||||
|
|
||||||
std::string query = "SELECT count(id) from aa_effects";
|
std::string query = "SELECT count(id) from aa_effects";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if((row = mysql_fetch_row(result))!=nullptr){
|
if((row = mysql_fetch_row(result))!=nullptr){
|
||||||
count = atoi(row[0]);
|
count = atoi(row[0]);
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::CountAALevels query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -1796,13 +1796,13 @@ uint32 ZoneDatabase::GetSizeAA(){
|
|||||||
void ZoneDatabase::LoadAAs(SendAA_Struct **load){
|
void ZoneDatabase::LoadAAs(SendAA_Struct **load){
|
||||||
if(!load)
|
if(!load)
|
||||||
return;
|
return;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT skill_id from altadv_vars order by skill_id";
|
std::string query = "SELECT skill_id from altadv_vars order by skill_id";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
int skill=0,ndx=0;
|
int skill=0,ndx=0;
|
||||||
while((row = mysql_fetch_row(result))!=nullptr) {
|
while((row = mysql_fetch_row(result))!=nullptr) {
|
||||||
skill=atoi(row[0]);
|
skill=atoi(row[0]);
|
||||||
@ -1812,14 +1812,14 @@ void ZoneDatabase::LoadAAs(SendAA_Struct **load){
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
AARequiredLevelAndCost.clear();
|
AARequiredLevelAndCost.clear();
|
||||||
|
|
||||||
query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id";
|
query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
AALevelCost_Struct aalcs;
|
AALevelCost_Struct aalcs;
|
||||||
while((row = mysql_fetch_row(result))!=nullptr)
|
while((row = mysql_fetch_row(result))!=nullptr)
|
||||||
@ -1831,18 +1831,18 @@ void ZoneDatabase::LoadAAs(SendAA_Struct **load){
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
|
SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
SendAA_Struct* sendaa = nullptr;
|
SendAA_Struct* sendaa = nullptr;
|
||||||
uchar* buffer;
|
uchar* buffer;
|
||||||
|
|
||||||
std::string query = "SET @row = 0";
|
std::string query = "SET @row = 0";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf)) { //initialize "row" variable in database for next query
|
if (RunQuery(query, &errbuf)) { //initialize "row" variable in database for next query
|
||||||
MYSQL_RES *result; //we don't really need these unless we get to this point, so why bother?
|
MYSQL_RES *result; //we don't really need these unless we get to this point, so why bother?
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -1880,7 +1880,7 @@ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
|
|||||||
"a.sof_next_id, a.level_inc "
|
"a.sof_next_id, a.level_inc "
|
||||||
" FROM altadv_vars a WHERE skill_id=%i", skill_id);
|
" FROM altadv_vars a WHERE skill_id=%i", skill_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
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 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);
|
int totalsize = total_abilities * sizeof(AA_Ability) + sizeof(SendAA_Struct);
|
||||||
@ -1937,10 +1937,10 @@ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetAASkillVars '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return sendaa;
|
return sendaa;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2329,14 +2329,14 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) {
|
|||||||
}
|
}
|
||||||
else if (!npc_spells_loadtried[iDBSpellsID]) { // no reason to ask the DB again if we have failed once already
|
else if (!npc_spells_loadtried[iDBSpellsID]) { // no reason to ask the DB again if we have failed once already
|
||||||
npc_spells_loadtried[iDBSpellsID] = true;
|
npc_spells_loadtried[iDBSpellsID] = true;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT id, parent_list, attack_proc, proc_chance from npc_spells where id=%d", iDBSpellsID);
|
StringFormat(query, "SELECT id, parent_list, attack_proc, proc_chance from npc_spells where id=%d", iDBSpellsID);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
uint32 tmpparent_list = atoi(row[1]);
|
uint32 tmpparent_list = atoi(row[1]);
|
||||||
@ -2349,7 +2349,7 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) {
|
|||||||
"where npc_spells_id=%d ORDER BY minlevel",
|
"where npc_spells_id=%d ORDER BY minlevel",
|
||||||
iDBSpellsID);
|
iDBSpellsID);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
uint32 tmpSize = sizeof(DBnpcspells_Struct) + (sizeof(DBnpcspells_entries_Struct) * mysql_num_rows(result));
|
uint32 tmpSize = sizeof(DBnpcspells_Struct) + (sizeof(DBnpcspells_entries_Struct) * mysql_num_rows(result));
|
||||||
npc_spells_cache[iDBSpellsID] = (DBnpcspells_Struct*) new uchar[tmpSize];
|
npc_spells_cache[iDBSpellsID] = (DBnpcspells_Struct*) new uchar[tmpSize];
|
||||||
memset(npc_spells_cache[iDBSpellsID], 0, tmpSize);
|
memset(npc_spells_cache[iDBSpellsID], 0, tmpSize);
|
||||||
@ -2403,13 +2403,13 @@ DBnpcspells_Struct* ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GetMaxNPCSpellsID() {
|
uint32 ZoneDatabase::GetMaxNPCSpellsID() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT max(id) from npc_spells";
|
std::string query = "SELECT max(id) from npc_spells";
|
||||||
|
|
||||||
if (RunQuery(query,errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
uint32 ret = 0;
|
uint32 ret = 0;
|
||||||
|
|||||||
@ -558,7 +558,7 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
|
|||||||
// Add new Zone Object (theoretically only called for items dropped to ground)
|
// 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)
|
uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
uint32 database_id = 0;
|
uint32 database_id = 0;
|
||||||
@ -581,8 +581,8 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob
|
|||||||
item_id, charges, object_name.c_str(), type, icon);
|
item_id, charges, object_name.c_str(), type, icon);
|
||||||
|
|
||||||
// Save new record for object
|
// Save new record for object
|
||||||
if (!RunQuery(query, errbuf, nullptr, nullptr, &database_id)) {
|
if (!RunQuery(query, &errbuf, nullptr, nullptr, &database_id)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to insert object: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to insert object: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Save container contents, if container
|
// Save container contents, if container
|
||||||
@ -597,7 +597,7 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob
|
|||||||
// Update information about existing object in database
|
// Update information about existing object in database
|
||||||
void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst)
|
void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Object_Struct& object, const ItemInst* inst)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
uint32 item_id = 0;
|
uint32 item_id = 0;
|
||||||
@ -619,8 +619,8 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec
|
|||||||
item_id, charges, object_name.c_str(), type, icon, id);
|
item_id, charges, object_name.c_str(), type, icon, id);
|
||||||
|
|
||||||
// Save new record for object
|
// Save new record for object
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to update object: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to update object: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Save container contents, if container
|
// Save container contents, if container
|
||||||
@ -631,7 +631,7 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec
|
|||||||
|
|
||||||
}
|
}
|
||||||
Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs){
|
Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -642,7 +642,7 @@ Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Gro
|
|||||||
"(version=%u OR version=-1) limit 50",
|
"(version=%u OR version=-1) limit 50",
|
||||||
zone_id, version);
|
zone_id, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
while( (row=mysql_fetch_row(result) ) ) {
|
while( (row=mysql_fetch_row(result) ) ) {
|
||||||
@ -667,14 +667,14 @@ Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Gro
|
|||||||
}
|
}
|
||||||
void ZoneDatabase::DeleteObject(uint32 id)
|
void ZoneDatabase::DeleteObject(uint32 id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
// Save new record for object
|
// Save new record for object
|
||||||
StringFormat(query,"delete from object where id=%i", id);
|
StringFormat(query,"delete from object where id=%i", id);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to delete object: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to delete object: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1445,14 +1445,14 @@ void Corpse::Spawn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
|
bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 query_length = 0;
|
uint32 query_length = 0;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE zone SET graveyard_id=0 WHERE zoneidnumber=%u AND version=0", zone_id);
|
StringFormat(query, "UPDATE zone SET graveyard_id=0 WHERE zoneidnumber=%u AND version=0", zone_id);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
std::cerr << "Error1 in DeleteGraveyard query " << errbuf << std::endl;
|
std::cerr << "Error1 in DeleteGraveyard query " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1464,7 +1464,7 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM graveyard WHERE id=%u", graveyard_id);
|
StringFormat(query,"DELETE FROM graveyard WHERE id=%u", graveyard_id);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
std::cerr << "Error3 in DeleteGraveyard query " << errbuf << std::endl;
|
std::cerr << "Error3 in DeleteGraveyard query " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1477,7 +1477,7 @@ bool ZoneDatabase::DeleteGraveyard(uint32 zone_id, uint32 graveyard_id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
|
uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -1485,7 +1485,7 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
|
|||||||
"WHERE zoneidnumber=%u AND version=0",
|
"WHERE zoneidnumber=%u AND version=0",
|
||||||
graveyard_id, zone_id);
|
graveyard_id, zone_id);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
std::cerr << "Error1 in AddGraveyardIDToZone query " << errbuf << std::endl;
|
std::cerr << "Error1 in AddGraveyardIDToZone query " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1498,7 +1498,7 @@ uint32 ZoneDatabase::AddGraveyardIDToZone(uint32 zone_id, uint32 graveyard_id) {
|
|||||||
return zone_id;
|
return zone_id;
|
||||||
}
|
}
|
||||||
uint32 ZoneDatabase::NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) {
|
uint32 ZoneDatabase::NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
uint32 new_graveyard_id = 0;
|
uint32 new_graveyard_id = 0;
|
||||||
@ -1506,7 +1506,7 @@ uint32 ZoneDatabase::NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard
|
|||||||
StringFormat(query, "INSERT INTO graveyard SET zone_id=%u, x=%1.1f, y=%1.1f, z=%1.1f, heading=%1.1f",
|
StringFormat(query, "INSERT INTO graveyard SET zone_id=%u, x=%1.1f, y=%1.1f, z=%1.1f, heading=%1.1f",
|
||||||
graveyard_zoneid, graveyard_x, graveyard_y, graveyard_z, graveyard_heading);
|
graveyard_zoneid, graveyard_x, graveyard_y, graveyard_z, graveyard_heading);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows, &new_graveyard_id)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows, &new_graveyard_id)) {
|
||||||
std::cerr << "Error1 in NewGraveyardRecord query " << errbuf << std::endl;
|
std::cerr << "Error1 in NewGraveyardRecord query " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1525,7 +1525,7 @@ uint32 ZoneDatabase::NewGraveyardRecord(uint32 graveyard_zoneid, float graveyard
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading) {
|
uint32 ZoneDatabase::GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
|
|
||||||
@ -1535,7 +1535,7 @@ uint32 ZoneDatabase::GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 in
|
|||||||
"WasAtGraveyard=1 WHERE id=%d",
|
"WasAtGraveyard=1 WHERE id=%d",
|
||||||
zoneid, x, y, z, heading, dbid);
|
zoneid, x, y, z, heading, dbid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
std::cerr << "Error1 in GraveyardPlayerCorpse query " << errbuf << std::endl;
|
std::cerr << "Error1 in GraveyardPlayerCorpse query " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1548,7 +1548,7 @@ uint32 ZoneDatabase::GraveyardPlayerCorpse(uint32 dbid, uint32 zoneid, uint16 in
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading, bool rezzed) {
|
uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading, bool rezzed) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
std::string dataSection;
|
std::string dataSection;
|
||||||
std::string endOfQuery;
|
std::string endOfQuery;
|
||||||
@ -1568,7 +1568,7 @@ uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char*
|
|||||||
|
|
||||||
query.append(endOfQuery);
|
query.append(endOfQuery);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
std::cerr << "Error1 in UpdatePlayerCorpse query " << errbuf << std::endl;
|
std::cerr << "Error1 in UpdatePlayerCorpse query " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1581,7 +1581,7 @@ uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char*
|
|||||||
|
|
||||||
StringFormat(query,"update player_corpses set rezzed = 1 WHERE id=%d",dbid);
|
StringFormat(query,"update player_corpses set rezzed = 1 WHERE id=%d",dbid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in UpdatePlayerCorpse/Rezzed query: " << errbuf << std::endl;
|
std::cerr << "Error in UpdatePlayerCorpse/Rezzed query: " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1590,19 +1590,19 @@ uint32 ZoneDatabase::UpdatePlayerCorpse(uint32 dbid, uint32 charid, const char*
|
|||||||
|
|
||||||
void ZoneDatabase::MarkCorpseAsRezzed(uint32 dbid)
|
void ZoneDatabase::MarkCorpseAsRezzed(uint32 dbid)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE player_corpses SET rezzed = 1 WHERE id = %i", dbid);
|
StringFormat(query,"UPDATE player_corpses SET rezzed = 1 WHERE id = %i", dbid);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "MarkCorpseAsRezzed failed: %s, %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MarkCorpseAsRezzed failed: %s, %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::CreatePlayerCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading) {
|
uint32 ZoneDatabase::CreatePlayerCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string dataSection;
|
std::string dataSection;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
uint32 last_insert_id = 0;
|
uint32 last_insert_id = 0;
|
||||||
@ -1620,7 +1620,7 @@ uint32 ZoneDatabase::CreatePlayerCorpse(uint32 charid, const char* charname, uin
|
|||||||
charname, zoneid, instanceid, charid, x, y, z, heading);
|
charname, zoneid, instanceid, charid, x, y, z, heading);
|
||||||
query.append(endOfQuery);
|
query.append(endOfQuery);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows, &last_insert_id)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows, &last_insert_id)) {
|
||||||
std::cerr << "Error1 in CreatePlayerCorpse query " << errbuf << std::endl;
|
std::cerr << "Error1 in CreatePlayerCorpse query " << errbuf << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1639,7 +1639,7 @@ uint32 ZoneDatabase::CreatePlayerCorpse(uint32 charid, const char* charname, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading) {
|
bool ZoneDatabase::CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
std::string dataSection;
|
std::string dataSection;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
@ -1666,7 +1666,7 @@ bool ZoneDatabase::CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const ch
|
|||||||
|
|
||||||
query.append(endOfQuery);
|
query.append(endOfQuery);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
if (affected_rows == 1)
|
if (affected_rows == 1)
|
||||||
result = true;
|
result = true;
|
||||||
else
|
else
|
||||||
@ -1683,7 +1683,7 @@ bool ZoneDatabase::CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GetPlayerBurriedCorpseCount(uint32 char_id) {
|
uint32 ZoneDatabase::GetPlayerBurriedCorpseCount(uint32 char_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1692,7 +1692,7 @@ uint32 ZoneDatabase::GetPlayerBurriedCorpseCount(uint32 char_id) {
|
|||||||
StringFormat(query,"select count(*) from player_corpses "
|
StringFormat(query,"select count(*) from player_corpses "
|
||||||
"where charid = '%u' and IsBurried = 1", char_id);
|
"where charid = '%u' and IsBurried = 1", char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
CorpseCount = atoi(row[0]);
|
CorpseCount = atoi(row[0]);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@ -1705,7 +1705,7 @@ uint32 ZoneDatabase::GetPlayerBurriedCorpseCount(uint32 char_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GetPlayerCorpseCount(uint32 char_id) {
|
uint32 ZoneDatabase::GetPlayerCorpseCount(uint32 char_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1713,7 +1713,7 @@ uint32 ZoneDatabase::GetPlayerCorpseCount(uint32 char_id) {
|
|||||||
|
|
||||||
StringFormat(query,"select count(*) from player_corpses where charid = '%u'", char_id);
|
StringFormat(query,"select count(*) from player_corpses where charid = '%u'", char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
CorpseCount = atoi(row[0]);
|
CorpseCount = atoi(row[0]);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@ -1726,7 +1726,7 @@ uint32 ZoneDatabase::GetPlayerCorpseCount(uint32 char_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GetPlayerCorpseID(uint32 char_id, uint8 corpse) {
|
uint32 ZoneDatabase::GetPlayerCorpseID(uint32 char_id, uint8 corpse) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1734,7 +1734,7 @@ uint32 ZoneDatabase::GetPlayerCorpseID(uint32 char_id, uint8 corpse) {
|
|||||||
|
|
||||||
StringFormat(query,"select id from player_corpses where charid = '%u'", char_id);
|
StringFormat(query,"select id from player_corpses where charid = '%u'", char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
for (int i=0; i<corpse;i++) {
|
for (int i=0; i<corpse;i++) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
id = (uint32)atoi(row[0]);
|
id = (uint32)atoi(row[0]);
|
||||||
@ -1760,7 +1760,7 @@ uint32 ZoneDatabase::GetPlayerCorpseItemAt(uint32 corpse_id, uint16 slotid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Corpse* ZoneDatabase::SummonBurriedPlayerCorpse(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading) {
|
Corpse* ZoneDatabase::SummonBurriedPlayerCorpse(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, float dest_x, float dest_y, float dest_z, float dest_heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1771,7 +1771,7 @@ Corpse* ZoneDatabase::SummonBurriedPlayerCorpse(uint32 char_id, uint32 dest_zone
|
|||||||
"FROM player_corpses WHERE charid='%u' AND "
|
"FROM player_corpses WHERE charid='%u' AND "
|
||||||
"IsBurried=1 ORDER BY timeofdeath LIMIT 1", char_id);
|
"IsBurried=1 ORDER BY timeofdeath LIMIT 1", char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
if(row) {
|
if(row) {
|
||||||
@ -1799,7 +1799,7 @@ Corpse* ZoneDatabase::SummonBurriedPlayerCorpse(uint32 char_id, uint32 dest_zone
|
|||||||
bool ZoneDatabase::SummonAllPlayerCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid,
|
bool ZoneDatabase::SummonAllPlayerCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid,
|
||||||
float dest_x, float dest_y, float dest_z, float dest_heading)
|
float dest_x, float dest_y, float dest_z, float dest_heading)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1811,15 +1811,15 @@ bool ZoneDatabase::SummonAllPlayerCorpses(uint32 char_id, uint32 dest_zoneid, ui
|
|||||||
"heading = %f, IsBurried = 0, WasAtGraveyard = 0 WHERE charid = %i",
|
"heading = %f, IsBurried = 0, WasAtGraveyard = 0 WHERE charid = %i",
|
||||||
dest_zoneid, dest_instanceid, dest_x, dest_y, dest_z, dest_heading, char_id);
|
dest_zoneid, dest_instanceid, dest_x, dest_y, dest_z, dest_heading, char_id);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf))
|
if(!RunQuery(query, &errbuf))
|
||||||
LogFile->write(EQEMuLog::Error, "Error moving corpses, Query = %s, Error = %s\n", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error moving corpses, Query = %s, Error = %s\n", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
StringFormat(query,"SELECT id, charname, data, timeofdeath, rezzed "
|
StringFormat(query,"SELECT id, charname, data, timeofdeath, rezzed "
|
||||||
"FROM player_corpses WHERE charid='%u'"
|
"FROM player_corpses WHERE charid='%u'"
|
||||||
"ORDER BY timeofdeath",
|
"ORDER BY timeofdeath",
|
||||||
char_id);
|
char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -1839,13 +1839,13 @@ bool ZoneDatabase::SummonAllPlayerCorpses(uint32 char_id, uint32 dest_zoneid, ui
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogFile->write(EQEMuLog::Error, "Error in SummonAllPlayerCorpses Query = %s, Error = %s\n", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in SummonAllPlayerCorpses Query = %s, Error = %s\n", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return (CorpseCount > 0);
|
return (CorpseCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::UnburyPlayerCorpse(uint32 dbid, uint32 new_zoneid, uint16 new_instanceid, float new_x, float new_y, float new_z, float new_heading) {
|
bool ZoneDatabase::UnburyPlayerCorpse(uint32 dbid, uint32 new_zoneid, uint16 new_instanceid, float new_x, float new_y, float new_z, float new_heading) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
bool Result = false;
|
bool Result = false;
|
||||||
@ -1856,7 +1856,7 @@ bool ZoneDatabase::UnburyPlayerCorpse(uint32 dbid, uint32 new_zoneid, uint16 new
|
|||||||
new_zoneid, new_instanceid, new_x, new_y, new_z,
|
new_zoneid, new_instanceid, new_x, new_y, new_z,
|
||||||
new_heading, dbid);
|
new_heading, dbid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||||
if (affected_rows == 1)
|
if (affected_rows == 1)
|
||||||
Result = true;
|
Result = true;
|
||||||
else
|
else
|
||||||
@ -1869,7 +1869,7 @@ bool ZoneDatabase::UnburyPlayerCorpse(uint32 dbid, uint32 new_zoneid, uint16 new
|
|||||||
}
|
}
|
||||||
|
|
||||||
Corpse* ZoneDatabase::LoadPlayerCorpse(uint32 player_corpse_id) {
|
Corpse* ZoneDatabase::LoadPlayerCorpse(uint32 player_corpse_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1881,7 +1881,7 @@ Corpse* ZoneDatabase::LoadPlayerCorpse(uint32 player_corpse_id) {
|
|||||||
"FROM player_corpses WHERE id='%u'",
|
"FROM player_corpses WHERE id='%u'",
|
||||||
player_corpse_id);
|
player_corpse_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
if(row && lengths)
|
if(row && lengths)
|
||||||
@ -1900,7 +1900,7 @@ Corpse* ZoneDatabase::LoadPlayerCorpse(uint32 player_corpse_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) {
|
bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1924,7 +1924,7 @@ bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) {
|
|||||||
iZoneID, iInstanceID);
|
iZoneID, iInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10])));
|
entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10])));
|
||||||
@ -1941,7 +1941,7 @@ bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
|
uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1951,7 +1951,7 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
|
|||||||
"AND IsBurried=0 ORDER BY timeofdeath LIMIT 1",
|
"AND IsBurried=0 ORDER BY timeofdeath LIMIT 1",
|
||||||
char_id);
|
char_id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result)!= 0) {
|
if (mysql_num_rows(result)!= 0) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
CorpseID = atoi(row[0]);
|
CorpseID = atoi(row[0]);
|
||||||
@ -1966,12 +1966,12 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::BuryPlayerCorpse(uint32 dbid) {
|
bool ZoneDatabase::BuryPlayerCorpse(uint32 dbid) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE player_corpses SET IsBurried = 1 WHERE id=%d", dbid);
|
StringFormat(query,"UPDATE player_corpses SET IsBurried = 1 WHERE id=%d", dbid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1980,12 +1980,12 @@ bool ZoneDatabase::BuryPlayerCorpse(uint32 dbid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::BuryAllPlayerCorpses(uint32 charid) {
|
bool ZoneDatabase::BuryAllPlayerCorpses(uint32 charid) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE player_corpses SET IsBurried = 1 WHERE charid=%d", charid);
|
StringFormat(query,"UPDATE player_corpses SET IsBurried = 1 WHERE charid=%d", charid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in BuryPlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1994,12 +1994,12 @@ bool ZoneDatabase::BuryAllPlayerCorpses(uint32 charid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::DeletePlayerCorpse(uint32 dbid) {
|
bool ZoneDatabase::DeletePlayerCorpse(uint32 dbid) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"Delete from player_corpses where id=%d", dbid);
|
StringFormat(query,"Delete from player_corpses where id=%d", dbid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in DeletePlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in DeletePlayerCorpse query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2057,7 +2057,7 @@ void Corpse::AddLooter(Mob* who)
|
|||||||
void Corpse::LoadPlayerCorpseDecayTime(uint32 dbid){
|
void Corpse::LoadPlayerCorpseDecayTime(uint32 dbid){
|
||||||
if(!dbid)
|
if(!dbid)
|
||||||
return;
|
return;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -2066,7 +2066,7 @@ void Corpse::LoadPlayerCorpseDecayTime(uint32 dbid){
|
|||||||
"FROM player_corpses WHERE id=%d and not timeofdeath=0",
|
"FROM player_corpses WHERE id=%d and not timeofdeath=0",
|
||||||
dbid);
|
dbid);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
if(atoi(row[0]) > 0 && RuleI(Character, CorpseDecayTimeMS) > (atoi(row[0]) * 1000)) {
|
if(atoi(row[0]) > 0 && RuleI(Character, CorpseDecayTimeMS) > (atoi(row[0]) * 1000)) {
|
||||||
corpse_decay_timer.SetTimer(RuleI(Character, CorpseDecayTimeMS) - (atoi(row[0]) * 1000));
|
corpse_decay_timer.SetTimer(RuleI(Character, CorpseDecayTimeMS) - (atoi(row[0]) * 1000));
|
||||||
|
|||||||
@ -139,7 +139,7 @@ void QGlobalCache::PurgeExpiredGlobals()
|
|||||||
|
|
||||||
void QGlobalCache::LoadByNPCID(uint32 npcID)
|
void QGlobalCache::LoadByNPCID(uint32 npcID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -147,7 +147,7 @@ void QGlobalCache::LoadByNPCID(uint32 npcID)
|
|||||||
StringFormat(query,"select name, charid, npcid, zoneid, value, expdate"
|
StringFormat(query,"select name, charid, npcid, zoneid, value, expdate"
|
||||||
" from quest_globals where npcid = %d", npcID);
|
" from quest_globals where npcid = %d", npcID);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -159,7 +159,7 @@ void QGlobalCache::LoadByNPCID(uint32 npcID)
|
|||||||
|
|
||||||
void QGlobalCache::LoadByCharID(uint32 charID)
|
void QGlobalCache::LoadByCharID(uint32 charID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -168,7 +168,7 @@ void QGlobalCache::LoadByCharID(uint32 charID)
|
|||||||
"quest_globals where charid = %d && npcid = 0",
|
"quest_globals where charid = %d && npcid = 0",
|
||||||
charID);
|
charID);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -180,7 +180,7 @@ void QGlobalCache::LoadByCharID(uint32 charID)
|
|||||||
|
|
||||||
void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -188,7 +188,7 @@ void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
|||||||
StringFormat(query,"select name, charid, npcid, zoneid, value, expdate from quest_globals"
|
StringFormat(query,"select name, charid, npcid, zoneid, value, expdate from quest_globals"
|
||||||
" where zoneid = %d && npcid = 0 && charid = 0", zoneID);
|
" where zoneid = %d && npcid = 0 && charid = 0", zoneID);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -199,7 +199,7 @@ void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
|||||||
}
|
}
|
||||||
void QGlobalCache::LoadByGlobalContext()
|
void QGlobalCache::LoadByGlobalContext()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -207,7 +207,7 @@ void QGlobalCache::LoadByGlobalContext()
|
|||||||
query = "select name, charid, npcid, zoneid, value, expdate from quest_globals"
|
query = "select name, charid, npcid, zoneid, value, expdate from quest_globals"
|
||||||
" where zoneid = 0 && npcid = 0 && charid = 0";
|
" where zoneid = 0 && npcid = 0 && charid = 0";
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
|
|||||||
309
zone/bot.cpp
309
zone/bot.cpp
@ -1467,7 +1467,6 @@ void Bot::GenerateAABonuses(StatBonuses* newbon) {
|
|||||||
void Bot::LoadAAs() {
|
void Bot::LoadAAs() {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -1479,10 +1478,11 @@ void Bot::LoadAAs() {
|
|||||||
else
|
else
|
||||||
StringFormat(query,"SELECT skill_id FROM altadv_vars WHERE ((classes & ( 1 << %i )) >> %i) = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetClass(), GetClass(), GetLevel(), maxAAExpansion);
|
StringFormat(query,"SELECT skill_id FROM altadv_vars WHERE ((classes & ( 1 << %i )) >> %i) = 1 AND class_type > 1 AND class_type <= %i AND aa_expansion <= %i ORDER BY skill_id;", GetClass(), GetClass(), GetLevel(), maxAAExpansion);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult))
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
{
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadAAs(). Error Message: %s",errorMessage.c_str());
|
||||||
}
|
}
|
||||||
else {
|
{
|
||||||
int totalAAs = database.CountAAs();
|
int totalAAs = database.CountAAs();
|
||||||
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -1537,10 +1537,6 @@ void Bot::LoadAAs() {
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadAAs()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::GetAA(uint32 aa_id) {
|
uint32 Bot::GetAA(uint32 aa_id) {
|
||||||
@ -2349,14 +2345,15 @@ bool Bot::IsBotNameAvailable(std::string* errorMessage) {
|
|||||||
|
|
||||||
if(this->GetCleanName()) {
|
if(this->GetCleanName()) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
std::string errorMessageBuffer;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT COUNT(id) FROM vwBotCharacterMobs WHERE name LIKE '%s'", this->GetCleanName());
|
StringFormat(query,"SELECT COUNT(id) FROM vwBotCharacterMobs WHERE name LIKE '%s'", this->GetCleanName());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessageBuffer, &DatasetResult)) {
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
// probably was supposed to *do* something with the error message here.
|
||||||
|
// TODO: log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 ExistingNameCount = 0;
|
uint32 ExistingNameCount = 0;
|
||||||
@ -2381,7 +2378,7 @@ bool Bot::Save() {
|
|||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
uint32 affectedRows = 0;
|
uint32 affectedRows = 0;
|
||||||
|
|
||||||
if(this->GetBotID() == 0) {
|
if(this->GetBotID() == 0) {
|
||||||
@ -2404,10 +2401,7 @@ bool Bot::Save() {
|
|||||||
GetCorrup(), GetAC(), GetSTR(), GetSTA(), GetDEX(), GetAGI(), GetINT(), GetWIS(), GetCHA(),
|
GetCorrup(), GetAC(), GetSTR(), GetSTA(), GetDEX(), GetAGI(), GetINT(), GetWIS(), GetCHA(),
|
||||||
GetATK(), _lastZoneId);
|
GetATK(), _lastZoneId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, nullptr, &affectedRows, &TempNewBotID)) {
|
if(database.RunQuery(query, &errorMessage, nullptr, &affectedRows, &TempNewBotID)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SetBotID(TempNewBotID);
|
SetBotID(TempNewBotID);
|
||||||
Result = true;
|
Result = true;
|
||||||
}
|
}
|
||||||
@ -2436,10 +2430,7 @@ bool Bot::Save() {
|
|||||||
_baseAGI, _baseINT, _baseWIS, _baseCHA, _baseATK, GetTotalPlayTime(),
|
_baseAGI, _baseINT, _baseWIS, _baseCHA, _baseATK, GetTotalPlayTime(),
|
||||||
_lastZoneId, GetBotID());
|
_lastZoneId, GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, 0, &affectedRows)) {
|
if(database.RunQuery(query, &errorMessage, 0, &affectedRows)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Result = true;
|
Result = true;
|
||||||
time(&_startTotalPlayTime);
|
time(&_startTotalPlayTime);
|
||||||
}
|
}
|
||||||
@ -2483,7 +2474,6 @@ uint32 Bot::GetTotalPlayTime() {
|
|||||||
void Bot::SaveBuffs() {
|
void Bot::SaveBuffs() {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
int BuffCount = 0;
|
int BuffCount = 0;
|
||||||
int InsertCount = 0;
|
int InsertCount = 0;
|
||||||
|
|
||||||
@ -2495,8 +2485,7 @@ void Bot::SaveBuffs() {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM botbuffs WHERE BotId = %u", GetBotID());
|
StringFormat(query, "DELETE FROM botbuffs WHERE BotId = %u", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2523,8 +2512,7 @@ void Bot::SaveBuffs() {
|
|||||||
buffs[BuffCount].deathSaveSuccessChance,
|
buffs[BuffCount].deathSaveSuccessChance,
|
||||||
buffs[BuffCount].deathsaveCasterAARank, IsPersistent);
|
buffs[BuffCount].deathsaveCasterAARank, IsPersistent);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2543,7 +2531,6 @@ void Bot::SaveBuffs() {
|
|||||||
void Bot::LoadBuffs() {
|
void Bot::LoadBuffs() {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -2554,10 +2541,7 @@ void Bot::LoadBuffs() {
|
|||||||
"HitCount, MeleeRune, MagicRune, DeathSaveSuccessChance, CasterAARank, "
|
"HitCount, MeleeRune, MagicRune, DeathSaveSuccessChance, CasterAARank, "
|
||||||
"Persistent FROM botbuffs WHERE BotId = %u", GetBotID());
|
"Persistent FROM botbuffs WHERE BotId = %u", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int BuffCount = 0;
|
int BuffCount = 0;
|
||||||
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -2604,8 +2588,8 @@ void Bot::LoadBuffs() {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM botbuffs WHERE BotId = %u", GetBotID());
|
StringFormat(query, "DELETE FROM botbuffs WHERE BotId = %u", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2618,14 +2602,13 @@ uint32 Bot::GetPetSaveId() {
|
|||||||
uint32 Result = 0;
|
uint32 Result = 0;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query, "select BotPetsId from botpets where BotId = %u;", GetBotID());
|
StringFormat(query, "select BotPetsId from botpets where BotId = %u;", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -2636,10 +2619,6 @@ uint32 Bot::GetPetSaveId() {
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2678,7 +2657,6 @@ void Bot::LoadPetStats(std::string* petName, uint16* petMana, uint16* petHitPoin
|
|||||||
if(botPetSaveId > 0) {
|
if(botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -2686,8 +2664,8 @@ void Bot::LoadPetStats(std::string* petName, uint16* petMana, uint16* petHitPoin
|
|||||||
|
|
||||||
StringFormat(query,"select PetId, Name, Mana, HitPoints from botpets where BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"select PetId, Name, Mana, HitPoints from botpets where BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -2703,10 +2681,6 @@ void Bot::LoadPetStats(std::string* petName, uint16* petMana, uint16* petHitPoin
|
|||||||
statsLoaded = true;
|
statsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2714,7 +2688,6 @@ void Bot::LoadPetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
if(petBuffs && botPetSaveId > 0) {
|
if(petBuffs && botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -2722,8 +2695,8 @@ void Bot::LoadPetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT SpellId, CasterLevel, Duration FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"SELECT SpellId, CasterLevel, Duration FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int BuffCount = 0;
|
int BuffCount = 0;
|
||||||
@ -2748,14 +2721,11 @@ void Bot::LoadPetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query, "DELETE FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query,TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query,&errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2763,7 +2733,6 @@ void Bot::LoadPetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
if(petItems && botPetSaveId > 0) {
|
if(petItems && botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -2771,8 +2740,8 @@ void Bot::LoadPetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT ItemId FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"SELECT ItemId FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int ItemCount = 0;
|
int ItemCount = 0;
|
||||||
@ -2795,14 +2764,11 @@ void Bot::LoadPetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"DELETE FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2847,12 +2813,11 @@ uint32 Bot::SavePetStats(std::string petName, uint16 petMana, uint16 petHitPoint
|
|||||||
|
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query,"REPLACE INTO botpets SET PetId = %u, BotId = %u, Name = '%s', Mana = %u, HitPoints = %u;", botPetId, GetBotID(), petName.c_str(), petMana, petHitPoints);
|
StringFormat(query,"REPLACE INTO botpets SET PetId = %u, BotId = %u, Name = '%s', Mana = %u, HitPoints = %u;", botPetId, GetBotID(), petName.c_str(), petMana, petHitPoints);
|
||||||
|
|
||||||
if(!database.RunQuery(query,TempErrorMessageBuffer, 0, 0, &Result)) {
|
if(!database.RunQuery(query, &errorMessage, nullptr, nullptr, &Result)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
@ -2862,7 +2827,6 @@ void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
if(petBuffs && botPetSaveId > 0) {
|
if(petBuffs && botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
int BuffCount = 0;
|
int BuffCount = 0;
|
||||||
|
|
||||||
while(BuffCount < BUFF_COUNT) {
|
while(BuffCount < BUFF_COUNT) {
|
||||||
@ -2871,8 +2835,8 @@ void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
StringFormat(query,"INSERT INTO botpetbuffs (BotPetsId, SpellId, CasterLevel, Duration) VALUES(%u, %u, %u, %u);",
|
StringFormat(query,"INSERT INTO botpetbuffs (BotPetsId, SpellId, CasterLevel, Duration) VALUES(%u, %u, %u, %u);",
|
||||||
botPetSaveId, petBuffs[BuffCount].spellid, petBuffs[BuffCount].level, petBuffs[BuffCount].duration);
|
botPetSaveId, petBuffs[BuffCount].spellid, petBuffs[BuffCount].level, petBuffs[BuffCount].duration);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2883,9 +2847,6 @@ void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) {
|
|||||||
BuffCount++;
|
BuffCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2893,7 +2854,6 @@ void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
if(petItems && botPetSaveId > 0) {
|
if(petItems && botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
int ItemCount = 0;
|
int ItemCount = 0;
|
||||||
|
|
||||||
while(ItemCount < MAX_WORN_INVENTORY) {
|
while(ItemCount < MAX_WORN_INVENTORY) {
|
||||||
@ -2902,8 +2862,8 @@ void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
StringFormat(query,"INSERT INTO botpetinventory (BotPetsId, ItemId) VALUES(%u, %u);",
|
StringFormat(query,"INSERT INTO botpetinventory (BotPetsId, ItemId) VALUES(%u, %u);",
|
||||||
botPetSaveId, petItems[ItemCount]);
|
botPetSaveId, petItems[ItemCount]);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2914,9 +2874,6 @@ void Bot::SavePetItems(uint32* petItems, uint32 botPetSaveId) {
|
|||||||
ItemCount++;
|
ItemCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2924,12 +2881,11 @@ void Bot::DeletePetBuffs(uint32 botPetSaveId) {
|
|||||||
if(botPetSaveId > 0) {
|
if(botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"DELETE FROM botpetbuffs WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2938,12 +2894,11 @@ void Bot::DeletePetItems(uint32 botPetSaveId) {
|
|||||||
if(botPetSaveId > 0) {
|
if(botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
StringFormat(query,"DELETE FROM botpetinventory WHERE BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2952,12 +2907,11 @@ void Bot::DeletePetStats(uint32 botPetSaveId) {
|
|||||||
if(botPetSaveId > 0) {
|
if(botPetSaveId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query, "DELETE from botpets where BotPetsId = %u;", botPetSaveId);
|
StringFormat(query, "DELETE from botpets where BotPetsId = %u;", botPetSaveId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2968,14 +2922,14 @@ void Bot::LoadStance() {
|
|||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"select StanceID from botstances where BotID = %u;", GetBotID());
|
StringFormat(query,"select StanceID from botstances where BotID = %u;", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadStance(). Error message: %s", errorMessage.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -2987,10 +2941,6 @@ void Bot::LoadStance() {
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadStance()");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(loaded)
|
if(loaded)
|
||||||
SetBotStance((BotStanceType)Result);
|
SetBotStance((BotStanceType)Result);
|
||||||
else
|
else
|
||||||
@ -3001,24 +2951,19 @@ void Bot::SaveStance() {
|
|||||||
if(_baseBotStance != _botStance) {
|
if(_baseBotStance != _botStance) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query,"REPLACE INTO botstances (BotID, StanceId) VALUES(%u, %u);", GetBotID(), GetBotStance());
|
StringFormat(query,"REPLACE INTO botstances (BotID, StanceId) VALUES(%u, %u);", GetBotID(), GetBotStance());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveStance()");
|
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveStance()");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::LoadTimers() {
|
void Bot::LoadTimers() {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -3028,8 +2973,8 @@ void Bot::LoadTimers() {
|
|||||||
"WHERE TimerID = bt.TimerID AND BotID = bt.BotID ) AND sn.classes%i <= %i;",
|
"WHERE TimerID = bt.TimerID AND BotID = bt.BotID ) AND sn.classes%i <= %i;",
|
||||||
GetBotID(), DisciplineReuseStart-1, DisciplineReuseStart-1, GetClass(), GetLevel());
|
GetBotID(), DisciplineReuseStart-1, DisciplineReuseStart-1, GetClass(), GetLevel());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadTimers()");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int TimerID = 0;
|
int TimerID = 0;
|
||||||
@ -3049,20 +2994,16 @@ void Bot::LoadTimers() {
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadTimers()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SaveTimers() {
|
void Bot::SaveTimers() {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM bottimers WHERE BotID = %u;", GetBotID());
|
StringFormat(query,"DELETE FROM bottimers WHERE BotID = %u;", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveTimers()");
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < MaxTimer; i++) {
|
for(int i = 0; i < MaxTimer; i++) {
|
||||||
@ -3071,16 +3012,13 @@ void Bot::SaveTimers() {
|
|||||||
StringFormat(query,"REPLACE INTO bottimers (BotID, TimerID, Value) VALUES(%u, %u, %u);",
|
StringFormat(query,"REPLACE INTO bottimers (BotID, TimerID, Value) VALUES(%u, %u, %u);",
|
||||||
GetBotID(), i+1, timers[i]);
|
GetBotID(), i+1, timers[i]);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(!database.RunQuery(query, &errorMessage)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveTimers()");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveTimers()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::Process()
|
bool Bot::Process()
|
||||||
@ -4284,43 +4222,31 @@ void Bot::Depop() {
|
|||||||
bool Bot::DeleteBot(std::string* errorMessage) {
|
bool Bot::DeleteBot(std::string* errorMessage) {
|
||||||
bool Result = false;
|
bool Result = false;
|
||||||
int TempCounter = 0;
|
int TempCounter = 0;
|
||||||
|
|
||||||
if(this->GetBotID() > 0) {
|
if(this->GetBotID() > 0) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
std::string errorMessage;
|
||||||
|
|
||||||
// TODO: These queries need to be ran together as a transaction.. ie, if one or more fail then they all will fail to commit to the database.
|
// TODO: These queries need to be ran together as a transaction.. ie, if one or more fail then they all will fail to commit to the database.
|
||||||
|
// TODO: Cleanup
|
||||||
StringFormat(query,"DELETE FROM botinventory WHERE botid = '%u'", this->GetBotID());
|
StringFormat(query,"DELETE FROM botinventory WHERE botid = '%u'", this->GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(database.RunQuery(query, &errorMessage))
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
TempCounter++;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM botbuffs WHERE botid = '%u'", this->GetBotID());
|
StringFormat(query, "DELETE FROM botbuffs WHERE botid = '%u'", this->GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(database.RunQuery(query, &errorMessage))
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
TempCounter++;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM botstances WHERE BotID = '%u'", this->GetBotID());
|
StringFormat(query, "DELETE FROM botstances WHERE BotID = '%u'", this->GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(database.RunQuery(query, &errorMessage))
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
TempCounter++;
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM bots WHERE BotID = '%u'", this->GetBotID());
|
StringFormat(query,"DELETE FROM bots WHERE BotID = '%u'", this->GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer)) {
|
if(database.RunQuery(query, &errorMessage))
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
TempCounter++;
|
||||||
|
|
||||||
if(TempCounter == 4)
|
if(TempCounter == 4)
|
||||||
@ -4381,7 +4307,7 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
|
|||||||
|
|
||||||
// Saves the specified item as an inventory record in the database for this bot.
|
// Saves the specified item as an inventory record in the database for this bot.
|
||||||
void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, std::string *errorMessage) {
|
void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, std::string *errorMessage) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
|
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
@ -4403,7 +4329,7 @@ void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, s
|
|||||||
(unsigned long)inst->GetColor(),(unsigned long)augslot[0],(unsigned long)augslot[1],
|
(unsigned long)inst->GetColor(),(unsigned long)augslot[0],(unsigned long)augslot[1],
|
||||||
(unsigned long)augslot[2],(unsigned long)augslot[3],(unsigned long)augslot[4]);
|
(unsigned long)augslot[2],(unsigned long)augslot[3],(unsigned long)augslot[4]);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
*errorMessage = std::string(errbuf);
|
*errorMessage = std::string(errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4411,15 +4337,15 @@ void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, s
|
|||||||
|
|
||||||
// Deletes the inventory record for the specified item from the database for this bot.
|
// Deletes the inventory record for the specified item from the database for this bot.
|
||||||
void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) {
|
void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(this->GetBotID() > 0 && slotID >= 0) {
|
if(this->GetBotID() > 0 && slotID >= 0) {
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM botinventory WHERE botid=%i AND slotid=%i", this->GetBotID(), slotID);
|
StringFormat(query,"DELETE FROM botinventory WHERE botid=%i AND slotid=%i", this->GetBotID(), slotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)){
|
if(!database.RunQuery(query, &errbuf)){
|
||||||
*errorMessage = std::string(errbuf);
|
// TODO: Log to zone.
|
||||||
}
|
}
|
||||||
m_inv.DeleteItem(slotID);
|
m_inv.DeleteItem(slotID);
|
||||||
}
|
}
|
||||||
@ -4429,7 +4355,7 @@ void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) {
|
|||||||
void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
|
void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
|
||||||
|
|
||||||
if(this->GetBotID() > 0) {
|
if(this->GetBotID() > 0) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
@ -4438,7 +4364,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
|
|||||||
"augslot3, augslot4, augslot5, instnodrop FROM botinventory "
|
"augslot3, augslot4, augslot5, instnodrop FROM botinventory "
|
||||||
"WHERE botid=%i order by slotid", this->GetBotID());
|
"WHERE botid=%i order by slotid", this->GetBotID());
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &DatasetResult)) {
|
if(database.RunQuery(query, &errbuf, &DatasetResult)) {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
int16 slot_id = atoi(DataRow[0]);
|
int16 slot_id = atoi(DataRow[0]);
|
||||||
uint32 item_id = atoi(DataRow[1]);
|
uint32 item_id = atoi(DataRow[1]);
|
||||||
@ -4523,14 +4449,14 @@ uint32 Bot::GetBotItemsCount(std::string *errorMessage) {
|
|||||||
uint32 Result = 0;
|
uint32 Result = 0;
|
||||||
|
|
||||||
if(this->GetBotID() > 0) {
|
if(this->GetBotID() > 0) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT COUNT(*) FROM botinventory WHERE botid=%i", this->GetBotID());
|
StringFormat(query,"SELECT COUNT(*) FROM botinventory WHERE botid=%i", this->GetBotID());
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &DatasetResult)) {
|
if(database.RunQuery(query, &errbuf, &DatasetResult)) {
|
||||||
if(mysql_num_rows(DatasetResult) == 1) {
|
if(mysql_num_rows(DatasetResult) == 1) {
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
DataRow = mysql_fetch_row(DatasetResult);
|
||||||
if(DataRow)
|
if(DataRow)
|
||||||
@ -4738,15 +4664,14 @@ uint32 Bot::GetBotIDByBotName(std::string botName) {
|
|||||||
|
|
||||||
if(!botName.empty()) {
|
if(!botName.empty()) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
|
|
||||||
StringFormat(query,"SELECT BotID FROM bots WHERE Name = '%s'", botName.c_str());
|
StringFormat(query,"SELECT BotID FROM bots WHERE Name = '%s'", botName.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Log this error to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -4758,9 +4683,6 @@ uint32 Bot::GetBotIDByBotName(std::string botName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Log this error to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
@ -4771,7 +4693,6 @@ Bot* Bot::LoadBot(uint32 botID, std::string* errorMessage) {
|
|||||||
|
|
||||||
if(botID > 0) {
|
if(botID > 0) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -4783,8 +4704,8 @@ Bot* Bot::LoadBot(uint32 botID, std::string* errorMessage) {
|
|||||||
"BotCreateDate, LastSpawnDate, TotalPlayTime, LastZoneId "
|
"BotCreateDate, LastSpawnDate, TotalPlayTime, LastZoneId "
|
||||||
"FROM bots WHERE BotID = '%u'", botID);
|
"FROM bots WHERE BotID = '%u'", botID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Log this error to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -4807,14 +4728,13 @@ std::list<uint32> Bot::GetGroupedBotsByGroupId(uint32 groupId, std::string* erro
|
|||||||
|
|
||||||
if(groupId > 0) {
|
if(groupId > 0) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"select g.mobid as BotID from vwGroups as g join bots as b on g.mobid = b.BotId and g.mobtype = 'B' where g.groupid = %u", groupId);
|
StringFormat(query,"select g.mobid as BotID from vwGroups as g join bots as b on g.mobid = b.BotId and g.mobtype = 'B' where g.groupid = %u", groupId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -4898,14 +4818,13 @@ std::list<BotsAvailableList> Bot::GetBotList(uint32 botOwnerCharacterID, std::st
|
|||||||
|
|
||||||
if(botOwnerCharacterID > 0) {
|
if(botOwnerCharacterID > 0) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT BotID, Name, Class, BotLevel, Race FROM bots WHERE BotOwnerCharacterID = '%u'", botOwnerCharacterID);
|
StringFormat(query,"SELECT BotID, Name, Class, BotLevel, Race FROM bots WHERE BotOwnerCharacterID = '%u'", botOwnerCharacterID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Log Error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -4931,7 +4850,7 @@ std::list<BotsAvailableList> Bot::GetBotList(uint32 botOwnerCharacterID, std::st
|
|||||||
|
|
||||||
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
||||||
std::list<SpawnedBotsList> Result;
|
std::list<SpawnedBotsList> Result;
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
@ -4939,8 +4858,8 @@ std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string*
|
|||||||
StringFormat(query,"SELECT bot_name, zone_name FROM botleader WHERE leaderid=%i", characterID);
|
StringFormat(query,"SELECT bot_name, zone_name FROM botleader WHERE leaderid=%i", characterID);
|
||||||
|
|
||||||
if(characterID > 0) {
|
if(characterID > 0) {
|
||||||
if(!database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: Log Error
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
uint32 RowCount = mysql_num_rows(DatasetResult);
|
||||||
@ -4967,7 +4886,6 @@ std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string*
|
|||||||
|
|
||||||
void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) {
|
void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) {
|
||||||
if(botGroup && !botGroupName.empty()) {
|
if(botGroup && !botGroupName.empty()) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
Mob* tempGroupLeader = botGroup->GetLeader();
|
Mob* tempGroupLeader = botGroup->GetLeader();
|
||||||
@ -4979,8 +4897,8 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e
|
|||||||
|
|
||||||
StringFormat(query,"INSERT into botgroup (BotGroupLeaderBotId, BotGroupName) values (%u, '%s')", botGroupLeaderBotId, botGroupName.c_str());
|
StringFormat(query,"INSERT into botgroup (BotGroupLeaderBotId, BotGroupName) values (%u, '%s')", botGroupLeaderBotId, botGroupName.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf, 0, 0, &botGroupId)) {
|
if(!database.RunQuery(query, errorMessage, 0, 0, &botGroupId)) {
|
||||||
*errorMessage = std::string(errbuf);
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(botGroupId > 0) {
|
if(botGroupId > 0) {
|
||||||
@ -4993,8 +4911,8 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e
|
|||||||
StringFormat(query, "INSERT into botgroupmembers (BotGroupId, BotId) values (%u, %u)",
|
StringFormat(query, "INSERT into botgroupmembers (BotGroupId, BotId) values (%u, %u)",
|
||||||
botGroupId, botGroupMemberBotId);
|
botGroupId, botGroupMemberBotId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, errorMessage)) {
|
||||||
*errorMessage = std::string(errbuf);
|
// TODO: Log error message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5006,7 +4924,7 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(!botGroupName.empty()) {
|
if(!botGroupName.empty()) {
|
||||||
@ -5016,14 +4934,14 @@ void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId);
|
StringFormat(query, "DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
*errorMessage = std::string(errbuf);
|
*errorMessage = std::string(errbuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId);
|
StringFormat(query, "DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
*errorMessage = std::string(errbuf);
|
*errorMessage = std::string(errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5033,7 +4951,6 @@ void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
|||||||
|
|
||||||
std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) {
|
std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) {
|
||||||
std::list<BotGroup> Result;
|
std::list<BotGroup> Result;
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
@ -5045,8 +4962,8 @@ std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* err
|
|||||||
|
|
||||||
StringFormat(query,"select BotId from botgroupmembers where BotGroupId = %u", botGroupId);
|
StringFormat(query,"select BotId from botgroupmembers where BotGroupId = %u", botGroupId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
uint32 RowCount = mysql_num_rows(DatasetResult);
|
||||||
@ -5078,15 +4995,14 @@ std::list<BotGroupList> Bot::GetBotGroupListByBotOwnerCharacterId(uint32 botOwne
|
|||||||
std::list<BotGroupList> result;
|
std::list<BotGroupList> result;
|
||||||
|
|
||||||
if(botOwnerCharacterId > 0) {
|
if(botOwnerCharacterId > 0) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"select BotGroupName, BotGroupLeaderName from vwBotGroups where BotOwnerCharacterId = %u", botOwnerCharacterId);
|
StringFormat(query,"select BotGroupName, BotGroupLeaderName from vwBotGroups where BotOwnerCharacterId = %u", botOwnerCharacterId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
uint32 RowCount = mysql_num_rows(DatasetResult);
|
||||||
@ -5154,15 +5070,14 @@ uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName
|
|||||||
uint32 result = 0;
|
uint32 result = 0;
|
||||||
|
|
||||||
if(botOwnerCharacterId > 0 && !botGroupName.empty()) {
|
if(botOwnerCharacterId > 0 && !botGroupName.empty()) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"select BotGroupId, BotGroupName from vwBotGroups where BotOwnerCharacterId = %u", botOwnerCharacterId);
|
StringFormat(query,"select BotGroupId, BotGroupName from vwBotGroups where BotOwnerCharacterId = %u", botOwnerCharacterId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
uint32 RowCount = mysql_num_rows(DatasetResult);
|
||||||
@ -5195,15 +5110,14 @@ uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* e
|
|||||||
uint32 result = 0;
|
uint32 result = 0;
|
||||||
|
|
||||||
if(!botGroupName.empty()) {
|
if(!botGroupName.empty()) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"select BotGroupId from vwBotGroups where BotGroupName = '%s'", botGroupName.c_str());
|
StringFormat(query,"select BotGroupId from vwBotGroups where BotGroupName = '%s'", botGroupName.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(!database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: log error.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
uint32 RowCount = mysql_num_rows(DatasetResult);
|
||||||
@ -5263,14 +5177,13 @@ uint32 Bot::AllowedBotSpawns(uint32 botOwnerCharacterID, std::string* errorMessa
|
|||||||
uint32 Result = 0;
|
uint32 Result = 0;
|
||||||
|
|
||||||
if(botOwnerCharacterID > 0) {
|
if(botOwnerCharacterID > 0) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT value FROM quest_globals WHERE name='bot_spawn_limit' and charid=%i", botOwnerCharacterID);
|
StringFormat(query,"SELECT value FROM quest_globals WHERE name='bot_spawn_limit' and charid=%i", botOwnerCharacterID);
|
||||||
|
|
||||||
if(database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
if(mysql_num_rows(DatasetResult) == 1) {
|
if(mysql_num_rows(DatasetResult) == 1) {
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
DataRow = mysql_fetch_row(DatasetResult);
|
||||||
if(DataRow)
|
if(DataRow)
|
||||||
@ -5279,8 +5192,10 @@ uint32 Bot::AllowedBotSpawns(uint32 botOwnerCharacterID, std::string* errorMessa
|
|||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
*errorMessage = std::string(ErrBuf);
|
// TODO: Log error.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5303,14 +5218,13 @@ uint32 Bot::CreatedBotCount(uint32 botOwnerCharacterID, std::string* errorMessag
|
|||||||
uint32 Result = 0;
|
uint32 Result = 0;
|
||||||
|
|
||||||
if(botOwnerCharacterID > 0) {
|
if(botOwnerCharacterID > 0) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT COUNT(BotID) FROM bots WHERE BotOwnerCharacterID=%i", botOwnerCharacterID);
|
StringFormat(query,"SELECT COUNT(BotID) FROM bots WHERE BotOwnerCharacterID=%i", botOwnerCharacterID);
|
||||||
|
|
||||||
if(database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
if(mysql_num_rows(DatasetResult) == 1) {
|
if(mysql_num_rows(DatasetResult) == 1) {
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
DataRow = mysql_fetch_row(DatasetResult);
|
||||||
if(DataRow)
|
if(DataRow)
|
||||||
@ -5320,7 +5234,9 @@ uint32 Bot::CreatedBotCount(uint32 botOwnerCharacterID, std::string* errorMessag
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*errorMessage = std::string(ErrBuf);
|
{
|
||||||
|
// TODO: Log error.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5331,14 +5247,13 @@ uint32 Bot::GetBotOwnerCharacterID(uint32 botID, std::string* errorMessage) {
|
|||||||
uint32 Result = 0;
|
uint32 Result = 0;
|
||||||
|
|
||||||
if(botID > 0) {
|
if(botID > 0) {
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
StringFormat(query,"SELECT BotOwnerCharacterID FROM bots WHERE BotID = %u", botID);
|
StringFormat(query,"SELECT BotOwnerCharacterID FROM bots WHERE BotID = %u", botID);
|
||||||
|
|
||||||
if(database.RunQuery(query, ErrBuf, &DatasetResult)) {
|
if(database.RunQuery(query, errorMessage, &DatasetResult)) {
|
||||||
if(mysql_num_rows(DatasetResult) == 1) {
|
if(mysql_num_rows(DatasetResult) == 1) {
|
||||||
if(DataRow = mysql_fetch_row(DatasetResult))
|
if(DataRow = mysql_fetch_row(DatasetResult))
|
||||||
Result = atoi(DataRow[0]);
|
Result = atoi(DataRow[0]);
|
||||||
@ -5347,7 +5262,9 @@ uint32 Bot::GetBotOwnerCharacterID(uint32 botID, std::string* errorMessage) {
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*errorMessage = std::string(ErrBuf);
|
{
|
||||||
|
//TODO: log error message.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9326,14 +9243,14 @@ bool Bot::ProcessGuildRemoval(Client* guildOfficer, std::string botName) {
|
|||||||
void Bot::SetBotGuildMembership(uint32 botId, uint32 guildid, uint8 rank) {
|
void Bot::SetBotGuildMembership(uint32 botId, uint32 guildid, uint8 rank) {
|
||||||
if(botId > 0) {
|
if(botId > 0) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(guildid > 0) {
|
if(guildid > 0) {
|
||||||
|
|
||||||
StringFormat(query,"REPLACE INTO botguildmembers SET char_id = %u, guild_id = %u, rank = %u;", botId, guildid, rank);
|
StringFormat(query,"REPLACE INTO botguildmembers SET char_id = %u, guild_id = %u, rank = %u;", botId, guildid, rank);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
errorMessage = std::string(errbuf);
|
errorMessage = std::string(errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9341,7 +9258,7 @@ void Bot::SetBotGuildMembership(uint32 botId, uint32 guildid, uint8 rank) {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM botguildmembers WHERE char_id = %u;",botId);
|
StringFormat(query, "DELETE FROM botguildmembers WHERE char_id = %u;",botId);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
errorMessage = std::string(errbuf);
|
errorMessage = std::string(errbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9356,7 +9273,6 @@ void Bot::LoadGuildMembership(uint32* guildId, uint8* guildRank, std::string* gu
|
|||||||
if(guildId && guildRank && guildName) {
|
if(guildId && guildRank && guildName) {
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -9364,8 +9280,8 @@ void Bot::LoadGuildMembership(uint32* guildId, uint8* guildRank, std::string* gu
|
|||||||
"AS gm JOIN guilds AS g ON gm.guild_id = g.id "
|
"AS gm JOIN guilds AS g ON gm.guild_id = g.id "
|
||||||
"WHERE gm.char_id = %u AND gm.mobtype = 'B';", GetBotID());
|
"WHERE gm.char_id = %u AND gm.mobtype = 'B';", GetBotID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: Record this error message to zone error log
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -9379,9 +9295,6 @@ void Bot::LoadGuildMembership(uint32* guildId, uint8* guildRank, std::string* gu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Record this error message to zone error log
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3856,14 +3856,14 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
|
|||||||
|
|
||||||
void Client::KeyRingLoad()
|
void Client::KeyRingLoad()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
StringFormat(query, "SELECT item_id FROM keyring WHERE char_id='%i' ORDER BY item_id",character_id);
|
StringFormat(query, "SELECT item_id FROM keyring WHERE char_id='%i' ORDER BY item_id",character_id);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while(0 != (row = mysql_fetch_row(result))){
|
while(0 != (row = mysql_fetch_row(result))){
|
||||||
keyring.push_back(atoi(row[0]));
|
keyring.push_back(atoi(row[0]));
|
||||||
@ -3878,7 +3878,7 @@ void Client::KeyRingLoad()
|
|||||||
void Client::KeyRingAdd(uint32 item_id)
|
void Client::KeyRingAdd(uint32 item_id)
|
||||||
{
|
{
|
||||||
if(0==item_id)return;
|
if(0==item_id)return;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
std::string query;
|
std::string query;
|
||||||
bool bFound = KeyRingCheck(item_id);
|
bool bFound = KeyRingCheck(item_id);
|
||||||
@ -3887,7 +3887,7 @@ void Client::KeyRingAdd(uint32 item_id)
|
|||||||
StringFormat(query, "INSERT INTO keyring(char_id,item_id) VALUES(%i,%i)",
|
StringFormat(query, "INSERT INTO keyring(char_id,item_id) VALUES(%i,%i)",
|
||||||
character_id, item_id);
|
character_id, item_id);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, 0, &affected_rows))
|
if(database.RunQuery(query, &errbuf, 0, &affected_rows))
|
||||||
{
|
{
|
||||||
Message(4,"Added to keyring.");
|
Message(4,"Added to keyring.");
|
||||||
}
|
}
|
||||||
@ -3928,14 +3928,14 @@ void Client::KeyRingList()
|
|||||||
|
|
||||||
bool Client::IsDiscovered(uint32 itemid) {
|
bool Client::IsDiscovered(uint32 itemid) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query,"SELECT count(*) FROM discovered_items WHERE item_id = '%lu'", itemid);
|
StringFormat(query,"SELECT count(*) FROM discovered_items WHERE item_id = '%lu'", itemid);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (atoi(row[0]))
|
if (atoi(row[0]))
|
||||||
@ -3954,7 +3954,7 @@ bool Client::IsDiscovered(uint32 itemid) {
|
|||||||
|
|
||||||
void Client::DiscoverItem(uint32 itemid) {
|
void Client::DiscoverItem(uint32 itemid) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -3963,7 +3963,7 @@ void Client::DiscoverItem(uint32 itemid) {
|
|||||||
"discovered_date=UNIX_TIMESTAMP(), account_status=%i",
|
"discovered_date=UNIX_TIMESTAMP(), account_status=%i",
|
||||||
itemid, GetName(), Admin());
|
itemid, GetName(), Admin());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
@ -5109,7 +5109,7 @@ const bool Client::IsMQExemptedArea(uint32 zoneID, float x, float y, float z) co
|
|||||||
void Client::SendRewards()
|
void Client::SendRewards()
|
||||||
{
|
{
|
||||||
std::vector<ClientReward> rewards;
|
std::vector<ClientReward> rewards;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -5119,7 +5119,7 @@ void Client::SendRewards()
|
|||||||
"ORDER by reward_id",
|
"ORDER by reward_id",
|
||||||
AccountID());
|
AccountID());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query,&errbuf,&result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -5132,7 +5132,7 @@ void Client::SendRewards()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::SendRewards(): %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::SendRewards(): %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5199,7 +5199,7 @@ bool Client::TryReward(uint32 claim_id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -5211,7 +5211,7 @@ bool Client::TryReward(uint32 claim_id)
|
|||||||
"account_id=%i AND reward_id=%i",
|
"account_id=%i AND reward_id=%i",
|
||||||
AccountID(), claim_id);
|
AccountID(), claim_id);
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query,&errbuf,&result))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if(row)
|
if(row)
|
||||||
@ -5227,7 +5227,7 @@ bool Client::TryReward(uint32 claim_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5257,9 +5257,9 @@ bool Client::TryReward(uint32 claim_id)
|
|||||||
"account_id=%i AND reward_id=%i",
|
"account_id=%i AND reward_id=%i",
|
||||||
AccountID(), claim_id);
|
AccountID(), claim_id);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5268,9 +5268,9 @@ bool Client::TryReward(uint32 claim_id)
|
|||||||
" WHERE account_id=%i AND reward_id=%i",
|
" WHERE account_id=%i AND reward_id=%i",
|
||||||
AccountID(), claim_id);
|
AccountID(), claim_id);
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf))
|
if(!database.RunQuery(query,&errbuf))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::TryReward(): %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7637,7 +7637,7 @@ some day.
|
|||||||
|
|
||||||
void Client::LoadAccountFlags()
|
void Client::LoadAccountFlags()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -7648,7 +7648,7 @@ void Client::LoadAccountFlags()
|
|||||||
"account_flags WHERE p_accid = '%d'",
|
"account_flags WHERE p_accid = '%d'",
|
||||||
account_id);
|
account_id);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while(row = mysql_fetch_row(result))
|
while(row = mysql_fetch_row(result))
|
||||||
{
|
{
|
||||||
@ -7666,14 +7666,14 @@ void Client::LoadAccountFlags()
|
|||||||
|
|
||||||
void Client::SetAccountFlag(std::string flag, std::string val)
|
void Client::SetAccountFlag(std::string flag, std::string val)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "REPLACE INTO account_flags (p_accid, p_flag, p_value) "
|
StringFormat(query, "REPLACE INTO account_flags (p_accid, p_flag, p_value) "
|
||||||
"VALUES( '%d', '%s', '%s')",
|
"VALUES( '%d', '%s', '%s')",
|
||||||
account_id, flag.c_str(), val.c_str());
|
account_id, flag.c_str(), val.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
std::cerr << "Error in SetAccountFlags query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in SetAccountFlags query '" << query << "' " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3240,14 +3240,14 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
if (sayid && sayid > 0)
|
if (sayid && sayid > 0)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid);
|
StringFormat(query, "SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid);
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
if (mysql_num_rows(result) == 1)
|
if (mysql_num_rows(result) == 1)
|
||||||
{
|
{
|
||||||
@ -8733,10 +8733,10 @@ void Client::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DBA_b1_Entity_Client_Save: {
|
case DBA_b1_Entity_Client_Save: {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
||||||
if (dbaq->GetAnswer(errbuf, 0, &affected_rows) && affected_rows == 1) {
|
if (dbaq->GetAnswer(&errbuf, 0, &affected_rows) && affected_rows == 1) {
|
||||||
if (dbaq->QPT()) {
|
if (dbaq->QPT()) {
|
||||||
SaveBackup();
|
SaveBackup();
|
||||||
}
|
}
|
||||||
@ -8745,7 +8745,7 @@ void Client::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
|
|||||||
std::cout << "Async client save failed. '" << errbuf << "'" << std::endl;
|
std::cout << "Async client save failed. '" << errbuf << "'" << std::endl;
|
||||||
Message(13, "Error: Asyncronous save of your character failed.");
|
Message(13, "Error: Asyncronous save of your character failed.");
|
||||||
if (Admin() >= 200)
|
if (Admin() >= 200)
|
||||||
Message(13, "errbuf: %s", errbuf);
|
Message(13, "errbuf: %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
pQueuedSaveWorkID = 0;
|
pQueuedSaveWorkID = 0;
|
||||||
break;
|
break;
|
||||||
@ -8763,7 +8763,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) {
|
|||||||
EQApplicationPacket* outapp = 0;
|
EQApplicationPacket* outapp = 0;
|
||||||
MYSQL_RES* result = 0;
|
MYSQL_RES* result = 0;
|
||||||
bool loaditems = 0;
|
bool loaditems = 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
for (i=1; i<=3; i++) {
|
for (i=1; i<=3; i++) {
|
||||||
@ -8772,7 +8772,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) {
|
|||||||
std::cout << "Error in FinishConnState2(): dbaq==0" << std::endl;
|
std::cout << "Error in FinishConnState2(): dbaq==0" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!dbaq->GetAnswer(errbuf, &result)) {
|
if (!dbaq->GetAnswer(&errbuf, &result)) {
|
||||||
std::cout << "Error in FinishConnState2(): !dbaq[" << dbaq->QPT() << "]->GetAnswer(): " << errbuf << std::endl;
|
std::cout << "Error in FinishConnState2(): !dbaq[" << dbaq->QPT() << "]->GetAnswer(): " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -11519,7 +11519,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result = nullptr;
|
MYSQL_RES *result = nullptr;
|
||||||
MYSQL_ROW row = 0;
|
MYSQL_ROW row = 0;
|
||||||
@ -11533,7 +11533,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app)
|
|||||||
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
||||||
m_pp.class_, m_pp.deity, m_pp.race);
|
m_pp.class_, m_pp.deity, m_pp.race);
|
||||||
|
|
||||||
database.RunQuery(query, errbuf, &result);
|
database.RunQuery(query, &errbuf, &result);
|
||||||
|
|
||||||
if(!result) {
|
if(!result) {
|
||||||
LogFile->write(EQEMuLog::Error, "No valid start zones found for /setstartcity");
|
LogFile->write(EQEMuLog::Error, "No valid start zones found for /setstartcity");
|
||||||
@ -11564,7 +11564,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app)
|
|||||||
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
||||||
m_pp.class_, m_pp.deity, m_pp.race);
|
m_pp.class_, m_pp.deity, m_pp.race);
|
||||||
|
|
||||||
database.RunQuery(query,errbuf,&result);
|
database.RunQuery(query,&errbuf,&result);
|
||||||
|
|
||||||
Message(15,"Use \"/startcity #\" to choose a home city from the following list:");
|
Message(15,"Use \"/startcity #\" to choose a home city from the following list:");
|
||||||
char* name;
|
char* name;
|
||||||
@ -11698,7 +11698,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
GMSearchCorpse_Struct *gmscs = (GMSearchCorpse_Struct *)app->pBuffer;
|
GMSearchCorpse_Struct *gmscs = (GMSearchCorpse_Struct *)app->pBuffer;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *Result;
|
MYSQL_RES *Result;
|
||||||
MYSQL_ROW Row;
|
MYSQL_ROW Row;
|
||||||
@ -11711,7 +11711,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
|
|||||||
"player_corpses where charname like '%%%s%%' order by charname limit %i",
|
"player_corpses where charname like '%%%s%%' order by charname limit %i",
|
||||||
escSearchString.c_str(), MaxResults);
|
escSearchString.c_str(), MaxResults);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &Result))
|
if (database.RunQuery(query, &errbuf, &Result))
|
||||||
{
|
{
|
||||||
|
|
||||||
int NumberOfRows = mysql_num_rows(Result);
|
int NumberOfRows = mysql_num_rows(Result);
|
||||||
@ -11773,7 +11773,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app)
|
|||||||
SendPopupToClient("Corpses", PopupText.c_str());
|
SendPopupToClient("Corpses", PopupText.c_str());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Message(0, "Query failed: %s.", errbuf);
|
Message(0, "Query failed: %s.", errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
362
zone/command.cpp
362
zone/command.cpp
File diff suppressed because it is too large
Load Diff
@ -569,7 +569,7 @@ void Doors::DumpDoor(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version) {
|
int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 version) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 v
|
|||||||
|
|
||||||
StringFormat(query,"SELECT MAX(id), count(*) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)",zone_name, version);
|
StringFormat(query,"SELECT MAX(id), count(*) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)",zone_name, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (row != nullptr && row[1] != 0) {
|
if (row != nullptr && row[1] != 0) {
|
||||||
int32 ret = atoi(row[1]);
|
int32 ret = atoi(row[1]);
|
||||||
@ -601,7 +601,7 @@ int32 ZoneDatabase::GetDoorsCount(uint32* oMaxID, const char *zone_name, int16 v
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) {
|
int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 oMaxID = 0;
|
uint32 oMaxID = 0;
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) {
|
|||||||
|
|
||||||
StringFormat(query, "SELECT MAX(id) FROM doors WHERE zone='%s' AND version=%u", zone_name, version);
|
StringFormat(query, "SELECT MAX(id) FROM doors WHERE zone='%s' AND version=%u", zone_name, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (row != nullptr && row[1] != 0) {
|
if (row != nullptr && row[1] != 0) {
|
||||||
if (row[0])
|
if (row[0])
|
||||||
@ -632,7 +632,7 @@ int32 ZoneDatabase::GetDoorsCountPlusOne(const char *zone_name, int16 version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) {
|
int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 oMaxID = 0;
|
uint32 oMaxID = 0;
|
||||||
|
|
||||||
@ -641,7 +641,7 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version)
|
|||||||
|
|
||||||
StringFormat(query, "SELECT MAX(doorid) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)", zone_name, version);
|
StringFormat(query, "SELECT MAX(doorid) FROM doors WHERE zone='%s' AND (version=%u OR version=-1)", zone_name, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (row != nullptr && row[1] != 0) {
|
if (row != nullptr && row[1] != 0) {
|
||||||
if (row[0])
|
if (row[0])
|
||||||
@ -663,7 +663,7 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version)
|
|||||||
|
|
||||||
bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, 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...");
|
LogFile->write(EQEMuLog::Status, "Loading Doors from database...");
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -677,7 +677,7 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
|
|||||||
"FROM doors WHERE zone='%s' AND (version=%u OR version=-1) "
|
"FROM doors WHERE zone='%s' AND (version=%u OR version=-1) "
|
||||||
"ORDER BY doorid asc", zone_name, version);
|
"ORDER BY doorid asc", zone_name, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
int32 r;
|
int32 r;
|
||||||
for(r = 0; (row = mysql_fetch_row(result)); r++) {
|
for(r = 0; (row = mysql_fetch_row(result)); r++) {
|
||||||
if(r >= iDoorCount) {
|
if(r >= iDoorCount) {
|
||||||
|
|||||||
@ -85,7 +85,7 @@ CREATE TABLE fishing (
|
|||||||
|
|
||||||
// This allows EqEmu to have zone specific foraging - BoB
|
// This allows EqEmu to have zone specific foraging - BoB
|
||||||
uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
|
uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -103,7 +103,7 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT itemid,chance FROM forage WHERE zoneid= '%i' and level <= '%i' LIMIT %i", ZoneID, skill, FORAGE_ITEM_LIMIT);
|
StringFormat(query,"SELECT itemid,chance FROM forage WHERE zoneid= '%i' and level <= '%i' LIMIT %i", ZoneID, skill, FORAGE_ITEM_LIMIT);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result)) && (index < FORAGE_ITEM_LIMIT)) {
|
while ((row = mysql_fetch_row(result)) && (index < FORAGE_ITEM_LIMIT)) {
|
||||||
item[index] = atoi(row[0]);
|
item[index] = atoi(row[0]);
|
||||||
@ -116,7 +116,7 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Forage query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Forage query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
|
|||||||
|
|
||||||
uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance)
|
uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -163,7 +163,7 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id,
|
|||||||
|
|
||||||
StringFormat(query,"SELECT itemid,chance,npc_id,npc_chance FROM fishing WHERE (zoneid= '%i' || zoneid = 0) and skill_level <= '%i'",ZoneID, skill );
|
StringFormat(query,"SELECT itemid,chance,npc_id,npc_chance FROM fishing WHERE (zoneid= '%i' || zoneid = 0) and skill_level <= '%i'",ZoneID, skill );
|
||||||
|
|
||||||
if (RunQuery(query,errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result))&&(index<50)) {
|
while ((row = mysql_fetch_row(result))&&(index<50)) {
|
||||||
item[index] = atoi(row[0]);
|
item[index] = atoi(row[0]);
|
||||||
|
|||||||
@ -956,17 +956,17 @@ void Group::TeleportGroup(Mob* sender, uint32 zoneID, uint16 instance_id, float
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Group::LearnMembers() {
|
bool Group::LearnMembers() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT name FROM group_id WHERE groupid=%lu", (unsigned long)GetID());
|
StringFormat(query, "SELECT name FROM group_id WHERE groupid=%lu", (unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query,&errbuf,&result)){
|
||||||
if(mysql_num_rows(result) < 1) { //could prolly be 2
|
if(mysql_num_rows(result) < 1) { //could prolly be 2
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
LogFile->write(EQEMuLog::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -1272,15 +1272,14 @@ void Group::DelegateMainTank(const char *NewMainTankName, uint8 toggle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(updateDB) {
|
if(updateDB) {
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET maintank='%s' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET maintank='%s' WHERE gid=%i LIMIT 1",
|
||||||
MainTankName.c_str(), GetID());
|
MainTankName.c_str(), GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to set group main tank: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to set group main tank: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1322,15 +1321,14 @@ void Group::DelegateMainAssist(const char *NewMainAssistName, uint8 toggle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(updateDB) {
|
if(updateDB) {
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET assist='%s' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET assist='%s' WHERE gid=%i LIMIT 1",
|
||||||
MainAssistName.c_str(), GetID());
|
MainAssistName.c_str(), GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to set group main assist: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to set group main assist: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1372,15 +1370,14 @@ void Group::DelegatePuller(const char *NewPullerName, uint8 toggle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(updateDB) {
|
if(updateDB) {
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET puller='%s' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET puller='%s' WHERE gid=%i LIMIT 1",
|
||||||
PullerName.c_str(), GetID());
|
PullerName.c_str(), GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to set group main puller: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to set group main puller: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1527,15 +1524,15 @@ void Group::UnDelegateMainTank(const char *OldMainTankName, uint8 toggle)
|
|||||||
// informing them of the change and update the group_leaders table.
|
// informing them of the change and update the group_leaders table.
|
||||||
//
|
//
|
||||||
if(OldMainTankName == MainTankName) {
|
if(OldMainTankName == MainTankName) {
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET maintank='' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET maintank='' WHERE gid=%i LIMIT 1",
|
||||||
GetID());
|
GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to clear group main tank: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to clear group main tank: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
if(!toggle) {
|
if(!toggle) {
|
||||||
for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) {
|
for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) {
|
||||||
@ -1581,15 +1578,14 @@ void Group::UnDelegateMainAssist(const char *OldMainAssistName, uint8 toggle)
|
|||||||
|
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET assist='' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET assist='' WHERE gid=%i LIMIT 1",
|
||||||
GetID());
|
GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to clear group main assist: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to clear group main assist: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
|
|
||||||
if(!toggle)
|
if(!toggle)
|
||||||
@ -1614,14 +1610,14 @@ void Group::UnDelegatePuller(const char *OldPullerName, uint8 toggle)
|
|||||||
// informing them of the change and update the group_leaders table.
|
// informing them of the change and update the group_leaders table.
|
||||||
//
|
//
|
||||||
if(OldPullerName == PullerName) {
|
if(OldPullerName == PullerName) {
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET puller='' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET puller='' WHERE gid=%i LIMIT 1",
|
||||||
GetID());
|
GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to clear group main puller: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to clear group main puller: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
if(!toggle) {
|
if(!toggle) {
|
||||||
for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) {
|
for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) {
|
||||||
@ -1756,15 +1752,15 @@ void Group::DelegateMarkNPC(const char *NewNPCMarkerName)
|
|||||||
if(members[i] && members[i]->IsClient())
|
if(members[i] && members[i]->IsClient())
|
||||||
NotifyMarkNPC(members[i]->CastToClient());
|
NotifyMarkNPC(members[i]->CastToClient());
|
||||||
|
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET marknpc='%s' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET marknpc='%s' WHERE gid=%i LIMIT 1",
|
||||||
NewNPCMarkerName, GetID());
|
NewNPCMarkerName, GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to set group mark npc: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to set group mark npc: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1843,15 +1839,15 @@ void Group::UnDelegateMarkNPC(const char *OldNPCMarkerName)
|
|||||||
|
|
||||||
NPCMarkerName.clear();
|
NPCMarkerName.clear();
|
||||||
|
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE group_leaders SET marknpc='' WHERE gid=%i LIMIT 1",
|
StringFormat(query, "UPDATE group_leaders SET marknpc='' WHERE gid=%i LIMIT 1",
|
||||||
GetID());
|
GetID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to clear group marknpc: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to clear group marknpc: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1874,9 +1870,9 @@ void Group::SaveGroupLeaderAA()
|
|||||||
|
|
||||||
query.append(endingOfQuery);
|
query.append(endingOfQuery);
|
||||||
|
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
if (!database.RunQuery(query, errbuff))
|
if (!database.RunQuery(query, &errbuff))
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to store LeadershipAA: %s\n", errbuff);
|
LogFile->write(EQEMuLog::Error, "Unable to store LeadershipAA: %s\n", errbuff.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -380,15 +380,15 @@ void Client::GuildChangeRank(const char* name, uint32 guild_id, uint32 oldrank,
|
|||||||
|
|
||||||
bool ZoneDatabase::CheckGuildDoor(uint8 doorid,uint16 guild_id,const char* zone) {
|
bool ZoneDatabase::CheckGuildDoor(uint8 doorid,uint16 guild_id,const char* zone) {
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query, "SELECT guild FROM doors where doorid=%i AND zone='%s'",
|
StringFormat(query, "SELECT guild FROM doors where doorid=%i AND zone='%s'",
|
||||||
doorid-128, zone);
|
doorid-128, zone);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in CheckGuildDoor query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in CheckGuildDoor query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
@ -413,7 +413,7 @@ bool ZoneDatabase::CheckGuildDoor(uint8 doorid,uint16 guild_id,const char* zone)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::SetGuildDoor(uint8 doorid,uint16 guild_id, const char* zone) {
|
bool ZoneDatabase::SetGuildDoor(uint8 doorid,uint16 guild_id, const char* zone) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
if (doorid > 127)
|
if (doorid > 127)
|
||||||
@ -422,8 +422,8 @@ bool ZoneDatabase::SetGuildDoor(uint8 doorid,uint16 guild_id, const char* zone)
|
|||||||
StringFormat(query, "UPDATE doors SET guild = %i WHERE (doorid=%i) AND (zone='%s')",
|
StringFormat(query, "UPDATE doors SET guild = %i WHERE (doorid=%i) AND (zone='%s')",
|
||||||
guild_id, doorid, zone);
|
guild_id, doorid, zone);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, nullptr,&affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in SetGuildDoor query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in SetGuildDoor query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -646,7 +646,7 @@ GuildBankManager::~GuildBankManager()
|
|||||||
|
|
||||||
bool GuildBankManager::Load(uint32 GuildID)
|
bool GuildBankManager::Load(uint32 GuildID)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -654,7 +654,7 @@ bool GuildBankManager::Load(uint32 GuildID)
|
|||||||
StringFormat(query, "SELECT `area`, `slot`, `itemid`, `qty`, `donator`, `permissions`, `whofor` "
|
StringFormat(query, "SELECT `area`, `slot`, `itemid`, `qty`, `donator`, `permissions`, `whofor` "
|
||||||
"FROM `guild_bank` WHERE `guildid` = %i", GuildID);
|
"FROM `guild_bank` WHERE `guildid` = %i", GuildID);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
GuildBank *Bank = new GuildBank;
|
GuildBank *Bank = new GuildBank;
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ bool GuildBankManager::Load(uint32 GuildID)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "Error Loading guild bank: %s, %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "Error Loading guild bank: %s, %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -924,7 +924,7 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
@ -934,9 +934,9 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32
|
|||||||
GuildID, Area, Slot, ItemID, QtyOrCharges,
|
GuildID, Area, Slot, ItemID, QtyOrCharges,
|
||||||
Donator, Permissions, WhoFor);
|
Donator, Permissions, WhoFor);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "Insert Error: %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "Insert Error: %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1006,16 +1006,16 @@ int GuildBankManager::Promote(uint32 GuildID, int SlotID)
|
|||||||
|
|
||||||
strn0cpy((*Iterator)->Items.MainArea[MainSlot].WhoFor, (*Iterator)->Items.DepositArea[SlotID].WhoFor, sizeof((*Iterator)->Items.MainArea[MainSlot].WhoFor));
|
strn0cpy((*Iterator)->Items.MainArea[MainSlot].WhoFor, (*Iterator)->Items.DepositArea[SlotID].WhoFor, sizeof((*Iterator)->Items.MainArea[MainSlot].WhoFor));
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE `guild_bank` SET `area` = 1, `slot` = %i WHERE "
|
StringFormat(query, "UPDATE `guild_bank` SET `area` = 1, `slot` = %i WHERE "
|
||||||
"`guildid` = %i AND `area` = 0 AND `slot` = %i LIMIT 1",
|
"`guildid` = %i AND `area` = 0 AND `slot` = %i LIMIT 1",
|
||||||
MainSlot, GuildID, SlotID);
|
MainSlot, GuildID, SlotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "error promoting item: %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "error promoting item: %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1066,13 +1066,13 @@ void GuildBankManager::SetPermissions(uint32 GuildID, uint16 SlotID, uint32 Perm
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE `guild_bank` SET `permissions` = %i, `whofor` = '%s' WHERE `guildid` = %i AND `area` = 1 AND `slot` = %i LIMIT 1",Permissions, MemberName, GuildID, SlotID);
|
StringFormat(query, "UPDATE `guild_bank` SET `permissions` = %i, `whofor` = '%s' WHERE `guildid` = %i AND `area` = 1 AND `slot` = %i LIMIT 1",Permissions, MemberName, GuildID, SlotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
_log(GUILDS__BANK_ERROR, "error changing permissions: %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "error changing permissions: %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1200,7 +1200,7 @@ bool GuildBankManager::DeleteItem(uint32 GuildID, uint16 Area, uint16 SlotID, ui
|
|||||||
if(Iterator == Banks.end())
|
if(Iterator == Banks.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
@ -1232,9 +1232,9 @@ bool GuildBankManager::DeleteItem(uint32 GuildID, uint16 Area, uint16 SlotID, ui
|
|||||||
"AND `area` = %i AND `slot` = %i LIMIT 1",
|
"AND `area` = %i AND `slot` = %i LIMIT 1",
|
||||||
GuildID, Area, SlotID);
|
GuildID, Area, SlotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "Delete item failed. %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "Delete item failed. %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1249,9 +1249,9 @@ bool GuildBankManager::DeleteItem(uint32 GuildID, uint16 Area, uint16 SlotID, ui
|
|||||||
"`guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1",
|
"`guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1",
|
||||||
BankArea[SlotID].Quantity - Quantity, GuildID, Area, SlotID);
|
BankArea[SlotID].Quantity - Quantity, GuildID, Area, SlotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "Update item failed. %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "Update item failed. %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1408,16 +1408,16 @@ void GuildBankManager::UpdateItemQuantity(uint32 GuildID, uint16 Area, uint16 Sl
|
|||||||
{
|
{
|
||||||
// Helper method for MergeStacks. Assuming all passed parameters are valid.
|
// Helper method for MergeStacks. Assuming all passed parameters are valid.
|
||||||
//
|
//
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE `guild_bank` SET `qty` = %i where "
|
StringFormat(query, "UPDATE `guild_bank` SET `qty` = %i where "
|
||||||
"`guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1",
|
"`guildid` = %i AND `area` = %i AND `slot` = %i LIMIT 1",
|
||||||
Quantity, GuildID, Area, SlotID);
|
Quantity, GuildID, Area, SlotID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
_log(GUILDS__BANK_ERROR, "Update item quantity failed. %s : %s", query.c_str(), errbuf);
|
_log(GUILDS__BANK_ERROR, "Update item quantity failed. %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,14 +71,14 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) {
|
|||||||
|
|
||||||
char mount_color = 0;
|
char mount_color = 0;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT race,gender,texture,mountspeed FROM horses WHERE filename='%s'", FileName);
|
StringFormat(query, "SELECT race,gender,texture,mountspeed FROM horses WHERE filename='%s'", FileName);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5929,7 +5929,6 @@ void Client::SendMercAssignPacket(uint32 entityID, uint32 unk01, uint32 unk02) {
|
|||||||
void NPC::LoadMercTypes(){
|
void NPC::LoadMercTypes(){
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -5941,8 +5940,8 @@ void NPC::LoadMercTypes(){
|
|||||||
"MTem.merc_type_id = MTyp.merc_type_id;",
|
"MTem.merc_type_id = MTyp.merc_type_id;",
|
||||||
GetNPCTypeID());
|
GetNPCTypeID());
|
||||||
|
|
||||||
if(!database.RunQuery(query,TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes(). Error Message: %s", errorMessage.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -5957,16 +5956,12 @@ void NPC::LoadMercTypes(){
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::LoadMercs(){
|
void NPC::LoadMercs(){
|
||||||
|
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
std::string query;
|
std::string query;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
|
|
||||||
@ -5982,8 +5977,8 @@ void NPC::LoadMercs(){
|
|||||||
"MTem.merc_type_id = MTyp.merc_type_id;",
|
"MTem.merc_type_id = MTyp.merc_type_id;",
|
||||||
GetNPCTypeID());
|
GetNPCTypeID());
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes(). Error message: %s", errorMessage.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -6002,10 +5997,6 @@ void NPC::LoadMercs(){
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NPC::GetNumMercTypes(uint32 clientVersion)
|
int NPC::GetNumMercTypes(uint32 clientVersion)
|
||||||
|
|||||||
10
zone/mob.cpp
10
zone/mob.cpp
@ -3728,7 +3728,7 @@ void Mob::TarGlobal(const char *varname, const char *value, const char *duration
|
|||||||
|
|
||||||
void Mob::DelGlobal(const char *varname) {
|
void Mob::DelGlobal(const char *varname) {
|
||||||
// delglobal(varname)
|
// delglobal(varname)
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
int qgZoneid=zone->GetZoneID();
|
int qgZoneid=zone->GetZoneID();
|
||||||
int qgCharid=0;
|
int qgCharid=0;
|
||||||
@ -3753,8 +3753,9 @@ void Mob::DelGlobal(const char *varname) {
|
|||||||
"(charid=0 || charid=%i) && (zoneid=%i || zoneid=0)",
|
"(charid=0 || charid=%i) && (zoneid=%i || zoneid=0)",
|
||||||
varname,qgNpcid,qgCharid,qgZoneid);
|
varname,qgNpcid,qgCharid,qgZoneid);
|
||||||
|
|
||||||
if (!database.RunQuery(query,errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
//_log(QUESTS, "DelGlobal error deleting %s : %s", varname, errbuf);
|
//_log(QUESTS, "DelGlobal error deleting %s : %s", varname, errbuf);
|
||||||
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zone)
|
if(zone)
|
||||||
@ -3779,7 +3780,7 @@ void Mob::DelGlobal(const char *varname) {
|
|||||||
void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varname, const char *varvalue, int duration) {
|
void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varname, const char *varvalue, int duration) {
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
// Make duration string either "unix_timestamp(now()) + xxx" or "NULL"
|
// Make duration string either "unix_timestamp(now()) + xxx" or "NULL"
|
||||||
std::stringstream duration_ss;
|
std::stringstream duration_ss;
|
||||||
@ -3801,9 +3802,10 @@ void Mob::InsertQuestGlobal(int charid, int npcid, int zoneid, const char *varna
|
|||||||
"VALUES (%i, %i, %i, '%s', '%s', %s)",
|
"VALUES (%i, %i, %i, '%s', '%s', %s)",
|
||||||
charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str());
|
charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf))
|
if (!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
//_log(QUESTS, "SelGlobal error inserting %s : %s", varname, errbuf);
|
//_log(QUESTS, "SelGlobal error inserting %s : %s", varname, errbuf);
|
||||||
|
// TODO: Log error.
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zone)
|
if(zone)
|
||||||
|
|||||||
70
zone/npc.cpp
70
zone/npc.cpp
@ -981,7 +981,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, float in_x, float in_y, float in_z,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra) {
|
uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn, uint32 extra) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1000,7 +1000,7 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
StringFormat(query, "SELECT MAX(id) FROM npc_types WHERE id >= %i AND id < %i",
|
StringFormat(query, "SELECT MAX(id) FROM npc_types WHERE id >= %i AND id < %i",
|
||||||
starting_npc_id, (starting_npc_id + 1000));
|
starting_npc_id, (starting_npc_id + 1000));
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if(row)
|
if(row)
|
||||||
{
|
{
|
||||||
@ -1040,8 +1040,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(),
|
spawn->GetLoottableID(), spawn->MerchantType, 0, spawn->GetRunspeed(),
|
||||||
28, 28);
|
28, 28);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &npc_type_id)) {
|
if (!RunQuery(query, &errbuf, nullptr, nullptr, &npc_type_id)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1057,8 +1057,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
spawn->GetHelmTexture(), spawn->GetSize(), spawn->GetLoottableID(),
|
||||||
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
spawn->MerchantType, 0, spawn->GetRunspeed(), 28, 28);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &npc_type_id)) {
|
if (!RunQuery(query, &errbuf, 0, 0, &npc_type_id)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1070,8 +1070,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query,"INSERT INTO spawngroup (id, name) values(%i, '%s')", tmp, spawnIDAndName.c_str());
|
StringFormat(query,"INSERT INTO spawngroup (id, name) values(%i, '%s')", tmp, spawnIDAndName.c_str());
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf, 0, 0, &spawngroupid)) {
|
if (!RunQuery(query, &errbuf, 0, 0, &spawngroupid)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,8 +1084,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
zone, zone_version, spawn->GetX(), spawn->GetY(),
|
zone, zone_version, spawn->GetX(), spawn->GetY(),
|
||||||
spawn->GetZ(), 1200, spawn->GetHeading(), spawngroupid);
|
spawn->GetZ(), 1200, spawn->GetHeading(), spawngroupid);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &tmp)) {
|
if (!RunQuery(query, &errbuf, 0, 0, &tmp)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1095,8 +1095,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
StringFormat(query, "INSERT INTO spawnentry (spawngroupID, npcID, chance) values(%i, %i, %i)",
|
StringFormat(query, "INSERT INTO spawnentry (spawngroupID, npcID, chance) values(%i, %i, %i)",
|
||||||
spawngroupid, npc_type_id, 100);
|
spawngroupid, npc_type_id, 100);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0)) {
|
if (!RunQuery(query, &errbuf, 0)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(c)
|
if(c)
|
||||||
@ -1112,8 +1112,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "INSERT INTO spawngroup (name) values('%s')", zoneSpawnNameTime.c_str());
|
StringFormat(query, "INSERT INTO spawngroup (name) values('%s')", zoneSpawnNameTime.c_str());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &last_insert_id)) {
|
if (!RunQuery(query, &errbuf, 0, 0, &last_insert_id)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(c)
|
if(c)
|
||||||
@ -1135,8 +1135,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(),
|
zone, zone_version, spawn->GetX(), spawn->GetY(), spawn->GetZ(),
|
||||||
respawntime, spawn->GetHeading(), last_insert_id);
|
respawntime, spawn->GetHeading(), last_insert_id);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf, 0, 0, &spawnid)) {
|
if (!RunQuery(query, &errbuf, 0, 0, &spawnid)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(c)
|
if(c)
|
||||||
@ -1147,8 +1147,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
"values(%i, %i, %i)",
|
"values(%i, %i, %i)",
|
||||||
last_insert_id, tmp2, 100);
|
last_insert_id, tmp2, 100);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0)) {
|
if (!RunQuery(query, &errbuf, 0)) {
|
||||||
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "NPCSpawnDB Error: %s %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(c)
|
if(c)
|
||||||
@ -1167,7 +1167,7 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
|
spawn->GetTexture(), spawn->GetHelmTexture(), spawn->GetSize(),
|
||||||
spawn->GetLoottableID(), spawn->MerchantType, spawn->GetNPCTypeID());
|
spawn->GetLoottableID(), spawn->MerchantType, spawn->GetNPCTypeID());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0)) {
|
if (!RunQuery(query,&errbuf, 0)) {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
return true;
|
return true;
|
||||||
@ -1182,7 +1182,7 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
"spawngroupID=%i",
|
"spawngroupID=%i",
|
||||||
zone, spawn->GetSp2());
|
zone, spawn->GetSp2());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,7 +1193,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM spawn2 WHERE id='%i'", tmp);
|
StringFormat(query, "DELETE FROM spawn2 WHERE id='%i'", tmp);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(c)
|
if(c)
|
||||||
@ -1201,7 +1202,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM spawngroup WHERE id='%i'", tmp2);
|
StringFormat(query, "DELETE FROM spawngroup WHERE id='%i'", tmp2);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1210,7 +1212,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM spawnentry WHERE spawngroupID='%i'", tmp2);
|
StringFormat(query, "DELETE FROM spawnentry WHERE spawngroupID='%i'", tmp2);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1229,7 +1232,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
"spawngroupID=%i",
|
"spawngroupID=%i",
|
||||||
zone, zone_version, spawn->GetSp2());
|
zone, zone_version, spawn->GetSp2());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
|
// TODO: Log message
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,7 +1245,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM spawn2 WHERE id='%i'", tmp);
|
StringFormat(query,"DELETE FROM spawn2 WHERE id='%i'", tmp);
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,7 +1255,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM spawngroup WHERE id='%i'", tmp2);
|
StringFormat(query, "DELETE FROM spawngroup WHERE id='%i'", tmp2);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1259,7 +1265,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM spawnentry WHERE spawngroupID='%i'", tmp2);
|
StringFormat(query, "DELETE FROM spawnentry WHERE spawngroupID='%i'", tmp2);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,7 +1275,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
StringFormat(query,"DELETE FROM npc_types WHERE id='%i'", spawn->GetNPCTypeID());
|
StringFormat(query,"DELETE FROM npc_types WHERE id='%i'", spawn->GetNPCTypeID());
|
||||||
|
|
||||||
if (!RunQuery(query,errbuf,0)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1294,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
zone, zone_version, c->GetX(), c->GetY(), c->GetZ(), 120, c->GetHeading(), extra);
|
zone, zone_version, c->GetX(), c->GetY(), c->GetZ(), 120, c->GetHeading(), extra);
|
||||||
|
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &tmp)) {
|
if (!RunQuery(query, &errbuf, nullptr, nullptr, &tmp)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,7 +1324,8 @@ uint32 ZoneDatabase::NPCSpawnDB(uint8 command, const char* zone, uint32 zone_ver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, 0, &npc_type_id)) {
|
if (!RunQuery(query, &errbuf, nullptr, nullptr, &npc_type_id)) {
|
||||||
|
// TODO: Log message
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -315,7 +315,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
|
|||||||
|
|
||||||
if (npcmob->GetQglobal())
|
if (npcmob->GetQglobal())
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -339,9 +339,9 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
|
|||||||
"(zoneid=%i || zoneid=0) && expdate >= unix_timestamp(now())",
|
"(zoneid=%i || zoneid=0) && expdate >= unix_timestamp(now())",
|
||||||
npcmob->GetNPCTypeID(), charid, zone->GetZoneID());
|
npcmob->GetNPCTypeID(), charid, zone->GetZoneID());
|
||||||
|
|
||||||
database.RunQuery(query, errbuf, &result);
|
database.RunQuery(query, &errbuf, &result);
|
||||||
printf("%s\n",query.c_str());
|
printf("%s\n",query.c_str());
|
||||||
printf("%s\n",errbuf);
|
printf("%s\n",errbuf.c_str());
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
printf("Loading global variables for %s\n",npcmob->GetName());
|
printf("Loading global variables for %s\n",npcmob->GetName());
|
||||||
|
|||||||
@ -216,7 +216,7 @@ void PetitionList::UpdatePetition(Petition* pet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) {
|
void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
uint8 checkedout = 0;
|
uint8 checkedout = 0;
|
||||||
@ -228,15 +228,15 @@ void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) {
|
|||||||
|
|
||||||
StringFormat(query, "DELETE from petitions where petid = %i", wpet->GetID());
|
StringFormat(query, "DELETE from petitions where petid = %i", wpet->GetID());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in DeletePetitionFromDB query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in DeletePetitionFromDB query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
uint8 checkedout = 0;
|
uint8 checkedout = 0;
|
||||||
@ -250,8 +250,8 @@ void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
|||||||
wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(),
|
wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(),
|
||||||
wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetID());
|
wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetID());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
|||||||
|
|
||||||
void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
uint8 checkedout = 0;
|
uint8 checkedout = 0;
|
||||||
@ -282,8 +282,8 @@ void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
|||||||
wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(),
|
wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(),
|
||||||
wpet->GetUnavails(), checkedout, wpet->GetSentTime(), wpet->GetGMText());
|
wpet->GetUnavails(), checkedout, wpet->GetSentTime(), wpet->GetGMText());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, nullptr, &affected_rows)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EQDEBUG >= 5
|
#if EQDEBUG >= 5
|
||||||
@ -294,7 +294,7 @@ void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
|||||||
|
|
||||||
void ZoneDatabase::RefreshPetitionsFromDB()
|
void ZoneDatabase::RefreshPetitionsFromDB()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -305,7 +305,7 @@ void ZoneDatabase::RefreshPetitionsFromDB()
|
|||||||
"charlevel, checkouts, unavailables, ischeckedout, "
|
"charlevel, checkouts, unavailables, ischeckedout, "
|
||||||
"senttime, gmtext from petitions order by petid";
|
"senttime, gmtext from petitions order by petid";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
newpet = new Petition(atoi(row[0]));
|
newpet = new Petition(atoi(row[0]));
|
||||||
@ -334,7 +334,7 @@ void ZoneDatabase::RefreshPetitionsFromDB()
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in RefreshPetitionsFromDB query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in RefreshPetitionsFromDB query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -361,7 +361,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, c
|
|||||||
|
|
||||||
// handle monster summoning pet appearance
|
// handle monster summoning pet appearance
|
||||||
if(record.monsterflag) {
|
if(record.monsterflag) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result = nullptr;
|
MYSQL_RES *result = nullptr;
|
||||||
MYSQL_ROW row = nullptr;
|
MYSQL_ROW row = nullptr;
|
||||||
@ -378,7 +378,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, c
|
|||||||
zone->GetShortName());
|
zone->GetShortName());
|
||||||
|
|
||||||
// get a random npc id from the spawngroups assigned to this zone
|
// get a random npc id from the spawngroups assigned to this zone
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if (row)
|
if (row)
|
||||||
@ -387,7 +387,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, c
|
|||||||
monsterid = 567; // since we don't have any monsters, just make it look like an earth pet for now
|
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
|
else { // if the database query failed
|
||||||
LogFile->write(EQEMuLog::Error, "Error querying database for monster summoning pet in zone %s (%s)", zone->GetShortName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error querying database for monster summoning pet in zone %s (%s)", zone->GetShortName(), errbuf.c_str());
|
||||||
monsterid = 567;
|
monsterid = 567;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ bool ZoneDatabase::GetPetEntry(const char *pet_type, PetRecord *into) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into) {
|
bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetRecord *into) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 querylen = 0;
|
uint32 querylen = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -470,7 +470,7 @@ bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetR
|
|||||||
pet_type, petpower);
|
pet_type, petpower);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
|
|
||||||
@ -488,7 +488,7 @@ bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetR
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetPoweredPetEntry query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@ -659,7 +659,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
|
|||||||
// A slot will only get an item put in it if it is empty. That way
|
// 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.
|
// an equipmentset can overload a slot for the set(s) it includes.
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 querylen = 0;
|
uint32 querylen = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -680,7 +680,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT nested_set FROM pets_equipmentset WHERE set_id='%s'", curset);
|
StringFormat(query,"SELECT nested_set FROM pets_equipmentset WHERE set_id='%s'", curset);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -689,7 +689,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
|
|||||||
|
|
||||||
StringFormat(query,"SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset);
|
StringFormat(query,"SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%s'", curset);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -703,7 +703,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
curset = nextset;
|
curset = nextset;
|
||||||
depth++;
|
depth++;
|
||||||
@ -718,7 +718,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetBasePetItems query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
|
|||||||
@ -1237,7 +1237,7 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
|||||||
/* Inserts global variable into quest_globals table */
|
/* 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 errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
// Make duration string either "unix_timestamp(now()) + xxx" or "NULL"
|
// Make duration string either "unix_timestamp(now()) + xxx" or "NULL"
|
||||||
@ -1259,7 +1259,7 @@ int QuestManager::InsertQuestGlobal(int charid, int npcid, int zoneid,const char
|
|||||||
"VALUES (%i, %i, %i, '%s', '%s', %s)",
|
"VALUES (%i, %i, %i, '%s', '%s', %s)",
|
||||||
charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str());
|
charid, npcid, zoneid, varname, varvalue, duration_ss.str().c_str());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, nullptr, nullptr, &last_id)) {
|
if (!database.RunQuery(query, &errbuf, nullptr, nullptr, &last_id)) {
|
||||||
std::cerr << "setglobal error inserting " << varname << " : " << errbuf << std::endl;
|
std::cerr << "setglobal error inserting " << varname << " : " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1325,7 +1325,7 @@ void QuestManager::targlobal(const char *varname, const char *value, const char
|
|||||||
|
|
||||||
void QuestManager::delglobal(const char *varname) {
|
void QuestManager::delglobal(const char *varname) {
|
||||||
// delglobal(varname)
|
// delglobal(varname)
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
int qgZoneid=zone->GetZoneID();
|
int qgZoneid=zone->GetZoneID();
|
||||||
int qgCharid=0;
|
int qgCharid=0;
|
||||||
@ -1346,7 +1346,7 @@ void QuestManager::delglobal(const char *varname) {
|
|||||||
"&& (zoneid=%i || zoneid=0)",
|
"&& (zoneid=%i || zoneid=0)",
|
||||||
varname,qgNpcid,qgCharid,qgZoneid);
|
varname,qgNpcid,qgCharid,qgZoneid);
|
||||||
|
|
||||||
if (!database.RunQuery(query,errbuf))
|
if (!database.RunQuery(query, &errbuf))
|
||||||
{
|
{
|
||||||
std::cerr << "delglobal error deleting " << varname << " : " << errbuf << std::endl;
|
std::cerr << "delglobal error deleting " << varname << " : " << errbuf << std::endl;
|
||||||
}
|
}
|
||||||
@ -1560,7 +1560,7 @@ void QuestManager::showgrid(int grid) {
|
|||||||
if(initiator == nullptr)
|
if(initiator == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1579,7 +1579,7 @@ void QuestManager::showgrid(int grid) {
|
|||||||
"AND `zoneid`=%i ORDER BY `number`",
|
"AND `zoneid`=%i ORDER BY `number`",
|
||||||
grid,zone->GetZoneID());
|
grid,zone->GetZoneID());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -1594,7 +1594,7 @@ void QuestManager::showgrid(int grid) {
|
|||||||
}
|
}
|
||||||
else // DB query error!
|
else // DB query error!
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Quest, "Error loading grid %d for showgrid(): %s", grid, errbuf);
|
LogFile->write(EQEMuLog::Quest, "Error loading grid %d for showgrid(): %s", grid, errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2138,14 +2138,14 @@ void QuestManager::clearspawntimers() {
|
|||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
while (iterator.MoreElements())
|
while (iterator.MoreElements())
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM respawn_times WHERE id=%lu AND instance_id=%lu",
|
StringFormat(query,"DELETE FROM respawn_times WHERE id=%lu AND instance_id=%lu",
|
||||||
(unsigned long)iterator.GetData()->GetID(),
|
(unsigned long)iterator.GetData()->GetID(),
|
||||||
(unsigned long)zone->GetInstanceID());
|
(unsigned long)zone->GetInstanceID());
|
||||||
|
|
||||||
database.RunQuery(query, errbuf);
|
database.RunQuery(query, &errbuf);
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2477,7 +2477,7 @@ void QuestManager::FlagInstanceByRaidLeader(uint32 zone, int16 version)
|
|||||||
const char* QuestManager::saylink(char* Phrase, bool silent, char* LinkName) {
|
const char* QuestManager::saylink(char* Phrase, bool silent, char* LinkName) {
|
||||||
|
|
||||||
const char *ERR_MYSQLERROR = "Error in saylink phrase queries";
|
const char *ERR_MYSQLERROR = "Error in saylink phrase queries";
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -2490,7 +2490,7 @@ const char* QuestManager::saylink(char* Phrase, bool silent, char* LinkName) {
|
|||||||
// Query for an existing phrase and id in the saylink table
|
// Query for an existing phrase and id in the saylink table
|
||||||
StringFormat(query,"SELECT `id` FROM `saylink` WHERE `phrase` = '%s'", escaped_string.c_str());
|
StringFormat(query,"SELECT `id` FROM `saylink` WHERE `phrase` = '%s'", escaped_string.c_str());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
if (mysql_num_rows(result) >= 1)
|
if (mysql_num_rows(result) >= 1)
|
||||||
{
|
{
|
||||||
@ -2504,11 +2504,11 @@ const char* QuestManager::saylink(char* Phrase, bool silent, char* LinkName) {
|
|||||||
{
|
{
|
||||||
StringFormat(query,"INSERT INTO `saylink` (`phrase`) VALUES ('%s')", escaped_string.c_str());
|
StringFormat(query,"INSERT INTO `saylink` (`phrase`) VALUES ('%s')", escaped_string.c_str());
|
||||||
|
|
||||||
database.RunQuery(query,errbuf);
|
database.RunQuery(query, &errbuf);
|
||||||
|
|
||||||
StringFormat(query,"SELECT `id` FROM saylink WHERE `phrase` = '%s'", escaped_string.c_str());
|
StringFormat(query,"SELECT `id` FROM saylink WHERE `phrase` = '%s'", escaped_string.c_str());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
if (mysql_num_rows(result) >= 1)
|
if (mysql_num_rows(result) >= 1)
|
||||||
{
|
{
|
||||||
@ -2521,7 +2521,7 @@ const char* QuestManager::saylink(char* Phrase, bool silent, char* LinkName) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
|
|||||||
if(!c)
|
if(!c)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
|
|||||||
(unsigned long)GetID(), (unsigned long)c->CharacterID(), (unsigned long)group,
|
(unsigned long)GetID(), (unsigned long)c->CharacterID(), (unsigned long)group,
|
||||||
c->GetClass(), c->GetLevel(), c->GetName(), groupleader, rleader, looter );
|
c->GetClass(), c->GetLevel(), c->GetName(), groupleader, rleader, looter );
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,13 +107,13 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
|
|||||||
|
|
||||||
void Raid::RemoveMember(const char *c)
|
void Raid::RemoveMember(const char *c)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM raid_members where name='%s'", c );
|
StringFormat(query,"DELETE FROM raid_members where name='%s'", c );
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,13 +140,13 @@ void Raid::RemoveMember(const char *c)
|
|||||||
|
|
||||||
void Raid::DisbandRaid()
|
void Raid::DisbandRaid()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"DELETE FROM raid_members WHERE raidid=%lu", (unsigned long)GetID());
|
StringFormat(query,"DELETE FROM raid_members WHERE raidid=%lu", (unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,14 +168,14 @@ void Raid::DisbandRaid()
|
|||||||
|
|
||||||
void Raid::MoveMember(const char *name, uint32 newGroup)
|
void Raid::MoveMember(const char *name, uint32 newGroup)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET groupid=%lu WHERE name='%s'",
|
StringFormat(query,"UPDATE raid_members SET groupid=%lu WHERE name='%s'",
|
||||||
(unsigned long)newGroup, name);
|
(unsigned long)newGroup, name);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +195,14 @@ void Raid::MoveMember(const char *name, uint32 newGroup)
|
|||||||
|
|
||||||
void Raid::SetGroupLeader(const char *who, bool glFlag)
|
void Raid::SetGroupLeader(const char *who, bool glFlag)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET isgroupleader=%lu WHERE name='%s'",
|
StringFormat(query,"UPDATE raid_members SET isgroupleader=%lu WHERE name='%s'",
|
||||||
(unsigned long)glFlag, who);
|
(unsigned long)glFlag, who);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
LearnMembers();
|
LearnMembers();
|
||||||
@ -224,22 +224,22 @@ void Raid::SetGroupLeader(const char *who, bool glFlag)
|
|||||||
|
|
||||||
void Raid::SetRaidLeader(const char *wasLead, const char *name)
|
void Raid::SetRaidLeader(const char *wasLead, const char *name)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET israidleader=0 WHERE name='%s'", wasLead);
|
StringFormat(query,"UPDATE raid_members SET israidleader=0 WHERE name='%s'", wasLead);
|
||||||
|
|
||||||
if (!database.RunQuery(query,errbuf,&result)){
|
if (!database.RunQuery(query, &errbuf,&result)){
|
||||||
printf("Set Raid Leader error: %s\n", errbuf);
|
printf("Set Raid Leader error: %s\n", errbuf.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET israidleader=1 WHERE name='%s'", name);
|
StringFormat(query,"UPDATE raid_members SET israidleader=1 WHERE name='%s'", name);
|
||||||
|
|
||||||
if (!database.RunQuery(query,errbuf,&result)){
|
if (!database.RunQuery(query, &errbuf,&result)){
|
||||||
printf("Set Raid Leader error: %s\n", errbuf);
|
printf("Set Raid Leader error: %s\n", errbuf.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@ -278,14 +278,14 @@ bool Raid::IsGroupLeader(const char *who)
|
|||||||
|
|
||||||
void Raid::UpdateLevel(const char *name, int newLevel)
|
void Raid::UpdateLevel(const char *name, int newLevel)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET level=%lu WHERE name='%s'",
|
StringFormat(query,"UPDATE raid_members SET level=%lu WHERE name='%s'",
|
||||||
(unsigned long)newLevel, name);
|
(unsigned long)newLevel, name);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,14 +736,14 @@ void Raid::TeleportRaid(Mob* sender, uint32 zoneID, uint16 instance_id, float x,
|
|||||||
|
|
||||||
void Raid::ChangeLootType(uint32 type)
|
void Raid::ChangeLootType(uint32 type)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_details SET loottype=%lu WHERE raidid=%lu",
|
StringFormat(query,"UPDATE raid_details SET loottype=%lu WHERE raidid=%lu",
|
||||||
(unsigned long)type, (unsigned long)GetID());
|
(unsigned long)type, (unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,13 +752,13 @@ void Raid::ChangeLootType(uint32 type)
|
|||||||
|
|
||||||
void Raid::AddRaidLooter(const char* looter)
|
void Raid::AddRaidLooter(const char* looter)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_members SET islooter=1 WHERE name='%s'", looter);
|
StringFormat(query,"UPDATE raid_members SET islooter=1 WHERE name='%s'", looter);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,13 +790,13 @@ void Raid::AddRaidLooter(const char* looter)
|
|||||||
|
|
||||||
void Raid::RemoveRaidLooter(const char* looter)
|
void Raid::RemoveRaidLooter(const char* looter)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query, "UPDATE raid_members SET islooter=0 WHERE name='%s'", looter);
|
StringFormat(query, "UPDATE raid_members SET islooter=0 WHERE name='%s'", looter);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1247,14 +1247,14 @@ void Raid::SendRaidGroupRemove(const char *who, uint32 gid)
|
|||||||
|
|
||||||
void Raid::LockRaid(bool lockFlag)
|
void Raid::LockRaid(bool lockFlag)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"UPDATE raid_details SET locked=%d WHERE raidid=%lu",
|
StringFormat(query,"UPDATE raid_details SET locked=%d WHERE raidid=%lu",
|
||||||
lockFlag, (unsigned long)GetID());
|
lockFlag, (unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,14 +1276,14 @@ void Raid::LockRaid(bool lockFlag)
|
|||||||
|
|
||||||
void Raid::SetRaidDetails()
|
void Raid::SetRaidDetails()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
StringFormat(query,"INSERT INTO raid_details SET raidid=%lu, loottype=4, locked=0",
|
StringFormat(query,"INSERT INTO raid_details SET raidid=%lu, loottype=4, locked=0",
|
||||||
(unsigned long)GetID());
|
(unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf,&result)){
|
if (database.RunQuery(query, &errbuf, &result)){
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,7 +1291,7 @@ void Raid::SetRaidDetails()
|
|||||||
|
|
||||||
void Raid::GetRaidDetails()
|
void Raid::GetRaidDetails()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1299,10 +1299,10 @@ void Raid::GetRaidDetails()
|
|||||||
StringFormat(query,"SELECT locked, loottype FROM raid_details WHERE raidid=%lu",
|
StringFormat(query,"SELECT locked, loottype FROM raid_details WHERE raidid=%lu",
|
||||||
(unsigned long)GetID());
|
(unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf, &result)){
|
||||||
if(mysql_num_rows(result) < 1) {
|
if(mysql_num_rows(result) < 1) {
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
LogFile->write(EQEMuLog::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -1317,7 +1317,7 @@ void Raid::GetRaidDetails()
|
|||||||
bool Raid::LearnMembers()
|
bool Raid::LearnMembers()
|
||||||
{
|
{
|
||||||
memset(members, 0, (sizeof(RaidMember)*MAX_RAID_MEMBERS));
|
memset(members, 0, (sizeof(RaidMember)*MAX_RAID_MEMBERS));
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1326,10 +1326,10 @@ bool Raid::LearnMembers()
|
|||||||
"FROM raid_members WHERE raidid=%lu",
|
"FROM raid_members WHERE raidid=%lu",
|
||||||
(unsigned long)GetID());
|
(unsigned long)GetID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query, &errbuf,&result)){
|
||||||
if(mysql_num_rows(result) < 1) {
|
if(mysql_num_rows(result) < 1) {
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
LogFile->write(EQEMuLog::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), errbuf.c_str());
|
||||||
disbandCheck = true;
|
disbandCheck = true;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -354,7 +354,7 @@ void Spawn2::DeathReset(bool realdeath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version, uint32 repopdelay) {
|
bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version, uint32 repopdelay) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -366,7 +366,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
|
|||||||
"WHERE zone='%s' AND version=%u",
|
"WHERE zone='%s' AND version=%u",
|
||||||
zone_name, version);
|
zone_name, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -381,7 +381,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PopulateZoneLists query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PopulateZoneLists query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
|
|||||||
|
|
||||||
|
|
||||||
Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2id, uint32 timeleft) {
|
Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2id, uint32 timeleft) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -399,7 +399,7 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2
|
|||||||
"variance, pathgrid, _condition, cond_value, enabled, animation "
|
"variance, pathgrid, _condition, cond_value, enabled, animation "
|
||||||
"FROM spawn2 WHERE id=%i", spawn2id);
|
"FROM spawn2 WHERE id=%i", spawn2id);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1)
|
if (mysql_num_rows(result) == 1)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -412,13 +412,13 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList<Spawn2*> &spawn2_list, uint32 spawn2
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadSpawn2 query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 *c, 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];
|
std::string errbuf;
|
||||||
|
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
@ -433,7 +433,7 @@ bool ZoneDatabase::CreateSpawn2(Client *c, uint32 spawngroup, const char* zone,
|
|||||||
"Values (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)",
|
"Values (%i, '%s', %f, %f, %f, %f, %i, %i, %u, %i)",
|
||||||
spawngroup, zone, x, y, z, heading, respawn, variance, condition, cond_value);
|
spawngroup, zone, x, y, z, heading, respawn, variance, condition, cond_value);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||||
if (affected_rows == 1) {
|
if (affected_rows == 1) {
|
||||||
if(c) c->LogSQL(query.c_str());
|
if(c) c->LogSQL(query.c_str());
|
||||||
return true;
|
return true;
|
||||||
@ -443,7 +443,7 @@ bool ZoneDatabase::CreateSpawn2(Client *c, uint32 spawngroup, const char* zone,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in CreateSpawn2 query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in CreateSpawn2 query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +682,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
|
void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
char* query = 0;
|
char* query = 0;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -695,14 +695,14 @@ void SpawnConditionManager::UpdateDBEvent(SpawnEvent &event) {
|
|||||||
event.next.minute, event.next.hour, event.next.day, event.next.month,
|
event.next.minute, event.next.hour, event.next.day, event.next.month,
|
||||||
event.next.year, event.enabled?1:0, event.id
|
event.next.year, event.enabled?1:0, event.id
|
||||||
);
|
);
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to update spawn event '%s': %s\n", query, errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to update spawn event '%s': %s\n", query, &errbuf);
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
safe_delete_array(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) {
|
void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 instance_id, uint16 cond_id, int16 value) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -712,13 +712,13 @@ void SpawnConditionManager::UpdateDBCondition(const char* zone_name, uint32 inst
|
|||||||
"VALUES(%u, %u, '%s', %u)",
|
"VALUES(%u, %u, '%s', %u)",
|
||||||
cond_id, value, zone_name, instance_id);
|
cond_id, value, zone_name, instance_id);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to update spawn condition '%s': %s\n", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to update spawn condition '%s': %s\n", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) {
|
bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std::string &zone_name) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -733,7 +733,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std:
|
|||||||
"FROM spawn_events WHERE id=%d",
|
"FROM spawn_events WHERE id=%d",
|
||||||
event_id);
|
event_id);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
if((row = mysql_fetch_row(result))) {
|
if((row = mysql_fetch_row(result))) {
|
||||||
event.id = atoi(row[0]);
|
event.id = atoi(row[0]);
|
||||||
event.condition_id = atoi(row[1]);
|
event.condition_id = atoi(row[1]);
|
||||||
@ -759,14 +759,14 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std:
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadDBEvent query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadDBEvent query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id)
|
bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 instance_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -780,7 +780,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
|||||||
|
|
||||||
StringFormat(query, "SELECT id, onchange, value FROM spawn_conditions WHERE zone='%s'", zone_name);
|
StringFormat(query, "SELECT id, onchange, value FROM spawn_conditions WHERE zone='%s'", zone_name);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
cond.condition_id = atoi(row[0]);
|
cond.condition_id = atoi(row[0]);
|
||||||
cond.value = atoi(row[2]);
|
cond.value = atoi(row[2]);
|
||||||
@ -791,14 +791,14 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//load values
|
//load values
|
||||||
StringFormat(query, "SELECT id, value FROM spawn_condition_values WHERE zone='%s' and instance_id=%u", zone_name, instance_id);
|
StringFormat(query, "SELECT id, value FROM spawn_condition_values WHERE zone='%s' and instance_id=%u", zone_name, instance_id);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
std::map<uint16, SpawnCondition>::iterator iter = spawn_conditions.find(atoi(row[0]));
|
std::map<uint16, SpawnCondition>::iterator iter = spawn_conditions.find(atoi(row[0]));
|
||||||
@ -811,7 +811,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
spawn_conditions.clear();
|
spawn_conditions.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -823,7 +823,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
|||||||
"FROM spawn_events WHERE zone='%s'",
|
"FROM spawn_events WHERE zone='%s'",
|
||||||
zone_name);
|
zone_name);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
event.id = atoi(row[0]);
|
event.id = atoi(row[0]);
|
||||||
event.condition_id = atoi(row[1]);
|
event.condition_id = atoi(row[1]);
|
||||||
@ -849,7 +849,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions events query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadSpawnConditions events query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,7 +1160,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc
|
|||||||
return(cond.value);
|
return(cond.value);
|
||||||
} else {
|
} else {
|
||||||
//this is a remote spawn condition, grab it from the DB
|
//this is a remote spawn condition, grab it from the DB
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1174,7 +1174,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc
|
|||||||
"WHERE zone='%s' AND instance_id=%u AND id=%d",
|
"WHERE zone='%s' AND instance_id=%u AND id=%d",
|
||||||
zone_short, instance_id, condition_id);
|
zone_short, instance_id, condition_id);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
if((row = mysql_fetch_row(result))) {
|
if((row = mysql_fetch_row(result))) {
|
||||||
value = atoi(row[0]);
|
value = atoi(row[0]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -143,7 +143,7 @@ bool SpawnGroupList::RemoveSpawnGroup(uint32 in_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list) {
|
bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -157,7 +157,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG
|
|||||||
"and spawn2.version=%u and zone='%s'",
|
"and spawn2.version=%u and zone='%s'",
|
||||||
version, zone_name);
|
version, zone_name);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result))) {
|
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]));
|
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]));
|
||||||
@ -179,7 +179,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG
|
|||||||
zone_name);
|
zone_name);
|
||||||
|
|
||||||
|
|
||||||
if (RunQuery(query,errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
||||||
@ -202,7 +202,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char* zone_name, uint16 version, SpawnG
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list) {
|
bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -217,7 +217,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g
|
|||||||
"WHERE spawngroup.ID='%i'",
|
"WHERE spawngroup.ID='%i'",
|
||||||
spawngroupid);
|
spawngroupid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result))) {
|
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]));
|
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]));
|
||||||
@ -237,7 +237,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_g
|
|||||||
"AND spawngroup.spawn_limit='0' ORDER by chance",
|
"AND spawngroup.spawn_limit='0' ORDER by chance",
|
||||||
spawngroupid);
|
spawngroupid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
SpawnEntry* newSpawnEntry = new SpawnEntry( atoi(row[1]), atoi(row[2]), row[3]?atoi(row[3]):0);
|
||||||
|
|||||||
@ -4605,7 +4605,7 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
|
|||||||
int Spell_Global_Value;
|
int Spell_Global_Value;
|
||||||
int Global_Value;
|
int Global_Value;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -4614,7 +4614,7 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
|
|||||||
"spell_globals WHERE spellid=%i",
|
"spell_globals WHERE spellid=%i",
|
||||||
Spell_ID);
|
Spell_ID);
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -4631,7 +4631,7 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
|
|||||||
if (Spell_Global_Name.empty()) { // If the entry in the spell_globals table has nothing set for the qglobal name
|
if (Spell_Global_Name.empty()) { // If the entry in the spell_globals table has nothing set for the qglobal name
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (database.RunQuery(query, errbuf, &result)) {
|
else if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -4662,7 +4662,7 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error while querying Spell ID %i spell_globals table query '%s': %s", Spell_ID, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error while querying Spell ID %i spell_globals table query '%s': %s", Spell_ID, query.c_str(), errbuf.c_str());
|
||||||
return false; // Query failed, so prevent spell from scribing just in case
|
return false; // Query failed, so prevent spell from scribing just in case
|
||||||
}
|
}
|
||||||
return false; // Default is false
|
return false; // Default is false
|
||||||
|
|||||||
@ -61,7 +61,7 @@ TaskManager::~TaskManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::LoadTaskSets() {
|
bool TaskManager::LoadTaskSets() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -76,7 +76,7 @@ bool TaskManager::LoadTaskSets() {
|
|||||||
"AND `taskid` >= 0 AND `taskid` < %i ORDER BY `id`, `taskid` ASC",
|
"AND `taskid` >= 0 AND `taskid` < %i ORDER BY `id`, `taskid` ASC",
|
||||||
MAXTASKSETS, MAXTASKS);
|
MAXTASKSETS, MAXTASKS);
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result)) {
|
if(database.RunQuery(query,&errbuf,&result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int TaskSet = atoi(row[0]);
|
int TaskSet = atoi(row[0]);
|
||||||
@ -88,7 +88,7 @@ bool TaskManager::LoadTaskSets() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ bool TaskManager::LoadTasks(int SingleTask) {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTasks: %s";
|
const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTasks: %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
int QueryLength = 0;
|
int QueryLength = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@ -180,7 +180,7 @@ bool TaskManager::LoadTasks(int SingleTask) {
|
|||||||
StringFormat(query,SingleTaskQuery,SingleTask);
|
StringFormat(query,SingleTaskQuery,SingleTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result)) {
|
if(database.RunQuery(query,&errbuf,&result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int TaskID = atoi(row[0]);
|
int TaskID = atoi(row[0]);
|
||||||
@ -221,7 +221,7 @@ bool TaskManager::LoadTasks(int SingleTask) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ bool TaskManager::LoadTasks(int SingleTask) {
|
|||||||
StringFormat(query, SingleTaskActivityQuery, SingleTask, MAXACTIVITIESPERTASK);
|
StringFormat(query, SingleTaskActivityQuery, SingleTask, MAXACTIVITIESPERTASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int TaskID = atoi(row[0]);
|
int TaskID = atoi(row[0]);
|
||||||
@ -320,7 +320,7 @@ bool TaskManager::LoadTasks(int SingleTask) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -351,7 +351,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) {
|
|||||||
_log(TASKS__CLIENTSAVE,"TaskManager::SaveClientState for character ID %d", CharacterID);
|
_log(TASKS__CLIENTSAVE,"TaskManager::SaveClientState for character ID %d", CharacterID);
|
||||||
|
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
if(state->ActiveTaskCount > 0) {
|
if(state->ActiveTaskCount > 0) {
|
||||||
@ -366,8 +366,8 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) {
|
|||||||
StringFormat(query, TaskQuery, CharacterID,
|
StringFormat(query, TaskQuery, CharacterID,
|
||||||
TaskID, Task, state->ActiveTasks[Task].AcceptedTime);
|
TaskID, Task, state->ActiveTasks[Task].AcceptedTime);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state->ActiveTasks[Task].Updated = false;
|
state->ActiveTasks[Task].Updated = false;
|
||||||
@ -411,9 +411,9 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
query = UpdateActivityQuery;
|
query = UpdateActivityQuery;
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf)) {
|
if(!database.RunQuery(query,&errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state->ActiveTasks[Task].Updated=false;
|
state->ActiveTasks[Task].Updated=false;
|
||||||
@ -444,9 +444,9 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) {
|
|||||||
state->CompletedTasks[i].CompletedTime,
|
state->CompletedTasks[i].CompletedTime,
|
||||||
TaskID, -1);
|
TaskID, -1);
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf)) {
|
if(!database.RunQuery(query,&errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,9 +462,9 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) {
|
|||||||
CharacterID, state->CompletedTasks[i].CompletedTime,
|
CharacterID, state->CompletedTasks[i].CompletedTime,
|
||||||
TaskID, j);
|
TaskID, j);
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf)) {
|
if(!database.RunQuery(query,&errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR1 = "[TASKS]Error in TaskManager::LoadClientState load Tasks: %s";
|
const char *ERR_MYSQLERROR1 = "[TASKS]Error in TaskManager::LoadClientState load Tasks: %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -530,7 +530,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
StringFormat(query, TaskQuery, CharacterID);
|
StringFormat(query, TaskQuery, CharacterID);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
|
|
||||||
@ -579,7 +579,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR1, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR1, errbuf.c_str());
|
||||||
safe_delete(state);
|
safe_delete(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -602,7 +602,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
StringFormat(query, ActivityQuery, CharacterID);
|
StringFormat(query, ActivityQuery, CharacterID);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int TaskID = atoi(row[0]);
|
int TaskID = atoi(row[0]);
|
||||||
@ -649,7 +649,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR2, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR2, errbuf.c_str());
|
||||||
safe_delete(state);
|
safe_delete(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -669,7 +669,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
StringFormat(query, CompletedTaskQuery, CharacterID);
|
StringFormat(query, CompletedTaskQuery, CharacterID);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
CompletedTaskInformation cti;
|
CompletedTaskInformation cti;
|
||||||
|
|
||||||
@ -728,7 +728,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR3, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR3, errbuf.c_str());
|
||||||
safe_delete(state);
|
safe_delete(state);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -741,7 +741,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
|
|
||||||
StringFormat(query, EnabledTaskQuery, CharacterID, MAXTASKS);
|
StringFormat(query, EnabledTaskQuery, CharacterID, MAXTASKS);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
int TaskID = atoi(row[0]);
|
int TaskID = atoi(row[0]);
|
||||||
@ -751,7 +751,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR4, errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR4, errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that there is an entry in the client task state for every activity in each task
|
// Check that there is an entry in the client task state for every activity in each task
|
||||||
@ -838,7 +838,7 @@ void ClientTaskState::EnableTask(int CharID, int TaskCount, int *TaskList) {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR = "[TASKS]Error in ClientTaskState::EnableTask %s %s";
|
const char *ERR_MYSQLERROR = "[TASKS]Error in ClientTaskState::EnableTask %s %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
char *buf = 0;
|
char *buf = 0;
|
||||||
@ -855,9 +855,9 @@ void ClientTaskState::EnableTask(int CharID, int TaskCount, int *TaskList) {
|
|||||||
|
|
||||||
_log(TASKS__UPDATE, "Executing query %s", TaskQuery.c_str());
|
_log(TASKS__UPDATE, "Executing query %s", TaskQuery.c_str());
|
||||||
query = TaskQuery;
|
query = TaskQuery;
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -897,7 +897,7 @@ void ClientTaskState::DisableTask(int CharID, int TaskCount, int *TaskList) {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR = "[TASKS]Error in ClientTaskState::DisableTask %s %s";
|
const char *ERR_MYSQLERROR = "[TASKS]Error in ClientTaskState::DisableTask %s %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
char *buf = 0;
|
char *buf = 0;
|
||||||
@ -921,9 +921,9 @@ void ClientTaskState::DisableTask(int CharID, int TaskCount, int *TaskList) {
|
|||||||
|
|
||||||
query = TaskQuery;
|
query = TaskQuery;
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1426,7 +1426,7 @@ int ClientTaskState::GetActiveTaskID(int index) {
|
|||||||
|
|
||||||
static void DeleteCompletedTaskFromDatabase(int CharID, int TaskID) {
|
static void DeleteCompletedTaskFromDatabase(int CharID, int TaskID) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
const char *TaskQuery="DELETE FROM completed_tasks WHERE charid=%i AND taskid = %i";
|
const char *TaskQuery="DELETE FROM completed_tasks WHERE charid=%i AND taskid = %i";
|
||||||
@ -1436,9 +1436,9 @@ static void DeleteCompletedTaskFromDatabase(int CharID, int TaskID) {
|
|||||||
|
|
||||||
StringFormat(query, TaskQuery, CharID, TaskID);
|
StringFormat(query, TaskQuery, CharID, TaskID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s, %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s, %s", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_log(TASKS__UPDATE, "Delete query %s", query.c_str());
|
_log(TASKS__UPDATE, "Delete query %s", query.c_str());
|
||||||
@ -3130,7 +3130,7 @@ void ClientTaskState::RemoveTask(Client *c, int SequenceNumber) {
|
|||||||
|
|
||||||
int CharacterID = c->CharacterID();
|
int CharacterID = c->CharacterID();
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
const char *TaskQuery="DELETE FROM character_tasks WHERE charid=%i AND taskid = %i";
|
const char *TaskQuery="DELETE FROM character_tasks WHERE charid=%i AND taskid = %i";
|
||||||
@ -3141,18 +3141,18 @@ void ClientTaskState::RemoveTask(Client *c, int SequenceNumber) {
|
|||||||
|
|
||||||
StringFormat(query,ActivityQuery, CharacterID, ActiveTasks[SequenceNumber].TaskID);
|
StringFormat(query,ActivityQuery, CharacterID, ActiveTasks[SequenceNumber].TaskID);
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf)) {
|
if(!database.RunQuery(query,&errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s", errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_log(TASKS__UPDATE, "CancelTask: %s", query.c_str());
|
_log(TASKS__UPDATE, "CancelTask: %s", query.c_str());
|
||||||
|
|
||||||
StringFormat(query,TaskQuery, CharacterID, ActiveTasks[SequenceNumber].TaskID);
|
StringFormat(query,TaskQuery, CharacterID, ActiveTasks[SequenceNumber].TaskID);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
|
|
||||||
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "[TASKS]Error in CientTaskState::CancelTask %s", errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
_log(TASKS__UPDATE, "CancelTask: %s", query.c_str());
|
_log(TASKS__UPDATE, "CancelTask: %s", query.c_str());
|
||||||
@ -3292,7 +3292,7 @@ bool TaskGoalListManager::LoadLists() {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR = "Error in TaskGoalListManager::LoadLists: %s %s";
|
const char *ERR_MYSQLERROR = "Error in TaskGoalListManager::LoadLists: %s %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -3310,7 +3310,7 @@ bool TaskGoalListManager::LoadLists() {
|
|||||||
|
|
||||||
query = CountQuery;
|
query = CountQuery;
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result)) {
|
if(database.RunQuery(query,&errbuf,&result)) {
|
||||||
|
|
||||||
NumberOfLists = mysql_num_rows(result);
|
NumberOfLists = mysql_num_rows(result);
|
||||||
_log(TASKS__GLOBALLOAD, "Database returned a count of %i lists", NumberOfLists);
|
_log(TASKS__GLOBALLOAD, "Database returned a count of %i lists", NumberOfLists);
|
||||||
@ -3334,7 +3334,7 @@ bool TaskGoalListManager::LoadLists() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3345,7 +3345,7 @@ bool TaskGoalListManager::LoadLists() {
|
|||||||
|
|
||||||
StringFormat(query,ListQuery,ListID,Size);
|
StringFormat(query,ListQuery,ListID,Size);
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result)) {
|
if(database.RunQuery(query, &errbuf,&result)) {
|
||||||
// This should only happen if a row is deleted in between us retrieving the counts
|
// This should only happen if a row is deleted in between us retrieving the counts
|
||||||
// at the start of this method and getting to here. It should not be possible for
|
// at the start of this method and getting to here. It should not be possible for
|
||||||
// an INSERT to cause a problem, as the SELECT is used with a LIMIT
|
// an INSERT to cause a problem, as the SELECT is used with a LIMIT
|
||||||
@ -3371,7 +3371,7 @@ bool TaskGoalListManager::LoadLists() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf.c_str());
|
||||||
TaskGoalLists[ListIndex].Size = 0;
|
TaskGoalLists[ListIndex].Size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3480,7 +3480,7 @@ bool TaskProximityManager::LoadProximities(int ZoneID) {
|
|||||||
|
|
||||||
const char *ERR_MYSQLERROR = "Error in TaskProximityManager::LoadProximities %s %s";
|
const char *ERR_MYSQLERROR = "Error in TaskProximityManager::LoadProximities %s %s";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -3493,7 +3493,7 @@ bool TaskProximityManager::LoadProximities(int ZoneID) {
|
|||||||
|
|
||||||
StringFormat(query,ProximityQuery, ZoneID);
|
StringFormat(query,ProximityQuery, ZoneID);
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf,&result)) {
|
if(database.RunQuery(query, &errbuf,&result)) {
|
||||||
|
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
Proximity.ExploreID = atoi(row[0]);
|
Proximity.ExploreID = atoi(row[0]);
|
||||||
@ -3510,7 +3510,7 @@ bool TaskProximityManager::LoadProximities(int ZoneID) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ bool TitleManager::LoadTitles()
|
|||||||
|
|
||||||
TitleEntry Title;
|
TitleEntry Title;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -43,9 +43,9 @@ bool TitleManager::LoadTitles()
|
|||||||
"`char_id`, `status`, `item_id`, `prefix`, `suffix`, "
|
"`char_id`, `status`, `item_id`, `prefix`, `suffix`, "
|
||||||
"`title_set` from titles";
|
"`title_set` from titles";
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, &result))
|
if (!database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Unable to load titles: %s : %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Unable to load titles: %s : %s", query.c_str(), errbuf.c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ void TitleManager::CreateNewPlayerTitle(Client *c, const char *Title)
|
|||||||
if(!c || !Title)
|
if(!c || !Title)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ void TitleManager::CreateNewPlayerTitle(Client *c, const char *Title)
|
|||||||
|
|
||||||
StringFormat(query,"SELECT `id` from titles where `prefix` = '%s' and char_id = %i", escTitle.c_str(), c->CharacterID());
|
StringFormat(query,"SELECT `id` from titles where `prefix` = '%s' and char_id = %i", escTitle.c_str(), c->CharacterID());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if(mysql_num_rows(result) > 0)
|
if(mysql_num_rows(result) > 0)
|
||||||
{
|
{
|
||||||
@ -275,14 +275,14 @@ void TitleManager::CreateNewPlayerTitle(Client *c, const char *Title)
|
|||||||
StringFormat(query, "INSERT into titles (`char_id`, `prefix`) VALUES(%i, '%s')",
|
StringFormat(query, "INSERT into titles (`char_id`, `prefix`) VALUES(%i, '%s')",
|
||||||
c->CharacterID(), escTitle.c_str());
|
c->CharacterID(), escTitle.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf))
|
if(!database.RunQuery(query,& errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding title: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error adding title: %s %s", query.c_str(), errbuf.c_str());
|
||||||
else
|
return;
|
||||||
{
|
|
||||||
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
|
||||||
worldserver.SendPacket(pack);
|
|
||||||
safe_delete(pack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
||||||
|
worldserver.SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
||||||
@ -290,7 +290,7 @@ void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
|||||||
if(!c || !Suffix)
|
if(!c || !Suffix)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
|||||||
StringFormat(query, "SELECT `id` from titles where `suffix` = '%s' and char_id = %i",
|
StringFormat(query, "SELECT `id` from titles where `suffix` = '%s' and char_id = %i",
|
||||||
escSuffix.c_str(), c->CharacterID());
|
escSuffix.c_str(), c->CharacterID());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result))
|
if (database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if(mysql_num_rows(result) > 0)
|
if(mysql_num_rows(result) > 0)
|
||||||
{
|
{
|
||||||
@ -316,8 +316,8 @@ void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
|||||||
StringFormat(query, "INSERT into titles (`char_id`, `suffix`) VALUES(%i, '%s')",
|
StringFormat(query, "INSERT into titles (`char_id`, `suffix`) VALUES(%i, '%s')",
|
||||||
c->CharacterID(), escSuffix.c_str());
|
c->CharacterID(), escSuffix.c_str());
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding title suffix: %s %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error adding title suffix: %s %s", query.c_str(), errbuf.c_str());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
||||||
@ -369,14 +369,14 @@ void Client::EnableTitle(int titleset) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "INSERT INTO player_titlesets "
|
StringFormat(query, "INSERT INTO player_titlesets "
|
||||||
"(char_id, title_set) VALUES (%i, %i)",
|
"(char_id, title_set) VALUES (%i, %i)",
|
||||||
CharacterID(), titleset);
|
CharacterID(), titleset);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in EnableTitle query for titleset %i and charid %i", titleset, CharacterID());
|
LogFile->write(EQEMuLog::Error, "Error in EnableTitle query for titleset %i and charid %i", titleset, CharacterID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ void Client::EnableTitle(int titleset) {
|
|||||||
|
|
||||||
bool Client::CheckTitle(int titleset) {
|
bool Client::CheckTitle(int titleset) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
@ -394,16 +394,16 @@ bool Client::CheckTitle(int titleset) {
|
|||||||
"`char_id`=%i LIMIT 1",
|
"`char_id`=%i LIMIT 1",
|
||||||
titleset, CharacterID());
|
titleset, CharacterID());
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (!database.RunQuery(query, &errbuf, &result))
|
||||||
|
{
|
||||||
if (mysql_num_rows(result) >= 1) {
|
if (mysql_num_rows(result) >= 1) {
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in CheckTitle query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in CheckTitle query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -415,15 +415,15 @@ void Client::RemoveTitle(int titleset) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM player_titlesets WHERE "
|
StringFormat(query, "DELETE FROM player_titlesets WHERE "
|
||||||
"`title_set`=%i AND `char_id`=%i",
|
"`title_set`=%i AND `char_id`=%i",
|
||||||
titleset, CharacterID());
|
titleset, CharacterID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in RemoveTitle query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in RemoveTitle query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -390,7 +390,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -404,8 +404,8 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
|
|||||||
"WHERE tre.componentcount > 0 AND "
|
"WHERE tre.componentcount > 0 AND "
|
||||||
"tre.recipe_id=%u", rac->recipe_id);
|
"tre.recipe_id=%u", rac->recipe_id);
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, &result)) {
|
if (!database.RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in HandleAutoCombine query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in HandleAutoCombine query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
user->QueuePacket(outapp);
|
user->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
return;
|
return;
|
||||||
@ -608,12 +608,12 @@ SkillType Object::TypeToSkill(uint32 type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::TradeskillSearchResults(const std::string query, unsigned long qlen, unsigned long objtype, unsigned long someid) {
|
void Client::TradeskillSearchResults(const std::string query, unsigned long qlen, unsigned long objtype, unsigned long someid) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, &result)) {
|
if (!database.RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in TradeskillSearchResults query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in TradeskillSearchResults query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ void Client::TradeskillSearchResults(const std::string query, unsigned long qlen
|
|||||||
|
|
||||||
void Client::SendTradeskillDetails(uint32 recipe_id) {
|
void Client::SendTradeskillDetails(uint32 recipe_id) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -682,8 +682,8 @@ void Client::SendTradeskillDetails(uint32 recipe_id) {
|
|||||||
"LEFT JOIN items AS i ON tre.item_id = i.id "
|
"LEFT JOIN items AS i ON tre.item_id = i.id "
|
||||||
"WHERE tre.componentcount > 0 AND tre.recipe_id=%u", recipe_id);
|
"WHERE tre.componentcount > 0 AND tre.recipe_id=%u", recipe_id);
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, &result)) {
|
if (!database.RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in SendTradeskillDetails query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in SendTradeskillDetails query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,7 +1124,7 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float
|
|||||||
bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint32 some_id,
|
bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint32 some_id,
|
||||||
uint32 char_id, DBTradeskillRecipe_Struct *spec)
|
uint32 char_id, DBTradeskillRecipe_Struct *spec)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -1182,9 +1182,9 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
"AND sum(tre.item_id * tre.componentcount) = %u",
|
"AND sum(tre.item_id * tre.componentcount) = %u",
|
||||||
buf2, containers, count, sum);
|
buf2, containers, count, sum);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, query: %s", query.c_str());
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, query: %s", query.c_str());
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, error: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,9 +1219,9 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
"AND sum(tre.item_id * tre.componentcount) = %u",
|
"AND sum(tre.item_id * tre.componentcount) = %u",
|
||||||
buf2, count, sum);
|
buf2, count, sum);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1252,9 +1252,9 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
"AND tre.item_id = %u;",
|
"AND tre.item_id = %u;",
|
||||||
buf2, containerId);
|
buf2, containerId);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,7 +1277,6 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
//instead of part which is possible with experimentation.
|
//instead of part which is possible with experimentation.
|
||||||
//This is here because something's up with the query above.. it needs to be rethought out
|
//This is here because something's up with the query above.. it needs to be rethought out
|
||||||
bool has_components = true;
|
bool has_components = true;
|
||||||
char TSerrbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES *TSresult;
|
MYSQL_RES *TSresult;
|
||||||
MYSQL_ROW TSrow;
|
MYSQL_ROW TSrow;
|
||||||
|
|
||||||
@ -1286,7 +1285,7 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
"recipe_id=%i AND componentcount > 0",
|
"recipe_id=%i AND componentcount > 0",
|
||||||
recipe_id);
|
recipe_id);
|
||||||
|
|
||||||
if (RunQuery(query, TSerrbuf, &TSresult)) {
|
if (RunQuery(query, &errbuf, &TSresult)) {
|
||||||
while((TSrow = mysql_fetch_row(TSresult))!=nullptr) {
|
while((TSrow = mysql_fetch_row(TSresult))!=nullptr) {
|
||||||
int ccnt = 0;
|
int ccnt = 0;
|
||||||
for(int x = 0; x < 10; x++){
|
for(int x = 0; x < 10; x++){
|
||||||
@ -1305,7 +1304,7 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
}
|
}
|
||||||
mysql_free_result(TSresult);
|
mysql_free_result(TSresult);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in tradeskill verify query: '%s': %s", query.c_str(), TSerrbuf);
|
LogFile->write(EQEMuLog::Error, "Error in tradeskill verify query: '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(has_components == false){
|
if(has_components == false){
|
||||||
@ -1318,7 +1317,7 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
|
|||||||
bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id,
|
bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id,
|
||||||
uint32 char_id, DBTradeskillRecipe_Struct *spec)
|
uint32 char_id, DBTradeskillRecipe_Struct *spec)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -1349,9 +1348,9 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
|||||||
"GROUP BY tr.id",
|
"GROUP BY tr.id",
|
||||||
char_id, (unsigned long)recipe_id, containers);
|
char_id, (unsigned long)recipe_id, containers);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, query: %s", query.c_str());
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, query: %s", query.c_str());
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,8 +1384,8 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
|||||||
"WHERE successcount>0 AND recipe_id=%u",
|
"WHERE successcount>0 AND recipe_id=%u",
|
||||||
recipe_id);
|
recipe_id);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf, &result)) {
|
if (!RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept success query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept success query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1411,7 +1410,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
|||||||
recipe_id);
|
recipe_id);
|
||||||
|
|
||||||
spec->onfail.clear();
|
spec->onfail.clear();
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
|
|
||||||
qcount = mysql_num_rows(result);
|
qcount = mysql_num_rows(result);
|
||||||
uint8 r;
|
uint8 r;
|
||||||
@ -1432,7 +1431,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
|||||||
|
|
||||||
spec->salvage.clear();
|
spec->salvage.clear();
|
||||||
// Don't bother with the query if TS is nofail
|
// Don't bother with the query if TS is nofail
|
||||||
if (!spec->nofail && RunQuery(query, errbuf, &result)) {
|
if (!spec->nofail && RunQuery(query, &errbuf, &result)) {
|
||||||
qcount = mysql_num_rows(result);
|
qcount = mysql_num_rows(result);
|
||||||
uint8 r;
|
uint8 r;
|
||||||
for(r = 0; r < qcount; r++) {
|
for(r = 0; r < qcount; r++) {
|
||||||
@ -1452,15 +1451,15 @@ void ZoneDatabase::UpdateRecipeMadecount(uint32 recipe_id, uint32 char_id, uint3
|
|||||||
{
|
{
|
||||||
std::string query;
|
std::string query;
|
||||||
uint32 qlen;
|
uint32 qlen;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
StringFormat(query, "INSERT INTO char_recipe_list "
|
StringFormat(query, "INSERT INTO char_recipe_list "
|
||||||
"SET recipe_id = %u, char_id = %u, madecount = %u "
|
"SET recipe_id = %u, char_id = %u, madecount = %u "
|
||||||
"ON DUPLICATE KEY UPDATE madecount = %u;",
|
"ON DUPLICATE KEY UPDATE madecount = %u;",
|
||||||
recipe_id, char_id, madecount, madecount);
|
recipe_id, char_id, madecount, madecount);
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in UpdateRecipeMadecount query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in UpdateRecipeMadecount query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,7 +1468,7 @@ void Client::LearnRecipe(uint32 recipeID)
|
|||||||
std::string query;
|
std::string query;
|
||||||
uint32 qlen;
|
uint32 qlen;
|
||||||
uint32 qcount = 0;
|
uint32 qcount = 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -1481,8 +1480,8 @@ void Client::LearnRecipe(uint32 recipeID)
|
|||||||
"WHERE tr.id = %u ;",
|
"WHERE tr.id = %u ;",
|
||||||
CharacterID(), recipeID);
|
CharacterID(), recipeID);
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf, &result)) {
|
if (!database.RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Client::LearnRecipe query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Client::LearnRecipe query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1505,8 +1504,8 @@ void Client::LearnRecipe(uint32 recipeID)
|
|||||||
"ON DUPLICATE KEY UPDATE madecount = madecount;",
|
"ON DUPLICATE KEY UPDATE madecount = madecount;",
|
||||||
recipeID, CharacterID());
|
recipeID, CharacterID());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LearnRecipe query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LearnRecipe query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1187,13 +1187,13 @@ static void BazaarAuditTrail(const char *Seller, const char *Buyer, const char *
|
|||||||
const char *AuditQuery="INSERT INTO `trader_audit` (`time`, `seller`, `buyer`, `itemname`, `quantity`, `totalcost`, `trantype`) "
|
const char *AuditQuery="INSERT INTO `trader_audit` (`time`, `seller`, `buyer`, `itemname`, `quantity`, `totalcost`, `trantype`) "
|
||||||
"VALUES (NOW(), '%s', '%s', '%s', %i, %i, %i)";
|
"VALUES (NOW(), '%s', '%s', '%s', %i, %i, %i)";
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, AuditQuery, Seller, Buyer, ItemName, Quantity, TotalCost, TranType);
|
StringFormat(query, AuditQuery, Seller, Buyer, ItemName, Quantity, TotalCost, TranType);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf))
|
if(!database.RunQuery(query, &errbuf))
|
||||||
_log(TRADING__CLIENT, "Audit write error: %s : %s", query.c_str(), errbuf);
|
_log(TRADING__CLIENT, "Audit write error: %s : %s", query.c_str(), errbuf.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1335,13 +1335,13 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs,Client* Trader,const EQApplicat
|
|||||||
|
|
||||||
void Client::SendBazaarWelcome(){
|
void Client::SendBazaarWelcome(){
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "select count(distinct char_id),count(char_id) from trader";
|
std::string query = "select count(distinct char_id),count(char_id) from trader";
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query,&errbuf,&result)){
|
||||||
if(mysql_num_rows(result)==1){
|
if(mysql_num_rows(result)==1){
|
||||||
|
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -1367,7 +1367,7 @@ void Client::SendBazaarWelcome(){
|
|||||||
|
|
||||||
query = "select count(distinct charid) from buyer";
|
query = "select count(distinct charid) from buyer";
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&result)){
|
if (database.RunQuery(query,&errbuf,&result)){
|
||||||
if(mysql_num_rows(result)==1) {
|
if(mysql_num_rows(result)==1) {
|
||||||
|
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
@ -1382,7 +1382,7 @@ void Client::SendBazaarWelcome(){
|
|||||||
void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint32 ItemStat, uint32 Slot, uint32 Type,
|
void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint32 ItemStat, uint32 Slot, uint32 Type,
|
||||||
char Name[64], uint32 MinPrice, uint32 MaxPrice) {
|
char Name[64], uint32 MinPrice, uint32 MaxPrice) {
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
std::string Search, Values;
|
std::string Search, Values;
|
||||||
MYSQL_RES *Result;
|
MYSQL_RES *Result;
|
||||||
@ -1577,7 +1577,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint
|
|||||||
"items.id,charges,char_id limit %i",
|
"items.id,charges,char_id limit %i",
|
||||||
Values.c_str(),Search.c_str(), RuleI(Bazaar, MaxSearchResults));
|
Values.c_str(),Search.c_str(), RuleI(Bazaar, MaxSearchResults));
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&Result)){
|
if (database.RunQuery(query,&errbuf,&Result)){
|
||||||
|
|
||||||
_log(TRADING__CLIENT, "SRCH: %s", query.c_str());
|
_log(TRADING__CLIENT, "SRCH: %s", query.c_str());
|
||||||
|
|
||||||
@ -1688,7 +1688,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint
|
|||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
_log(TRADING__CLIENT, "Failed to retrieve Bazaar Search!! %s %s\n", query.c_str(), errbuf);
|
_log(TRADING__CLIENT, "Failed to retrieve Bazaar Search!! %s %s\n", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2018,7 +2018,7 @@ void Client::SendBuyerResults(char* SearchString, uint32 SearchID) {
|
|||||||
//
|
//
|
||||||
_log(TRADING__BARTER, "Client::SendBuyerResults %s\n", SearchString);
|
_log(TRADING__BARTER, "Client::SendBuyerResults %s\n", SearchString);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
char ItemName[64];
|
char ItemName[64];
|
||||||
std::string Search, Values;
|
std::string Search, Values;
|
||||||
@ -2031,7 +2031,7 @@ void Client::SendBuyerResults(char* SearchString, uint32 SearchID) {
|
|||||||
StringFormat(query, "select * from buyer where itemname like '%%%s%%' order by charid limit %i",
|
StringFormat(query, "select * from buyer where itemname like '%%%s%%' order by charid limit %i",
|
||||||
escSearchString.c_str(), RuleI(Bazaar, MaxBarterSearchResults));
|
escSearchString.c_str(), RuleI(Bazaar, MaxBarterSearchResults));
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf, &Result)) {
|
if (database.RunQuery(query,&errbuf, &Result)) {
|
||||||
|
|
||||||
int NumberOfRows = mysql_num_rows(Result);
|
int NumberOfRows = mysql_num_rows(Result);
|
||||||
|
|
||||||
@ -2106,7 +2106,7 @@ void Client::SendBuyerResults(char* SearchString, uint32 SearchID) {
|
|||||||
mysql_free_result(Result);
|
mysql_free_result(Result);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
_log(TRADING__CLIENT, "Failed to retrieve Barter Search!! %s %s\n", query.c_str(), errbuf);
|
_log(TRADING__CLIENT, "Failed to retrieve Barter Search!! %s %s\n", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2150,7 +2150,7 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) {
|
|||||||
|
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
char ItemName[64];
|
char ItemName[64];
|
||||||
std::string Search, Values;
|
std::string Search, Values;
|
||||||
@ -2160,7 +2160,7 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) {
|
|||||||
StringFormat(query, "select * from buyer where charid = %i",
|
StringFormat(query, "select * from buyer where charid = %i",
|
||||||
Buyer->CharacterID());
|
Buyer->CharacterID());
|
||||||
|
|
||||||
if (database.RunQuery(query,errbuf,&Result)){
|
if (database.RunQuery(query,&errbuf,&Result)){
|
||||||
|
|
||||||
if(mysql_num_rows(Result) == 0) {
|
if(mysql_num_rows(Result) == 0) {
|
||||||
mysql_free_result(Result);
|
mysql_free_result(Result);
|
||||||
|
|||||||
@ -266,7 +266,7 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
|
|||||||
|
|
||||||
//todo: rewrite this to not need direct access to trap members.
|
//todo: rewrite this to not need direct access to trap members.
|
||||||
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -280,7 +280,7 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
|||||||
"AND version=%u",
|
"AND version=%u",
|
||||||
zonename, version);
|
zonename, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
lengths = mysql_fetch_lengths(result);
|
lengths = mysql_fetch_lengths(result);
|
||||||
@ -306,7 +306,7 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -378,7 +378,7 @@ void Client::SendGuildTributes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadTributes() {
|
bool ZoneDatabase::LoadTributes() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ bool ZoneDatabase::LoadTributes() {
|
|||||||
|
|
||||||
std::string query = "SELECT id,name,descr,unknown,isguild FROM tributes";
|
std::string query = "SELECT id,name,descr,unknown,isguild FROM tributes";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
int r;
|
int r;
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -404,14 +404,14 @@ bool ZoneDatabase::LoadTributes() {
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadTributes first query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadTributes first query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string query2 = "SELECT tribute_id,level,cost,item_id FROM tribute_levels ORDER BY tribute_id,level";
|
std::string query2 = "SELECT tribute_id,level,cost,item_id FROM tribute_levels ORDER BY tribute_id,level";
|
||||||
|
|
||||||
if (RunQuery(query2, errbuf, &result)) {
|
if (RunQuery(query2, &errbuf, &result)) {
|
||||||
int r;
|
int r;
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -438,7 +438,7 @@ bool ZoneDatabase::LoadTributes() {
|
|||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadTributes level query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadTributes level query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -838,7 +838,7 @@ void NPC::AssignWaypoints(int32 grid) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -851,7 +851,7 @@ void NPC::AssignWaypoints(int32 grid) {
|
|||||||
"WHERE `id`=%i AND `zoneid`=%i",
|
"WHERE `id`=%i AND `zoneid`=%i",
|
||||||
grid, zone->GetZoneID());
|
grid, zone->GetZoneID());
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if((row = mysql_fetch_row(result)))
|
if((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -871,7 +871,7 @@ void NPC::AssignWaypoints(int32 grid) {
|
|||||||
else // DB query error!
|
else // DB query error!
|
||||||
{
|
{
|
||||||
GridErr = true;
|
GridErr = true;
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign grid %u to mob %s: %s", grid, name, errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign grid %u to mob %s: %s", grid, name, errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GridErr)
|
if(!GridErr)
|
||||||
@ -885,7 +885,7 @@ void NPC::AssignWaypoints(int32 grid) {
|
|||||||
"`zoneid`=%i ORDER BY `number`",
|
"`zoneid`=%i ORDER BY `number`",
|
||||||
grid,zone->GetZoneID());
|
grid,zone->GetZoneID());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query,&errbuf,&result))
|
||||||
{
|
{
|
||||||
roamer = true;
|
roamer = true;
|
||||||
max_wp = -1; // Initialize it; will increment it for each waypoint successfully added to the list
|
max_wp = -1; // Initialize it; will increment it for each waypoint successfully added to the list
|
||||||
@ -925,7 +925,7 @@ void NPC::AssignWaypoints(int32 grid) {
|
|||||||
else // DB query error!
|
else // DB query error!
|
||||||
{
|
{
|
||||||
WPErr = true;
|
WPErr = true;
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign waypoints from grid %u to mob %s: %s", grid, name, errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to assign waypoints from grid %u to mob %s: %s", grid, name, errbuf.c_str());
|
||||||
}
|
}
|
||||||
} // end if (!GridErr)
|
} // end if (!GridErr)
|
||||||
if(Waypoints.size() < 2) {
|
if(Waypoints.size() < 2) {
|
||||||
@ -997,7 +997,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
|
|||||||
|
|
||||||
int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
|
int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@ -1005,14 +1005,14 @@ int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
|
|||||||
StringFormat(query, "SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i",
|
StringFormat(query, "SELECT COALESCE(MAX(id), 0) FROM grid WHERE zoneid = %i",
|
||||||
zoneid);
|
zoneid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuff,&result)) {
|
if (RunQuery(query, &errbuff,&result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
res = atoi( row[0] );
|
res = atoi( row[0] );
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetHighestGrid query '%s': %s", query.c_str(), errbuff);
|
LogFile->write(EQEMuLog::Error, "Error in GetHighestGrid query '%s': %s", query.c_str(), errbuff.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(res);
|
return(res);
|
||||||
@ -1020,7 +1020,7 @@ int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
|
|||||||
|
|
||||||
uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
|
uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int type2 = 0;
|
int type2 = 0;
|
||||||
@ -1028,14 +1028,14 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
|
|||||||
StringFormat(query, "SELECT type2 from grid where id = %i and zoneid = %i",
|
StringFormat(query, "SELECT type2 from grid where id = %i and zoneid = %i",
|
||||||
grid,zoneid);
|
grid,zoneid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuff,&result)) {
|
if (RunQuery(query, &errbuff,&result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
type2 = atoi( row[0] );
|
type2 = atoi( row[0] );
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetGridType2 query '%s': %s", query.c_str(), errbuff);
|
LogFile->write(EQEMuLog::Error, "Error in GetGridType2 query '%s': %s", query.c_str(), errbuff.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(type2);
|
return(type2);
|
||||||
@ -1044,7 +1044,7 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
|
|||||||
bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) {
|
bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) {
|
||||||
_CP(Database_GetWaypoints);
|
_CP(Database_GetWaypoints);
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
@ -1052,7 +1052,7 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist*
|
|||||||
"gridid = %i and number = %i and zoneid = %i",
|
"gridid = %i and number = %i and zoneid = %i",
|
||||||
grid,num,zoneid);
|
grid,num,zoneid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuff,&result)) {
|
if (RunQuery(query, &errbuff,&result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if ( wp ) {
|
if ( wp ) {
|
||||||
@ -1068,7 +1068,7 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist*
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query.c_str(), errbuff);
|
LogFile->write(EQEMuLog::Error, "Error in GetWaypoints query '%s': %s", query.c_str(), errbuff.c_str());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1076,7 +1076,7 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist*
|
|||||||
void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
||||||
{
|
{
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int matches = 0, fuzzy = 0, spawn2id = 0;
|
int matches = 0, fuzzy = 0, spawn2id = 0;
|
||||||
@ -1089,8 +1089,8 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
|||||||
StringFormat(query, "SELECT id,x,y FROM spawn2 WHERE zone='%s' AND x=%i AND y=%i",
|
StringFormat(query, "SELECT id,x,y FROM spawn2 WHERE zone='%s' AND x=%i AND y=%i",
|
||||||
zone->GetShortName(), (int)x, (int)y);
|
zone->GetShortName(), (int)x, (int)y);
|
||||||
|
|
||||||
if(!RunQuery(query,errbuf,&result)) {
|
if(!RunQuery(query, &errbuf,&result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error querying spawn2 '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error querying spawn2 '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,8 +1106,8 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
|||||||
zone->GetShortName(), x, _GASSIGN_TOLERANCE,
|
zone->GetShortName(), x, _GASSIGN_TOLERANCE,
|
||||||
y, _GASSIGN_TOLERANCE);
|
y, _GASSIGN_TOLERANCE);
|
||||||
|
|
||||||
if(!RunQuery(query,errbuf,&result)) {
|
if(!RunQuery(query,&errbuf,&result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error querying fuzzy spawn2 '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error querying fuzzy spawn2 '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fuzzy = 1;
|
fuzzy = 1;
|
||||||
@ -1130,8 +1130,8 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
|||||||
|
|
||||||
StringFormat(query, "UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id);
|
StringFormat(query, "UPDATE spawn2 SET pathgrid = %d WHERE id = %d", grid, spawn2id);
|
||||||
|
|
||||||
if(!RunQuery(query,errbuf,&result, &affected_rows)) {
|
if(!RunQuery(query, &errbuf, &result, &affected_rows)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error updating spawn2 '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error updating spawn2 '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(affected_rows == 1)
|
if(affected_rows == 1)
|
||||||
@ -1171,7 +1171,7 @@ void ZoneDatabase::AssignGrid(Client *client, float x, float y, uint32 grid)
|
|||||||
|
|
||||||
void ZoneDatabase::ModifyGrid(Client *c, 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) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
if (!remove)
|
if (!remove)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1179,8 +1179,8 @@ void ZoneDatabase::ModifyGrid(Client *c, bool remove, uint32 id, uint8 type, uin
|
|||||||
"VALUES(%i,%i,%i,%i)",
|
"VALUES(%i,%i,%i,%i)",
|
||||||
id,zoneid,type,type2);
|
id,zoneid,type,type2);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error creating grid entry '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error creating grid entry '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(c)
|
if(c)
|
||||||
@ -1192,8 +1192,8 @@ void ZoneDatabase::ModifyGrid(Client *c, bool remove, uint32 id, uint8 type, uin
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM grid where id=%i",id);
|
StringFormat(query, "DELETE FROM grid where id=%i",id);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error deleting grid '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error deleting grid '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1201,8 +1201,8 @@ void ZoneDatabase::ModifyGrid(Client *c, bool remove, uint32 id, uint8 type, uin
|
|||||||
|
|
||||||
StringFormat(query, "DELETE FROM grid_entries WHERE zoneid=%i AND gridid=%i", zoneid, id);
|
StringFormat(query, "DELETE FROM grid_entries WHERE zoneid=%i AND gridid=%i", zoneid, id);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error deleting grid entries '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error deleting grid entries '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1217,14 +1217,14 @@ void ZoneDatabase::ModifyGrid(Client *c, bool remove, uint32 id, uint8 type, uin
|
|||||||
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 *c, uint32 gridid, uint32 wpnum, float xpos, float ypos, float zpos, uint32 pause, uint16 zoneid, float heading)
|
||||||
{
|
{
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
StringFormat(query, "INSERT INTO grid_entries (gridid,zoneid,`number`,x,y,z,pause,heading) "
|
StringFormat(query, "INSERT INTO grid_entries (gridid,zoneid,`number`,x,y,z,pause,heading) "
|
||||||
"values (%i, %i, %i, %f, %f, %f, %i, %f)",
|
"values (%i, %i, %i, %f, %f, %f, %i, %f)",
|
||||||
gridid, zoneid, wpnum, xpos, ypos, zpos, pause, heading);
|
gridid, zoneid, wpnum, xpos, ypos, zpos, pause, heading);
|
||||||
|
|
||||||
if(!RunQuery(query,errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding waypoint '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error adding waypoint '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1246,14 +1246,14 @@ void ZoneDatabase::AddWP(Client *c, uint32 gridid, uint32 wpnum, float xpos, flo
|
|||||||
void ZoneDatabase::DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid)
|
void ZoneDatabase::DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num, uint16 zoneid)
|
||||||
{
|
{
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM grid_entries where "
|
StringFormat(query, "DELETE FROM grid_entries where "
|
||||||
"gridid=%i and zoneid=%i and `number`=%i",
|
"gridid=%i and zoneid=%i and `number`=%i",
|
||||||
grid_num,zoneid,wp_num);
|
grid_num,zoneid,wp_num);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error deleting waypoint '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error deleting waypoint '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(c)
|
if(c)
|
||||||
@ -1278,12 +1278,12 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
bool CreatedNewGrid; // Did we create a new grid in this function?
|
bool CreatedNewGrid; // Did we create a new grid in this function?
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
|
|
||||||
// See what grid number our spawn is assigned
|
// See what grid number our spawn is assigned
|
||||||
StringFormat(query, "SELECT pathgrid FROM spawn2 WHERE id=%i",spawn2id);
|
StringFormat(query, "SELECT pathgrid FROM spawn2 WHERE id=%i",spawn2id);
|
||||||
|
|
||||||
if(RunQuery(query, errbuf,&result))
|
if(RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
if(mysql_num_rows(result) > 0)
|
if(mysql_num_rows(result) > 0)
|
||||||
{
|
{
|
||||||
@ -1296,7 +1296,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else { // Query error
|
else { // Query error
|
||||||
LogFile->write(EQEMuLog::Error, "Error setting pathgrid '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error setting pathgrid '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1309,8 +1309,8 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
StringFormat(query,"insert into grid set id='%i',zoneid= %i, type='%i', type2='%i'",
|
StringFormat(query,"insert into grid set id='%i',zoneid= %i, type='%i', type2='%i'",
|
||||||
grid_num,zoneid,type1,type2);
|
grid_num,zoneid,type1,type2);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding grid '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error adding grid '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1319,8 +1319,8 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
StringFormat(query, "update spawn2 set pathgrid='%i' where id='%i'",
|
StringFormat(query, "update spawn2 set pathgrid='%i' where id='%i'",
|
||||||
grid_num, spawn2id);
|
grid_num, spawn2id);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error updating spawn2 pathing '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error updating spawn2 pathing '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1336,7 +1336,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
"AND gridid='%i'",
|
"AND gridid='%i'",
|
||||||
zoneid, grid_num);
|
zoneid, grid_num);
|
||||||
|
|
||||||
if(RunQuery(query,errbuf,&result))
|
if(RunQuery(query,&errbuf,&result))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
if(row[0] != 0)
|
if(row[0] != 0)
|
||||||
@ -1347,7 +1347,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else { // Query error
|
else { // Query error
|
||||||
LogFile->write(EQEMuLog::Error, "Error getting next waypoint id '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error getting next waypoint id '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1355,8 +1355,8 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
"VALUES (%i,%i,%i,%f,%f,%f,%i,%f)",
|
"VALUES (%i,%i,%i,%f,%f,%f,%i,%f)",
|
||||||
grid_num, zoneid, next_wp_num, xpos, ypos, zpos, pause, heading);
|
grid_num, zoneid, next_wp_num, xpos, ypos, zpos, pause, heading);
|
||||||
|
|
||||||
if(!RunQuery(query, errbuf)) {
|
if(!RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding grid entry '%s': '%s'", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error adding grid entry '%s': '%s'", query.c_str(), errbuf.c_str());
|
||||||
} else {
|
} else {
|
||||||
if(c)
|
if(c)
|
||||||
c->LogSQL(query.c_str());
|
c->LogSQL(query.c_str());
|
||||||
@ -1371,13 +1371,13 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *c, uint32 spawn2id, float xpos, float
|
|||||||
|
|
||||||
uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) {
|
uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
StringFormat(query, "SELECT max(id) from grid where zoneid = %i",zoneid);
|
StringFormat(query, "SELECT max(id) from grid where zoneid = %i",zoneid);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf,&result)) {
|
if (RunQuery(query, &errbuf,&result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
uint32 tmp=0;
|
uint32 tmp=0;
|
||||||
@ -1390,14 +1390,14 @@ uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetFreeGrid query '%s': %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in GetFreeGrid query '%s': %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
|
int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
|
||||||
std::string query;
|
std::string query;
|
||||||
char errbuff[MYSQL_ERRMSG_SIZE];
|
std::string errbuff;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@ -1406,14 +1406,14 @@ int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
|
|||||||
"grid_entries WHERE zoneid = %i AND gridid = %i",
|
"grid_entries WHERE zoneid = %i AND gridid = %i",
|
||||||
zoneid, gridid);
|
zoneid, gridid);
|
||||||
|
|
||||||
if (RunQuery(query,errbuff,&result)) {
|
if (RunQuery(query, &errbuff, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
res = atoi( row[0] );
|
res = atoi( row[0] );
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
} else {
|
} else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in GetHighestWaypoint query '%s': %s", query.c_str(), errbuff);
|
LogFile->write(EQEMuLog::Error, "Error in GetHighestWaypoint query '%s': %s", query.c_str(), errbuff.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return(res);
|
return(res);
|
||||||
|
|||||||
109
zone/zone.cpp
109
zone/zone.cpp
@ -177,7 +177,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
|||||||
|
|
||||||
//this really loads the objects into entity_list
|
//this really loads the objects into entity_list
|
||||||
bool Zone::LoadZoneObjects() {
|
bool Zone::LoadZoneObjects() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -188,7 +188,7 @@ bool Zone::LoadZoneObjects() {
|
|||||||
"from object where zoneid=%i and (version=%u or version=-1)",
|
"from object where zoneid=%i and (version=%u or version=-1)",
|
||||||
zoneid, instanceversion);
|
zoneid, instanceversion);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Status, "Loading Objects from DB...");
|
LogFile->write(EQEMuLog::Status, "Loading Objects from DB...");
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
if (atoi(row[9]) == 0)
|
if (atoi(row[9]) == 0)
|
||||||
@ -306,7 +306,7 @@ bool Zone::LoadZoneObjects() {
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LogFile->write(EQEMuLog::Error, "Error Loading Objects from DB: %s",errbuf);
|
LogFile->write(EQEMuLog::Error, "Error Loading Objects from DB: %s", errbuf.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -487,7 +487,7 @@ void Zone::LoadTempMerchantData_result(MYSQL_RES* result) {
|
|||||||
|
|
||||||
//there should prolly be a temp counterpart of this...
|
//there should prolly be a temp counterpart of this...
|
||||||
void Zone::LoadNewMerchantData(uint32 merchantid){
|
void Zone::LoadNewMerchantData(uint32 merchantid){
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -498,7 +498,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid){
|
|||||||
"FROM merchantlist WHERE merchantid=%d",
|
"FROM merchantlist WHERE merchantid=%d",
|
||||||
merchantid);
|
merchantid);
|
||||||
|
|
||||||
if (database.RunQuery(query, errbuf, &result)) {
|
if (database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
MerchantList ml;
|
MerchantList ml;
|
||||||
ml.id = merchantid;
|
ml.id = merchantid;
|
||||||
@ -513,7 +513,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid){
|
|||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadNewMerchantData query '%s' %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in LoadNewMerchantData query '%s' %s", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::LoadMerchantData_result(MYSQL_RES* result) {
|
void Zone::LoadMerchantData_result(MYSQL_RES* result) {
|
||||||
@ -587,7 +587,6 @@ void Zone::GetMerchantDataForZoneLoad(){
|
|||||||
|
|
||||||
void Zone::LoadMercTemplates(){
|
void Zone::LoadMercTemplates(){
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
std::list<MercStanceInfo> merc_stances;
|
std::list<MercStanceInfo> merc_stances;
|
||||||
@ -596,8 +595,8 @@ void Zone::LoadMercTemplates(){
|
|||||||
std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` "
|
std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` "
|
||||||
"FROM `merc_stance_entries` order by `class_id`, `proficiency_id`, `stance_id`";
|
"FROM `merc_stance_entries` order by `class_id`, `proficiency_id`, `stance_id`";
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: log this query individually here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -621,8 +620,8 @@ void Zone::LoadMercTemplates(){
|
|||||||
"MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id "
|
"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;";
|
"ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;";
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
// TODO: log this query individually here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -666,15 +665,14 @@ void Zone::LoadMercTemplates(){
|
|||||||
|
|
||||||
void Zone::LoadLevelEXPMods(){
|
void Zone::LoadLevelEXPMods(){
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
level_exp_mod.clear();
|
level_exp_mod.clear();
|
||||||
|
|
||||||
std::string query = "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods";
|
std::string query = "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods";
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadEXPLevelMods()");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -687,22 +685,18 @@ void Zone::LoadLevelEXPMods(){
|
|||||||
mysql_free_result(DatasetResult);
|
mysql_free_result(DatasetResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadEXPLevelMods()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void Zone::LoadMercSpells(){
|
void Zone::LoadMercSpells(){
|
||||||
|
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
MYSQL_RES* DatasetResult;
|
||||||
MYSQL_ROW DataRow;
|
MYSQL_ROW DataRow;
|
||||||
merc_spells_list.clear();
|
merc_spells_list.clear();
|
||||||
|
|
||||||
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;";
|
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;";
|
||||||
|
|
||||||
if(!database.RunQuery(query, TempErrorMessageBuffer, &DatasetResult)) {
|
if(!database.RunQuery(query, &errorMessage, &DatasetResult)) {
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadMercSpells()");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
||||||
@ -728,23 +722,20 @@ void Zone::LoadMercSpells(){
|
|||||||
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());
|
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(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadMercSpells()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
|
void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
|
||||||
// LogFile->write(EQEMuLog::Debug, "Zone work complete...");
|
// LogFile->write(EQEMuLog::Debug, "Zone work complete...");
|
||||||
switch (workpt_b1) {
|
switch (workpt_b1) {
|
||||||
case DBA_b1_Zone_MerchantLists: {
|
case DBA_b1_Zone_MerchantLists: {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES* result = 0;
|
MYSQL_RES* result = 0;
|
||||||
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
||||||
if(dbaq == nullptr) {
|
if(dbaq == nullptr) {
|
||||||
LogFile->write(EQEMuLog::Error, "nullptr answer provided for async merchant list load.");
|
LogFile->write(EQEMuLog::Error, "nullptr answer provided for async merchant list load.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!dbaq->GetAnswer(errbuf, &result)) {
|
if(!dbaq->GetAnswer(&errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Zone::DBAWComplete(): Unable to get results for merchant lists");
|
LogFile->write(EQEMuLog::Error, "Zone::DBAWComplete(): Unable to get results for merchant lists");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -759,14 +750,14 @@ void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DBA_b1_Zone_MerchantListsTemp: {
|
case DBA_b1_Zone_MerchantListsTemp: {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES* result = 0;
|
MYSQL_RES* result = 0;
|
||||||
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
||||||
if(dbaq == nullptr) {
|
if(dbaq == nullptr) {
|
||||||
LogFile->write(EQEMuLog::Error, "nullptr answer provided for async temp merchant list load.");
|
LogFile->write(EQEMuLog::Error, "nullptr answer provided for async temp merchant list load.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!dbaq->GetAnswer(errbuf, &result)) {
|
if(!dbaq->GetAnswer(&errbuf, &result)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Zone::DBAWComplete(): Unable to get results for temp merchant lists");
|
LogFile->write(EQEMuLog::Error, "Zone::DBAWComplete(): Unable to get results for temp merchant lists");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1638,7 +1629,7 @@ ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Clien
|
|||||||
|
|
||||||
bool ZoneDatabase::LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list, const char* zonename, uint32 version)
|
bool ZoneDatabase::LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list, const char* zonename, uint32 version)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1651,7 +1642,7 @@ bool ZoneDatabase::LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,
|
|||||||
"WHERE zone='%s' AND (version=%i OR version=-1) order by number",
|
"WHERE zone='%s' AND (version=%i OR version=-1) order by number",
|
||||||
zonename, version);
|
zonename, version);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result))
|
if (RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -1682,12 +1673,12 @@ bool ZoneDatabase::LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::DumpZoneState() {
|
bool ZoneDatabase::DumpZoneState() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
StringFormat(query, "DELETE FROM zone_state_dump WHERE zonename='%s'", zone->GetShortName());
|
StringFormat(query, "DELETE FROM zone_state_dump WHERE zonename='%s'", zone->GetShortName());
|
||||||
|
|
||||||
if (!RunQuery(query, errbuf)) {
|
if (!RunQuery(query, &errbuf)) {
|
||||||
std::cerr << "Error in DumpZoneState query '" << query << "' " << errbuf << std::endl;
|
std::cerr << "Error in DumpZoneState query '" << query << "' " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1779,7 +1770,7 @@ bool ZoneDatabase::DumpZoneState() {
|
|||||||
query.append("\')");
|
query.append("\')");
|
||||||
|
|
||||||
uint32 affected_rows = 0;
|
uint32 affected_rows = 0;
|
||||||
if (!RunQuery(query, errbuf, 0, &affected_rows)) {
|
if (!RunQuery(query, &errbuf, 0, &affected_rows)) {
|
||||||
std::cerr << "Error in ZoneDump query " << errbuf << std::endl;
|
std::cerr << "Error in ZoneDump query " << errbuf << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1792,7 +1783,7 @@ bool ZoneDatabase::DumpZoneState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList<Spawn2*>& spawn2_list) {
|
int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList<Spawn2*>& spawn2_list) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -1815,7 +1806,7 @@ int8 ZoneDatabase::LoadZoneState(const char* zonename, LinkedList<Spawn2*>& spaw
|
|||||||
"npcs, npc_loot, gmspawntype, (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(time)) "
|
"npcs, npc_loot, gmspawntype, (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(time)) "
|
||||||
"as elapsedtime FROM zone_state_dump WHERE zonename='%s'", zonename);
|
"as elapsedtime FROM zone_state_dump WHERE zonename='%s'", zonename);
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
if (mysql_num_rows(result) == 1) {
|
if (mysql_num_rows(result) == 1) {
|
||||||
row = mysql_fetch_row(result);
|
row = mysql_fetch_row(result);
|
||||||
std::cout << "Elapsed time: " << row[8] << std::endl;
|
std::cout << "Elapsed time: " << row[8] << std::endl;
|
||||||
@ -2113,14 +2104,14 @@ bool Zone::RemoveSpawnGroup(uint32 in_id) {
|
|||||||
|
|
||||||
// Added By Hogie
|
// Added By Hogie
|
||||||
bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes) {
|
bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT varname, value FROM variables WHERE varname like 'decaytime%%' ORDER BY varname";
|
std::string query = "SELECT varname, value FROM variables WHERE varname like 'decaytime%%' ORDER BY varname";
|
||||||
|
|
||||||
if (RunQuery(query, errbuf, &result)) {
|
if (RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
Seperator sep(row[0]);
|
Seperator sep(row[0]);
|
||||||
npcCorpseDecayTimes[i].minlvl = atoi(sep.arg[1]);
|
npcCorpseDecayTimes[i].minlvl = atoi(sep.arg[1]);
|
||||||
@ -2323,14 +2314,14 @@ void Zone::SetInstanceTimer(uint32 new_duration)
|
|||||||
|
|
||||||
void Zone::LoadLDoNTraps()
|
void Zone::LoadLDoNTraps()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT id, type, spell_id, "
|
std::string query = "SELECT id, type, spell_id, "
|
||||||
"skill, locked FROM ldon_trap_templates";
|
"skill, locked FROM ldon_trap_templates";
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2347,20 +2338,20 @@ void Zone::LoadLDoNTraps()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTraps: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTraps: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::LoadLDoNTrapEntries()
|
void Zone::LoadLDoNTrapEntries()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT id, trap_id FROM ldon_trap_entries";
|
std::string query = "SELECT id, trap_id FROM ldon_trap_entries";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result)) {
|
if(database.RunQuery(query, &errbuf, &result)) {
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
uint32 id = atoi(row[0]);
|
uint32 id = atoi(row[0]);
|
||||||
@ -2398,7 +2389,7 @@ void Zone::LoadLDoNTrapEntries()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTrapEntries: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadLDoNTrapEntries: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2406,7 +2397,7 @@ void Zone::LoadLDoNTrapEntries()
|
|||||||
void Zone::LoadVeteranRewards()
|
void Zone::LoadVeteranRewards()
|
||||||
{
|
{
|
||||||
VeteranRewards.clear();
|
VeteranRewards.clear();
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
InternalVeteranReward current_reward;
|
InternalVeteranReward current_reward;
|
||||||
@ -2418,7 +2409,7 @@ void Zone::LoadVeteranRewards()
|
|||||||
"veteran_reward_templates WHERE reward_slot < 8 "
|
"veteran_reward_templates WHERE reward_slot < 8 "
|
||||||
"and claim_id > 0 ORDER by claim_id, reward_slot";
|
"and claim_id > 0 ORDER by claim_id, reward_slot";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf,&result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2452,21 +2443,21 @@ void Zone::LoadVeteranRewards()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadVeteranRewards: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadVeteranRewards: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::LoadAlternateCurrencies()
|
void Zone::LoadAlternateCurrencies()
|
||||||
{
|
{
|
||||||
AlternateCurrencies.clear();
|
AlternateCurrencies.clear();
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
AltCurrencyDefinition_Struct current_currency;
|
AltCurrencyDefinition_Struct current_currency;
|
||||||
|
|
||||||
std::string query = "SELECT id, item_id from alternate_currency";
|
std::string query = "SELECT id, item_id from alternate_currency";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2479,7 +2470,7 @@ void Zone::LoadAlternateCurrencies()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAlternateCurrencies: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAlternateCurrencies: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2515,13 +2506,13 @@ void Zone::DeleteQGlobal(std::string name, uint32 npcID, uint32 charID, uint32 z
|
|||||||
|
|
||||||
void Zone::LoadAdventureFlavor()
|
void Zone::LoadAdventureFlavor()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
std::string query = "SELECT id, text FROM adventure_template_entry_flavor";
|
std::string query = "SELECT id, text FROM adventure_template_entry_flavor";
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2533,7 +2524,7 @@ void Zone::LoadAdventureFlavor()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAdventureFlavor: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadAdventureFlavor: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2597,14 +2588,14 @@ void Zone::DoAdventureActions()
|
|||||||
|
|
||||||
void Zone::LoadNPCEmotes(LinkedList<NPC_Emote_Struct*>* NPCEmoteList)
|
void Zone::LoadNPCEmotes(LinkedList<NPC_Emote_Struct*>* NPCEmoteList)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
NPCEmoteList->Clear();
|
NPCEmoteList->Clear();
|
||||||
|
|
||||||
std::string query = "SELECT emoteid, event_, type, text FROM npc_emotes";
|
std::string query = "SELECT emoteid, event_, type, text FROM npc_emotes";
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2619,7 +2610,7 @@ void Zone::LoadNPCEmotes(LinkedList<NPC_Emote_Struct*>* NPCEmoteList)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadNPCEmotes: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadNPCEmotes: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2632,7 +2623,7 @@ void Zone::ReloadWorld(uint32 Option){
|
|||||||
|
|
||||||
void Zone::LoadTickItems()
|
void Zone::LoadTickItems()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -2640,7 +2631,7 @@ void Zone::LoadTickItems()
|
|||||||
|
|
||||||
query = "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick";
|
query = "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick";
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
while((row = mysql_fetch_row(result)))
|
||||||
{
|
{
|
||||||
@ -2659,7 +2650,7 @@ void Zone::LoadTickItems()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadTickItems: %s (%s)", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in Zone::LoadTickItems: %s (%s)", query.c_str(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2680,7 +2671,7 @@ uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) {
|
|||||||
|
|
||||||
void Zone::UpdateHotzone()
|
void Zone::UpdateHotzone()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -2688,7 +2679,7 @@ void Zone::UpdateHotzone()
|
|||||||
|
|
||||||
StringFormat(query, "SELECT hotzone FROM zone WHERE short_name = '%s'",GetShortName());
|
StringFormat(query, "SELECT hotzone FROM zone WHERE short_name = '%s'",GetShortName());
|
||||||
|
|
||||||
if(database.RunQuery(query, errbuf, &result) )
|
if(database.RunQuery(query, &errbuf, &result) )
|
||||||
{
|
{
|
||||||
if( (row = mysql_fetch_row(result)) )
|
if( (row = mysql_fetch_row(result)) )
|
||||||
{
|
{
|
||||||
|
|||||||
422
zone/zonedb.cpp
422
zone/zonedb.cpp
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ void DispatchFinishedDBAsync(DBAsyncWork* dbaw) {
|
|||||||
/* case DBA_b4_Main: {
|
/* case DBA_b4_Main: {
|
||||||
switch (workpt.i24_1()) {
|
switch (workpt.i24_1()) {
|
||||||
case DBA_i24_1_Main_LoadVariables: {
|
case DBA_i24_1_Main_LoadVariables: {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
MYSQL_RES* result;
|
MYSQL_RES* result;
|
||||||
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
DBAsyncQuery* dbaq = dbaw->PopAnswer();
|
||||||
if (dbaq->GetAnswer(errbuf, result))
|
if (dbaq->GetAnswer(errbuf, result))
|
||||||
@ -54,7 +54,7 @@ void DispatchFinishedDBAsync(DBAsyncWork* dbaw) {
|
|||||||
#define MAX_TO_DELETE 10
|
#define MAX_TO_DELETE 10
|
||||||
#define MAX_BACKUPS 5
|
#define MAX_BACKUPS 5
|
||||||
bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete data
|
bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete data
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE] = "dbaq == 0";
|
std::string errbuf = "dbaq == 0";
|
||||||
MYSQL_RES* result = 0;
|
MYSQL_RES* result = 0;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
std::string query;
|
std::string query;
|
||||||
@ -73,7 +73,7 @@ bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete
|
|||||||
BackupAges[1] = 3600;
|
BackupAges[1] = 3600;
|
||||||
|
|
||||||
DBAsyncQuery* dbaq = iWork->PopAnswer();
|
DBAsyncQuery* dbaq = iWork->PopAnswer();
|
||||||
if (dbaq && dbaq->GetAnswer(errbuf, &result)) {
|
if (dbaq && dbaq->GetAnswer(&errbuf, &result)) {
|
||||||
while ((row = mysql_fetch_row(result))) {
|
while ((row = mysql_fetch_row(result))) {
|
||||||
for (i=0; i<MAX_BACKUPS; i++) {
|
for (i=0; i<MAX_BACKUPS; i++) {
|
||||||
if (BackupAges[i] == 0 || (uint32)atoi(row[1]) > BackupAges[i])
|
if (BackupAges[i] == 0 || (uint32)atoi(row[1]) > BackupAges[i])
|
||||||
@ -102,8 +102,8 @@ bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete
|
|||||||
query.append(toAppend);
|
query.append(toAppend);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "Error in DBAsyncCB_CharacterBackup query2 '%s' %s", query.c_str(), errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in DBAsyncCB_CharacterBackup query2 '%s' %s", query.c_str(), errbuf.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete
|
|||||||
"select id, account_id, name, profile, level, class, x, y, z, zoneid "
|
"select id, account_id, name, profile, level, class, x, y, z, zoneid "
|
||||||
"from character_ where id=%u", iWork->WPT());
|
"from character_ where id=%u", iWork->WPT());
|
||||||
|
|
||||||
if (!database.RunQuery(query, errbuf)) {
|
if (!database.RunQuery(query, &errbuf)) {
|
||||||
std::cout << "Error in DBAsyncCB_CharacterBackup query3 '" << query << "' " << errbuf << std::endl;
|
std::cout << "Error in DBAsyncCB_CharacterBackup query3 '" << query << "' " << errbuf << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -730,7 +730,7 @@ void Client::SetZoneFlag(uint32 zone_id) {
|
|||||||
zone_flags.insert(zone_id);
|
zone_flags.insert(zone_id);
|
||||||
|
|
||||||
//update the DB
|
//update the DB
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
// Retrieve all waypoints for this grid
|
// Retrieve all waypoints for this grid
|
||||||
@ -738,8 +738,8 @@ void Client::SetZoneFlag(uint32 zone_id) {
|
|||||||
StringFormat(query, "INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)",
|
StringFormat(query, "INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)",
|
||||||
CharacterID(),zone_id);
|
CharacterID(),zone_id);
|
||||||
|
|
||||||
if(!database.RunQuery(query, errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ void Client::ClearZoneFlag(uint32 zone_id) {
|
|||||||
zone_flags.erase(zone_id);
|
zone_flags.erase(zone_id);
|
||||||
|
|
||||||
//update the DB
|
//update the DB
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
|
|
||||||
// Retrieve all waypoints for this grid
|
// Retrieve all waypoints for this grid
|
||||||
@ -758,13 +758,13 @@ void Client::ClearZoneFlag(uint32 zone_id) {
|
|||||||
StringFormat(query, "DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d",
|
StringFormat(query, "DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d",
|
||||||
CharacterID(),zone_id);
|
CharacterID(),zone_id);
|
||||||
|
|
||||||
if(!database.RunQuery(query,errbuf)) {
|
if(!database.RunQuery(query, &errbuf)) {
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::LoadZoneFlags() {
|
void Client::LoadZoneFlags() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string errbuf;
|
||||||
std::string query;
|
std::string query;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@ -774,7 +774,7 @@ void Client::LoadZoneFlags() {
|
|||||||
StringFormat(query,"SELECT zoneID from zone_flags WHERE charID=%d",
|
StringFormat(query,"SELECT zoneID from zone_flags WHERE charID=%d",
|
||||||
CharacterID());
|
CharacterID());
|
||||||
|
|
||||||
if(database.RunQuery(query,errbuf,&result))
|
if(database.RunQuery(query, &errbuf, &result))
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result))) {
|
while((row = mysql_fetch_row(result))) {
|
||||||
zone_flags.insert(atoi(row[0]));
|
zone_flags.insert(atoi(row[0]));
|
||||||
@ -783,7 +783,7 @@ void Client::LoadZoneFlags() {
|
|||||||
}
|
}
|
||||||
else // DB query error!
|
else // DB query error!
|
||||||
{
|
{
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), errbuf.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user