aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAzazel <azazel.kon@gmail.com>2011-03-11 17:18:17 +0600
committerAzazel <azazel.kon@gmail.com>2011-03-11 17:18:17 +0600
commit3973d1b45444c0c8fcd7aa1e033be4329dce05ae (patch)
tree48a785ae8bbdaf7b49eaf6a832d0a0ea2f577014 /src
parent20b44e82d5a0ba86e1b8819e5d7cad4681ba36f5 (diff)
CharDB Schema/Cleanup: cleanup channels table:
* rename columns (remove m_ prefix and convert to lowerCamel case); * rename prepared statements to conform to standards (there is no CLEAN statement).
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Chat/Channels/Channel.cpp4
-rwxr-xr-xsrc/server/game/Chat/Commands/Level3.cpp10
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.cpp11
-rwxr-xr-xsrc/server/shared/Database/Implementation/CharacterDatabase.h3
4 files changed, 18 insertions, 10 deletions
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp
index 24fb18349ef..afe487b2c1b 100755
--- a/src/server/game/Chat/Channels/Channel.cpp
+++ b/src/server/game/Chat/Channels/Channel.cpp
@@ -133,8 +133,8 @@ void Channel::CleanOldChannelsInDB()
{
if (sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) > 0)
{
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_CLEAN_CHANNEL);
- stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION)*DAY);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS);
+ stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) * DAY);
CharacterDatabase.Execute(stmt);
sLog->outDebug(LOG_FILTER_CHATSYS,"Cleaned out unused custom chat channels.");
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index a50fae33b19..88e4e2912d2 100755
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -4431,14 +4431,20 @@ bool ChatHandler::HandleChannelSetOwnership(const char *args)
{
if(chn)
chn->SetOwnership(true);
- CharacterDatabase.PExecute("UPDATE channels SET m_ownership = 1 WHERE m_name LIKE '%s'", channel);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_CHANNEL_OWNERSHIP);
+ stmt->setUInt8 (0, 1);
+ stmt->setString(1, channel);
+ CharacterDatabase.Execute(stmt);
PSendSysMessage(LANG_CHANNEL_ENABLE_OWNERSHIP, channel);
}
else if (strcmp(argstr, "off") == 0)
{
if(chn)
chn->SetOwnership(false);
- CharacterDatabase.PExecute("UPDATE channels SET m_ownership = 0 WHERE m_name LIKE '%s'", channel);
+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_CHANNEL_OWNERSHIP);
+ stmt->setUInt8 (0, 0);
+ stmt->setString(1, channel);
+ CharacterDatabase.Execute(stmt);
PSendSysMessage(LANG_CHANNEL_DISABLE_OWNERSHIP, channel);
}
else
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 44c186cdb82..98db2e51dfa 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
@@ -237,11 +237,12 @@ bool CharacterDatabaseConnection::Open()
PREPARE_STATEMENT(CHAR_ADD_GO_RESPAWN_TIME, "REPLACE INTO gameobject_respawn VALUES (?, ?, ?)", CONNECTION_ASYNC)
// Chat channel handling
- PREPARE_STATEMENT(CHAR_LOAD_CHANNEL, "SELECT m_announce, m_ownership, m_password, BannedList FROM channels WHERE m_name = ? AND m_team = ?", CONNECTION_SYNCH)
- PREPARE_STATEMENT(CHAR_ADD_CHANNEL, "INSERT INTO channels (m_name, m_team, last_used) VALUES (? , ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC)
- PREPARE_STATEMENT(CHAR_SET_CHANNEL, "UPDATE channels SET m_announce = ?, m_ownership = ?, m_password = ?, BannedList = ?, last_used = UNIX_TIMESTAMP() WHERE m_name = ? AND m_team = ?", CONNECTION_ASYNC)
- PREPARE_STATEMENT(CHAR_SET_CHANNEL_USAGE, "UPDATE channels SET last_used = UNIX_TIMESTAMP() WHERE m_name = ? AND m_team = ?", CONNECTION_ASYNC)
- PREPARE_STATEMENT(CHAR_CLEAN_CHANNEL, "DELETE FROM channels WHERE m_ownership = 1 AND (last_used + ?) < UNIX_TIMESTAMP()", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_LOAD_CHANNEL, "SELECT announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH)
+ PREPARE_STATEMENT(CHAR_ADD_CHANNEL, "INSERT INTO channels(name, team, lastUsed) VALUES (?, ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_SET_CHANNEL, "UPDATE channels SET announce = ?, ownership = ?, password = ?, bannedList = ?, lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_SET_CHANNEL_USAGE, "UPDATE channels SET lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_SET_CHANNEL_OWNERSHIP, "UPDATE channels SET ownership = ? WHERE name LIKE ?", CONNECTION_ASYNC)
+ PREPARE_STATEMENT(CHAR_DEL_OLD_CHANNELS, "DELETE FROM channels WHERE ownership = 1 AND lastUsed + ? < UNIX_TIMESTAMP()", CONNECTION_ASYNC)
// Equipmentsets
PREPARE_STATEMENT(CHAR_SET_EQUIP_SET, "UPDATE character_equipmentsets SET name=?, iconname=?, item0=?, item1=?, item2=?, item3=?, item4=?, item5=?, item6=?, item7=?, item8=?, item9=?, item10=?, item11=?, item12=?, item13=?, item14=?, item15=?, item16=?, item17=?, item18=? WHERE guid=? AND setguid=? AND setindex=?", CONNECTION_ASYNC)
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h
index 951ea90b326..8fc1c9a38e9 100755
--- a/src/server/shared/Database/Implementation/CharacterDatabase.h
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.h
@@ -202,7 +202,8 @@ enum CharacterDatabaseStatements
CHAR_ADD_CHANNEL,
CHAR_SET_CHANNEL,
CHAR_SET_CHANNEL_USAGE,
- CHAR_CLEAN_CHANNEL,
+ CHAR_SET_CHANNEL_OWNERSHIP,
+ CHAR_DEL_OLD_CHANNELS,
CHAR_SET_EQUIP_SET,
CHAR_ADD_EQUIP_SET,