mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-03 06:23:53 +00:00
Removed command character backup
Changed all remaining references from the character_ table to the character_data
This commit is contained in:
parent
e50cf5c4be
commit
4c12d31e4a
@ -728,7 +728,7 @@ uint32 Database::GetAccountIDByChar(const char* charname) {
|
||||
|
||||
// Retrieve account_id for a given char_id
|
||||
uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
std::string query = StringFormat("SELECT `account_id` FROM `character_` WHERE `id` = %i LIMIT 1", char_id);
|
||||
std::string query = StringFormat("SELECT `account_id` FROM `character_data` WHERE `id` = %i LIMIT 1", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetAccountIDByChar query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
@ -892,10 +892,10 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) {
|
||||
" FROM vwBotCharacterMobs AS c LEFT JOIN vwGuildMembers AS g ON c.id=g.char_id AND c.mobtype = g.mobtype "
|
||||
#else
|
||||
#define GuildMemberBaseQuery \
|
||||
"SELECT c.id,c.name,c.class,c.level,c.timelaston,c.zoneid," \
|
||||
"SELECT c.id,c.name,c.class,c.level,c.last_login,c.zone_id," \
|
||||
" g.guild_id,g.rank,g.tribute_enable,g.total_tribute,g.last_tribute," \
|
||||
" g.banker,g.public_note,g.alt " \
|
||||
" FROM character_ AS c LEFT JOIN guild_members AS g ON c.id=g.char_id "
|
||||
" FROM `character_data` AS c LEFT JOIN guild_members AS g ON c.id=g.char_id "
|
||||
#endif
|
||||
static void ProcessGuildMember(MySQLRequestRow row, CharGuildInfo &into) {
|
||||
//fields from `characer_`
|
||||
@ -1236,7 +1236,7 @@ BaseGuildManager::GuildInfo::GuildInfo() {
|
||||
uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||
{
|
||||
std::string query = StringFormat("SELECT guild_id FROM guild_members WHERE char_id IN "
|
||||
"(SELECT id FROM character_ WHERE account_id = %i) AND rank = 2",
|
||||
"(SELECT id FROM `character_data` WHERE account_id = %i) AND rank = 2",
|
||||
AccountID);
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
|
||||
@ -384,7 +384,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
if (is_charid) {
|
||||
len_query = MakeAnyLenString(&query,
|
||||
"SELECT sb.slotid,sb.itemid,sb.charges,sb.augslot1,sb.augslot2,sb.augslot3,sb.augslot4,sb.augslot5,sb.custom_data from sharedbank sb "
|
||||
"INNER JOIN character_ ch ON ch.account_id=sb.acctid "
|
||||
"INNER JOIN character_data ch ON ch.account_id=sb.acctid "
|
||||
"WHERE ch.id=%i", id);
|
||||
}
|
||||
else {
|
||||
@ -604,7 +604,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
if (RunQuery(query, MakeAnyLenString(&query,
|
||||
" SELECT `slotid`, `itemid`, `charges`, `color`, `augslot1`, `augslot2`, `augslot3`, `augslot4`, `augslot5`, `instnodrop`, `custom_data`"
|
||||
" FROM `inventory`"
|
||||
" INNER JOIN character_ ch ON ch.id = charid"
|
||||
" INNER JOIN `character_data` ch ON ch.id = charid"
|
||||
" WHERE ch.NAME = '%s'"
|
||||
" AND ch.account_id = % i"
|
||||
" ORDER BY `slotid`",
|
||||
|
||||
@ -139,7 +139,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
||||
|
||||
client->ClearCharacters();
|
||||
std::string query = StringFormat("SELECT `id`, `account_id`, `level` "
|
||||
"FROM `character_` WHERE `name` = '%s' LIMIT 1",
|
||||
"FROM `character_data` WHERE `name` = '%s' LIMIT 1",
|
||||
characterName);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -159,7 +159,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
||||
|
||||
_log(UCS__TRACE, "Account ID for %s is %i", characterName, accountID);
|
||||
|
||||
query = StringFormat("SELECT `id`, `name`, `level` FROM `character_` "
|
||||
query = StringFormat("SELECT `id`, `name`, `level` FROM `character_data` "
|
||||
"WHERE `account_id` = %i AND `name` != '%s'",
|
||||
accountID, characterName);
|
||||
results = QueryDatabase(query);
|
||||
@ -174,7 +174,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
||||
|
||||
bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::string MailKey) {
|
||||
|
||||
std::string query = StringFormat("SELECT `mailkey` FROM `character_` WHERE `name`='%s' LIMIT 1",
|
||||
std::string query = StringFormat("SELECT `mailkey` FROM `character_data` WHERE `name`='%s' LIMIT 1",
|
||||
characterName.c_str());
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
@ -202,7 +202,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri
|
||||
int Database::FindCharacter(const char *characterName) {
|
||||
|
||||
char *safeCharName = RemoveApostrophes(characterName);
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_` WHERE `name`='%s' LIMIT 1", safeCharName);
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name`='%s' LIMIT 1", safeCharName);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(UCS__ERROR, "FindCharacter failed. %s %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
@ -1069,7 +1069,7 @@ void AdventureManager::LoadLeaderboardInfo()
|
||||
leaderboard_info_percentage_tak.clear();
|
||||
|
||||
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;";
|
||||
"AS adv_stats LEFT JOIN `character_data` AS ch ON adv_stats.player_id = ch.id;";
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
@ -182,45 +182,16 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct*
|
||||
}
|
||||
|
||||
int WorldDatabase::MoveCharacterToBind(int CharID, uint8 bindnum) {
|
||||
// if an invalid bind point is specified, use the primary bind
|
||||
if (bindnum > 4)
|
||||
bindnum = 0;
|
||||
/* if an invalid bind point is specified, use the primary bind */
|
||||
if (bindnum > 4){ bindnum = 0; }
|
||||
int is_home = 0;
|
||||
if (bindnum == 4){ is_home = 1; }
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
uint32 affected_rows = 0;
|
||||
PlayerProfile_Struct pp;
|
||||
|
||||
bool PPValid = false;
|
||||
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT profile from character_ where id='%i'", CharID), errbuf, &result)) {
|
||||
row = mysql_fetch_row(result);
|
||||
unsigned long* lengths = mysql_fetch_lengths(result);
|
||||
if (lengths[0] == sizeof(PlayerProfile_Struct)) {
|
||||
memcpy(&pp, row[0], sizeof(PlayerProfile_Struct));
|
||||
PPValid = true;
|
||||
}
|
||||
mysql_free_result(result);
|
||||
std::string query = StringFormat("SELECT `zone_id` FROM `character_bind` WHERE `id` = %u AND `is_home` = %u LIMIT 1", CharID, is_home);
|
||||
auto results = database.QueryDatabase(query); int i = 0;
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
return atoi(row[0]);
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
if(!PPValid) return 0;
|
||||
|
||||
const char *BindZoneName = StaticGetZoneName(pp.binds[bindnum].zoneId);
|
||||
|
||||
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'",
|
||||
BindZoneName, pp.binds[bindnum].zoneId, pp.binds[bindnum].x, pp.binds[bindnum].y, pp.binds[bindnum].z,
|
||||
CharID), errbuf, 0,&affected_rows)) {
|
||||
|
||||
return pp.zone_id;
|
||||
}
|
||||
safe_delete_array(query);
|
||||
|
||||
return pp.binds[bindnum].zoneId;
|
||||
}
|
||||
|
||||
bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* in_cc)
|
||||
@ -481,7 +452,7 @@ 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'",
|
||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE `character_data` SET mailkey = '%s' WHERE id='%i'",
|
||||
MailKeyString, CharID), errbuf))
|
||||
|
||||
LogFile->write(EQEMuLog::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, errbuf);
|
||||
@ -497,7 +468,7 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level)
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "SELECT level FROM character_ WHERE name='%s'", name), errbuf, &result))
|
||||
if(RunQuery(query, MakeAnyLenString(&query, "SELECT `level` FROM `character_data` WHERE `name` = '%s'", name), errbuf, &result))
|
||||
{
|
||||
if(row = mysql_fetch_row(result))
|
||||
{
|
||||
|
||||
@ -454,7 +454,7 @@ bool ZoneServer::Process() {
|
||||
timeinfo = localtime ( &rawtime );
|
||||
char *telldate=asctime(timeinfo);
|
||||
|
||||
std::string query = StringFormat("SELECT name FROM character_ WHERE name = '%s'",scm->deliverto);
|
||||
std::string query = StringFormat("SELECT name FROM `character_data` WHERE name = '%s'",scm->deliverto);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
break;
|
||||
|
||||
@ -4750,7 +4750,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app)
|
||||
}
|
||||
#ifdef BOTS
|
||||
else if (invitee->IsBot()) {
|
||||
// The guild system is too tightly coupled with the character_ table so we have to avoid using much of the system
|
||||
// The guild system is too tightly coupled with the character_data table so we have to avoid using much of the system
|
||||
Bot::ProcessGuildInvite(this, invitee->CastToBot());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -257,12 +257,11 @@ int command_init(void) {
|
||||
command_add("dbspawn",nullptr,0,command_npctypespawn) ||
|
||||
command_add("heal","- Completely heal your target",10,command_heal) ||
|
||||
command_add("appearance","[type] [value] - Send an appearance packet for you or your target",150,command_appearance) ||
|
||||
command_add("charbackup","[list/restore] - Query or restore character backups",150,command_charbackup) ||
|
||||
command_add("nukeitem","[itemid] - Remove itemid from your player target's inventory",150,command_nukeitem) ||
|
||||
command_add("peekinv","[worn/cursor/inv/bank/trade/trib/all] - Print out contents of your player target's inventory",100,command_peekinv) ||
|
||||
command_add("findnpctype","[search criteria] - Search database NPC types",100,command_findnpctype) ||
|
||||
command_add("findzone","[search criteria] - Search database zones",100,command_findzone) ||
|
||||
command_add("fz",nullptr,100,command_findzone) ||
|
||||
command_add("fz",nullptr,100, command_findzone) ||
|
||||
command_add("viewnpctype","[npctype id] - Show info about an npctype",100,command_viewnpctype) ||
|
||||
command_add("reloadstatic","- Reload Static Zone Data",150,command_reloadstatic) ||
|
||||
command_add("reloadquest"," - Clear quest cache (any argument causes it to also stop all timers)",150,command_reloadqst) ||
|
||||
@ -2767,85 +2766,6 @@ void command_appearance(Client *c, const Seperator *sep)
|
||||
}
|
||||
}
|
||||
|
||||
void command_charbackup(Client *c, const Seperator *sep)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES* result;
|
||||
MYSQL_ROW row;
|
||||
if (strcasecmp(sep->arg[1], "list") == 0) {
|
||||
uint32 charid = 0;
|
||||
if (sep->IsNumber(2))
|
||||
charid = atoi(sep->arg[2]);
|
||||
else
|
||||
database.GetAccountIDByChar(sep->arg[2]);
|
||||
if (charid) {
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"Select id, backupreason, charid, account_id, zoneid, DATE_FORMAT(ts, '%%m/%%d/%%Y %%H:%%i:%%s') "
|
||||
" from character_backup where charid=%u", charid), errbuf, &result)) {
|
||||
safe_delete(query);
|
||||
uint32 x = 0;
|
||||
while ((row = mysql_fetch_row(result))) {
|
||||
c->Message(0, " %u: %s, %s (%u), reason=%u", atoi(row[0]), row[5], database.GetZoneName(atoi(row[4])), atoi(row[4]), atoi(row[1]));
|
||||
x++;
|
||||
}
|
||||
c->Message(0, " %u backups found.", x);
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
c->Message(13, "Query error: '%s' %s", query, errbuf);
|
||||
safe_delete(query);
|
||||
}
|
||||
}
|
||||
else
|
||||
c->Message(0, "Usage: #charbackup list [char name/id]");
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "restore") == 0) {
|
||||
uint32 charid = 0;
|
||||
if (sep->IsNumber(2))
|
||||
charid = atoi(sep->arg[2]);
|
||||
else
|
||||
database.GetAccountIDByChar(sep->arg[2]);
|
||||
|
||||
if (charid && sep->IsNumber(3)) {
|
||||
uint32 cbid = atoi(sep->arg[3]);
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"Insert into character_backup (backupreason, charid, account_id, name, profile, level, class, x, y, z, zoneid, alt_adv) "
|
||||
" select 1, id, account_id, name, profile, level, class, x, y, z, zoneid, alt_adv from character_ where id=%u", charid), errbuf)) {
|
||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
||||
"update character_ inner join character_backup on character_.id = character_backup.charid "
|
||||
" set character_.name = character_backup.name, "
|
||||
" character_.profile = character_backup.profile, "
|
||||
" character_.level = character_backup.level, "
|
||||
" character_.class = character_backup.class, "
|
||||
" character_.x = character_backup.x, "
|
||||
" character_.y = character_backup.y, "
|
||||
" character_.z = character_backup.z, "
|
||||
" character_.zoneid = character_backup.zoneid "
|
||||
" where character_backup.charid=%u and character_backup.id=%u", charid, cbid), errbuf)) {
|
||||
safe_delete(query);
|
||||
c->Message(0, "Character restored.");
|
||||
}
|
||||
else {
|
||||
c->Message(13, "Query error: '%s' %s", query, errbuf);
|
||||
safe_delete(query);
|
||||
}
|
||||
}
|
||||
else {
|
||||
c->Message(13, "Query error: '%s' %s", query, errbuf);
|
||||
safe_delete(query);
|
||||
}
|
||||
}
|
||||
else
|
||||
c->Message(0, "Usage: #charbackup list [char name/id]");
|
||||
}
|
||||
else {
|
||||
c->Message(0, "#charbackup sub-commands:");
|
||||
c->Message(0, " list [char name/id]");
|
||||
c->Message(0, " restore [char name/id] [backup#]");
|
||||
}
|
||||
}
|
||||
|
||||
void command_nukeitem(Client *c, const Seperator *sep)
|
||||
{
|
||||
int numitems, itemid;
|
||||
@ -6296,7 +6216,7 @@ void command_ban(Client *c, const Seperator *sep)
|
||||
}
|
||||
else
|
||||
{
|
||||
database.RunQuery(query, MakeAnyLenString(&query, "SELECT account_id from character_ where name = '%s'", sep->arg[1]), errbuf, &result);
|
||||
database.RunQuery(query, MakeAnyLenString(&query, "SELECT account_id from `character_data` where name = '%s'", sep->arg[1]), errbuf, &result);
|
||||
if(query)
|
||||
{
|
||||
safe_delete_array(query);
|
||||
|
||||
@ -150,7 +150,6 @@ void command_texture(Client *c, const Seperator *sep);
|
||||
void command_npctypespawn(Client *c, const Seperator *sep);
|
||||
void command_heal(Client *c, const Seperator *sep);
|
||||
void command_appearance(Client *c, const Seperator *sep);
|
||||
void command_charbackup(Client *c, const Seperator *sep);
|
||||
void command_nukeitem(Client *c, const Seperator *sep);
|
||||
void command_peekinv(Client *c, const Seperator *sep);
|
||||
void command_findnpctype(Client *c, const Seperator *sep);
|
||||
|
||||
@ -24,59 +24,6 @@
|
||||
#include "client.h"
|
||||
#include "entity.h"
|
||||
|
||||
/*
|
||||
|
||||
CREATE TABLE guilds (
|
||||
id MEDIUMINT UNSIGNED NOT NULL,
|
||||
name VARCHAR(32) NOT NULL,
|
||||
leader int NOT NULL,
|
||||
minstatus SMALLINT NOT NULL,
|
||||
tribute INT UNSIGNED NOT NULL,
|
||||
motd TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(id),
|
||||
UNIQUE KEY(name),
|
||||
UNIQUE KEY(leader)
|
||||
);
|
||||
|
||||
CREATE TABLE guild_ranks (
|
||||
guild_id MEDIUMINT UNSIGNED NOT NULL,
|
||||
rank TINYINT UNSIGNED NOT NULL,
|
||||
title VARCHAR(128) NOT NULL,
|
||||
can_hear TINYINT UNSIGNED NOT NULL,
|
||||
can_speak TINYINT UNSIGNED NOT NULL,
|
||||
can_invite TINYINT UNSIGNED NOT NULL,
|
||||
can_remove TINYINT UNSIGNED NOT NULL,
|
||||
can_promote TINYINT UNSIGNED NOT NULL,
|
||||
can_demote TINYINT UNSIGNED NOT NULL,
|
||||
can_motd TINYINT UNSIGNED NOT NULL,
|
||||
can_warpeace TINYINT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY(guild_id,rank)
|
||||
);
|
||||
|
||||
# guild1 < guild2 by definition.
|
||||
CREATE TABLE guild_relations (
|
||||
guild1 MEDIUMINT UNSIGNED NOT NULL,
|
||||
guild2 MEDIUMINT UNSIGNED NOT NULL,
|
||||
relation TINYINT NOT NULL,
|
||||
PRIMARY KEY(guild1, guild1)
|
||||
);
|
||||
|
||||
CREATE TABLE guild_members (
|
||||
char_id INT NOT NULL,
|
||||
guild_id MEDIUMINT UNSIGNED NOT NULL,
|
||||
rank TINYINT UNSIGNED NOT NULL,
|
||||
tribute_enable TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
total_tribute INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
last_tribute INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
banker TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
public_note TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(char_id)
|
||||
);
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
ZoneGuildManager guild_mgr;
|
||||
GuildBankManager *GuildBanks;
|
||||
|
||||
|
||||
@ -1705,7 +1705,7 @@ bool ZoneDatabase::NoRentExpired(const char* name){
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "Select (UNIX_TIMESTAMP(NOW())-timelaston) from character_ where name='%s'", name), errbuf, &result)) {
|
||||
if (RunQuery(query, MakeAnyLenString(&query, "Select (UNIX_TIMESTAMP(NOW()) - last_login) from `character_data` where name='%s'", name), errbuf, &result)) {
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
row = mysql_fetch_row(result);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user