- Ported inspect_messages to character_inspect_messages

- Ported character leadership abilities to character_leadership_abilities
- Removed player profile debug printing
- Refactored total time entitled on account to load from the sum of time_played from all characters in character_data
This commit is contained in:
Akkadius 2014-09-06 21:50:29 -05:00
parent ca7dd7d741
commit e50cf5c4be
10 changed files with 935 additions and 1144 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@
#include "eq_packet_structs.h"
#include "item.h"
#pragma pack(1)
/*
@ -37,24 +36,24 @@
*/
struct ExtendedProfile_Struct {
// Pet stuff
uint16 pet_id;
uint16 old_pet_hp;
uint16 old_pet_mana;
SpellBuff_Struct pet_buffs[BUFF_COUNT];
uint32 pet_items[_MaterialCount];
char merc_name[64];
uint16 pet_id; /* Not Used */
uint16 old_pet_hp; /* Not Used */
uint16 old_pet_mana; /* Not Used */
SpellBuff_Struct pet_buffs[BUFF_COUNT]; /* Not Used */
uint32 pet_items[_MaterialCount]; /* Not Used */
char merc_name[64]; /* Used */
uint32 aa_effects;
uint32 perAA; //% of exp going to AAs
uint32 expended_aa; // Total of expended AA
uint32 pet_hp;
uint32 pet_mana;
uint32 mercTemplateID;
uint32 mercSuspendedTime;
bool mercIsSuspended;
uint32 mercTimerRemaining;
uint8 mercGender;
int32 mercState;
uint32 aa_effects; /* Used */
uint32 perAA; /* Used: % of exp going to AAs */
uint32 expended_aa; /* Used: Total of expended AA */
uint32 pet_hp; /* Not Used */
uint32 pet_mana; /* Not Used */
uint32 mercTemplateID; /* Not Used */
uint32 mercSuspendedTime; /* Not Used */
bool mercIsSuspended; /* Not Used */
uint32 mercTimerRemaining; /* Not Used */
uint8 mercGender; /* Not Used */
int32 mercState; /* Not Used */
};
#pragma pack()

View File

@ -114,31 +114,12 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
}
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {
uint32 EntitledTime = 0;
const char *EntitledQuery = "select sum(ascii(substring(profile, 237, 1)) + (ascii(substring(profile, 238, 1)) * 256) +"
"(ascii(substring(profile, 239, 1)) * 65536) + (ascii(substring(profile, 240, 1)) * 16777216))"
"from character_ where account_id = %i";
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, EntitledQuery, AccountID), errbuf, &result)) {
if (mysql_num_rows(result) == 1) {
row = mysql_fetch_row(result);
EntitledTime = atoi(row[0]);
}
mysql_free_result(result);
std::string query = StringFormat("SELECT `time_played` FROM `character_data` WHERE `account_id` = %u", AccountID);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
EntitledTime += atoi(row[0]);
}
safe_delete_array(query);
return EntitledTime;
}
@ -2003,38 +1984,19 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
return nullptr;
}
void SharedDatabase::GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT inspectmessage FROM character_ WHERE name='%s'", playername), errbuf, &result)) {
safe_delete_array(query);
if (mysql_num_rows(result) == 1) {
row = mysql_fetch_row(result);
memcpy(message, row[0], sizeof(InspectMessage_Struct));
}
mysql_free_result(result);
}
else {
std::cerr << "Error in GetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message) {
std::string query = StringFormat("SELECT `inspect_message` FROM `character_inspect_messages` WHERE `id` = %u LIMIT 1", character_id);
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::LoadCharacterInspectMessage", query);
auto row = results.begin();
memcpy(message, "", sizeof(InspectMessage_Struct));
for (auto row = results.begin(); row != results.end(); ++row) {
memcpy(message, row[0], sizeof(InspectMessage_Struct));
}
}
void SharedDatabase::SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE character_ SET inspectmessage='%s' WHERE name='%s'", message->text, playername), errbuf)) {
std::cerr << "Error in SetPlayerInspectMessage query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message) {
std::string query = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message) VALUES (%u, '%s')", character_id, EscapeString(message->text).c_str());
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::SaveCharacterInspectMessage", query);
}
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {

View File

@ -42,8 +42,8 @@ public:
bool SetHideMe(uint32 account_id, uint8 hideme);
int32 DeleteStalePlayerCorpses();
int32 DeleteStalePlayerBackups();
void GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message);
void SetPlayerInspectMessage(char* playername, const InspectMessage_Struct* message);
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
void SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message);
bool GetCommandSettings(std::map<std::string,uint8> &commands);

