Created
November 11, 2014 08:06
-
-
Save Salja/dc77a64ac13fefc40e29 to your computer and use it in GitHub Desktop.
AutoBroadcast System V1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/Language.h b/src/game/Language.h | |
index d408bfd..cfc1a5d 100644 | |
--- a/src/game/Language.h | |
+++ b/src/game/Language.h | |
@@ -1017,6 +1017,8 @@ enum MangosStrings | |
// FREE IDS 1700-9999 | |
+ LANG_AUTO_BROADCAST = 1700, | |
+ | |
// Use for not-in-official-sources patches | |
// 10000-10999 | |
diff --git a/src/game/World.cpp b/src/game/World.cpp | |
index c509454..a4100f1 100644 | |
--- a/src/game/World.cpp | |
+++ b/src/game/World.cpp | |
@@ -50,6 +50,7 @@ | |
#include "Policies/Singleton.h" | |
#include "BattleGround/BattleGroundMgr.h" | |
#include "OutdoorPvP/OutdoorPvP.h" | |
+#include "Language.h" | |
#include "TemporarySummon.h" | |
#include "VMapFactory.h" | |
#include "MoveMap.h" | |
@@ -1307,12 +1308,16 @@ 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_WEATHERS].SetInterval(1 * IN_MILLISECONDS); | |
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE * IN_MILLISECONDS); | |
m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE * IN_MILLISECONDS); | |
// Update "uptime" table based on configuration entry in minutes. | |
m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS); | |
m_timers[WUPDATE_DELETECHARS].SetInterval(DAY * IN_MILLISECONDS); // check for chars to delete every day | |
+ m_timers[WUPDATE_AUTOBROADCAST].SetInterval(abtimer); | |
// for AhBot | |
m_timers[WUPDATE_AHBOT].SetInterval(20 * IN_MILLISECONDS); // every 20 sec | |
@@ -1533,6 +1538,18 @@ void World::Update(uint32 diff) | |
m_timers[WUPDATE_EVENTS].Reset(); | |
} | |
+ static uint32 autobroadcaston = 0; | |
+ autobroadcaston = sConfig.GetIntDefault("AutoBroadcast.On", 0); | |
+ | |
+ if (autobroadcaston == 1) | |
+ { | |
+ if (m_timers[WUPDATE_AUTOBROADCAST].Passed()) | |
+ { | |
+ m_timers[WUPDATE_AUTOBROADCAST].Reset(); | |
+ SendBroadcast(); | |
+ } | |
+ } | |
+ | |
/// </ul> | |
///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" | |
sMapMgr.RemoveAllObjectsInRemoveList(); | |
@@ -1934,6 +1951,61 @@ void World::ProcessCliCommands() | |
} | |
} | |
+void World::SendBroadcast() | |
+{ | |
+ std::string msg; | |
+ static int nextid; | |
+ | |
+ QueryResult* result; | |
+ | |
+ if (nextid != 0) | |
+ { | |
+ result = LoginDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` WHERE `id` = %u", nextid); | |
+ } | |
+ else | |
+ { | |
+ result = LoginDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` ORDER BY RAND() LIMIT 1"); | |
+ } | |
+ | |
+ if (!result) | |
+ return; | |
+ | |
+ Field* fields = result->Fetch(); | |
+ nextid = fields[1].GetUInt32(); | |
+ msg = fields[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() | |
{ | |
} | |
diff --git a/src/game/World.h b/src/game/World.h | |
index 2d6651e..3220487 100644 | |
--- a/src/game/World.h | |
+++ b/src/game/World.h | |
@@ -75,7 +75,8 @@ enum WorldTimers | |
WUPDATE_EVENTS = 4, | |
WUPDATE_DELETECHARS = 5, | |
WUPDATE_AHBOT = 6, | |
- WUPDATE_COUNT = 7 | |
+ WUPDATE_AUTOBROADCAST = 7, | |
+ WUPDATE_COUNT = 8 | |
}; | |
/// Configuration elements | |
@@ -442,6 +443,7 @@ class World | |
WorldSession* FindSession(uint32 id) const; | |
void AddSession(WorldSession* s); | |
+ void SendBroadcast(); | |
bool RemoveSession(uint32 id); | |
/// Get the number of current active sessions | |
void UpdateMaxSessionCounters(); | |
diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in | |
index 7b6e228..cfc41f2 100644 | |
--- a/src/mangosd/mangosd.conf.dist.in | |
+++ b/src/mangosd/mangosd.conf.dist.in | |
@@ -855,6 +855,29 @@ AllowTwoSide.AddFriend = 0 | |
TalentsInspecting = 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 | |
+ | |
+################################################################################################################### | |
# CREATURE AND GAMEOBJECT SETTINGS | |
# | |
# ThreatRadius |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM `mangos_string` WHERE `entry` = 1700; | |
INSERT INTO `mangos_string` VALUES (1700, '|cffffcc00[Server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `autobroadcast` ( | |
`id` INT(11) NOT NULL AUTO_INCREMENT, | |
`text` LONGTEXT NOT NULL, | |
`next` INT(11) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MYISAM DEFAULT CHARSET=utf8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment