diff options
author | maximius <none@none> | 2009-08-08 15:05:21 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-08-08 15:05:21 -0700 |
commit | 64ee35bd94d70872d404c23094f96962fe8f6114 (patch) | |
tree | ece661f589d14283948bffcd8806a583f53f2c98 | |
parent | 38abfbeedde470a3798c1c4db237ded23291bce7 (diff) |
*Added autoannounce to core, and optimized autobroadcast db query to put less strain on MySQL
--HG--
branch : trunk
-rw-r--r-- | sql/updates/XXX_world_announce.sql | 14 | ||||
-rw-r--r-- | src/game/Language.h | 1 | ||||
-rw-r--r-- | src/game/World.cpp | 53 | ||||
-rw-r--r-- | src/game/World.h | 4 | ||||
-rw-r--r-- | src/trinitycore/trinitycore.conf.dist | 22 |
5 files changed, 93 insertions, 1 deletions
diff --git a/sql/updates/XXX_world_announce.sql b/sql/updates/XXX_world_announce.sql new file mode 100644 index 00000000000..59accbfc9bb --- /dev/null +++ b/sql/updates/XXX_world_announce.sql @@ -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.'); diff --git a/src/game/Language.h b/src/game/Language.h index bf0705a35cb..bd74333c45a 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -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) diff --git a/src/game/World.cpp b/src/game/World.cpp index 450840f1714..f7cc552342a 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -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; diff --git a/src/game/World.h b/src/game/World.h index d590a552f26..0bd2abb4c9b 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -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(); diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index a9c987c0ed6..1db57b9e08a 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -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 |