View File

@ -18,6 +18,8 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
// Test 1
#include <iostream>
#include "../common/debug.h"
#include "aa.h"
#include "mob.h"
@ -316,13 +318,14 @@ void Client::ActivateAA(aaID activate){
}
}
// Check if AA is expendable
if (aas_send[activate - activate_val]->special_category == 7)
{
if (aas_send[activate - activate_val]->special_category == 7) {
// Add the AA cost to the extended profile to track overall total
m_epp.expended_aa += aas_send[activate]->cost;
SetAA(activate, 0);
Save();
SaveAA(); /* Save Character AA */
SendAA(activate);
SendAATable();
}
@ -1047,7 +1050,7 @@ void Client::BuyAA(AA_Action* action)
mlog(AA__MESSAGE, "Set AA %d to level %d", aa2->id, cur_level + 1);
m_pp.aapoints -= real_cost;
/* Do Player Profile rank calculations and set player profile */
SaveAA();
/* Save to Database to avoid having to write the whole AA array to the profile, only write changes*/
@ -1533,6 +1536,8 @@ void Client::ResetAA(){
m_pp.raid_leadership_points = 0;
m_pp.group_leadership_exp = 0;
m_pp.raid_leadership_exp = 0;
database.DeleteCharacterLeadershipAAs(this->CharacterID());
}
int Client::GroupLeadershipAAHealthEnhancement()

View File

@ -503,7 +503,7 @@ bool Client::SaveAA(){
}
}
}
m_pp.aapoints_spent = spentpoints + m_epp.expended_aa;
m_pp.aapoints_spent = spentpoints + m_epp.expended_aa;
for (int a = 0; a < MAX_PP_AA_ARRAY; a++) {
if (aa[a]->AA > 0 && aa[a]->value){
if (first_entry != 1){
@ -582,7 +582,7 @@ bool Client::Save(uint8 iCommitNow) {
database.SaveCharacterTribute(this->CharacterID(), &m_pp);
SaveTaskState(); /* Save Character Task */
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp); /* Save Character Data */
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp, &m_epp); /* Save Character Data */
LogFile->write(EQEMuLog::Status, "Client::Save %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
return true;
@ -4233,7 +4233,6 @@ void Client::VoiceMacroReceived(uint32 Type, char *Target, uint32 MacroNumber) {
}
void Client::ClearGroupAAs() {
for(unsigned int i = 0; i < MAX_GROUP_LEADERSHIP_AA_ARRAY; i++)
m_pp.leader_abilities.ranks[i] = 0;
@ -4243,28 +4242,18 @@ void Client::ClearGroupAAs() {
m_pp.raid_leadership_exp = 0;
Save();
database.SaveCharacterLeadershipAA(this->CharacterID(), &m_pp);
}
void Client::UpdateGroupAAs(int32 points, uint32 type) {
switch(type)
{
case 0:
{
m_pp.group_leadership_points += points;
break;
}
case 1:
{
m_pp.raid_leadership_points += points;
break;
}
switch(type) {
case 0: { m_pp.group_leadership_points += points; break; }
case 1: { m_pp.raid_leadership_points += points; break; }
}
SendLeadershipEXPUpdate();
}
bool Client::IsLeadershipEXPOn()
{
bool Client::IsLeadershipEXPOn() {
if(!m_pp.leadAAActive)
return false;

View File

@ -494,8 +494,7 @@ int Client::HandlePacket(const EQApplicationPacket *app)
return(true);
}
void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
{
void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) {
if(app->size != sizeof(ClientZoneEntry_Struct))
return;
ClientZoneEntry_Struct *cze = (ClientZoneEntry_Struct *) app->pBuffer;
@ -543,7 +542,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
std::string query;
unsigned long* lengths;
/* Set item materials */
/* Set item material tint */
for (int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_END; i++)
if (m_pp.item_tint[i].rgb.use_tint == 1)
m_pp.item_tint[i].rgb.use_tint = 0xFF;
@ -569,24 +568,24 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
if (account_creation){ account_creation = atoul(row[6]); }
}
/* Load Character Legacy Data: Temp until I move */
query = StringFormat("SELECT id,profile,zonename,x,y,z,guild_id,rank,extprofile,class,level,lfp,lfg,instanceid,xtargets,firstlogon FROM character_ LEFT JOIN guild_members ON id=char_id WHERE id=%i", cid);
/* Load Character Data */
query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid);
results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
m_pp.lastlogin = time(nullptr);
if (row[6]){
guild_id = atoi(row[6]);
if (row[4]){
guild_id = atoi(row[4]);
if (guildrank) {
if (row[7] != nullptr){ guildrank = atoi(row[7]); }
if (row[5] != nullptr){ guildrank = atoi(row[5]); }
else{ guildrank = GUILD_RANK_NONE; }
}
}
if (RuleB(Character, SharedBankPlat))
m_pp.platinum_shared = database.GetSharedPlatinum(database.GetAccountIDByChar(cid));
if (LFP){ LFP = atoi(row[11]); }
if (LFG){ LFG = atoi(row[12]); }
if (firstlogon){ firstlogon = atoi(row[15]); }
if (LFP){ LFP = atoi(row[0]); }
if (LFG){ LFG = atoi(row[1]); }
if (firstlogon){ firstlogon = atoi(row[3]); }
}
loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */
@ -595,13 +594,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */
database.LoadCharacterPotions(cid, &m_pp); /* Load Character Potion Belt */
database.LoadCharacterCurrency(cid, &m_pp); /* Load Character Currency into PP */
database.LoadCharacterData(cid, &m_pp); /* Load Character Data from DB into PP */
database.LoadCharacterData(cid, &m_pp, &m_epp); /* Load Character Data from DB into PP as well as E_PP */
database.LoadCharacterSkills(cid, &m_pp); /* Load Character Skills */
database.GetPlayerInspectMessage(m_pp.name, &m_inspect_message); /* Move to another method when can, this is pointless... */
database.LoadCharacterInspectMessage(cid, &m_inspect_message); /* Load Character Inspect Message */
database.LoadCharacterSpellBook(cid, &m_pp); /* Load Character Spell Book */
database.LoadCharacterMemmedSpells(cid, &m_pp); /* Load Character Memorized Spells */
database.LoadCharacterDisciplines(cid, &m_pp); /* Load Character Disciplines */
database.LoadCharacterLanguages(cid, &m_pp); /* Load Character Languages */
database.LoadCharacterLeadershipAA(cid, &m_pp); /* Load Character Leadership AA's */
if (level){ level = m_pp.level; }
@ -619,7 +619,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
m_pp.intoxication = 0;
strcpy(name, m_pp.name);
strcpy(lastname, m_pp.last_name);
/* If PP is set to wierd coordinates */
/* If PP is set to weird coordinates */
if ((m_pp.x == -1 && m_pp.y == -1 && m_pp.z == -1) || (m_pp.x == -2 && m_pp.y == -2 && m_pp.z == -2)) {
m_pp.x = zone->safe_x();
m_pp.y = zone->safe_y();
@ -900,8 +900,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
if (zone->IsPVPZone())
m_pp.pvp = 1;
/* Time entitled on Account: Move to account */
m_pp.timeentitledonaccount = database.GetTotalTimeEntitledOnAccount(AccountID()) / 1440;
m_pp.timeentitledonaccount = database.GetTotalTimeEntitledOnAccount(AccountID()) / 1440;
/* Reset rest timer if the durations have been lowered in the database */
if ((m_pp.RestTimer > RuleI(Character, RestRegenTimeToActivate)) && (m_pp.RestTimer > RuleI(Character, RestRegenRaidTimeToActivate)))
m_pp.RestTimer = 0;
@ -926,8 +925,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
in hopes that it adds more consistency...
Remake pet
*/
if (m_petinfo.SpellID > 1 && !GetPet() && m_petinfo.SpellID <= SPDAT_RECORDS)
{
if (m_petinfo.SpellID > 1 && !GetPet() && m_petinfo.SpellID <= SPDAT_RECORDS) {
MakePoweredPet(m_petinfo.SpellID, spells[m_petinfo.SpellID].teleport_zone, m_petinfo.petpower, m_petinfo.Name, m_petinfo.size);
if (GetPet() && GetPet()->IsNPC()) {
NPC *pet = GetPet()->CastToNPC();
@ -1022,8 +1020,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
QueuePacket(outapp);
safe_delete(outapp);
SetAttackTimer();
SetAttackTimer();
conn_state = ZoneInfoSent;
return;
@ -7312,7 +7309,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) {
InspectMessage_Struct* newmessage = (InspectMessage_Struct*) insr->text;
InspectMessage_Struct& playermessage = this->GetInspectMessage();
memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct));
database.SetPlayerInspectMessage(name, &playermessage);
database.SaveCharacterInspectMessage(this->CharacterID(), &playermessage);
if(tmp != 0 && tmp->IsClient()) { tmp->CastToClient()->QueuePacket(outapp); } // Send answer to requester
@ -7329,7 +7326,7 @@ void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) {
InspectMessage_Struct* newmessage = (InspectMessage_Struct*) app->pBuffer;
InspectMessage_Struct& playermessage = this->GetInspectMessage();
memcpy(&playermessage, newmessage, sizeof(InspectMessage_Struct));
database.SetPlayerInspectMessage(name, &playermessage);
database.SaveCharacterInspectMessage(this->CharacterID(), &playermessage);
}
#if 0 // I dont think there's an op for this now, and we check this
@ -9559,6 +9556,8 @@ void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) {
//sell them the ability.
m_pp.group_leadership_points -= cost;
m_pp.leader_abilities.ranks[aaid]++;
database.SaveCharacterLeadershipAA(this->CharacterID(), &m_pp);
}
//success, send them an update

View File

@ -103,7 +103,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
}
zone->zonemap = Map::LoadMapFile(zone->map_name);
zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name);
zone->pathing = PathManager::LoadPathFile(zone->map_name);
zone->pathing = PathManager::LoadPathFile(zone->map_name);
char tmp[10];
if (database.GetVariable("loglevel",tmp, 9)) {

View File

@ -821,7 +821,7 @@ void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity)
#define StructDist(in, f1, f2) (uint32(&in->f2)-uint32(&in->f1))
bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct* pp){
bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp){
std::string query = StringFormat(
"SELECT "
"`name`, "
@ -911,100 +911,106 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct*
"group_auto_consent, "
"raid_auto_consent, "
"guild_auto_consent, "
"RestTimer "
"RestTimer, "
"`e_aa_effects`, "
"`e_percent_to_aa`, "
"`e_expended_aa_spent` "
"FROM "
"character_data "
"WHERE `id` = %i ", character_id);
auto results = database.QueryDatabase(query); int r = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
strcpy(pp->name, row[r]); r++;
strcpy(pp->last_name, row[r]); r++;
pp->gender = atoi(row[r]); r++;
pp->race = atoi(row[r]); r++;
pp->class_ = atoi(row[r]); r++;
pp->level = atoi(row[r]); r++;
pp->deity = atoi(row[r]); r++;
pp->birthday = atoi(row[r]); r++;
pp->lastlogin = atoi(row[r]); r++;
pp->timePlayedMin = atoi(row[r]); r++;
pp->pvp = atoi(row[r]); r++;
pp->level2 = atoi(row[r]); r++;
pp->anon = atoi(row[r]); r++;
pp->gm = atoi(row[r]); r++;
pp->intoxication = atoi(row[r]); r++;
pp->haircolor = atoi(row[r]); r++;
pp->beardcolor = atoi(row[r]); r++;
pp->eyecolor1 = atoi(row[r]); r++;
pp->eyecolor2 = atoi(row[r]); r++;
pp->hairstyle = atoi(row[r]); r++;
pp->beard = atoi(row[r]); r++;
pp->ability_time_seconds = atoi(row[r]); r++;
pp->ability_number = atoi(row[r]); r++;
pp->ability_time_minutes = atoi(row[r]); r++;
pp->ability_time_hours = atoi(row[r]); r++;
strcpy(pp->title, row[r]); r++;
strcpy(pp->suffix, row[r]); r++;
pp->exp = atoi(row[r]); r++;
pp->points = atoi(row[r]); r++;
pp->mana = atoi(row[r]); r++;
pp->cur_hp = atoi(row[r]); r++;
pp->STR = atoi(row[r]); r++;
pp->STA = atoi(row[r]); r++;
pp->CHA = atoi(row[r]); r++;
pp->DEX = atoi(row[r]); r++;
pp->INT = atoi(row[r]); r++;
pp->AGI = atoi(row[r]); r++;
pp->WIS = atoi(row[r]); r++;
pp->face = atoi(row[r]); r++;
pp->y = atof(row[r]); r++;
pp->x = atof(row[r]); r++;
pp->z = atof(row[r]); r++;
pp->heading = atof(row[r]); r++;
pp->pvp2 = atoi(row[r]); r++;
pp->pvptype = atoi(row[r]); r++;
pp->autosplit = atoi(row[r]); r++;
pp->zone_change_count = atoi(row[r]); r++;
pp->drakkin_heritage = atoi(row[r]); r++;
pp->drakkin_tattoo = atoi(row[r]); r++;
pp->drakkin_details = atoi(row[r]); r++;
pp->toxicity = atoi(row[r]); r++;
pp->hunger_level = atoi(row[r]); r++;
pp->thirst_level = atoi(row[r]); r++;
pp->ability_up = atoi(row[r]); r++;
pp->zone_id = atoi(row[r]); r++;
pp->zoneInstance = atoi(row[r]); r++;
pp->leadAAActive = atoi(row[r]); r++;
pp->ldon_points_guk = atoi(row[r]); r++;
pp->ldon_points_mir = atoi(row[r]); r++;
pp->ldon_points_mmc = atoi(row[r]); r++;
pp->ldon_points_ruj = atoi(row[r]); r++;
pp->ldon_points_tak = atoi(row[r]); r++;
pp->ldon_points_available = atoi(row[r]); r++;
pp->tribute_time_remaining = atoi(row[r]); r++;
pp->showhelm = atoi(row[r]); r++;
pp->career_tribute_points = atoi(row[r]); r++;
pp->tribute_points = atoi(row[r]); r++;
pp->tribute_active = atoi(row[r]); r++;
pp->endurance = atoi(row[r]); r++;
pp->group_leadership_exp = atoi(row[r]); r++;
pp->raid_leadership_exp = atoi(row[r]); r++;
pp->group_leadership_points = atoi(row[r]); r++;
pp->raid_leadership_points = atoi(row[r]); r++;
pp->air_remaining = atoi(row[r]); r++;
pp->PVPKills = atoi(row[r]); r++;
pp->PVPDeaths = atoi(row[r]); r++;
pp->PVPCurrentPoints = atoi(row[r]); r++;
pp->PVPCareerPoints = atoi(row[r]); r++;
pp->PVPBestKillStreak = atoi(row[r]); r++;
pp->PVPWorstDeathStreak = atoi(row[r]); r++;
pp->PVPCurrentKillStreak = atoi(row[r]); r++;
pp->aapoints_spent = atoi(row[r]); r++;
pp->expAA = atoi(row[r]); r++;
pp->aapoints = atoi(row[r]); r++;
pp->groupAutoconsent = atoi(row[r]); r++;
pp->raidAutoconsent = atoi(row[r]); r++;
pp->guildAutoconsent = atoi(row[r]); r++;
pp->RestTimer = atoi(row[r]); r++;
strcpy(pp->name, row[r]); r++; // "`name`, "
strcpy(pp->last_name, row[r]); r++; // "last_name, "
pp->gender = atoi(row[r]); r++; // "gender, "
pp->race = atoi(row[r]); r++; // "race, "
pp->class_ = atoi(row[r]); r++; // "class, "
pp->level = atoi(row[r]); r++; // "`level`, "
pp->deity = atoi(row[r]); r++; // "deity, "
pp->birthday = atoi(row[r]); r++; // "birthday, "
pp->lastlogin = atoi(row[r]); r++; // "last_login, "
pp->timePlayedMin = atoi(row[r]); r++; // "time_played, "
pp->pvp = atoi(row[r]); r++; // "pvp_status, "
pp->level2 = atoi(row[r]); r++; // "level2, "
pp->anon = atoi(row[r]); r++; // "anon, "
pp->gm = atoi(row[r]); r++; // "gm, "
pp->intoxication = atoi(row[r]); r++; // "intoxication, "
pp->haircolor = atoi(row[r]); r++; // "hair_color, "
pp->beardcolor = atoi(row[r]); r++; // "beard_color, "
pp->eyecolor1 = atoi(row[r]); r++; // "eye_color_1, "
pp->eyecolor2 = atoi(row[r]); r++; // "eye_color_2, "
pp->hairstyle = atoi(row[r]); r++; // "hair_style, "
pp->beard = atoi(row[r]); r++; // "beard, "
pp->ability_time_seconds = atoi(row[r]); r++; // "ability_time_seconds, "
pp->ability_number = atoi(row[r]); r++; // "ability_number, "
pp->ability_time_minutes = atoi(row[r]); r++; // "ability_time_minutes, "
pp->ability_time_hours = atoi(row[r]); r++; // "ability_time_hours, "
strcpy(pp->title, row[r]); r++; // "title, "
strcpy(pp->suffix, row[r]); r++; // "suffix, "
pp->exp = atoi(row[r]); r++; // "exp, "
pp->points = atoi(row[r]); r++; // "points, "
pp->mana = atoi(row[r]); r++; // "mana, "
pp->cur_hp = atoi(row[r]); r++; // "cur_hp, "
pp->STR = atoi(row[r]); r++; // "str, "
pp->STA = atoi(row[r]); r++; // "sta, "
pp->CHA = atoi(row[r]); r++; // "cha, "
pp->DEX = atoi(row[r]); r++; // "dex, "
pp->INT = atoi(row[r]); r++; // "`int`, "
pp->AGI = atoi(row[r]); r++; // "agi, "
pp->WIS = atoi(row[r]); r++; // "wis, "
pp->face = atoi(row[r]); r++; // "face, "
pp->y = atof(row[r]); r++; // "y, "
pp->x = atof(row[r]); r++; // "x, "
pp->z = atof(row[r]); r++; // "z, "
pp->heading = atof(row[r]); r++; // "heading, "
pp->pvp2 = atoi(row[r]); r++; // "pvp2, "
pp->pvptype = atoi(row[r]); r++; // "pvp_type, "
pp->autosplit = atoi(row[r]); r++; // "autosplit_enabled, "
pp->zone_change_count = atoi(row[r]); r++; // "zone_change_count, "
pp->drakkin_heritage = atoi(row[r]); r++; // "drakkin_heritage, "
pp->drakkin_tattoo = atoi(row[r]); r++; // "drakkin_tattoo, "
pp->drakkin_details = atoi(row[r]); r++; // "drakkin_details, "
pp->toxicity = atoi(row[r]); r++; // "toxicity, "
pp->hunger_level = atoi(row[r]); r++; // "hunger_level, "
pp->thirst_level = atoi(row[r]); r++; // "thirst_level, "
pp->ability_up = atoi(row[r]); r++; // "ability_up, "
pp->zone_id = atoi(row[r]); r++; // "zone_id, "
pp->zoneInstance = atoi(row[r]); r++; // "zone_instance, "
pp->leadAAActive = atoi(row[r]); r++; // "leadership_exp_on, "
pp->ldon_points_guk = atoi(row[r]); r++; // "ldon_points_guk, "
pp->ldon_points_mir = atoi(row[r]); r++; // "ldon_points_mir, "
pp->ldon_points_mmc = atoi(row[r]); r++; // "ldon_points_mmc, "
pp->ldon_points_ruj = atoi(row[r]); r++; // "ldon_points_ruj, "
pp->ldon_points_tak = atoi(row[r]); r++; // "ldon_points_tak, "
pp->ldon_points_available = atoi(row[r]); r++; // "ldon_points_available, "
pp->tribute_time_remaining = atoi(row[r]); r++; // "tribute_time_remaining, "
pp->showhelm = atoi(row[r]); r++; // "show_helm, "
pp->career_tribute_points = atoi(row[r]); r++; // "career_tribute_points, "
pp->tribute_points = atoi(row[r]); r++; // "tribute_points, "
pp->tribute_active = atoi(row[r]); r++; // "tribute_active, "
pp->endurance = atoi(row[r]); r++; // "endurance, "
pp->group_leadership_exp = atoi(row[r]); r++; // "group_leadership_exp, "
pp->raid_leadership_exp = atoi(row[r]); r++; // "raid_leadership_exp, "
pp->group_leadership_points = atoi(row[r]); r++; // "group_leadership_points, "
pp->raid_leadership_points = atoi(row[r]); r++; // "raid_leadership_points, "
pp->air_remaining = atoi(row[r]); r++; // "air_remaining, "
pp->PVPKills = atoi(row[r]); r++; // "pvp_kills, "
pp->PVPDeaths = atoi(row[r]); r++; // "pvp_deaths, "
pp->PVPCurrentPoints = atoi(row[r]); r++; // "pvp_current_points, "
pp->PVPCareerPoints = atoi(row[r]); r++; // "pvp_career_points, "
pp->PVPBestKillStreak = atoi(row[r]); r++; // "pvp_best_kill_streak, "
pp->PVPWorstDeathStreak = atoi(row[r]); r++; // "pvp_worst_death_streak, "
pp->PVPCurrentKillStreak = atoi(row[r]); r++; // "pvp_current_kill_streak, "
pp->aapoints_spent = atoi(row[r]); r++; // "aa_points_spent, "
pp->expAA = atoi(row[r]); r++; // "aa_exp, "
pp->aapoints = atoi(row[r]); r++; // "aa_points, "
pp->groupAutoconsent = atoi(row[r]); r++; // "group_auto_consent, "
pp->raidAutoconsent = atoi(row[r]); r++; // "raid_auto_consent, "
pp->guildAutoconsent = atoi(row[r]); r++; // "guild_auto_consent, "
pp->RestTimer = atoi(row[r]); r++; // "RestTimer, "
m_epp->aa_effects = atoi(row[r]); r++; // "`e_aa_effects`, "
m_epp->perAA = atoi(row[r]); r++; // "`e_percent_to_aa`, "
m_epp->expended_aa = atoi(row[r]); r++; // "`e_expended_aa_spent` "
LogFile->write(EQEMuLog::Status, "Loading Character Data for character ID: %i, done", character_id);
}
return true;
@ -1060,6 +1066,16 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str
return true;
}
bool ZoneDatabase::LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT slot, rank FROM character_leadership_abilities WHERE `id` = %u", character_id);
auto results = database.QueryDatabase(query); uint32 slot = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
slot = atoi(row[0]);
pp->leader_abilities.ranks[slot] = atoi(row[1]);
}
return true;
}
bool ZoneDatabase::LoadCharacterDisciplines(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat(
"SELECT "
@ -1288,7 +1304,23 @@ bool ZoneDatabase::SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id,
return true;
}
bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp){
bool ZoneDatabase::SaveCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp){
uint8 first_entry = 0; std::string query = "";
for (int i = 0; i <= MAX_LEADERSHIP_AA_ARRAY; i++){
if (pp->leader_abilities.ranks[i] > 0){
if (first_entry != 1){
query = StringFormat("REPLACE INTO `character_leadership_abilities` (id, slot, rank) VALUES (%i, %u, %u)", character_id, i, pp->leader_abilities.ranks[i]);
first_entry = 1;
}
query = query + StringFormat(", (%i, %u, %u)", character_id, i, pp->leader_abilities.ranks[i]);
}
}
auto results = QueryDatabase(query);
ThrowDBError(results.ErrorMessage(), "ZoneDatabase::SaveCharacterLeadershipAA", query);
return true;
}
bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp){
clock_t t = std::clock(); /* Function timer start */
std::string query = StringFormat(
"REPLACE INTO `character_data` ("
@ -1381,7 +1413,11 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
" group_auto_consent, "
" raid_auto_consent, "
" guild_auto_consent, "
" RestTimer) "
" RestTimer, "
" e_aa_effects, "
" e_percent_to_aa, "
" e_expended_aa_spent "
") "
"VALUES ("
"%u," // id " id, "
"%u," // account_id " account_id, "
@ -1472,7 +1508,10 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
"%u," // group_auto_consent pp->groupAutoconsent, " group_auto_consent, "
"%u," // raid_auto_consent pp->raidAutoconsent, " raid_auto_consent, "
"%u," // guild_auto_consent pp->guildAutoconsent, " guild_auto_consent, "
"%u" // RestTimer pp->RestTimer, " RestTimer) "
"%u," // RestTimer pp->RestTimer, " RestTimer) "
"%u," // e_aa_effects
"%u," // e_percent_to_aa
"%u" // e_expended_aa_spent
")",
character_id, // " id, "
account_id, // " account_id, "
@ -1563,7 +1602,10 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
pp->groupAutoconsent, // " group_auto_consent, "
pp->raidAutoconsent, // " raid_auto_consent, "
pp->guildAutoconsent, // " guild_auto_consent, "
pp->RestTimer // " RestTimer) "
pp->RestTimer, // " RestTimer) "
m_epp->aa_effects,
m_epp->perAA,
m_epp->expended_aa
);
auto results = database.QueryDatabase(query);
if (!results.RowsAffected()){ std::cout << "ERROR ZoneDatabase:SaveCharacterData: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
@ -1650,7 +1692,11 @@ bool ZoneDatabase::DeleteCharacterBandolier(uint32 character_id, uint32 band_id)
std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id); QueryDatabase(query); return true;
}
bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
bool ZoneDatabase::DeleteCharacterLeadershipAAs(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id); QueryDatabase(query); return true;
}
bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); QueryDatabase(query); return true;
}

View File

@ -255,18 +255,19 @@ public:
bool LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterDisciplines(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterData(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterData(uint32 character_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp);
bool LoadCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterMaterialColor(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterBandolier(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp);
/* Character Data Saves */
bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home);
bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp, ExtendedProfile_Struct* m_epp);
bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level);
bool SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot);
bool SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
@ -278,12 +279,14 @@ public:
bool SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name);
bool SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon);
bool SaveCharacterLeadershipAA(uint32 character_id, PlayerProfile_Struct* pp);
/* Character Data Deletes */
bool DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterDisc(uint32 character_id, uint32 slot_id);
bool DeleteCharacterBandolier(uint32 character_id, uint32 band_id);
bool DeleteCharacterLeadershipAAs(uint32 character_id);
/* Character Inventory */
bool NoRentExpired(const char* name);