diff -Nuar oregoncore-current/sql/CMakeLists.txt oregoncore-pq/sql/CMakeLists.txt--- oregoncore-current/sql/CMakeLists.txt 2011-01-01 10:03:07.000000000 -0500
+++ oregoncore-pq/sql/CMakeLists.txt 2011-01-01 10:05:25.000000000 -0500
@@ -1,6 +1,7 @@
add_subdirectory(updates)
add_subdirectory(tools)
add_subdirectory(scripts)
+add_subdirectory(oc-patch)
########### install files ###############
diff -Nuar oregoncore-current/sql/oc-patch/CMakeLists.txt oregoncore-pq/sql/oc-patch/CMakeLists.txt
--- oregoncore-current/sql/oc-patch/CMakeLists.txt 1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/sql/oc-patch/CMakeLists.txt 2011-01-01 10:05:25.000000000 -0500
@@ -0,0 +1,6 @@
+
+########### install files ###############
+
+FILE(GLOB _SQL *.sql)
+
+install(FILES ${_SQL} DESTINATION share/oregon/sql/oc-patch)
diff -Nuar oregoncore-current/sql/oc-patch/world-autobroadcast.sql oregoncore-pq/sql/oc-patch/world-autobroadcast.sql
--- oregoncore-current/sql/oc-patch/world-autobroadcast.sql 1969-12-31 19:00:00.000000000 -0500
+++ oregoncore-pq/sql/oc-patch/world-autobroadcast.sql 2011-01-01 10:05:25.000000000 -0500
@@ -0,0 +1,29 @@
+--
+-- Table structure for table `autobroadcast`
+--
+
+CREATE TABLE IF NOT EXISTS `autobroadcast` (
+ `id` int(11) NOT NULL auto_increment,
+ `message` longtext NOT NULL,
+ `addedby` varchar(12) NOT NULL default 'System',
+ `enabled` tinyint(3) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `enabled` (`enabled`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+--
+-- Data for table `autobroadcast`
+--
+
+DELETE FROM `autobroadcast` WHERE `id` = 1;
+INSERT INTO `autobroadcast` (`id`, `message`, `addedby`, `enabled`) VALUES
+(1, 'Welcome! Please report any issues you find.','System',1);
+
+DELETE FROM `oregon_string` WHERE `entry` = 11000;
+INSERT INTO `oregon_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);
+
+DELETE FROM `command` WHERE `name` = 'reload autobroadcast';
+INSERT INTO `command` (`name`, `security`, `help`) VALUES ('reload autobroadcast', 3, 'Syntax: .reload autobroadcast Reload autobroadcast table.');
+
+
diff -Nuar oregoncore-current/src/game/Chat.cpp oregoncore-pq/src/game/Chat.cpp
--- oregoncore-current/src/game/Chat.cpp 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/Chat.cpp 2011-01-01 10:05:25.000000000 -0500
@@ -285,6 +285,7 @@
{ "areatrigger_teleport", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL },
{ "access_requirement", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAccessRequirementCommand, "", NULL },
{ "areatrigger_involvedrelation",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL },
+ { "autobroadcast", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAutobroadcastCommand, "", NULL },
{ "event_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventScriptsCommand, "", NULL },
{ "command", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCommandCommand, "", NULL },
{ "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand,"",NULL },
diff -Nuar oregoncore-current/src/game/Chat.h oregoncore-pq/src/game/Chat.h
--- oregoncore-current/src/game/Chat.h 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/Chat.h 2011-01-01 10:05:25.000000000 -0500
@@ -241,6 +241,7 @@
bool HandleReloadWpScriptsCommand(const char* args);
bool HandleReloadAreaTriggerTavernCommand(const char* args);
+ bool HandleReloadAutobroadcastCommand(const char* args);
bool HandleReloadAreaTriggerTeleportCommand(const char* args);
bool HandleReloadAccessRequirementCommand(const char* args);
bool HandleReloadEventScriptsCommand(const char* args);
diff -Nuar oregoncore-current/src/game/Language.h oregoncore-pq/src/game/Language.h
--- oregoncore-current/src/game/Language.h 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/Language.h 2011-01-01 10:05:25.000000000 -0500
@@ -918,6 +918,7 @@
LANG_NO_ENTER_CHAMPIONS_HALL = 10057,
// 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 -Nuar oregoncore-current/src/game/Level3.cpp oregoncore-pq/src/game/Level3.cpp
--- oregoncore-current/src/game/Level3.cpp 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/Level3.cpp 2011-01-01 10:05:25.000000000 -0500
@@ -558,6 +558,7 @@
HandleReloadReservedNameCommand("");
HandleReloadOregonStringCommand("");
HandleReloadGameTeleCommand("");
+ HandleReloadAutobroadcastCommand("");
return true;
}
@@ -685,7 +686,15 @@
objmgr.LoadAccessRequirements();
SendGlobalGMSysMessage("DB table access_requirement reloaded.");
return true;
- }
+}
+
+bool ChatHandler::HandleReloadAutobroadcastCommand(const char*)
+{
+ sLog.outString("Re-Loading Autobroadcast...");
+ sWorld.LoadAutobroadcasts();
+ SendGlobalGMSysMessage("DB table `autobroadcast` reloaded.");
+ return true;
+}
bool ChatHandler::HandleReloadCommandCommand(const char*)
{
diff -Nuar oregoncore-current/src/game/World.cpp oregoncore-pq/src/game/World.cpp
--- oregoncore-current/src/game/World.cpp 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/World.cpp 2011-01-01 10:07:56.000000000 -0500
@@ -65,6 +65,7 @@
#include "Transports.h"
#include "CreatureEventAIMgr.h"
#include "ScriptMgr.h"
+#include "ProgressBar.h"
INSTANTIATE_SINGLETON_1(World);
@@ -572,6 +573,12 @@
sLog.outError("Anticheat.Movement.MaxMovementAlarms (%d) must be <=100. Using 100 instead.", m_MaxMovementAlarms);
m_MaxMovementAlarms = 100;
}
+
+ // AutoBroadcast
+ m_configs[CONFIG_AUTOBROADCAST] = sConfig.GetBoolDefault("AutoBroadcast.On", false);
+ m_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
+ m_configs[CONFIG_AUTOBROADCAST_INTERVAL] = (sConfig.GetIntDefault("AutoBroadcast.Timer", 5)*MINUTE*1000);
+
// Read other configuration items from the config file
m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1);
@@ -1429,6 +1436,9 @@
sLog.outString("Returning old mails...");
objmgr.ReturnOrDeleteOldMails(false);
+ sLog.outString("Loading Autobroadcasts...");
+ LoadAutobroadcasts();
+
// Load and initialize scripts
sLog.outString("Loading Scripts...");
sLog.outString();
@@ -1471,7 +1481,7 @@
WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', " UI64FMTD ", 0)",
isoDate, uint64(m_startTime));
-
+
m_timers[WUPDATE_OBJECTS].SetInterval(IN_MILLISECONDS/2);
m_timers[WUPDATE_SESSIONS].SetInterval(0);
m_timers[WUPDATE_WEATHERS].SetInterval(IN_MILLISECONDS);
@@ -1485,6 +1495,7 @@
m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day
+ m_timers[WUPDATE_AUTOBROADCAST].SetInterval(getConfig(CONFIG_AUTOBROADCAST_INTERVAL));
//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)
@@ -1623,6 +1634,36 @@
m_currentTime = thisTime;
}
+void World::LoadAutobroadcasts()
+{
+ m_Autobroadcasts.clear();
+
+ QueryResult_AutoPtr result = WorldDatabase.Query("SELECT message FROM autobroadcast WHERE enabled = 1");
+
+ if (!result)
+ {
+ barGoLink bar(1);
+ bar.step();
+ sLog.outString();
+ sLog.outString(">> Loaded 0 autobroadcasts definitions");
+ return;
+ }
+
+ barGoLink bar(result->GetRowCount());
+ uint32 count = 0;
+ do
+ {
+ bar.step();
+ Field *fields = result->Fetch();
+ std::string message = fields[0].GetCppString();
+ m_Autobroadcasts.push_back(message);
+ count++;
+ } while (result->NextRow());
+
+ sLog.outString();
+ sLog.outString(">> Loaded %u autobroadcast definitions", count);
+}
+
// Update the World !
void World::Update(time_t diff)
{
@@ -1749,6 +1790,16 @@
ScriptsProcess();
RecordTimeDiff("UpdateScriptsProcess");
}
+
+ if (sWorld.getConfig(CONFIG_AUTOBROADCAST))
+ {
+ if (m_timers[WUPDATE_AUTOBROADCAST].Passed())
+ {
+ m_timers[WUPDATE_AUTOBROADCAST].Reset();
+ SendAutoBroadcast();
+ }
+ }
+
sBattleGroundMgr.Update(diff);
RecordTimeDiff("UpdateBattleGroundMgr");
@@ -3055,6 +3106,37 @@
}
}
+void World::SendAutoBroadcast()
+{
+ if (m_Autobroadcasts.empty())
+ return;
+
+ std::string msg;
+
+ std::list<std::string>::const_iterator itr = m_Autobroadcasts.begin();
+ std::advance(itr, rand() % m_Autobroadcasts.size());
+ msg = *itr;
+
+ uint32 abcenter = sWorld.getConfig(CONFIG_AUTOBROADCAST_CENTER);
+ if (abcenter == 0)
+ {
+ sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
+ }
+ if (abcenter == 1)
+ {
+ WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
+ data << msg;
+ sWorld.SendGlobalMessage(&data);
+ }
+ if (abcenter == 2)
+ {
+ sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
+ WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
+ data << msg;
+ sWorld.SendGlobalMessage(&data);
+ }
+}
+
void World::InitResultQueue()
{
m_resultQueue = new SqlResultQueue;
diff -Nuar oregoncore-current/src/game/World.h oregoncore-pq/src/game/World.h
--- oregoncore-current/src/game/World.h 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/game/World.h 2011-01-01 10:07:13.000000000 -0500
@@ -79,7 +79,8 @@
WUPDATE_EVENTS = 6,
WUPDATE_CLEANDB = 7,
WUPDATE_DELETECHARS = 8,
- WUPDATE_COUNT = 9
+ WUPDATE_AUTOBROADCAST = 9,
+ WUPDATE_COUNT = 10
};
// Configuration elements
@@ -247,6 +248,9 @@
CONFIG_CHARDELETE_KEEP_DAYS,
CONFIG_CHARDELETE_METHOD,
CONFIG_CHARDELETE_MIN_LEVEL,
+ CONFIG_AUTOBROADCAST,
+ CONFIG_AUTOBROADCAST_CENTER,
+ CONFIG_AUTOBROADCAST_INTERVAL,
CONFIG_VALUE_COUNT
};
@@ -412,6 +416,7 @@
WorldSession* FindSession(uint32 id) const;
void AddSession(WorldSession *s);
+ void SendAutoBroadcast();
bool RemoveSession(uint32 id);
// Get the number of current active sessions
void UpdateMaxSessionCounters();
@@ -585,6 +590,7 @@
char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }
void RecordTimeDiff(const char * text, ...);
+ void LoadAutobroadcasts();
protected:
void _UpdateGameTime();
void ScriptsProcess();
@@ -670,6 +676,8 @@
//used versions
std::string m_DBVersion;
std::string m_ScriptsVersion;
+
+ std::list<std::string> m_Autobroadcasts;
};
extern uint32 realmID;
diff -Nuar oregoncore-current/src/oregoncore/oregoncore.conf.dist oregoncore-pq/src/oregoncore/oregoncore.conf.dist
--- oregoncore-current/src/oregoncore/oregoncore.conf.dist 2011-01-01 10:03:08.000000000 -0500
+++ oregoncore-pq/src/oregoncore/oregoncore.conf.dist 2011-01-01 10:05:25.000000000 -0500
@@ -2022,3 +2022,27 @@
Anticheat.Movement.Enable = 0
Anticheat.Movement.TeleportToPlaneAlarms = 50
Anticheat.Movement.MaxMovementAlarms = 50
+
+###############################################################################
+# 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 (in minutes)
+#
+###############################################################################
+
+AutoBroadcast.On = 0
+AutoBroadcast.Center = 0
+AutoBroadcast.Timer = 15
+
回复下载完整代码:
|