Jump to content

[Patch] Auto Announcer(With Next ID)


Recommended Posts

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Up to date patch(untested)

diff --git a/sql/autobroadcast/mangos_mangos_string.sql b/sql/autobroadcast/mangos_mangos_string.sql
new file mode 100644
index 0000000..110a7e9
--- /dev/null
+++ b/sql/autobroadcast/mangos_mangos_string.sql
@@ -0,0 +1,2 @@
+INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES
+(1300, '|cffffcc00[server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
\\ No newline at end of file
diff --git a/sql/autobroadcast/realmd_autobroadcast.sql b/sql/autobroadcast/realmd_autobroadcast.sql
new file mode 100644
index 0000000..d396083
--- /dev/null
+++ b/sql/autobroadcast/realmd_autobroadcast.sql
@@ -0,0 +1,6 @@
+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 ;
\\ No newline at end of file
diff --git a/src/game/Language.h b/src/game/Language.h
index e1c15fb..0643b24 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -773,6 +773,9 @@ enum MangosStrings

    // FREE IDS                           1300-9999

+    // Broadcaster
+    LANG_AUTO_BROADCAST                 = 1300,
+
    // Use for not-in-offcial-sources patches
    //                                    10000-10999

diff --git a/src/game/World.cpp b/src/game/World.cpp
index bf20ccf..affcb5f 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -46,6 +46,7 @@
#include "ItemEnchantmentMgr.h"
#include "MapManager.h"
#include "ScriptCalls.h"
+#include "Language.h"
#include "CreatureAIRegistry.h"
#include "Policies/SingletonImp.h"
#include "BattleGroundMgr.h"
@@ -1398,8 +1399,10 @@ void World::SetInitialWorldSettings()
    sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
        local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

-    loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
-        realmID, uint64(m_startTime), isoDate);
+    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);
@@ -1409,7 +1412,7 @@ void World::SetInitialWorldSettings()
                                                            //Update "uptime" table based on configuration entry in minutes.
    m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS);
                                                            //erase corpses every 20 minutes
-
+    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
    //one second is 1000 -(tested on win system)
@@ -1448,6 +1451,7 @@ void World::SetInitialWorldSettings()
    sLog.outString("Starting Game Event system..." );
    uint32 nextGameEvent = gameeventmgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event
+    sLog.outString("Starting Autobroadcast system..." );

    sLog.outString( "WORLD: World initialized" );
}
@@ -1604,6 +1608,17 @@ void World::Update(uint32 diff)
        m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
        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();
+       }
+    }
+

    /// [/list]
    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
@@ -2728,6 +2743,56 @@ void World::ProcessCliCommands()
    // print the console message here so it looks right
    zprint("mangos>");
}
+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 8c2f2df..e2f9c1a 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -76,7 +76,8 @@ enum WorldTimers
    WUPDATE_UPTIME      = 4,
    WUPDATE_CORPSES     = 5,
    WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7
+    WUPDATE_AUTOBROADCAST = 7,
+    WUPDATE_COUNT         = 8
};

/// Configuration elements
@@ -371,6 +372,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 de5dbe2..29bbef1 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -680,6 +680,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 = 1
+AutoBroadcast.Center = 2
+AutoBroadcast.Timer = 30000
+
+###################################################################################################################
# CREATURE SETTINGS
#
#    ThreatRadius

Link to comment
Share on other sites

Here it is!!! :D

git pull git://github.com/Diablox/mangos.git autobroadcast

Edit: I finaly created patch file :D

[HIGHLIGHT=diff]From 71dcce34aeb586a253b4645fe893ebc22a50332e Mon Sep 17 00:00:00 2001

From: Diablox <[email protected]>

Date: Thu, 9 Jul 2009 21:42:54 +0200

Subject: [PATCH] Autobroadcast

---

sql/autobroadcast/mangos_mangos_string.sql | 4 ++

sql/autobroadcast/realmd_autobroadcast.sql | 6 ++

