Skip to content

Commit

Permalink
remove transferts tables and code; it sometimes prevented login (The-…
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongdove authored Nov 25, 2024
1 parent 37be94c commit 0788ee5
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 148 deletions.
7 changes: 7 additions & 0 deletions sql/updates/auth/2024_11_24_drop_transferts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--
DROP TABLE `transferts`;
DROP TABLE `transferts_logs`;
DROP TABLE `transfer_requests`;

ALTER TABLE `account_character_template`
DROP COLUMN `transferId`;
5 changes: 5 additions & 0 deletions sql/updates/characters/2024_11_24_drop_transfers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--
ALTER TABLE `characters`
DROP COLUMN `transfer`,
DROP COLUMN `transfer_history`,
DROP COLUMN `transfer_request`;
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions src/server/database/Database/Implementation/LoginDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -115,7 +111,6 @@ enum LoginDatabaseStatements : uint32

LOGIN_SEL_ACCOUNT_CHARACTER_TEMPLATE,
LOGIN_UPD_ACCOUNT_CHARACTER_TEMPLATE,
LOGIN_UPD_TRANSFER_REQUESTS,

MAX_LOGINDATABASE_STATEMENTS,
};
Expand Down
15 changes: 0 additions & 15 deletions src/server/game/Handlers/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/server/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Tools/PlayerDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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`"},
Expand Down
118 changes: 0 additions & 118 deletions src/server/game/World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,6 @@ void World::Update(uint32 diff)
{
m_timers[WUPDATE_MAILBOXQUEUE].Reset();
ProcessMailboxQueue();
Transfer();
}

if (m_timers[WUPDATE_DONATE_AND_SERVICES].Passed())
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/server/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ class World
void SetClosed(bool val);

void ProcessMailboxQueue();
void Transfer();

uint32 GetPvPMysticCount() const { return m_pvpMysticCount; }
void AddPvPMysticCount() { m_pvpMysticCount++; }
Expand Down

0 comments on commit 0788ee5

Please sign in to comment.