aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpp <none@none>2010-03-09 12:58:48 +0100
committerSpp <none@none>2010-03-09 12:58:48 +0100
commitcef249ff2cec86c4059daa744f2f30e0b999f217 (patch)
tree4c1e37b4933982278ad60b4ced6ee868683b8f86
parent8034a6c48ea565345cd769422bb80acf5df015e4 (diff)
Add level restrictions to some commands:
say, yell, emote, whisper, channel use, trade, auction, mail, tickets By azazel. Closes issue #598 --HG-- branch : trunk
-rw-r--r--sql/updates/7508_world_trinity_string.sql11
-rw-r--r--sql/world.sql9
-rw-r--r--src/game/AuctionHouseHandler.cpp6
-rw-r--r--src/game/ChatHandler.cpp19
-rw-r--r--src/game/Language.h13
-rw-r--r--src/game/Mail.cpp19
-rw-r--r--src/game/TicketHandler.cpp6
-rw-r--r--src/game/TradeHandler.cpp12
-rw-r--r--src/game/World.cpp8
-rw-r--r--src/game/World.h6
-rw-r--r--src/trinitycore/trinitycore.conf.dist34
11 files changed, 138 insertions, 5 deletions
diff --git a/sql/updates/7508_world_trinity_string.sql b/sql/updates/7508_world_trinity_string.sql
new file mode 100644
index 00000000000..f00d526f02c
--- /dev/null
+++ b/sql/updates/7508_world_trinity_string.sql
@@ -0,0 +1,11 @@
+DELETE FROM `trinity_string` WHERE `entry` IN (6604,6605,6606,6607,6608,6609,6610,6611,6612);
+INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
+(6604, 'You cannot say, yell or emote until you become level %d.'),
+(6605, 'You cannot whisper until you become level %d.'),
+(6606, 'You cannot write to channels until you become level %d.'),
+(6607, 'You cannot use auction until you become level %d.'),
+(6608, 'You cannot write tickets until you become level %d.'),
+(6609, 'You cannot trade until you become level %d.'),
+(6610, 'You cannot trade with characters lower than level %d.'),
+(6611, 'You cannot send mail until you become level %d.'),
+(6612, 'You cannot send mail to characters lower than level %d.');
diff --git a/sql/world.sql b/sql/world.sql
index 2dcb737b40c..666e3069b18 100644
--- a/sql/world.sql
+++ b/sql/world.sql
@@ -14805,6 +14805,15 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
(5025, 'Type: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(5026, 'DisplayID: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(5027, 'Name: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6604, 'You cannot say, yell or emote until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6605, 'You cannot whisper until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6606, 'You cannot write to channels until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6607, 'You cannot use auction until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6608, 'You cannot write tickets until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6609, 'You cannot trade until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6610, 'You cannot trade with characters lower than level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6611, 'You cannot send mail until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6612, 'You cannot send mail to characters lower than level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6613, '|cfff00000[GM Announcement]: %s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6614, 'Notification to GM''s - ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6615, '|cffffff00[|c1f40af20GM Announce by|r |cffff0000%s|cffffff00]:|r %s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
index 268666c5399..603a0e2bc63 100644
--- a/src/game/AuctionHouseHandler.cpp
+++ b/src/game/AuctionHouseHandler.cpp
@@ -57,6 +57,12 @@ void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data)
//this void causes that auction window is opened
void WorldSession::SendAuctionHello(uint64 guid, Creature* unit)
{
+ if (GetPlayer()->getLevel() < sWorld.getConfig(CONFIG_AUCTION_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_AUCTION_REQ), sWorld.getConfig(CONFIG_AUCTION_LEVEL_REQ));
+ return;
+ }
+
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
if (!ahEntry)
return;
diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
index befe5ee3a09..a95eee32789 100644
--- a/src/game/ChatHandler.cpp
+++ b/src/game/ChatHandler.cpp
@@ -199,6 +199,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (ChatHandler(this).ParseCommands(msg.c_str()) > 0)
break;
+ if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_SAY_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_SAY_REQ), sWorld.getConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
+ return;
+ }
+
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
@@ -219,6 +225,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
recv_data >> to;
recv_data >> msg;
+ if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_WHISPER_REQ), sWorld.getConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
+ return;
+ }
+
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
@@ -519,8 +531,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
- if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
- return;
+ if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_CHANNEL_REQ), sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
+ return;
+ }
if(msg.empty())
break;
diff --git a/src/game/Language.h b/src/game/Language.h
index 4e5e3de4a9d..c4459c18c71 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -884,6 +884,19 @@ enum TrinityStrings
LANG_GOINFO_DISPLAYID = 5026,
LANG_GOINFO_NAME = 5027,
// Room for more Trinity strings 5028-9999
+
+ // Level requirement notifications
+ LANG_SAY_REQ = 6604,
+ LANG_WHISPER_REQ = 6605,
+ LANG_CHANNEL_REQ = 6606,
+ LANG_AUCTION_REQ = 6607,
+ LANG_TICKET_REQ = 6608,
+ LANG_TRADE_REQ = 6609,
+ LANG_TRADE_OTHER_REQ = 6610,
+ LANG_MAIL_SENDER_REQ = 6611,
+ LANG_MAIL_RECEIVER_REQ = 6612,
+
+
// Used for GM Announcements
LANG_GM_BROADCAST = 6613,
LANG_GM_NOTIFY = 6614,
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index 667b5ef19ec..b0d75eed9c9 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -92,6 +92,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
Player* pl = _player;
+ if (pl->getLevel() < sWorld.getConfig(CONFIG_MAIL_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_MAIL_SENDER_REQ), sWorld.getConfig(CONFIG_MAIL_LEVEL_REQ));
+ return;
+ }
+
uint64 rc = 0;
if (normalizePlayerName(receiver))
rc = objmgr.GetPlayerGUIDByName(receiver);
@@ -126,11 +132,13 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
uint32 rc_team = 0;
uint8 mails_count = 0; //do not allow to send to one player more than 100 mails
+ uint8 receiveLevel = 0;
if (receive)
{
rc_team = receive->GetTeam();
mails_count = receive->GetMailSize();
+ receiveLevel = receive->getLevel();
}
else
{
@@ -140,6 +148,11 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
Field *fields = result->Fetch();
mails_count = fields[0].GetUInt32();
}
+ if (QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid = '%u'", GUID_LOPART(rc)))
+ {
+ Field *fields = result->Fetch();
+ receiveLevel = fields[0].GetUInt8();
+ }
}
//do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
if (mails_count > 100)
@@ -154,6 +167,12 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
return;
}
+ if (receiveLevel < sWorld.getConfig(CONFIG_MAIL_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_MAIL_RECEIVER_REQ), sWorld.getConfig(CONFIG_MAIL_LEVEL_REQ));
+ return;
+ }
+
uint32 rc_account = receive
? receive->GetSession()->GetAccountId()
: objmgr.GetPlayerAccountIdByGUID(rc);
diff --git a/src/game/TicketHandler.cpp b/src/game/TicketHandler.cpp
index e766cb2763e..520c4f61bf9 100644
--- a/src/game/TicketHandler.cpp
+++ b/src/game/TicketHandler.cpp
@@ -27,6 +27,12 @@
void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
{
+ if (GetPlayer()->getLevel() < sWorld.getConfig(CONFIG_TICKET_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_TICKET_REQ), sWorld.getConfig(CONFIG_TICKET_LEVEL_REQ));
+ return;
+ }
+
if(GM_Ticket *ticket = objmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID()))
{
WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp
index eebbaf0c2a5..64c1d8e904c 100644
--- a/src/game/TradeHandler.cpp
+++ b/src/game/TradeHandler.cpp
@@ -495,6 +495,12 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
+ if (GetPlayer()->getLevel() < sWorld.getConfig(CONFIG_TRADE_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_TRADE_REQ), sWorld.getConfig(CONFIG_TRADE_LEVEL_REQ));
+ return;
+ }
+
recvPacket >> ID;
Player* pOther = ObjectAccessor::FindPlayer( ID );
@@ -553,6 +559,12 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
return;
}
+ if (pOther->getLevel() < sWorld.getConfig(CONFIG_TRADE_LEVEL_REQ))
+ {
+ SendNotification(GetTrinityString(LANG_TRADE_OTHER_REQ), sWorld.getConfig(CONFIG_TRADE_LEVEL_REQ));
+ return;
+ }
+
// OK start trade
_player->pTrader = pOther;
pOther->pTrader =_player;
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 6a0ec55a86e..689f35f4177 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -602,7 +602,13 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_COMPRESSION] = 1;
}
m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true);
- m_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ] = sConfig.GetIntDefault("ChannelLevelReq", 1);
+ m_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ] = sConfig.GetIntDefault("ChatLevelReq.Channel", 1);
+ m_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ] = sConfig.GetIntDefault("ChatLevelReq.Whisper", 1);
+ m_configs[CONFIG_CHAT_SAY_LEVEL_REQ] = sConfig.GetIntDefault("ChatLevelReq.Say", 1);
+ m_configs[CONFIG_TRADE_LEVEL_REQ] = sConfig.GetIntDefault("LevelReq.Trade", 1);
+ m_configs[CONFIG_TICKET_LEVEL_REQ] = sConfig.GetIntDefault("LevelReq.Ticket", 1);
+ m_configs[CONFIG_AUCTION_LEVEL_REQ] = sConfig.GetIntDefault("LevelReq.Auction", 1);
+ m_configs[CONFIG_MAIL_LEVEL_REQ] = sConfig.GetIntDefault("LevelReq.Mail", 1);
m_configs[CONFIG_ALLOW_PLAYER_COMMANDS] = sConfig.GetBoolDefault("AllowPlayerCommands", 1);
m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true);
m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 15 * MINUTE * IN_MILISECONDS);
diff --git a/src/game/World.h b/src/game/World.h
index a105a995099..ba0cd8e4f44 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -202,6 +202,12 @@ enum WorldConfigs
CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY,
CONFIG_CHAT_STRICT_LINK_CHECKING_KICK,
CONFIG_CHAT_CHANNEL_LEVEL_REQ,
+ CONFIG_CHAT_WHISPER_LEVEL_REQ,
+ CONFIG_CHAT_SAY_LEVEL_REQ,
+ CONFIG_TRADE_LEVEL_REQ,
+ CONFIG_TICKET_LEVEL_REQ,
+ CONFIG_AUCTION_LEVEL_REQ,
+ CONFIG_MAIL_LEVEL_REQ,
CONFIG_ALLOW_PLAYER_COMMANDS,
CONFIG_CORPSE_DECAY_NORMAL,
CONFIG_CORPSE_DECAY_RARE,
diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist
index b1b1d322635..43efc8e095d 100644
--- a/src/trinitycore/trinitycore.conf.dist
+++ b/src/trinitycore/trinitycore.conf.dist
@@ -1164,10 +1164,18 @@ ListenRange.Yell = 300
# Default: 0 (join announcement in normal way)
# 1 (GM join without announcement)
#
-# ChannelLevelReq
+# ChatLevelReq.Channel
# The required level of character to be able to write in chat channels
# Default: 1 (From level 1)
#
+# ChatLevelReq.Whisper
+# The required level of character to be able to whisper
+# Default: 1 (From level 1)
+#
+# ChatLevelReq.Say
+# The required level of character to be able to say/yell/emote
+# Default: 1 (From level 1)
+#
# AllowPlayerCommands
# Allowed the players to use commands
# Default: 1 (allow)
@@ -1182,7 +1190,9 @@ ChatFlood.MessageDelay = 1
ChatFlood.MuteTime = 10
Channel.RestrictedLfg = 1
Channel.SilentlyGMJoin = 0
-ChannelLevelReq = 1
+ChatLevelReq.Channel = 1
+ChatLevelReq.Whisper = 1
+ChatLevelReq.Say = 1
AllowPlayerCommands = 1
###############################################################################
@@ -2146,6 +2156,22 @@ Ra.Secure = 1
# to players when they login to a newly created character.
# Default: "" - send no text
#
+# LevelReq.Trade
+# The required level of character to be able to trade
+# Default: 1 (From level 1)
+#
+# LevelReq.Ticket
+# The required level of character to be able to write tickets
+# Default: 1 (From level 1)
+#
+# LevelReq.Auction
+# The required level of character to be able to use auction
+# Default: 1 (From level 1)
+#
+# LevelReq.Mail
+# The required level of character to be able to send and receive mail
+# Default: 1 (From level 1)
+#
###############################################################################
PlayerStart.AllReputation = 0
@@ -2164,3 +2190,7 @@ ShowKickInWorld = 0
RecordUpdateTimeDiffInterval = 60000
MinRecordUpdateTimeDiff = 100
PlayerStart.String = ""
+LevelReq.Trade = 1
+LevelReq.Ticket = 1
+LevelReq.Auction = 1
+LevelReq.Mail = 1