src/game/Language.h | 3 +

src/game/World.cpp | 72 ++++++++++++++++++++++++++--

src/game/World.h | 3 +-

src/mangosd/mangosd.conf.dist.in | 23 +++++++++

6 files changed, 106 insertions(+), 5 deletions(-)

create mode 100644 sql/autobroadcast/mangos_mangos_string.sql

create mode 100644 sql/autobroadcast/realmd_autobroadcast.sql

diff --git a/sql/autobroadcast/mangos_mangos_string.sql b/sql/autobroadcast/mangos_mangos_string.sql

new file mode 100644

index 0000000..39dc1ce

--- /dev/null

+++ b/sql/autobroadcast/mangos_mangos_string.sql

@@ -0,0 +1,4 @@

+DELETE FROM `mangos_string` WHERE `entry` = '1300';

+

+INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES

+(1300, '|cffffcc00[server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

diff --git a/sql/autobroadcast/realmd_autobroadcast.sql b/sql/autobroadcast/realmd_autobroadcast.sql

new file mode 100644

index 0000000..1e1ad4c

--- /dev/null

+++ b/sql/autobroadcast/realmd_autobroadcast.sql

@@ -0,0 +1,6 @@

+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 ;

diff --git a/src/game/Language.h b/src/game/Language.h

index e1c15fb..0643b24 100644

--- a/src/game/Language.h

+++ b/src/game/Language.h

@@ -773,6 +773,9 @@ enum MangosStrings

// FREE IDS 1300-9999

+ // Broadcaster

+ LANG_AUTO_BROADCAST = 1300,

+

// Use for not-in-offcial-sources patches

// 10000-10999

diff --git a/src/game/World.cpp b/src/game/World.cpp

index bf20ccf..3651b62 100644

--- a/src/game/World.cpp

+++ b/src/game/World.cpp

@@ -49,6 +49,7 @@

#include "CreatureAIRegistry.h"

#include "Policies/SingletonImp.h"

#include "BattleGroundMgr.h"

+#include "Language.h"

#include "TemporarySummon.h"

#include "WaypointMovementGenerator.h"

#include "VMapFactory.h"

@@ -1398,8 +1399,10 @@ void World::SetInitialWorldSettings()

sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",

local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

- loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",

- realmID, uint64(m_startTime), isoDate);

+ 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);

@@ -1409,7 +1412,7 @@ void World::SetInitialWorldSettings()

//Update "uptime" table based on configuration entry in minutes.

m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS);

//erase corpses every 20 minutes

-

+ 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

//one second is 1000 -(tested on win system)

@@ -1448,7 +1451,7 @@ void World::SetInitialWorldSettings()

sLog.outString("Starting Game Event system..." );

uint32 nextGameEvent = gameeventmgr.Initialize();

m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event

-

+ sLog.outString("Starting Autobroadcast system by Xeross..." );

sLog.outString( "WORLD: World initialized" );

}

@@ -1604,6 +1607,16 @@ void World::Update(uint32 diff)

m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);

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();

+ }

+ }

///

///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"

@@ -2729,6 +2742,57 @@ void World::ProcessCliCommands()

zprint("mangos>");

}

+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()

{

m_resultQueue = new SqlResultQueue;

diff --git a/src/game/World.h b/src/game/World.h

index 8c2f2df..16c0394 100644

--- a/src/game/World.h

+++ b/src/game/World.h

@@ -76,7 +76,8 @@ enum WorldTimers

WUPDATE_UPTIME = 4,

WUPDATE_CORPSES = 5,

WUPDATE_EVENTS = 6,

- WUPDATE_COUNT = 7

+ WUPDATE_AUTOBROADCAST = 7,

+ WUPDATE_COUNT = 8

};

/// Configuration elements

@@ -372,6 +372,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 de5dbe2..29bbef1 100644

--- a/src/mangosd/mangosd.conf.dist.in

+++ b/src/mangosd/mangosd.conf.dist.in

@@ -680,6 +680,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 = 1

