*Added autoannounce to core, and optimized autobroadcast db query to put less strain on MySQL

--HG--
branch : trunk
This commit is contained in:
maximius
2009-08-08 15:05:21 -07:00
parent 38abfbeedd
commit 64ee35bd94
5 changed files with 93 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
CREATE TABLE `autobroadcast` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`text` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DELETE FROM `trinity_string` WHERE `entry` = 11000;
INSERT INTO `trinity_string` (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8)
VALUES (11000, '|cffffff00[|c00077766Autobroadcast|cffffff00]: |cFFF222FF%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-- optional examples
-- insert into `autobroadcast` (`id`, `text`) values('1','All Battlegrounds and Arena's work on this server.');
-- insert into `autobroadcast` (`id`, `text`) values('2','This server has 2 realms, The other realm is a PVP instant level 70 realm. Try it!');
-- insert into `autobroadcast` (`id`, `text`) values('3','The Auction House on this server is always full, because we use an AH Bot.');
+1
View File
@@ -943,6 +943,7 @@ enum TrinityStrings
LANG_OPVP_ZM_GOSSIP_HORDE = 10055,
// Use for custom patches 11000-11999
LANG_AUTO_BROADCAST = 11000,
// NOT RESERVED IDS 12000-1999999999
// `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
+53
View File
@@ -1551,6 +1551,8 @@ void World::SetInitialWorldSettings()
loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
realmID, uint64(m_startTime), isoDate);
static uint32 abtimer = 0;
abtimer = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000);
m_timers[WUPDATE_OBJECTS].SetInterval(IN_MILISECONDS/2);
m_timers[WUPDATE_SESSIONS].SetInterval(0);
m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILISECONDS);
@@ -1561,6 +1563,7 @@ void World::SetInitialWorldSettings()
//erase corpses every 20 minutes
m_timers[WUPDATE_CLEANDB].SetInterval(m_configs[CONFIG_LOGDB_CLEARINTERVAL]*MINUTE*IN_MILISECONDS);
// clean logs table every 14 days by default
m_timers[WUPDATE_AUTOBROADCAST].SetInterval(abtimer);
//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
@@ -1809,6 +1812,17 @@ void World::Update(uint32 diff)
MapManager::Instance().DoDelayedMovesAndRemoves();
}*/
static uint32 autobroadcaston = 0;
autobroadcaston = sConfig.GetIntDefault("AutoBroadcast.On", 0);
if(autobroadcaston == 1)
{
if (m_timers[WUPDATE_AUTOBROADCAST].Passed())
{
m_timers[WUPDATE_AUTOBROADCAST].Reset();
SendRNDBroadcast();
}
}
sBattleGroundMgr.Update(diff);
RecordTimeDiff("UpdateBattleGroundMgr");
@@ -2305,6 +2319,45 @@ void World::ProcessCliCommands()
zprint("TC> ");
}
void World::SendRNDBroadcast()
{
std::string msg;
QueryResult *result = WorldDatabase.PQuery("SELECT `text` FROM autobroadcast AS r1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM autobroadcast)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 1"); // ORDER BY RAND() is bad.. look it up to see why.
if(!result)
return;
msg = result->Fetch()[0].GetString();
delete result;
static uint32 abcenter = 0;
abcenter = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
if(abcenter == 0)
{
sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
if(abcenter == 1)
{
WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
data << msg;
sWorld.SendGlobalMessage(&data);
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
if(abcenter == 2)
{
sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
data << msg;
sWorld.SendGlobalMessage(&data);
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
}
void World::InitResultQueue()
{
m_resultQueue = new SqlResultQueue;
+3 -1
View File
@@ -80,7 +80,8 @@ enum WorldTimers
WUPDATE_CORPSES = 5,
WUPDATE_EVENTS = 6,
WUPDATE_CLEANDB = 7,
WUPDATE_COUNT = 8
WUPDATE_AUTOBROADCAST = 8,
WUPDATE_COUNT = 9
};
/// Configuration elements
@@ -419,6 +420,7 @@ class World
WorldSession* FindSession(uint32 id) const;
void AddSession(WorldSession *s);
void SendRNDBroadcast();
bool RemoveSession(uint32 id);
/// Get the number of current active sessions
void UpdateMaxSessionCounters();
+22
View File
@@ -1347,6 +1347,28 @@ Death.CorpseReclaimDelay.PvE = 0
Death.Bones.World = 1
Death.Bones.BattlegroundOrArena = 1
###################################################################################################################
# AUTO BROADCAST
#
# AutoBroadcast.On
# Enable auto broadcast
# Default: 0 - off
# 1 - on
#
# AutoBroadcast.Center
# Display method
# Default: 0 - announce
# 1 - notify
# 2 - both
#
# AutoBroadcast.Timer
# Timer for auto broadcast
#
###################################################################################################################
AutoBroadcast.On = 0
AutoBroadcast.Center = 0
AutoBroadcast.Timer = 60000
###################################################################################################################
# BATTLEGROUND CONFIG