mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 13:16:39 +00:00
DoEscapeString changed to string for first argument.
RunQuery changed to string for first argument, removed len argument.
This commit is contained in:
+11
-13
@@ -375,11 +375,13 @@ void Adventure::MoveCorpsesToGraveyard()
|
||||
std::list<uint32> dbid_list;
|
||||
std::list<uint32> charid_list;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID()), errbuf, &result))
|
||||
StringFormat(query,"SELECT id, charid FROM player_corpses WHERE instanceid=%d", GetInstanceID());
|
||||
|
||||
if(database.RunQuery(query,errbuf, &result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@@ -387,12 +389,10 @@ void Adventure::MoveCorpsesToGraveyard()
|
||||
charid_list.push_back(atoi(row[1]));
|
||||
}
|
||||
mysql_free_result(result);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf);
|
||||
}
|
||||
|
||||
std::list<uint32>::iterator iter = dbid_list.begin();
|
||||
@@ -401,15 +401,13 @@ void Adventure::MoveCorpsesToGraveyard()
|
||||
float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
|
||||
float y = GetTemplate()->graveyard_y + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
|
||||
float z = GetTemplate()->graveyard_z;
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query, "UPDATE player_corpses SET zoneid=%d, instanceid=0, x=%f, y=%f, z=%f WHERE instanceid=%d",
|
||||
GetTemplate()->graveyard_zone_id, x, y, z, GetInstanceID()), errbuf))
|
||||
|
||||
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());
|
||||
|
||||
if(!database.RunQuery(query,errbuf))
|
||||
{
|
||||
safe_delete_array(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::MoveCorpsesToGraveyard: %s (%s)", query.c_str(), errbuf);
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
+20
-22
@@ -636,16 +636,17 @@ AdventureTemplate *AdventureManager::GetAdventureTemplate(int id)
|
||||
bool AdventureManager::LoadAdventureTemplates()
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, zone, zone_version, "
|
||||
"is_hard, min_level, max_level, type, type_data, type_count, assa_x, "
|
||||
"assa_y, assa_z, assa_h, text, duration, zone_in_time, win_points, lose_points, "
|
||||
"theme, zone_in_zone_id, zone_in_x, zone_in_y, zone_in_object_id, dest_x, dest_y,"
|
||||
" dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, "
|
||||
"graveyard_radius FROM adventure_template"), errbuf, &result))
|
||||
std::string query = "SELECT id, zone, zone_version, "
|
||||
"is_hard, min_level, max_level, type, type_data, type_count, assa_x, "
|
||||
"assa_y, assa_z, assa_h, text, duration, zone_in_time, win_points, lose_points, "
|
||||
"theme, zone_in_zone_id, zone_in_x, zone_in_y, zone_in_object_id, dest_x, dest_y,"
|
||||
" dest_z, dest_h, graveyard_zone_id, graveyard_x, graveyard_y, graveyard_z, "
|
||||
"graveyard_radius FROM adventure_template";
|
||||
|
||||
if(database.RunQuery(query,errbuf, &result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@@ -686,13 +687,11 @@ bool AdventureManager::LoadAdventureTemplates()
|
||||
adventure_templates[t->id] = t;
|
||||
}
|
||||
mysql_free_result(result);
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventures: %s (%s)", query.c_str(), errbuf);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -701,11 +700,12 @@ bool AdventureManager::LoadAdventureTemplates()
|
||||
bool AdventureManager::LoadAdventureEntries()
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, template_id FROM adventure_template_entry"), errbuf, &result))
|
||||
|
||||
std::string query= "SELECT id, template_id FROM adventure_template_entry";
|
||||
|
||||
if(database.RunQuery(query, errbuf, &result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@@ -738,13 +738,11 @@ bool AdventureManager::LoadAdventureEntries()
|
||||
}
|
||||
}
|
||||
mysql_free_result(result);
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query.c_str(), errbuf);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -1093,12 +1091,14 @@ void AdventureManager::LoadLeaderboardInfo()
|
||||
leaderboard_info_wins_tak.clear();
|
||||
leaderboard_info_percentage_tak.clear();
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(database.RunQuery(query,MakeAnyLenString(&query,"select ch.name, ch.id, adv_stats.* from adventure_stats "
|
||||
"AS adv_stats ""left join character_ AS ch on adv_stats.player_id = ch.id;"), errbuf, &result))
|
||||
std::string query = "select ch.name, ch.id, adv_stats.* from adventure_stats "
|
||||
"AS adv_stats ""left join character_ AS ch on "
|
||||
"adv_stats.player_id = ch.id;";
|
||||
|
||||
if(database.RunQuery(query,errbuf, &result))
|
||||
{
|
||||
while((row = mysql_fetch_row(result)))
|
||||
{
|
||||
@@ -1155,13 +1155,11 @@ void AdventureManager::LoadLeaderboardInfo()
|
||||
}
|
||||
}
|
||||
mysql_free_result(result);
|
||||
safe_delete_array(query);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), errbuf);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
+73
-83
@@ -34,19 +34,18 @@ EQLConfig::EQLConfig(const char *launcher_name)
|
||||
|
||||
void EQLConfig::LoadSettings() {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
LauncherZone tmp;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63); //limit len to 64
|
||||
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"SELECT dynamics FROM launcher WHERE name='%s'",
|
||||
namebuf)
|
||||
, errbuf, &result))
|
||||
StringFormat(query,"SELECT dynamics FROM launcher WHERE name='%s'",namebuf.c_str());
|
||||
|
||||
if (database.RunQuery(query, errbuf, &result))
|
||||
{
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
m_dynamics = atoi(row[0]);
|
||||
@@ -55,12 +54,10 @@ void EQLConfig::LoadSettings() {
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"SELECT zone,port FROM launcher_zones WHERE launcher='%s'",
|
||||
namebuf)
|
||||
, errbuf, &result))
|
||||
StringFormat(query, "SELECT zone,port FROM launcher_zones WHERE launcher='%s'", namebuf.c_str());
|
||||
|
||||
if (database.RunQuery(query, errbuf, &result))
|
||||
{
|
||||
LauncherZone zs;
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
@@ -72,25 +69,23 @@ void EQLConfig::LoadSettings() {
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, name, strlen(name)&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, name, strlen(name));
|
||||
namebuf.resize(63); //limit len to 64
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"INSERT INTO launcher (name,dynamics) VALUES('%s', %d)",
|
||||
namebuf, dynamic_count), errbuf)) {
|
||||
StringFormat(query, "INSERT INTO launcher (name,dynamics) VALUES('%s', %d)",
|
||||
namebuf.c_str(), dynamic_count);
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return nullptr;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
return(new EQLConfig(name));
|
||||
}
|
||||
@@ -127,29 +122,26 @@ void EQLConfig::DeleteLauncher() {
|
||||
launcher_list.Remove(m_name.c_str());
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63); //limit len to 64
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"DELETE FROM launcher WHERE name='%s'",
|
||||
namebuf), errbuf)) {
|
||||
StringFormat(query, "DELETE FROM launcher WHERE name='%s'",namebuf.c_str());
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"DELETE FROM launcher_zones WHERE launcher='%s'",
|
||||
namebuf), errbuf)) {
|
||||
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s'",
|
||||
namebuf.c_str());
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
bool EQLConfig::IsConnected() const {
|
||||
@@ -185,23 +177,23 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
|
||||
|
||||
//database update
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
char zonebuf[32];
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
|
||||
zonebuf[31] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63); //limit len to 64
|
||||
|
||||
std::string zonebuf;
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name));
|
||||
zonebuf.resize(15); //limit len to 16
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)",
|
||||
namebuf, zonebuf, port), errbuf)) {
|
||||
StringFormat(query, "INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)",
|
||||
namebuf.c_str(), zonebuf.c_str(), port);
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
//update our internal state.
|
||||
LauncherZone lz;
|
||||
@@ -235,24 +227,23 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
||||
|
||||
//database update
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
char zonebuf[32];
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
|
||||
zonebuf[31] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63); //limit len to 64
|
||||
|
||||
std::string zonebuf;
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name)); //limit len to 16
|
||||
zonebuf.resize(15);
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
|
||||
port, namebuf, zonebuf), errbuf)) {
|
||||
StringFormat(query, "UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
|
||||
port, namebuf.c_str(), zonebuf.c_str());
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
|
||||
//update internal state
|
||||
res->second.port = port;
|
||||
@@ -278,23 +269,23 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
||||
|
||||
//database update
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
char zonebuf[32];
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
|
||||
zonebuf[31] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63);//limit len to 64
|
||||
|
||||
std::string zonebuf;
|
||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name));
|
||||
zonebuf.resize(15); //limit len to 16
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'",
|
||||
namebuf, zonebuf), errbuf)) {
|
||||
StringFormat(query, "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'",
|
||||
namebuf.c_str(), zonebuf.c_str());
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
//internal update.
|
||||
m_zones.erase(res);
|
||||
@@ -310,20 +301,19 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
||||
|
||||
bool EQLConfig::SetDynamicCount(int count) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char namebuf[128];
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||
namebuf[127] = '\0';
|
||||
std::string namebuf;
|
||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length());
|
||||
namebuf.resize(63);//limit len to 64
|
||||
|
||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"UPDATE launcher SET dynamics=%d WHERE name='%s'",
|
||||
count, namebuf), errbuf)) {
|
||||
StringFormat(query, "UPDATE launcher SET dynamics=%d WHERE name='%s'",
|
||||
count, namebuf.c_str());
|
||||
|
||||
if (!database.RunQuery(query, errbuf)) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", errbuf);
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
//update in-memory version.
|
||||
m_dynamics = count;
|
||||
|
||||
+20
-16
@@ -385,11 +385,12 @@ bool EQW::SetPublicNote(uint32 charid, const char *note) {
|
||||
|
||||
int EQW::CountBugs() {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT count(*) FROM bugs where status = 0"), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
std::string query = "SELECT count(*) FROM bugs where status = 0";
|
||||
|
||||
if(database.RunQuery(query, errbuf, &result)) {
|
||||
if((row = mysql_fetch_row(result))) {
|
||||
int count = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
@@ -397,35 +398,37 @@ int EQW::CountBugs() {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> EQW::ListBugs(uint32 offset) {
|
||||
std::vector<std::string> res;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
StringFormat(query,"SELECT id FROM bugs WHERE status = 0 limit %d, 30", offset);
|
||||
|
||||
if(database.RunQuery(query, errbuf, &result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
res.push_back(row[0]);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
return res;
|
||||
}
|
||||
|
||||
std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
|
||||
std::map<std::string,std::string> res;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if(database.RunQuery(query, MakeAnyLenString(&query, "select name, zone, x, y, z, target, bug from bugs where id = %s", id), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
StringFormat(query,"select name, zone, x, y, z, target, bug from bugs where id = %s", id);
|
||||
|
||||
if(database.RunQuery(query, errbuf, &result)) {
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
res["name"] = row[0];
|
||||
res["zone"] = row[1];
|
||||
@@ -438,18 +441,19 @@ std::map<std::string,std::string> EQW::GetBugDetails(Const_char *id) {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
return res;
|
||||
}
|
||||
|
||||
void EQW::ResolveBug(const char *id) {
|
||||
std::vector<std::string> res;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
if(database.RunQuery(query, MakeAnyLenString(&query, "UPDATE bugs SET status=1 WHERE id=%s", id), errbuf)) {
|
||||
safe_delete_array(query);
|
||||
std::string query;
|
||||
|
||||
StringFormat(query,"UPDATE bugs SET status=1 WHERE id=%s", id);
|
||||
|
||||
if(!database.RunQuery(query, errbuf)) {
|
||||
// TODO: log failed statement.
|
||||
}
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
void EQW::SendMessage(uint32 type, const char *msg) {
|
||||
|
||||
+65
-68
@@ -36,7 +36,7 @@ extern std::vector<RaceClassCombos> character_create_race_class_combos;
|
||||
// solar: the current stuff is at the bottom of this function
|
||||
void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* cs) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
Inventory *inv;
|
||||
@@ -53,8 +53,12 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
||||
unsigned long* lengths;
|
||||
|
||||
// Populate character info
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name,profile,zonename,class,level FROM character_ WHERE account_id=%i order by name limit 10", account_id), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
StringFormat(query,"SELECT name,profile,zonename,class,level "
|
||||
"FROM character_ WHERE account_id=%i "
|
||||
"order by name limit 10",
|
||||
account_id);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
lengths = mysql_fetch_lengths(result);
|
||||
////////////
|
||||
@@ -119,18 +123,12 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
||||
}
|
||||
}
|
||||
else {
|
||||
RunQuery(query,
|
||||
MakeAnyLenString(&query,
|
||||
"SELECT zone_id,bind_id,x,y,z FROM start_zones "
|
||||
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
||||
pp->class_,
|
||||
pp->deity,
|
||||
pp->race
|
||||
),
|
||||
errbuf,
|
||||
&result2
|
||||
);
|
||||
safe_delete_array(query);
|
||||
|
||||
StringFormat(query, "SELECT zone_id,bind_id,x,y,z FROM start_zones "
|
||||
"WHERE player_class=%i AND player_deity=%i AND player_race=%i",
|
||||
pp->class_, pp->deity, pp->race);
|
||||
|
||||
RunQuery(query,errbuf,&result2);
|
||||
|
||||
// if there is only one possible start city, set it
|
||||
if(mysql_num_rows(result2) == 1) {
|
||||
@@ -160,8 +158,10 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
||||
// update the player profile
|
||||
if(altered) {
|
||||
uint32 char_id = GetCharacterID(cs->name[char_num]);
|
||||
RunQuery(query,MakeAnyLenString(&query,"SELECT extprofile FROM character_ WHERE id=%i",char_id), errbuf, &result2);
|
||||
safe_delete_array(query);
|
||||
|
||||
StringFormat(query,"SELECT extprofile FROM character_ WHERE id=%i",char_id);
|
||||
|
||||
RunQuery(query,errbuf, &result2);
|
||||
if(result2) {
|
||||
row2 = mysql_fetch_row(result2);
|
||||
ExtendedProfile_Struct* ext = (ExtendedProfile_Struct*)row2[0];
|
||||
@@ -229,7 +229,6 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
||||
else
|
||||
{
|
||||
std::cerr << "Error in GetCharSelectInfo query '" << query << "' " << errbuf << std::endl;
|
||||
safe_delete_array(query);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -242,7 +241,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
bindnum = 0;
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
uint32 affected_rows = 0;
|
||||
@@ -250,7 +249,9 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
|
||||
bool PPValid = false;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT profile from character_ where id='%i'", CharID), errbuf, &result)) {
|
||||
StringFormat(query, "SELECT profile from character_ where id='%i'", CharID);
|
||||
|
||||
if (RunQuery(query, errbuf, &result)) {
|
||||
row = mysql_fetch_row(result);
|
||||
unsigned long* lengths = mysql_fetch_lengths(result);
|
||||
if (lengths[0] == sizeof(PlayerProfile_Struct)) {
|
||||
@@ -259,7 +260,6 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if(!PPValid) return 0;
|
||||
|
||||
@@ -267,13 +267,14 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
|
||||
if(!strcmp(BindZoneName, "UNKNWN")) return pp.zone_id;
|
||||
|
||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=%f, y=%f, z=%f, instanceid=0 WHERE id='%i'",
|
||||
StringFormat(query, "UPDATE character_ SET zonename = '%s',zoneid=%i,x=%f, y=%f, z=%f, instanceid=0 WHERE id='%i'",
|
||||
BindZoneName, pp.binds[bindnum].zoneId, pp.binds[bindnum].x, pp.binds[bindnum].y, pp.binds[bindnum].z,
|
||||
CharID), errbuf, 0,&affected_rows)) {
|
||||
CharID);
|
||||
|
||||
if (!RunQuery(query, errbuf, nullptr,&affected_rows)) {
|
||||
|
||||
return pp.zone_id;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
return pp.binds[bindnum].zoneId;
|
||||
}
|
||||
@@ -281,7 +282,7 @@ int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row = 0;
|
||||
int rows;
|
||||
@@ -292,20 +293,19 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct*
|
||||
in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0;
|
||||
in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = 0;
|
||||
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "SELECT x,y,z,heading,zone_id,bind_id FROM start_zones WHERE player_choice=%i AND player_class=%i "
|
||||
"AND player_deity=%i AND player_race=%i",
|
||||
in_cc->start_zone,
|
||||
in_cc->class_,
|
||||
in_cc->deity,
|
||||
in_cc->race), errbuf, &result))
|
||||
StringFormat(query, "SELECT x,y,z,heading,zone_id,bind_id FROM "
|
||||
"start_zones WHERE player_choice=%i AND player_class=%i "
|
||||
"AND player_deity=%i AND player_race=%i",
|
||||
in_cc->start_zone, in_cc->class_,
|
||||
in_cc->deity, in_cc->race);
|
||||
|
||||
if(!RunQuery(query, errbuf, &result))
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "Start zone query failed: %s : %s\n", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Error, "Start zone query failed: %s : %s\n", query.c_str(), errbuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogFile->write(EQEMuLog::Status, "Start zone query: %s\n", query);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Status, "Start zone query: %s\n", query.c_str());
|
||||
|
||||
if((rows = mysql_num_rows(result)) > 0)
|
||||
row = mysql_fetch_row(result);
|
||||
@@ -433,7 +433,7 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
||||
// reason for no match being found.
|
||||
//
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row = 0;
|
||||
int rows;
|
||||
@@ -444,20 +444,19 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
||||
in_pp->x = in_pp->y = in_pp->z = in_pp->heading = in_pp->zone_id = 0;
|
||||
in_pp->binds[0].x = in_pp->binds[0].y = in_pp->binds[0].z = in_pp->binds[0].zoneId = 0;
|
||||
|
||||
if(!RunQuery(query, MakeAnyLenString(&query, "SELECT x,y,z,heading,bind_id FROM start_zones WHERE zone_id=%i AND player_class=%i "
|
||||
"AND player_deity=%i AND player_race=%i",
|
||||
in_cc->start_zone,
|
||||
in_cc->class_,
|
||||
in_cc->deity,
|
||||
in_cc->race), errbuf, &result))
|
||||
StringFormat(query,"SELECT x,y,z,heading,bind_id FROM "
|
||||
"start_zones WHERE zone_id=%i AND player_class=%i "
|
||||
"AND player_deity=%i AND player_race=%i",
|
||||
in_cc->start_zone, in_cc->class_,
|
||||
in_cc->deity, in_cc->race);
|
||||
|
||||
if(!RunQuery(query, errbuf, &result))
|
||||
{
|
||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query failed: %s : %s\n", query.c_str(), errbuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query: %s\n", query);
|
||||
safe_delete_array(query);
|
||||
LogFile->write(EQEMuLog::Status, "SoF Start zone query: %s\n", query.c_str());
|
||||
|
||||
if((rows = mysql_num_rows(result)) > 0)
|
||||
row = mysql_fetch_row(result);
|
||||
@@ -499,15 +498,14 @@ bool WorldDatabase::GetStartZoneSoF(PlayerProfile_Struct* in_pp, CharCreate_Stru
|
||||
|
||||
void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
rl.clear();
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query,
|
||||
"SELECT name FROM launcher" )
|
||||
, errbuf, &result))
|
||||
std::string query = "SELECT name FROM launcher";
|
||||
|
||||
if (RunQuery(query, errbuf, &result))
|
||||
{
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
rl.push_back(row[0]);
|
||||
@@ -517,13 +515,12 @@ void WorldDatabase::GetLauncherList(std::vector<std::string> &rl) {
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetLauncherList: %s", errbuf);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) {
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
|
||||
char MailKeyString[17];
|
||||
|
||||
@@ -532,29 +529,29 @@ void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) {
|
||||
else
|
||||
sprintf(MailKeyString, "%08X", MailKey);
|
||||
|
||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET mailkey = '%s' WHERE id='%i'",
|
||||
MailKeyString, CharID), errbuf))
|
||||
StringFormat(query, "UPDATE character_ SET mailkey = '%s' WHERE id='%i'",
|
||||
MailKeyString, CharID);
|
||||
|
||||
if (!RunQuery(query, errbuf))
|
||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, errbuf);
|
||||
|
||||
safe_delete_array(query);
|
||||
|
||||
}
|
||||
|
||||
bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "SELECT level FROM character_ WHERE name='%s'", name), errbuf, &result))
|
||||
StringFormat(query, "SELECT level FROM character_ WHERE name='%s'", name);
|
||||
|
||||
if(RunQuery(query, errbuf, &result))
|
||||
{
|
||||
if(row = mysql_fetch_row(result))
|
||||
{
|
||||
level = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
safe_delete_array(query);
|
||||
return true;
|
||||
}
|
||||
mysql_free_result(result);
|
||||
@@ -563,7 +560,6 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
||||
{
|
||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::GetCharacterLevel: %s", errbuf);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -571,11 +567,13 @@ bool WorldDatabase::LoadCharacterCreateAllocations() {
|
||||
character_create_allocations.clear();
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "SELECT * FROM char_create_point_allocations order by id"), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
std::string query = "SELECT * FROM char_create_point_allocations order by id";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
while(row = mysql_fetch_row(result)) {
|
||||
RaceClassAllocation allocate;
|
||||
int r = 0;
|
||||
@@ -598,7 +596,6 @@ bool WorldDatabase::LoadCharacterCreateAllocations() {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -609,11 +606,12 @@ bool WorldDatabase::LoadCharacterCreateCombos() {
|
||||
character_create_race_class_combos.clear();
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "select * from char_create_combinations order by race, class, deity, start_zone"), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
|
||||
std::string query ="select * from char_create_combinations order by race, class, deity, start_zone";
|
||||
|
||||
if(RunQuery(query, errbuf, &result)) {
|
||||
while(row = mysql_fetch_row(result)) {
|
||||
RaceClassCombos combo;
|
||||
int r = 0;
|
||||
@@ -627,7 +625,6 @@ bool WorldDatabase::LoadCharacterCreateCombos() {
|
||||
}
|
||||
mysql_free_result(result);
|
||||
} else {
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+11
-7
@@ -448,7 +448,7 @@ bool ZoneServer::Process() {
|
||||
else if (cle->Online() == CLE_Status_Zoning) {
|
||||
if (!scm->noreply) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
std::string query;
|
||||
MYSQL_RES *result;
|
||||
//MYSQL_ROW row; Trumpcard - commenting. Currently unused.
|
||||
time_t rawtime;
|
||||
@@ -456,21 +456,25 @@ bool ZoneServer::Process() {
|
||||
time ( &rawtime );
|
||||
timeinfo = localtime ( &rawtime );
|
||||
char *telldate=asctime(timeinfo);
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT name from character_ where name='%s'",scm->deliverto), errbuf, &result)) {
|
||||
safe_delete(query);
|
||||
|
||||
StringFormat(query,"SELECT name from character_ where name='%s'",scm->deliverto);
|
||||
|
||||
if (database.RunQuery(query,errbuf, &result)) {
|
||||
if (result!=0) {
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO tellque (Date,Receiver,Sender,Message) values('%s','%s','%s','%s')",telldate,scm->deliverto,scm->from,scm->message), errbuf, &result))
|
||||
|
||||
StringFormat(query, "INSERT INTO tellque (Date,Receiver,Sender,Message) "
|
||||
"values('%s','%s','%s','%s')",
|
||||
telldate, scm->deliverto, scm->from,scm->message);
|
||||
|
||||
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);
|
||||
else
|
||||
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
|
||||
safe_delete(query);
|
||||
}
|
||||
else
|
||||
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
safe_delete(query);
|
||||
}
|
||||
// zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user