+AutoBroadcast.Center = 2

+AutoBroadcast.Timer = 30000

+

+###################################################################################################################

# CREATURE SETTINGS

#

# ThreatRadius

--

1.5.6.3

[/HIGHLIGHT]

Link to comment
Share on other sites

Error compile

mangos 8157

g++ -DHAVE_CONFIG_H -I. -I../../../src/game -I../.. -I/usr/include/mysql -I../../../dep/ACE_wrappers -I../../dep/ACE_wrappers -I../../src/shared -I../../../src/game -I../../../src/game/../../dep/include -I../../../src/game/../framework -I../../../src/game/../shared -I../../../src/game/../shared/vmap -I../../../src/game/../realmd -DSYSCONFDIR=\\"/opt/mangos8157/etc/\\" -DDO_MYSQL -g -O2 -MT World.o -MD -MP -MF .deps/World.Tpo -c -o World.o ../../../src/game/World.cpp

../../../src/game/World.cpp: In member function \\u2018void World::Update(uint32)\\u2019:

../../../src/game/World.cpp:1617: error: \\u2018SendBroadcast\\u2019 was not declared in this scope

../../../src/game/World.cpp: At global scope:

../../../src/game/World.cpp:2745: error: no \\u2018void World::SendBroadcast()\\u2019 member function declared in class \\u2018World\\u2019

make[3]: *** [World.o] Error 1

make[3]: Leaving directory `/opt/mangos/objdir/src/game'

make[2]: *** [all-recursive] Error 1

make[2]: Leaving directory `/opt/mangos/objdir/src'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/opt/mangos/objdir'

make: *** [all] Error 2

Edit: Diablox

Link to comment
Share on other sites

Sory there was a error in my patch (and in my repo). Now is fixed.

From 71dcce34aeb586a253b4645fe893ebc22a50332e Mon Sep 17 00:00:00 2001
From: Diablox <[email protected]>
Date: Thu, 9 Jul 2009 21:42:54 +0200
Subject: PATCH Autobroadcast

---
sql/autobroadcast/mangos_mangos_string.sql |    4 ++
sql/autobroadcast/realmd_autobroadcast.sql |    6 ++
src/game/Language.h                        |    3 +
src/game/World.cpp                         |   72 ++++++++++++++++++++++++++--
src/game/World.h                           |    3 +-
src/mangosd/mangosd.conf.dist.in           |   23 +++++++++
6 files changed, 106 insertions(+), 5 deletions(-)
create mode 100644 sql/autobroadcast/mangos_mangos_string.sql
create mode 100644 sql/autobroadcast/realmd_autobroadcast.sql

diff --git a/sql/autobroadcast/mangos_mangos_string.sql b/sql/autobroadcast/mangos_mangos_string.sql
new file mode 100644
index 0000000..39dc1ce
--- /dev/null
+++ b/sql/autobroadcast/mangos_mangos_string.sql
@@ -0,0 +1,4 @@
+DELETE FROM `mangos_string` WHERE `entry` = '1300';
+
+INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES
+(1300, '|cffffcc00[server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
diff --git a/sql/autobroadcast/realmd_autobroadcast.sql b/sql/autobroadcast/realmd_autobroadcast.sql
new file mode 100644
index 0000000..1e1ad4c
--- /dev/null
+++ b/sql/autobroadcast/realmd_autobroadcast.sql
@@ -0,0 +1,6 @@
+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 ;
diff --git a/src/game/Language.h b/src/game/Language.h
index e1c15fb..0643b24 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -773,6 +773,9 @@ enum MangosStrings

    // FREE IDS                           1300-9999

+    // Broadcaster
+    LANG_AUTO_BROADCAST                 = 1300,
+
    // Use for not-in-offcial-sources patches
    //                                    10000-10999

diff --git a/src/game/World.cpp b/src/game/World.cpp
index bf20ccf..3651b62 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -49,6 +49,7 @@
#include "CreatureAIRegistry.h"
#include "Policies/SingletonImp.h"
#include "BattleGroundMgr.h"
+#include "Language.h"
#include "TemporarySummon.h"
#include "WaypointMovementGenerator.h"
#include "VMapFactory.h"
@@ -1398,8 +1399,10 @@ void World::SetInitialWorldSettings()
    sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
        local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

-    loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",
-        realmID, uint64(m_startTime), isoDate);
+    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);
@@ -1409,7 +1412,7 @@ void World::SetInitialWorldSettings()
                                                            //Update "uptime" table based on configuration entry in minutes.
    m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS);
                                                            //erase corpses every 20 minutes
