From 0788ee561768ee3571f72c1146d50217c68d6044 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Mon, 25 Nov 2024 06:01:04 -0600 Subject: [PATCH] remove transferts tables and code; it sometimes prevented login (#177) --- .../auth/2024_11_24_drop_transferts.sql | 7 ++ .../characters/2024_11_24_drop_transfers.sql | 5 + .../Database/Implementation/LoginDatabase.cpp | 7 +- .../Database/Implementation/LoginDatabase.h | 5 - src/server/game/Handlers/CharacterHandler.cpp | 15 --- src/server/game/Server/WorldSession.cpp | 1 - src/server/game/Server/WorldSession.h | 1 - src/server/game/Tools/PlayerDump.cpp | 2 +- src/server/game/World/World.cpp | 118 ------------------ src/server/game/World/World.h | 1 - 10 files changed, 14 insertions(+), 148 deletions(-) create mode 100644 sql/updates/auth/2024_11_24_drop_transferts.sql create mode 100644 sql/updates/characters/2024_11_24_drop_transfers.sql diff --git a/sql/updates/auth/2024_11_24_drop_transferts.sql b/sql/updates/auth/2024_11_24_drop_transferts.sql new file mode 100644 index 00000000..a6624df4 --- /dev/null +++ b/sql/updates/auth/2024_11_24_drop_transferts.sql @@ -0,0 +1,7 @@ +-- +DROP TABLE `transferts`; +DROP TABLE `transferts_logs`; +DROP TABLE `transfer_requests`; + +ALTER TABLE `account_character_template` + DROP COLUMN `transferId`; diff --git a/sql/updates/characters/2024_11_24_drop_transfers.sql b/sql/updates/characters/2024_11_24_drop_transfers.sql new file mode 100644 index 00000000..a6891aab --- /dev/null +++ b/sql/updates/characters/2024_11_24_drop_transfers.sql @@ -0,0 +1,5 @@ +-- +ALTER TABLE `characters` + DROP COLUMN `transfer`, + DROP COLUMN `transfer_history`, + DROP COLUMN `transfer_request`; diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp index bb2d27a1..fd66320f 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.cpp +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp @@ -82,10 +82,6 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_REALMLIST_SECURITY_LEVEL, "SELECT allowedSecurityLevel from realmlist WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_DEL_ACCOUNT, "DELETE FROM account WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(LOGIN_SET_DUMP, "INSERT INTO `transferts` (`account`, `perso_guid`, `from`, `to`, `state`, `dump`) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(LOGIN_UPD_DUMP, "UPDATE transferts SET dump = ? ,state = ? WHERE id = ?", CONNECTION_ASYNC); - PrepareStatement(LOGIN_ADD_TRANSFERTS_LOGS, "INSERT INTO transferts_logs (`id`, `account`, `perso_guid`, `from`, `to`, `dump`, `toacc`, `newguid`, `transferId`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(LOGIN_SEL_BNET_ACCOUNT_INFO, "SELECT a.id, a.username, a.locked, a.lock_country, a.last_ip, a.failed_logins, ab.unbandate > UNIX_TIMESTAMP(), ab.unbandate = ab.bandate, a.activate, a.access_ip, ab.unbandate, aa.gmlevel, a.sha_pass_hash FROM account a LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account_access aa ON a.id = aa.id AND aa.RealmID = -1 WHERE a.username = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_LAST_LOGIN_INFO, "UPDATE account SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?", CONNECTION_ASYNC); @@ -111,9 +107,8 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_UPD_REFERER, "UPDATE account SET referer = ? WHERE id = ?", CONNECTION_BOTH); PrepareStatement(LOGIN_INS_LOG_USE_DONATE_TOKEN, "INSERT INTO `account_donate_token_log` (`accountId`, `realmId`, `characterId`, `change`, `tokenType`, `buyType`, `productId`) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(LOGIN_SEL_ACCOUNT_CHARACTER_TEMPLATE, "SELECT `id`, `level`, `iLevel`, `money`, `artifact`, `transferId`, `templateId` FROM account_character_template WHERE account = ? AND realm = ? AND charGuid = 0", CONNECTION_ASYNC); + PrepareStatement(LOGIN_SEL_ACCOUNT_CHARACTER_TEMPLATE, "SELECT `id`, `level`, `iLevel`, `money`, `artifact`, `templateId` FROM account_character_template WHERE account = ? AND realm = ? AND charGuid = 0", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_ACCOUNT_CHARACTER_TEMPLATE, "UPDATE `account_character_template` SET charGuid = ? WHERE id = ?;", CONNECTION_ASYNC); - PrepareStatement(LOGIN_UPD_TRANSFER_REQUESTS, "UPDATE `transfer_requests` SET guid = ?, `status` = '0', `char_class` = ?, `char_faction` = ? WHERE id = ?", CONNECTION_ASYNC); } LoginDatabaseConnection::LoginDatabaseConnection(MySQLConnectionInfo& connInfo, ConnectionFlags connectionFlags) : MySQLConnection(connInfo, connectionFlags) diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index e69bc16c..cb1e9771 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.h +++ b/src/server/database/Database/Implementation/LoginDatabase.h @@ -87,10 +87,6 @@ enum LoginDatabaseStatements : uint32 LOGIN_SEL_REALMLIST_SECURITY_LEVEL, LOGIN_DEL_ACCOUNT, - LOGIN_SET_DUMP, - LOGIN_UPD_DUMP, - LOGIN_ADD_TRANSFERTS_LOGS, - LOGIN_SEL_BNET_ACCOUNT_INFO, LOGIN_UPD_LAST_LOGIN_INFO, @@ -115,7 +111,6 @@ enum LoginDatabaseStatements : uint32 LOGIN_SEL_ACCOUNT_CHARACTER_TEMPLATE, LOGIN_UPD_ACCOUNT_CHARACTER_TEMPLATE, - LOGIN_UPD_TRANSFER_REQUESTS, MAX_LOGINDATABASE_STATEMENTS, }; diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 06708d93..002a7963 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -469,21 +469,6 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateChar& c stmt->setUInt32(0, newChar.GetGUIDLow()); stmt->setUInt32(1, charTemplateData->id); trans->Append(stmt); - - if (charTemplateData->transferId) - { - uint8 raceID = 2; - if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(createInfo->Race)) - raceID = rEntry->Alliance; - - stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_TRANSFER_REQUESTS); - stmt->setUInt32(0, newChar.GetGUIDLow()); - stmt->setUInt8(1, createInfo->Class); - stmt->setUInt8(2, raceID); - stmt->setUInt32(3, charTemplateData->transferId); - trans->Append(stmt); - CharacterDatabase.PExecute("UPDATE `characters` SET transfer_request = '%u' WHERE guid = '%u'", charTemplateData->transferId, newChar.GetGUIDLow()); - } } } diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 1340c82f..38246ccb 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -941,7 +941,6 @@ void WorldSession::LoadCharacterTemplates(PreparedQueryResult const& result) templateData.iLevel = fields[2].GetUInt32(); templateData.money = fields[3].GetUInt32(); templateData.artifact = fields[4].GetBool(); - templateData.transferId = fields[5].GetUInt32(); templateData.templateId = fields[6].GetUInt32(); templateData.charTemplate = sCharacterDataStore->GetCharacterTemplate(templateData.templateId); } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 9a1ad1b4..9a07abe6 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -1039,7 +1039,6 @@ struct CharacterTemplateData uint32 id = 0; uint32 iLevel = 0; uint32 money = 0; - uint32 transferId = 0; uint32 templateId = 0; uint8 level = 0; bool artifact = true; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 839bc429..40713e04 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -42,7 +42,7 @@ struct DumpTable //REMEMBER TO UPDATE DUMP_TABLE_COUNT!!! static DumpTable dumpTables[DUMP_TABLE_COUNT] = { - { "characters", DTT_CHARACTER, "`guid`, `account`, `name`, `slot`, `race`, `class`, `gender`, `level`, `xp`, `money`, `skin`, `face`, `hairStyle`, `hairColor`, `tattoo`, `horn`, `inventorySlots`, `blindfold`, `facialStyle`, `bankSlots`, `drunk`, `playerFlags`, `playerFlagsEx`, `position_x`, `position_y`, `position_z`, `map`, `instance_id`, `dungeonDifficulty`, `raidDifficulty`, `legacyRaidDifficulty`, `orientation`, `taximask`, `online`, `cinematic`, `totaltime`, `leveltime`, `created_time`, `logout_time`, `is_logout_resting`, `rest_bonus`, `trans_x`, `trans_y`, `trans_z`, `trans_o`, `transguid`, `extra_flags`, `summonedPetNumber`, `at_login`, `zone`, `death_expire_time`, `taxi_path`, `totalKills`, `todayKills`, `yesterdayKills`, `killPoints`, `chosenTitle`, `watchedFaction`, `lfgBonusFaction`, `health`, `mana`, `latency`, `activespec`, `specialization`, `lootspecialization`, `exploredZones`, `equipmentCache`, `knownTitles`, `actionBars`, `grantableLevels`, `deleteInfos_Account`, `deleteInfos_Name`, `deleteDate`, `LastCharacterUndelete`, `transfer`, `transfer_request`, `transfer_history`"}, + { "characters", DTT_CHARACTER, "`guid`, `account`, `name`, `slot`, `race`, `class`, `gender`, `level`, `xp`, `money`, `skin`, `face`, `hairStyle`, `hairColor`, `tattoo`, `horn`, `inventorySlots`, `blindfold`, `facialStyle`, `bankSlots`, `drunk`, `playerFlags`, `playerFlagsEx`, `position_x`, `position_y`, `position_z`, `map`, `instance_id`, `dungeonDifficulty`, `raidDifficulty`, `legacyRaidDifficulty`, `orientation`, `taximask`, `online`, `cinematic`, `totaltime`, `leveltime`, `created_time`, `logout_time`, `is_logout_resting`, `rest_bonus`, `trans_x`, `trans_y`, `trans_z`, `trans_o`, `transguid`, `extra_flags`, `summonedPetNumber`, `at_login`, `zone`, `death_expire_time`, `taxi_path`, `totalKills`, `todayKills`, `yesterdayKills`, `killPoints`, `chosenTitle`, `watchedFaction`, `lfgBonusFaction`, `health`, `mana`, `latency`, `activespec`, `specialization`, `lootspecialization`, `exploredZones`, `equipmentCache`, `knownTitles`, `actionBars`, `grantableLevels`, `deleteInfos_Account`, `deleteInfos_Name`, `deleteDate`, `LastCharacterUndelete`"}, { "character_donate", DTT_DONA_TABLE, "`owner_guid`, `itemguid`, `type`, `itemEntry`, `efircount`, `count`, `state`, `date`, `deletedate`, `account`"}, { "character_achievement", DTT_CHAR_TABLE, "`guid`, `achievement`, `date`"}, { "character_achievement_progress", DTT_CHAR_TABLE, "`guid`, `criteria`, `counter`, `date`"}, diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 14cffe01..37e20a69 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2530,7 +2530,6 @@ void World::Update(uint32 diff) { m_timers[WUPDATE_MAILBOXQUEUE].Reset(); ProcessMailboxQueue(); - Transfer(); } if (m_timers[WUPDATE_DONATE_AND_SERVICES].Passed()) @@ -4507,123 +4506,6 @@ void World::AutoRestartServer() sWorld->setWorldState(WS_AUTO_SERVER_RESTART_TIME, m_NextServerRestart); } -void World::Transfer() -{ - //state 0 waiting to dump on source server - //state 1 load dump char to dest server - //state 2 error to many char on acc - //state 3 dump char to waiting buy transfer - //state 4 waiting buy transfer - QueryResult toDump = LoginDatabase.PQuery("SELECT `id`, `account`, `perso_guid`, `to`, `state` FROM transferts WHERE `from` = %u AND state IN (0,3)", realm.Id.Realm); - QueryResult toLoad = LoginDatabase.PQuery("SELECT `id`, `account`, `perso_guid`, `from`, `dump`, `toacc`, `transferId` FROM transferts WHERE `to` = %u AND state = 1", realm.Id.Realm); - - TC_LOG_DEBUG("network", "World::Transfer()"); - - if(toDump) - { - do - { - Field* field = toDump->Fetch(); - uint32 transaction = field[0].GetUInt32(); - ObjectGuid::LowType guid = field[2].GetUInt64(); - uint32 to = field[3].GetUInt32(); - uint32 state = field[4].GetUInt32(); - - if (Player * pPlayer = sObjectMgr->GetPlayerByLowGUID(guid)) - { - pPlayer->GetSession()->SendNotification("You must logout to transfer your char"); - continue; - } - - CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `memberGuid` = '%u'", guid); - CharacterDatabase.PExecute("DELETE FROM `guild_member` WHERE `guid` = '%u'", guid); - - std::string dump; - DumpReturn dumpState = PlayerDumpWriter().WriteDump(guid, dump); - - TC_LOG_DEBUG("network", "Transfer toDump guid %lu, dump %u", guid, dumpState); - - if (dumpState == DUMP_SUCCESS) - { - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = '512', `deleteInfos_Name` = `name`, `deleteInfos_Account` = `account`, `deleteDate` ='" UI64FMTD "', `name` = '', `account` = 0, `transfer` = '%u' WHERE `guid` = '" UI64FMTD "'", uint64(GameTime::GetGameTime()), to, guid); - LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_DUMP); - if(stmt) - { - stmt->setString(0, dump); - if(state == 3) - stmt->setUInt32(1, 4); - else - stmt->setUInt32(1, 1); - stmt->setUInt32(2, transaction); - LoginDatabase.Execute(stmt); - } - } - else - { - LoginDatabase.PQuery("UPDATE `transferts` SET `error` = %u WHERE `id` = '%u'", dumpState, transaction); - continue; - } - } - while(toDump->NextRow()); - } - - if(toLoad) - { - do - { - Field* field = toLoad->Fetch(); - uint32 transaction = field[0].GetUInt32(); - uint32 account = field[1].GetUInt32(); - ObjectGuid::LowType guid = field[2].GetUInt64(); - uint32 from = field[3].GetUInt32(); - std::string dump = field[4].GetString(); - uint32 toacc = field[5].GetUInt32(); - uint32 transferId = field[6].GetUInt32(); - uint32 newguid = 0; - if(!toacc) - toacc = account; - - DumpReturn dumpState = PlayerDumpReader().LoadDump(toacc, dump, "", newguid); - - TC_LOG_DEBUG("network", "Transfer toLoad guid %lu, dump %u", guid, dumpState); - - if (dumpState == DUMP_SUCCESS) - { - LoginDatabase.PQuery("DELETE FROM `transferts` WHERE `id` = %u", transaction); - LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_TRANSFERTS_LOGS); - if(stmt) - { - stmt->setUInt32(0, transaction); - stmt->setUInt32(1, account); - stmt->setUInt64(2, guid); - stmt->setUInt32(3, from); - stmt->setUInt32(4, realm.Id.Realm); - stmt->setString(5, dump); - stmt->setUInt32(6, toacc); - stmt->setUInt32(7, newguid); - stmt->setUInt32(8, transferId); - LoginDatabase.Execute(stmt); - if(transferId) - { - if (realm.Id.Realm == 59) - LoginDatabase.PQuery("UPDATE `transfer_requests` SET `guid` = '%u' WHERE `id` = '%u'", newguid, transferId); - else - LoginDatabase.PQuery("UPDATE `transfer_requests` SET `status` = '%u', `guid` = '%u' WHERE `id` = '%u'", dumpState, newguid, transferId); - } - } - } - else - { - LoginDatabase.PQuery("UPDATE `transferts` SET `error` = '%u', `nb_attempt` = `nb_attempt` + 1 WHERE `id` = '%u'", dumpState, transaction); - if (transferId && realm.Id.Realm != 59) - LoginDatabase.PQuery("UPDATE `transfer_requests` SET `status` = '%u' WHERE `id` = '%u'", dumpState, transferId); - continue; - } - } - while (toLoad->NextRow()); - } -} - Realm realm; uint32 GetVirtualRealmAddress() diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index ffceb411..a19d6d79 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -711,7 +711,6 @@ class World void SetClosed(bool val); void ProcessMailboxQueue(); - void Transfer(); uint32 GetPvPMysticCount() const { return m_pvpMysticCount; } void AddPvPMysticCount() { m_pvpMysticCount++; }