From e0db3c0b60aa049ee8e74e2c08916eca21cd8b2c Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 1 Sep 2014 22:17:06 -0500 Subject: [PATCH] Fixed Character select to be loaded from new character data tables --- common/database.cpp | 250 ++++++++++++++++++++--------------------- common/shareddb.cpp | 40 +++++++ common/shareddb.h | 3 + world/worlddb.cpp | 25 +++-- zone/client.cpp | 52 ++++----- zone/client_packet.cpp | 15 ++- zone/zonedb.cpp | 17 +-- 7 files changed, 218 insertions(+), 184 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index cd5693e89..d926cb950 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -798,7 +798,7 @@ bool Database::CheckDatabaseConversions() { int character_id = 0; int account_id = 0; int number_of_characters = 0; - int printppdebug = 0; + int printppdebug = 0; /* Prints Player Profile */ int runconvert = 0; /* Check For Legacy Storage Method */ @@ -842,7 +842,7 @@ bool Database::CheckDatabaseConversions() { " `race` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, " " `class` tinyint(11) UNSIGNED NOT NULL DEFAULT 0, " " `level` int(11) UNSIGNED NOT NULL DEFAULT 0, " - " `deity` tinyint(11) UNSIGNED NOT NULL, " + " `deity` int(11) UNSIGNED NOT NULL, " " `birthday` int(11) UNSIGNED NOT NULL DEFAULT 0, " " `last_login` int(11) UNSIGNED NOT NULL DEFAULT 0, " " `time_played` int(11) UNSIGNED NOT NULL DEFAULT 0, " @@ -886,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) NOT NULL DEFAULT 0, " - " `hunger_level` int(11) NOT NULL DEFAULT 0, " - " `thirst_level` int(11) 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, " " `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, " @@ -1113,9 +1113,9 @@ bool Database::CheckDatabaseConversions() { printf("Starting conversion...\n\n"); } - // querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` = 61238"); + // querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` = 61238"); // WHERE `account_id` = 11001 int char_iter_count = 0; - querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `id` >= 61238 LIMIT 10"); + querylen = MakeAnyLenString(&query, "SELECT `id` FROM `character_` WHERE `account_id` = 11001"); if (RunQuery(query, querylen, errbuf, &result)) { safe_delete_array(query); while (row = mysql_fetch_row(result)) { @@ -1176,96 +1176,96 @@ bool Database::CheckDatabaseConversions() { /* Run Character Data Convert */ rquery = StringFormat( "REPLACE INTO `character_data` (" - " id, " - " account_id, " - " `name`, " - " last_name, " - " gender, " - " race, " - " class, " - " `level`, " - " deity, " - " birthday, " - " last_login, " - " time_played, " - " pvp_status, " - " level2, " - " anon, " - " gm, " - " intoxication, " - " hair_color, " - " beard_color, " - " eye_color_1, " - " eye_color_2, " - " hair_style, " - " beard, " - " ability_time_seconds, " - " ability_number, " - " ability_time_minutes, " - " ability_time_hours, " - " title, " - " suffix, " - " exp, " - " points, " - " mana, " - " cur_hp, " - " str, " - " sta, " - " cha, " - " dex, " - " `int`, " - " agi, " - " wis, " - " face, " - " y, " - " x, " - " z, " - " heading, " - " pvp2, " - " pvp_type, " - " autosplit_enabled, " - " zone_change_count, " - " drakkin_heritage, " - " drakkin_tattoo, " - " drakkin_details, " - " toxicity, " - " hunger_level, " - " thirst_level, " - " ability_up, " - " zone_id, " - " zone_instance, " - " leadership_exp_on, " - " ldon_points_guk, " - " ldon_points_mir, " - " ldon_points_mmc, " - " ldon_points_ruj, " - " ldon_points_tak, " - " ldon_points_available, " - " tribute_time_remaining, " - " show_helm, " - " career_tribute_points, " - " tribute_points, " - " tribute_active, " - " endurance, " - " group_leadership_exp, " - " raid_leadership_exp, " - " group_leadership_points, " - " raid_leadership_points, " - " air_remaining, " - " pvp_kills, " - " pvp_deaths, " - " pvp_current_points, " - " pvp_career_points, " - " pvp_best_kill_streak, " - " pvp_worst_death_streak, " - " pvp_current_kill_streak, " - " aa_points_spent, " - " aa_exp, " - " aa_points, " - " group_auto_consent, " - " raid_auto_consent, " - " guild_auto_consent, " - " RestTimer) " + "id," + "account_id," + "`name`," + "last_name," + "gender," + "race," + "class," + "`level`," + "deity," + "birthday," + "last_login," + "time_played," + "pvp_status," + "level2," + "anon," + "gm," + "intoxication," + "hair_color," + "beard_color," + "eye_color_1," + "eye_color_2," + "hair_style," + "beard," + "ability_time_seconds," + "ability_number," + "ability_time_minutes," + "ability_time_hours," + "title," + "suffix," + "exp," + "points," + "mana," + "cur_hp," + "str," + "sta," + "cha," + "dex," + "`int`," + "agi," + "wis," + "face," + "y," + "x," + "z," + "heading," + "pvp2," + "pvp_type," + "autosplit_enabled," + "zone_change_count," + "drakkin_heritage," + "drakkin_tattoo," + "drakkin_details," + "toxicity," + "hunger_level," + "thirst_level," + "ability_up," + "zone_id," + "zone_instance," + "leadership_exp_on," + "ldon_points_guk," + "ldon_points_mir," + "ldon_points_mmc," + "ldon_points_ruj," + "ldon_points_tak," + "ldon_points_available," + "tribute_time_remaining," + "show_helm," + "career_tribute_points," + "tribute_points," + "tribute_active," + "endurance," + "group_leadership_exp," + "raid_leadership_exp," + "group_leadership_points," + "raid_leadership_points," + "air_remaining," + "pvp_kills," + "pvp_deaths," + "pvp_current_points," + "pvp_career_points," + "pvp_best_kill_streak," + "pvp_worst_death_streak," + "pvp_current_kill_streak," + "aa_points_spent," + "aa_exp," + "aa_points," + "group_auto_consent," + "raid_auto_consent," + "guild_auto_consent," + "RestTimer)" "VALUES (" "%u," // id "%u," // account_id @@ -1450,6 +1450,7 @@ bool Database::CheckDatabaseConversions() { pp->RestTimer ); results = QueryDatabase(rquery); + if (!results.RowsAffected()){ std::cout << "ERROR PP Data Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } /* Run AA Convert */ for (i = 0; i < MAX_PP_AA_ARRAY; i++){ @@ -1457,21 +1458,21 @@ bool Database::CheckDatabaseConversions() { rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)" " VALUES (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value); - QueryDatabase(rquery); + results = QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR AA Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } /* Run Bind Home Convert */ rquery = StringFormat("REPLACE INTO `character_bind_home` (id, zone_id, instance_id, x, y, z, heading)" " VALUES (%u, %u, %u, %f, %f, %f, %f)", - character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading); - QueryDatabase(rquery); + character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading); + results = QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Bind Home Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } /* Run Language Convert */ for (i = 0; i < MAX_PP_LANGUAGE; i++){ if (pp->languages[i] > 0){ rquery = StringFormat("REPLACE INTO `character_languages` (id, lang_id, value) VALUES (%u, %u, %u)", character_id, i, pp->languages[i]); - QueryDatabase(rquery); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Language Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } @@ -1479,7 +1480,7 @@ bool Database::CheckDatabaseConversions() { for (i = 0; i < MAX_PP_SKILL; i++){ if (pp->skills[i] > 0){ rquery = StringFormat("REPLACE INTO `character_skills` (id, skill_id, value) VALUES (%u, %u, %u)", character_id, i, pp->skills[i]); - QueryDatabase(rquery); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Skill Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } @@ -1487,7 +1488,7 @@ bool Database::CheckDatabaseConversions() { for (i = 0; i < MAX_PP_SPELLBOOK; i++){ if (pp->spell_book[i] > 0 && pp->spell_book[i] != 4294967295){ rquery = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, i, pp->spell_book[i]); - QueryDatabase(rquery); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Spell Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } @@ -1495,7 +1496,7 @@ bool Database::CheckDatabaseConversions() { for (i = 0; i < MAX_PP_MEMSPELL; i++){ if (pp->mem_spells[i] > 0){ rquery = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, i, pp->mem_spells[i]); - QueryDatabase(rquery); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Memmed Spell Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } @@ -1503,16 +1504,16 @@ bool Database::CheckDatabaseConversions() { for (i = 0; i < MAX_PP_DISCIPLINES; i++){ if (pp->disciplines.values[i] > 0){ rquery = StringFormat("REPLACE INTO `character_disciplines` (id, disc_id) VALUES (%u, %u)", character_id, pp->disciplines.values[i]); - QueryDatabase(rquery); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Discipline Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } } } /* Run Material Color Convert */ for (i = 0; i < _MaterialCount; i++){ if (pp->item_tint[i].color > 0){ - if (pp->item_tint[i].rgb.use_tint > 0){ pp->item_tint[i].rgb.use_tint = 1; } rquery = StringFormat("REPLACE INTO `character_material` (id, slot, blue, green, red, use_tint, color) VALUES (%u, %u, %u, %u, %u, %u, %u)", character_id, i, pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint, pp->item_tint[i].color); - QueryDatabase(rquery); - } + // printf("REPLACE INTO `character_material` (id, slot, blue, green, red, use_tint, color) VALUES (%u, %u, %u, %u, %u, %u, %u);\n", character_id, i, pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint, pp->item_tint[i].color); + QueryDatabase(rquery); if (!results.RowsAffected()){ std::cout << "ERROR Color Convert: " << results.ErrorMessage() << "\n\n" << rquery << "\n" << std::endl; } + } } } @@ -2568,13 +2569,13 @@ uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 return base_cap; } -uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZoneID, uint32* oInstanceID, float* oX, float* oY, float* oZ) { - - std::string query = StringFormat("SELECT id, account_id, zonename, instanceid, x, y, z FROM character_ WHERE name='%s'", iName); +uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZoneID, uint32* oInstanceID, float* oX, float* oY, float* oZ) { + std::string query = StringFormat("SELECT `id`, `account_id`, `zone_id`, `zone_instance`, `x`, `y`, `z` FROM `character_data` WHERE `name` = '%s'", iName); auto results = QueryDatabase(query); - if (!results.Success()) - { + printf("Calling Database::GetCharacterInfo: ACCID: %u ZONEID: %u INSTANCEID: %u \n", oAccID, oZoneID, oInstanceID); + + if (!results.Success()) { std::cerr << "Error in GetCharacterInfo query '" << query << "' " << results.ErrorMessage() << std::endl; return 0; } @@ -2582,21 +2583,16 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo if (results.RowCount() != 1) return 0; - auto row = results.begin(); - + auto row = results.begin(); uint32 charid = atoi(row[0]); - if (oAccID) - *oAccID = atoi(row[1]); - if (oZoneID) - *oZoneID = GetZoneID(row[2]); - if(oInstanceID) - *oInstanceID = atoi(row[3]); - if (oX) - *oX = atof(row[4]); - if (oY) - *oY = atof(row[5]); - if (oZ) - *oZ = atof(row[6]); + if (oAccID){ *oAccID = atoi(row[1]); } + if (oZoneID){ *oZoneID = atoi(row[2]); } + if (oInstanceID){ *oInstanceID = atoi(row[3]); } + if (oX){ *oX = atof(row[4]); } + if (oY){ *oY = atof(row[5]); } + if (oZ){ *oZ = atof(row[6]); } + + printf("Calling Database::GetCharacterInfo: ACCID: %u ZONEID: %u INSTANCEID: %u \n", oAccID, oZoneID, oInstanceID); return charid; } diff --git a/common/shareddb.cpp b/common/shareddb.cpp index e4336b02f..9f234b4ae 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -61,6 +61,46 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme) return true; } +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; + + 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); + } + + 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, ", pp->name, "halas", 29, 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)); +} + uint8 SharedDatabase::GetGMSpeed(uint32 account_id) { diff --git a/common/shareddb.h b/common/shareddb.h index 5401bfa0a..c55163465 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -34,6 +34,9 @@ public: SharedDatabase(const char* host, const char* user, const char* passwd, const char* database,uint32 port); virtual ~SharedDatabase(); + /* Temp */ + 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); + bool SetPlayerProfile(uint32 account_id, uint32 charid, PlayerProfile_Struct* pp, Inventory* inv, ExtendedProfile_Struct *ext, uint32 current_zone, uint32 current_instance, uint8 MaxXTargets); /* * General Character Related Stuff */ diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 81c99d022..deccc9207 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -35,9 +35,7 @@ extern std::vector 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) { - /* Initialize Player Profile for the small time it is being used for item material */ - PlayerProfile_Struct pp; - memset(&pp, 0, sizeof(PlayerProfile_Struct)); + Inventory *inv; /* Initialize Variables */ for (int i=0; i<10; i++) { @@ -73,10 +71,12 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* "zone_id " // 19 "FROM " "character_data " - "WHERE `account_id` = %i LIMIT 10 ", account_id); - auto results = database.QueryDatabase(cquery); uint16 char_num = 0; + "WHERE `account_id` = %i ORDER BY `name` LIMIT 10 ", account_id); + auto results = database.QueryDatabase(cquery); int char_num = 0; for (auto row = results.begin(); row != results.end(); ++row) { - printf("id is %i \n", atoi(row[0])); + PlayerProfile_Struct pp; + memset(&pp, 0, sizeof(PlayerProfile_Struct)); + uint32 character_id = atoi(row[0]); strcpy(cs->name[char_num], row[1]); uint8 lvl = atoi(row[5]); @@ -133,16 +133,17 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* */ /* Load Character Material Data for Char Select */ - cquery = StringFormat("SELECT slot, use_tint, color FROM `character_material` WHERE `id` = %u", character_id); + cquery = StringFormat("SELECT slot, red, green, blue, use_tint, color FROM `character_material` WHERE `id` = %u", character_id); auto results_b = database.QueryDatabase(cquery); uint8 slot = 0; for (auto row_b = results_b.begin(); row_b != results_b.end(); ++row_b) { slot = atoi(row_b[0]); - if (atoi(row_b[1]) == 1){ pp.item_tint[slot].rgb.use_tint = 0xFF; } - pp.item_tint[slot].color = atoul(row_b[2]); + pp.item_tint[slot].rgb.red = atoi(row_b[1]); + pp.item_tint[slot].rgb.green = atoi(row_b[2]); + pp.item_tint[slot].rgb.blue = atoi(row_b[3]); + pp.item_tint[slot].rgb.use_tint = atoi(row_b[4]); } /* Load Inventory */ - Inventory *inv; inv = new Inventory; if (GetInventory(account_id, cs->name[char_num], inv)) { for (uint8 material = 0; material <= 8; material++) { @@ -156,9 +157,9 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, CharacterSelect_Struct* if (pp.item_tint[material].rgb.use_tint){ color = pp.item_tint[material].color; } else{ color = item->GetItem()->Color; } - cs->cs_colors[char_num][material].color = color; + cs->cs_colors[char_num][material].color = color; - // the weapons are kept elsewhere + /* Weapons are handled a bit differently */ if ((material == MaterialPrimary) || (material == MaterialSecondary)) { if (strlen(item->GetItem()->IDFile) > 2) { uint32 idfile = atoi(&item->GetItem()->IDFile[2]); diff --git a/zone/client.cpp b/zone/client.cpp index 6d2a784a4..2213c0a26 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -588,35 +588,35 @@ bool Client::Save(uint8 iCommitNow) { /* Save Character Task */ SaveTaskState(); + if (iCommitNow <= 1) { + // char* query = 0; + // uint32_breakdown workpt; + // workpt.b4() = DBA_b4_Entity; + // workpt.w2_3() = GetID(); + // workpt.b1() = DBA_b1_Entity_Client_Save; + // DBAsyncWork* dbaw = new DBAsyncWork(&database, &MTdbafq, workpt, DBAsync::Write, 0xFFFFFFFF); + // dbaw->AddQuery(iCommitNow == 0 ? true : false, &query, database.SetPlayerProfile_MQ(&query, account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets), false); + // if (iCommitNow == 0){ + // pQueuedSaveWorkID = dbasync->AddWork(&dbaw, 2500); + // } + // else { + // dbasync->AddWork(&dbaw, 0); + // SaveBackup(); + // } + // safe_delete_array(query); + // return true; + } + else if (database.SetPlayerProfile(account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets)) { + SaveBackup(); + } + else { + std::cerr << "Failed to update player profile" << std::endl; + return false; + } + /* Save Character Data */ database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp); - // if (iCommitNow <= 1) { - // char* query = 0; - // uint32_breakdown workpt; - // workpt.b4() = DBA_b4_Entity; - // workpt.w2_3() = GetID(); - // workpt.b1() = DBA_b1_Entity_Client_Save; - // DBAsyncWork* dbaw = new DBAsyncWork(&database, &MTdbafq, workpt, DBAsync::Write, 0xFFFFFFFF); - // dbaw->AddQuery(iCommitNow == 0 ? true : false, &query, database.SetPlayerProfile_MQ(&query, account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets), false); - // if (iCommitNow == 0){ - // pQueuedSaveWorkID = dbasync->AddWork(&dbaw, 2500); - // } - // else { - // dbasync->AddWork(&dbaw, 0); - // SaveBackup(); - // } - // safe_delete_array(query); - // return true; - // } - // else if (database.SetPlayerProfile(account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets)) { - // SaveBackup(); - // } - // else { - // std::cerr << "Failed to update player profile" << std::endl; - // return false; - // } - /* Mirror Character Data */ database.StoreCharacterLookup(this->CharacterID()); LogFile->write(EQEMuLog::Status, "Client::Save %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 88425fade..87d884eb7 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -553,7 +553,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_pp.item_tint[i].rgb.use_tint = 0xFF; uint32 cid = CharacterID(); - character_id = cid; + character_id = cid; /* Global character_id reference */ /* Flush and reload factions */ database.RemoveTempFactions(this); @@ -588,8 +588,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) if (RuleB(Character, SharedBankPlat)) m_pp.platinum_shared = database.GetSharedPlatinum(database.GetAccountIDByChar(cid)); - // if (ext) { SetExtendedProfile(ext, row[8], lengths[8]); } - if (level){ level = atoi(row[10]); } if (LFP){ LFP = atoi(row[11]); } if (LFG){ LFG = atoi(row[12]); } if (firstlogon){ firstlogon = atoi(row[15]); } @@ -608,6 +606,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) database.LoadCharacterMemmedSpells(cid, &m_pp); /* Load Character Memorized Spells */ database.LoadCharacterDisciplines(cid, &m_pp); /* Load Character Disciplines */ + if (level){ level = m_pp.level; } + /* If GM, not trackable */ if (gmhideme) { trackable = false; } /* Set Con State for Reporting */ @@ -632,9 +632,9 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_pp.z = zone->safe_z(); } /* If too far below ground, then fix */ - float ground_z = GetGroundZ(m_pp.x, m_pp.y, m_pp.z); - if (m_pp.z < (ground_z - 500)) - m_pp.z = ground_z; + // float ground_z = GetGroundZ(m_pp.x, m_pp.y, m_pp.z); + // if (m_pp.z < (ground_z - 500)) + // m_pp.z = ground_z; /* Set Mob variables for spawn */ class_ = m_pp.class_; @@ -1019,8 +1019,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) outapp = new EQApplicationPacket(OP_Weather, 12); Weather_Struct *ws = (Weather_Struct *)outapp->pBuffer; ws->val1 = 0x000000FF; - if (zone->zone_weather == 1) - ws->type = 0x31; // Rain + if (zone->zone_weather == 1){ ws->type = 0x31; } // Rain if (zone->zone_weather == 2) { outapp->pBuffer[8] = 0x01; ws->type = 0x02; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 50a74c892..794b1240f 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1146,7 +1146,7 @@ bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Str } bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color){ - std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, color) VALUES (%u, %u, %u)", character_id, slot_id, color); QueryDatabase(query); + std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, color, use_tint) VALUES (%u, %u, %u, 255)", character_id, slot_id, color); QueryDatabase(query); LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color); return true; } @@ -1160,9 +1160,8 @@ bool ZoneDatabase::LoadCharacterMaterialColor(uint32 character_id, PlayerProfile pp->item_tint[i].rgb.blue = atoi(row[r]); r++; pp->item_tint[i].rgb.green = atoi(row[r]); r++; pp->item_tint[i].rgb.red = atoi(row[r]); r++; - if (row[r] && atoi(row[r]) > 0){ pp->item_tint[i].rgb.use_tint = 0xFF; } r++; - pp->item_tint[i].color = atoi(row[r]); r++; - printf("Loading color: %u tint: %u \n", pp->item_tint[i].color, pp->item_tint[i].rgb.use_tint); + pp->item_tint[i].rgb.use_tint = atoi(row[r]); + printf("Material Load: %u %u %u %u\n", pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint); } return true; } @@ -1445,13 +1444,9 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla pp->guildAutoconsent, pp->RestTimer ); - auto results = database.QueryDatabase(query); - //if (results.RowsAffected() != 2) { - // LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::SaveCharacterData Error! Query: %s \n", query); return false; - //} - //else{ - LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); - //} + auto results = database.QueryDatabase(query); + if (!results.RowsAffected()){ std::cout << "ERROR ZoneDatabase:SaveCharacterData: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; } + LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); return true; }