-
+    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
    //one second is 1000 -(tested on win system)
@@ -1448,7 +1451,7 @@ void World::SetInitialWorldSettings()
    sLog.outString("Starting Game Event system..." );
    uint32 nextGameEvent = gameeventmgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event
-
+    sLog.outString("Starting Autobroadcast system by Xeross..." );
    sLog.outString( "WORLD: World initialized" );
}

@@ -1604,6 +1607,16 @@ void World::Update(uint32 diff)
        m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
        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();
+       }
+    }

    /// [/list]
    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
@@ -2729,6 +2742,57 @@ void World::ProcessCliCommands()
    zprint("mangos>");
}

+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()
{
    m_resultQueue = new SqlResultQueue;
diff --git a/src/game/World.h b/src/game/World.h
index 8c2f2df..16c0394 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -76,7 +76,8 @@ enum WorldTimers
    WUPDATE_UPTIME      = 4,
    WUPDATE_CORPSES     = 5,
    WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7
+    WUPDATE_AUTOBROADCAST = 7,
+    WUPDATE_COUNT         = 8
};

/// Configuration elements
@@ -372,6 +372,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 de5dbe2..29bbef1 100644
--- a/src/mangosd/mangosd.conf.dist.in
+++ b/src/mangosd/mangosd.conf.dist.in
@@ -680,6 +680,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 = 1
+AutoBroadcast.Center = 2
+AutoBroadcast.Timer = 30000
+
+###################################################################################################################
# CREATURE SETTINGS
#
#    ThreatRadius
-- 
1.5.6.3

Link to comment
Share on other sites

I know that this goes to the help section, but its also related to this addon.

First, how can I make patches from someone elses git repos;

and

Second, how can I use the patch diablox posted here since I can't just copy the text and paste it into a txt file?

I know that these are noob questions, but can someone please help?

Thanks

Link to comment
Share on other sites

What I did was first pull Diablox autobroadcast mangos.

Then I added the official mangos as a remote.

Then I created a new branch.

Then I fetched the official mangos and merged it's master with Diabloxes code.

Then I commited the changes locally.

Then I used git diff on the new branch and the mangos official master

Link to comment
Share on other sites

Copy paste this in your patch.txt

[HIGHLIGHT=diff]From 71dcce34aeb586a253b4645fe893ebc22a50332e Mon Sep 17 00:00:00 2001

From: Diablox <[email protected]>

Date: Thu, 9 Jul 2009 21:42:54 +0200

Subject: PATCH Autobroadcast

---

sql/autobroadcast/mangos_mangos_string.sql | 4 ++

sql/autobroadcast/realmd_autobroadcast.sql | 6 ++

src/game/Language.h | 3 +

src/game/World.cpp | 72 ++++++++++++++++++++++++++--

src/game/World.h | 3 +-

src/mangosd/mangosd.conf.dist.in | 23 +++++++++

6 files changed, 106 insertions(+), 5 deletions(-)

create mode 100644 sql/autobroadcast/mangos_mangos_string.sql

create mode 100644 sql/autobroadcast/realmd_autobroadcast.sql

diff --git a/sql/autobroadcast/mangos_mangos_string.sql b/sql/autobroadcast/mangos_mangos_string.sql

new file mode 100644

index 0000000..39dc1ce

--- /dev/null

