aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/characters_database.sql4
-rw-r--r--sql/updates/auth_char/2011_02_24_0_characters_account_data.sql1
-rwxr-xr-xsrc/server/game/Accounts/AccountMgr.cpp4
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp4
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/CharacterHandler.cpp2
-rwxr-xr-xsrc/server/game/Server/WorldSession.cpp31
-rwxr-xr-xsrc/server/game/Server/WorldSession.h3
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.cpp10
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.h9
9 files changed, 43 insertions, 25 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql
index e0bf22ab4c0..13678facdc2 100644
--- a/sql/base/characters_database.sql
+++ b/sql/base/characters_database.sql
@@ -23,11 +23,11 @@ DROP TABLE IF EXISTS `account_data`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `account_data` (
- `account` int(10) unsigned NOT NULL DEFAULT '0',
+ `accountId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Account Identifier',
`type` tinyint(3) unsigned NOT NULL DEFAULT '0',
`time` int(10) unsigned NOT NULL DEFAULT '0',
`data` blob NOT NULL,
- PRIMARY KEY (`account`,`type`)
+ PRIMARY KEY (`accountId`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/sql/updates/auth_char/2011_02_24_0_characters_account_data.sql b/sql/updates/auth_char/2011_02_24_0_characters_account_data.sql
new file mode 100644
index 00000000000..b4a8ed25e8d
--- /dev/null
+++ b/sql/updates/auth_char/2011_02_24_0_characters_account_data.sql
@@ -0,0 +1 @@
+ALTER TABLE `account_data` CHANGE COLUMN `account` `accountId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Account Identifier';
diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp
index 3c0072b54fa..aa8658d1d65 100755
--- a/src/server/game/Accounts/AccountMgr.cpp
+++ b/src/server/game/Accounts/AccountMgr.cpp
@@ -75,7 +75,9 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
// table realm specific but common for all characters of account for realm
CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid);
- CharacterDatabase.PExecute("DELETE FROM account_data WHERE account = '%u'",accid);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
+ stmt->setUInt32(0, accid);
+ CharacterDatabase.Execute(stmt);
SQLTransaction trans = LoginDatabase.BeginTransaction();
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1179eef26e6..9a850fd389e 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -4630,7 +4630,9 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
}
trans->PAppend("DELETE FROM characters WHERE guid = '%u'",guid);
- trans->PAppend("DELETE FROM character_account_data WHERE guid = '%u'",guid);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA);
+ stmt->setUInt32(0, guid);
+ trans->Append(stmt);
trans->PAppend("DELETE FROM character_declinedname WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_action WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_aura WHERE guid = '%u'",guid);
diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
index 9327906190d..904453dc978 100755
--- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp
@@ -166,7 +166,7 @@ bool LoginQueryHolder::Initialize()
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADTALENTS, stmt);
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACCOUNTDATA);
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_PLAYER_ACCOUNT_DATA);
stmt->setUInt32(0, lowGuid);
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, stmt);
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index e0412272688..7b9a530bfed 100755
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -596,7 +596,7 @@ void WorldSession::SendAuthWaitQue(uint32 position)
void WorldSession::LoadGlobalAccountData()
{
- PreparedStatement *stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_ACCOUNT_DATA);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_ACCOUNT_DATA);
stmt->setUInt32(0, GetAccountId());
LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
}
@@ -632,17 +632,14 @@ void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
while (result->NextRow());
}
-void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::string data)
+void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string data)
{
+ uint32 id = 0;
+ uint32 index = 0;
if ((1 << type) & GLOBAL_CACHE_MASK)
{
- uint32 acc = GetAccountId();
-
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
- trans->PAppend("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
- CharacterDatabase.escape_string(data);
- trans->PAppend("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)time_, data.c_str());
- CharacterDatabase.CommitTransaction(trans);
+ id = GetAccountId();
+ index = CHAR_SET_ACCOUNT_DATA;
}
else
{
@@ -650,14 +647,18 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
if (!m_GUIDLow)
return;
- SQLTransaction trans = CharacterDatabase.BeginTransaction();
- trans->PAppend("DELETE FROM character_account_data WHERE guid='%u' AND type='%u'", m_GUIDLow, type);
- CharacterDatabase.escape_string(data);
- trans->PAppend("INSERT INTO character_account_data VALUES ('%u','%u','%u','%s')", m_GUIDLow, type, (uint32)time_, data.c_str());
- CharacterDatabase.CommitTransaction(trans);
+ id = m_GUIDLow;
+ index = CHAR_SET_PLAYER_ACCOUNT_DATA;
}
- m_accountData[type].Time = time_;
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(index);
+ stmt->setUInt32(0, id);
+ stmt->setUInt8 (1, type);
+ stmt->setUInt32(2, uint32(tm));
+ stmt->setString(3, data);
+ CharacterDatabase.Execute(stmt);
+
+ m_accountData[type].Time = tm;
m_accountData[type].Data = data;
}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index b16d61f8da7..767dfcf38ce 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -278,10 +278,11 @@ class WorldSession
// Account Data
AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; }
- void SetAccountData(AccountDataType type, time_t time_, std::string data);
+ void SetAccountData(AccountDataType type, time_t tm, std::string data);
void SendAccountDataTimes(uint32 mask);
void LoadGlobalAccountData();
void LoadAccountData(PreparedQueryResult result, uint32 mask);
+
void LoadTutorialsData();
void SendTutorialsData();
void SaveTutorialsData(SQLTransaction& trans);
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 8d36973be7f..5d0591df9f5 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
@@ -79,7 +79,6 @@ bool CharacterDatabaseConnection::Open()
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_BGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_GLYPHS, "SELECT spec, glyph1, glyph2, glyph3, glyph4, glyph5, glyph6 FROM character_glyphs WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_TALENTS, "SELECT spell, spec FROM character_talent WHERE guid = ?", CONNECTION_ASYNC)
- PREPARE_STATEMENT(CHAR_LOAD_PLAYER_ACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_SKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_RANDOMBG, "SELECT guid FROM character_battleground_random WHERE guid = ?", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_ARENASTATS, "SELECT slot, personal_rating, matchmaker_rating FROM character_arena_stats WHERE guid = ? ORDER BY slot ASC", CONNECTION_ASYNC)
@@ -89,7 +88,6 @@ bool CharacterDatabaseConnection::Open()
// End LoginQueryHolder content
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_ACTIONS_SPEC, "SELECT button, action, type FROM character_action WHERE guid = ? AND spec = ? ORDER BY button", CONNECTION_SYNCH)
- PREPARE_STATEMENT(CHAR_LOAD_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE account = ?", CONNECTION_SYNCH)
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_MAILITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, itemEntry, owner_guid FROM mail_items mi JOIN item_instance ii ON mi.item_guid = ii.guid WHERE mail_id = ?", CONNECTION_SYNCH)
PREPARE_STATEMENT(CHAR_LOAD_AUCTION_ITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, itemguid, itemEntry FROM auctionhouse ah JOIN item_instance ii ON ah.itemguid = ii.guid", CONNECTION_SYNCH)
PREPARE_STATEMENT(CHAR_LOAD_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH)
@@ -259,6 +257,14 @@ bool CharacterDatabaseConnection::Open()
PREPARE_STATEMENT(CHAR_ADD_AURA, "INSERT INTO character_aura (guid,caster_guid,item_guid,spell,effect_mask,recalculate_mask,stackcount,amount0,amount1,amount2,base_amount0,base_amount1,base_amount2,maxduration,remaintime,remaincharges) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
+ // Account data
+ PREPARE_STATEMENT(CHAR_LOAD_ACCOUNT_DATA, "SELECT type, time, data FROM account_data WHERE accountId = ?", CONNECTION_SYNCH)
+ PREPARE_STATEMENT(CHAR_SET_ACCOUNT_DATA, "REPLACE INTO account_data(accountId, type, time, data) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_DEL_ACCOUNT_DATA, "DELETE FROM account_data WHERE accountId = ?", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_LOAD_PLAYER_ACCOUNT_DATA, "SELECT type, time, data FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_SET_PLAYER_ACCOUNT_DATA, "REPLACE INTO character_account_data(guid, type, time, data) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_DEL_PLAYER_ACCOUNT_DATA, "DELETE FROM character_account_data WHERE guid = ?", CONNECTION_ASYNC)
+
// Instance saves
PREPARE_STATEMENT(CHAR_ADD_INSTANCE_SAVE, "INSERT INTO instance (id,map,resettime,difficulty,completedEncounters,data) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
PREPARE_STATEMENT(CHAR_UPDATE_INSTANCE_DATA, "UPDATE instance SET completedEncounters=?, data=? WHERE id=?", CONNECTION_ASYNC)
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h
index 4d47878eba6..2c7c4ed345a 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.h
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.h
@@ -86,14 +86,12 @@ enum CharacterDatabaseStatements
CHAR_LOAD_PLAYER_BGDATA,
CHAR_LOAD_PLAYER_GLYPHS,
CHAR_LOAD_PLAYER_TALENTS,
- CHAR_LOAD_PLAYER_ACCOUNTDATA,
CHAR_LOAD_PLAYER_SKILLS,
CHAR_LOAD_PLAYER_RANDOMBG,
CHAR_LOAD_PLAYER_ARENASTATS,
CHAR_LOAD_PLAYER_BANNED,
CHAR_LOAD_PLAYER_QUESTSTATUSREW,
CHAR_LOAD_ACCOUNT_INSTANCELOCKTIMES,
- CHAR_LOAD_ACCOUNT_DATA,
CHAR_LOAD_PLAYER_MAILITEMS,
CHAR_LOAD_AUCTION_ITEMS,
CHAR_ADD_AUCTION,
@@ -218,6 +216,13 @@ enum CharacterDatabaseStatements
CHAR_DEL_AURA,
CHAR_ADD_AURA,
+ CHAR_LOAD_ACCOUNT_DATA,
+ CHAR_SET_ACCOUNT_DATA,
+ CHAR_DEL_ACCOUNT_DATA,
+ CHAR_LOAD_PLAYER_ACCOUNT_DATA,
+ CHAR_SET_PLAYER_ACCOUNT_DATA,
+ CHAR_DEL_PLAYER_ACCOUNT_DATA,
+
CHAR_ADD_INSTANCE_SAVE,
CHAR_UPDATE_INSTANCE_DATA,