Fix void Database::GetCharName(uint32 char_id, char* name)

Increased MAX_PP_SPELLBOOK to 720 for UF/RoF
Increased MAX_PP_MEMSPELL to 12
Implemented up to 12 spell slots
Fix for public_note default value in bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank)
Updated all CastSpell entries to use the appropriate slot type defines located now in zone/common.h
Fixed Guild Loading from character_data
Fixed #guild list
Refactored Merchantlist loading
Refactored Temp Merchantlist loading
Gutted most of dbasync

Added:
LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Struct* pp);
LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_Struct* pp);
LoadCharacterLanguages(uint32 character_id, PlayerProfile_Struct* pp);
LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp);
SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot);
SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);

Removed Zone::LoadTempMerchantData_result(MYSQL_RES* result)
Removed Zone::LoadMerchantData_result(MYSQL_RES* result)
Removed SharedDatabase::GetPlayerProfile
Removed SharedDatabase::SetPlayerProfile
Removed SharedDatabase::SetPlayerProfile_MQ
Removed Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) from zone.cpp
This commit is contained in:
Akkadius
2014-08-31 17:52:43 -05:00
parent f8439fd6e6
commit ca430e2494
22 changed files with 423 additions and 521 deletions
+13 -10
View File
@@ -758,17 +758,18 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
void Database::GetCharName(uint32 char_id, char* name) {
std::string query = StringFormat("SELECT name FROM character_ WHERE id='%i'", char_id);
std::string query = StringFormat("SELECT `name` FROM `character_data` WHERE id='%i'", char_id);
auto results = QueryDatabase(query);
if (!results.Success())
{
if (!results.Success()) {
std::cerr << "Error in GetCharName query '" << query << "' " << results.ErrorMessage() << std::endl;
return;
return;
}
auto row = results.begin();
strcpy(name, row[0]);
for (auto row = results.begin(); row != results.end(); ++row) {
strcpy(name, row[0]);
}
}
static inline void loadbar(unsigned int x, unsigned int n, unsigned int w = 50) {
@@ -849,7 +850,7 @@ bool Database::CheckDatabaseConversions() {
" `level2` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
" `anon` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
" `gm` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
" `intoxication` int(11) UNSIGNED NOT NULL, "
" `intoxication` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `hair_color` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
" `beard_color` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
" `eye_color_1` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, "
@@ -885,9 +886,9 @@ bool Database::CheckDatabaseConversions() {
" `drakkin_heritage` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `drakkin_tattoo` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `drakkin_details` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `toxicity` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `hunger_level` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `thirst_level` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `toxicity` int(11) NOT NULL DEFAULT 0, "
" `hunger_level` int(11) NOT NULL DEFAULT 0, "
" `thirst_level` int(11) NOT NULL DEFAULT 0, "
" `ability_up` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `zone_id` int(11) UNSIGNED NOT NULL DEFAULT 0, "
" `zone_instance` int(11) UNSIGNED NOT NULL DEFAULT 0, "
@@ -1092,7 +1093,7 @@ bool Database::CheckDatabaseConversions() {
// querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` = 61238");
int char_iter_count = 0;
querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` >= 61238 LIMIT 1");
querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` >= 61238 LIMIT 100");
if (RunQuery(query, querylen, errbuf, &result)) {
safe_delete_array(query);
while (row = mysql_fetch_row(result)) {
@@ -1147,6 +1148,8 @@ bool Database::CheckDatabaseConversions() {
);
auto results = QueryDatabase(rquery);
if (pp->tribute_time_remaining < 0 || pp->tribute_time_remaining == 4294967295){ pp->tribute_time_remaining = 0; }
/* Run Character Data Convert */
rquery = StringFormat(
"REPLACE INTO `character_data` ("
+2 -2
View File
@@ -801,8 +801,8 @@ struct SuspendedMinion_Struct
** OpCode: 0x006a
*/
static const uint32 MAX_PP_LANGUAGE = 28;
static const uint32 MAX_PP_SPELLBOOK = 480; // Increased to 480 to support SoF
static const uint32 MAX_PP_MEMSPELL = 9;
static const uint32 MAX_PP_SPELLBOOK = 720; // Increased to 480 to support SoF
static const uint32 MAX_PP_MEMSPELL = 12;
static const uint32 MAX_PP_SKILL = _SkillPacketArraySize; // 100 - actual skills buffer size
static const uint32 MAX_PP_AA_ARRAY = 240;
static const uint32 MAX_GROUP_MEMBERS = 6;
+1 -1
View File
@@ -751,7 +751,7 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
std::string query;
if(guild_id != GUILD_NONE) {
query = StringFormat("REPLACE INTO guild_members (char_id,guild_id,rank) VALUES(%d,%d,%d)", charid, guild_id, rank);
query = StringFormat("REPLACE INTO guild_members (char_id,guild_id,rank,public_note) VALUES(%d,%d,%d,'')", charid, guild_id, rank);
auto results = m_db->QueryDatabase(query);
if (!results.Success()) {
+1 -2
View File
@@ -479,7 +479,6 @@ ENCODE(OP_PlayerProfile) {
uint32 r;
eq->available_slots=0xffffffff;
memset(eq->unknown06284, 0xff, sizeof(eq->unknown06284));
memset(eq->unknown07284, 0xff, sizeof(eq->unknown07284));
// OUT(checksum);
@@ -546,7 +545,7 @@ ENCODE(OP_PlayerProfile) {
OUT(gold);
OUT(silver);
OUT(copper);
OUT(platinum_cursor);
OUT(platinum_cursor);
OUT(gold_cursor);
OUT(silver_cursor);
OUT(copper_cursor);
+1 -2
View File
@@ -766,7 +766,7 @@ struct BindStruct {
** OpCode: 0x006a
*/
static const uint32 MAX_PP_LANGUAGE = 25; //
static const uint32 MAX_PP_SPELLBOOK = 480; // Confirmed 60 pages on Underfoot now
static const uint32 MAX_PP_SPELLBOOK = 720; // Confirmed 60 pages on Underfoot now
static const uint32 MAX_PP_MEMSPELL = 10; //was 9 now 10 on Underfoot
static const uint32 MAX_PP_SKILL = _SkillPacketArraySize; // 100 - actual skills buffer size
static const uint32 MAX_PP_AA_ARRAY = 300; //was 299
@@ -879,7 +879,6 @@ struct PlayerProfile_Struct
/*04216*/ uint8 face; // Player face - Actually uint32?
/*04217*/ uint8 unknown04217[147]; // was [175]
/*04364*/ uint32 spell_book[MAX_PP_SPELLBOOK]; // List of the Spells in spellbook 720 = 90 pages [2880] was [1920]
/*06284*/ uint8 unknown06284[960]; // Spacer for the end of the book for now (pages 60 to 90)
/*07244*/ uint32 mem_spells[MAX_PP_MEMSPELL]; // List of spells memorized
/*07284*/ uint8 unknown07284[28]; //#### uint8 unknown04396[32]; in Titanium ####[28]
/*07312*/ uint32 platinum; // Platinum Pieces on player
-100
View File
@@ -1209,106 +1209,6 @@ bool SharedDatabase::LoadNPCFactionLists() {
return true;
}
// Get the player profile and inventory for the given account "account_id" and
// character name "name". Return true if the character was found, otherwise false.
// 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) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES* result;
MYSQL_ROW row;
bool ret = false;
unsigned long* lengths;
if (RunQuery(query, MakeAnyLenString(&query, "SELECT profile,zonename,x,y,z,extprofile,instanceid FROM character_ WHERE account_id=%i AND name='%s'", account_id, name), errbuf, &result)) {
if (mysql_num_rows(result) == 1) {
row = mysql_fetch_row(result);
lengths = mysql_fetch_lengths(result);
if (lengths[0] == sizeof(PlayerProfile_Struct)) {
memcpy(pp, row[0], sizeof(PlayerProfile_Struct));
if (current_zone)
strcpy(current_zone, row[1]);
pp->zone_id = GetZoneID(row[1]);
pp->x = atof(row[2]);
pp->y = atof(row[3]);
pp->z = atof(row[4]);
pp->zoneInstance = atoi(row[6]);
if (pp->x == -1 && pp->y == -1 && pp->z == -1)
GetSafePoints(pp->zone_id, GetInstanceVersion(pp->zoneInstance), &pp->x, &pp->y, &pp->z);
if(current_instance)
*current_instance = pp->zoneInstance;
if(ext) {
//SetExtendedProfile handles any conversion
SetExtendedProfile(ext, row[5], lengths[5]);
}
// Retrieve character inventory
ret = GetInventory(account_id, name, inv);
}
else {
LogFile->write(EQEMuLog::Error, "Player profile length mismatch in GetPlayerProfile. Found: %i, Expected: %i",
lengths[0], sizeof(PlayerProfile_Struct));
}
}
mysql_free_result(result);
}
else {
LogFile->write(EQEMuLog::Error, "GetPlayerProfile query '%s' %s", query, errbuf);
}
safe_delete_array(query);
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) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
uint32 affected_rows = 0;
bool ret = false;
clock_t t = std::clock(); /* Function timer start */
if (RunQuery(query, SetPlayerProfile_MQ(&query, account_id, charid, pp, inv, ext, current_zone, current_instance, MaxXTargets), errbuf, 0, &affected_rows)) {
ret = (affected_rows != 0);
}
LogFile->write(EQEMuLog::Status, "SharedDatabase::SetPlayerProfile SetPlayerProfile_MQ done... Took %f seconds", ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
if (!ret) {
LogFile->write(EQEMuLog::Error, "SetPlayerProfile query '%s' %s", query, errbuf);
}
safe_delete_array(query);
return ret;
}
// Generate SQL for updating player profile
uint32 SharedDatabase::SetPlayerProfile_MQ(char** query, uint32 account_id, uint32 charid, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, uint32 current_zone, uint32 current_instance, uint8 MaxXTargets) {
*query = new char[396 + sizeof(PlayerProfile_Struct)*2 + sizeof(ExtendedProfile_Struct)*2 + 4];
char* end = *query;
if (!current_zone)
current_zone = pp->zone_id;
if (!current_instance)
current_instance = pp->zoneInstance;
if(strlen(pp->name) == 0) /* Sanity check in case pp never loaded */
return false;
end += sprintf(end, "UPDATE character_ SET timelaston=unix_timestamp(now()),name=\'%s\', zonename=\'%s\', zoneid=%u, instanceid=%u, x = %f, y = %f, z = %f, profile=\'", pp->name, GetZoneName(current_zone), current_zone, current_instance, pp->x, pp->y, pp->z);
end += DoEscapeString(end, (char*)pp, sizeof(PlayerProfile_Struct));
end += sprintf(end,"\', extprofile=\'");
end += DoEscapeString(end, (char*)ext, sizeof(ExtendedProfile_Struct));
end += sprintf(end,"\',class=%d,level=%d,xtargets=%u WHERE id=%u", pp->class_, pp->level, MaxXTargets, charid);
return (uint32) (end - (*query));
}
// Create appropriate ItemInst class
ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5)
{
-3
View File
@@ -40,9 +40,6 @@ public:
bool SetGMSpeed(uint32 account_id, uint8 gmspeed);
uint8 GetGMSpeed(uint32 account_id);
bool SetHideMe(uint32 account_id, uint8 hideme);
bool GetPlayerProfile(uint32 account_id, char* name, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, char* current_zone = 0, uint32 *current_instance = 0);
bool SetPlayerProfile(uint32 account_id, uint32 charid, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, uint32 current_zone, uint32 current_instance, uint8 MaxXTargets);
uint32 SetPlayerProfile_MQ(char** query, uint32 account_id, uint32 charid, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, uint32 current_zone, uint32 current_instance, uint8 MaxXTargets);
int32 DeleteStalePlayerCorpses();
int32 DeleteStalePlayerBackups();
void GetPlayerInspectMessage(char* playername, InspectMessage_Struct* message);