Bonjour,
Voici un petit patch de l'auto broadcast, adapté pour la révision minimum 10872 de mangos
Fonction:
Affiche ce que vous voulait, dans le jeu, toute les certaines heures que vous choisissez
[code=diff]
diff --git a/sql/Annonce automatique/Broadcast Mangos.sql b/sql/Annonce automatique/Broadcast Mangos.sql
new file mode 100644
index 0000000..51cf3f4
--- /dev/null
+++ b/sql/Annonce automatique/Broadcast Mangos.sql
@@ -0,0 +1,3 @@
+--appliquer dans la base Mangos
+INSERT IGNORE INTO mangos_string (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8)
+VALUES (11023, '|cffffff00[|c00077766Annonce Automatique|cffffff00]: |cFFF222FF%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
diff --git a/sql/Annonce automatique/realmd autobroadcast.sql b/sql/Annonce automatique/realmd autobroadcast.sql
new file mode 100644
index 0000000..4052cf7
--- /dev/null
+++ b/sql/Annonce automatique/realmd autobroadcast.sql
@@ -0,0 +1,6 @@
+--appliquer dans la db realmd
+CREATE TABLE `autobroadcast` (
+`id` int(11) NOT NULL AUTO_INCREMENT,
+`text` longtext NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 6823efe..23fb913 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -60,6 +60,7 @@
#include "GMTicketMgr.h"
#include "Util.h"
#include "CharacterDatabaseCleaner.h"
+#include "Language.h"
INSTANTIATE_SINGLETON_1( World );
@@ -1274,6 +1275,9 @@ 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(0);
m_timers[WUPDATE_SESSIONS].SetInterval(0);
m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS);
@@ -1282,6 +1286,7 @@ void World::SetInitialWorldSettings()
//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);
//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
@@ -1499,6 +1504,17 @@ 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();
+ SendRNDBroadcast();
+ }
+ }
+
/// </ul>
///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
sMapMgr.RemoveAllObjectsInRemoveList();
@@ -1915,6 +1931,44 @@ void World::ProcessCliCommands()
delete command;
}
}
+void World::SendRNDBroadcast()
+{
+ std::string msg;
+ QueryResult *result = WorldDatabase.PQuery("SELECT `text` FROM `autobroadcast` ORDER BY RAND() LIMIT 1");
+
+ 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()
{
diff --git a/src/game/World.h b/src/game/World.h
index 5dea911..9977a76 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -82,7 +82,8 @@ enum WorldTimers
WUPDATE_CORPSES = 5,
WUPDATE_EVENTS = 6,
WUPDATE_DELETECHARS = 7,
- WUPDATE_COUNT = 8
+ WUPDATE_AUTOBROADCAST = 8,
+ WUPDATE_COUNT = 9
};
/// Configuration elements
@@ -432,6 +433,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/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
index e82ba21..a30a462 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -1553,3 +1553,35 @@ SOAP.Port = 7878
CharDelete.Method = 0
CharDelete.MinLevel = 0
CharDelete.KeepDays = 30
+
+###################################################################################################################
+# AUTO BROADCAST
+#
+# AutoBroadcast.On
+# Activer ou non l'auto broadcast
+# Default: 0 - off
+# 1 - on
+#
+# AutoBroadcast.Center
+# Mode d'affichage
+
+# Default: 0 - announce
+
+# 1 - notify
+# 2 - both
+
+#
+
+# AutoBroadcast.Timer
+
+# Tous les combiens de minutes
+ pour afficher
+#
+###################################################################################################################
+
+
+AutoBroadcast.On = 0
+AutoBroadcast.Center = 0
+AutoBroadcast.Timer = 60000
+
+
\ No newline at end of file
[/code]