+++ b/sql/autobroadcast/mangos_mangos_string.sql

@@ -0,0 +1,4 @@

+DELETE FROM `mangos_string` WHERE `entry` = '1300';

+

+INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES

+(1300, '|cffffcc00[server]: |cff00ff00%s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

diff --git a/sql/autobroadcast/realmd_autobroadcast.sql b/sql/autobroadcast/realmd_autobroadcast.sql

new file mode 100644

index 0000000..1e1ad4c

--- /dev/null

+++ b/sql/autobroadcast/realmd_autobroadcast.sql

@@ -0,0 +1,6 @@

+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 ;

diff --git a/src/game/Language.h b/src/game/Language.h

index e1c15fb..0643b24 100644

--- a/src/game/Language.h

+++ b/src/game/Language.h

@@ -773,6 +773,9 @@ enum MangosStrings

// FREE IDS 1300-9999

+ // Broadcaster

+ LANG_AUTO_BROADCAST = 1300,

+

// Use for not-in-offcial-sources patches

// 10000-10999

diff --git a/src/game/World.cpp b/src/game/World.cpp

index bf20ccf..3651b62 100644

--- a/src/game/World.cpp

+++ b/src/game/World.cpp

@@ -49,6 +49,7 @@

#include "CreatureAIRegistry.h"

#include "Policies/SingletonImp.h"

#include "BattleGroundMgr.h"

+#include "Language.h"

#include "TemporarySummon.h"

#include "WaypointMovementGenerator.h"

#include "VMapFactory.h"

@@ -1398,8 +1399,10 @@ void World::SetInitialWorldSettings()

sprintf( isoDate, "%04d-%02d-%02d %02d:%02d:%02d",

local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

- loginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)",

- realmID, uint64(m_startTime), isoDate);

+ 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);

@@ -1409,7 +1412,7 @@ void World::SetInitialWorldSettings()

//Update "uptime" table based on configuration entry in minutes.

m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILISECONDS);

//erase corpses every 20 minutes

-

+ 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

//one second is 1000 -(tested on win system)

@@ -1448,7 +1451,7 @@ void World::SetInitialWorldSettings()

sLog.outString("Starting Game Event system..." );

uint32 nextGameEvent = gameeventmgr.Initialize();

m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event

-

+ sLog.outString("Starting Autobroadcast system by Xeross..." );

sLog.outString( "WORLD: World initialized" );

}

@@ -1604,6 +1607,16 @@ void World::Update(uint32 diff)

m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);

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();

+ }

+ }

///

///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"

@@ -2729,6 +2742,57 @@ void World::ProcessCliCommands()

zprint("mangos>");

}

+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()

{

m_resultQueue = new SqlResultQueue;

diff --git a/src/game/World.h b/src/game/World.h

index 8c2f2df..16c0394 100644

--- a/src/game/World.h

+++ b/src/game/World.h

@@ -76,7 +76,8 @@ enum WorldTimers

WUPDATE_UPTIME = 4,

WUPDATE_CORPSES = 5,

WUPDATE_EVENTS = 6,

- WUPDATE_COUNT = 7

+ WUPDATE_AUTOBROADCAST = 7,

+ WUPDATE_COUNT = 8

};

/// Configuration elements

@@ -372,6 +372,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 de5dbe2..29bbef1 100644

--- a/src/mangosd/mangosd.conf.dist.in

+++ b/src/mangosd/mangosd.conf.dist.in

@@ -680,6 +680,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 = 1

+AutoBroadcast.Center = 2

+AutoBroadcast.Timer = 30000

+

+###################################################################################################################

# CREATURE SETTINGS

#

# ThreatRadius

--

1.5.6.3[/HIGHLIGHT]

Link to comment
Share on other sites

In your realmd DB you have a table caled autobroadcast

It looks like this

id text next

Lets say you want 3 mesage to broadcast

message 1

message 2

message 3

id text next

1 message1 2

2 message2 3

3 message3 1

I think you can understend now how it works,

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use