Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge

  • Loading branch information...
commit 3738c940b3857732e665f56a5502b8f6396b0aaa 2 parents 47f6203 + 14b3ed9
@wasy authored
View
36 src/server/game/Addons/AddonMgr.cpp
@@ -16,27 +16,31 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "DatabaseEnv.h"
#include "AddonMgr.h"
-#include "ObjectAccessor.h"
-#include "Player.h"
-#include "Util.h"
-#include "SHA1.h"
+#include "DatabaseEnv.h"
+#include "Log.h"
+#include "Timer.h"
-AddonMgr::AddonMgr()
+#include <list>
+
+namespace AddonMgr
{
-}
-AddonMgr::~AddonMgr()
+// Anonymous namespace ensures file scope of all the stuff inside it, even
+// if you add something more to this namespace somewhere else.
+namespace
{
+ // List of saved addons (in DB).
+ typedef std::list<SavedAddon> SavedAddonsList;
+
+ SavedAddonsList m_knownAddons;
}
-void AddonMgr::LoadFromDB()
+void LoadFromDB()
{
uint32 oldMSTime = getMSTime();
QueryResult result = CharacterDatabase.Query("SELECT name, crc FROM addons");
-
if (!result)
{
sLog->outString(">> Loaded 0 known addons. DB table `addons` is empty!");
@@ -53,8 +57,7 @@ void AddonMgr::LoadFromDB()
std::string name = fields[0].GetString();
uint32 crc = fields[1].GetUInt32();
- SavedAddon addon(name, crc);
- m_knownAddons.push_back(addon);
+ m_knownAddons.push_back(SavedAddon(name, crc));
++count;
}
@@ -64,17 +67,16 @@ void AddonMgr::LoadFromDB()
sLog->outString();
}
-void AddonMgr::SaveAddon(AddonInfo const& addon)
+void SaveAddon(AddonInfo const& addon)
{
std::string name = addon.Name;
CharacterDatabase.EscapeString(name);
CharacterDatabase.PExecute("INSERT INTO addons (name, crc) VALUES ('%s', %u)", name.c_str(), addon.CRC);
- SavedAddon newAddon(addon.Name, addon.CRC);
- m_knownAddons.push_back(newAddon);
+ m_knownAddons.push_back(SavedAddon(addon.Name, addon.CRC));
}
-SavedAddon const* AddonMgr::GetAddonInfo(const std::string& name) const
+SavedAddon const* GetAddonInfo(const std::string& name)
{
for (SavedAddonsList::const_iterator it = m_knownAddons.begin(); it != m_knownAddons.end(); ++it)
{
@@ -85,3 +87,5 @@ SavedAddon const* AddonMgr::GetAddonInfo(const std::string& name) const
return NULL;
}
+
+} // Namespace
View
35 src/server/game/Addons/AddonMgr.h
@@ -19,13 +19,9 @@
#ifndef _ADDONMGR_H
#define _ADDONMGR_H
-#include "Common.h"
-#include <ace/Singleton.h>
-
+#include "Define.h"
#include <string>
-class WorldSession;
-
struct AddonInfo
{
AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey)
@@ -56,33 +52,14 @@ struct SavedAddon
uint32 CRC;
};
-// List of client addons (for WorldSession).
-typedef std::list<AddonInfo> AddonsList;
-
-// List of saved addons (in DB).
-typedef std::list<SavedAddon> SavedAddonsList;
-
#define STANDARD_ADDON_CRC 0x4c1c776d
-class AddonMgr
+namespace AddonMgr
{
- friend class ACE_Singleton<AddonMgr, ACE_Null_Mutex>;
- AddonMgr();
- ~AddonMgr();
-
- public:
-
- void LoadFromDB();
- void SaveAddon(AddonInfo const& addon);
-
- SavedAddon const* GetAddonInfo(const std::string& name) const;
-
- private:
-
- SavedAddonsList m_knownAddons; // Known addons.
-};
-
-#define sAddonMgr ACE_Singleton<AddonMgr, ACE_Null_Mutex>::instance()
+ void LoadFromDB();
+ void SaveAddon(AddonInfo const& addon);
+ SavedAddon const* GetAddonInfo(const std::string& name);
+}
#endif
View
6 src/server/game/AuctionHouse/AuctionHouseMgr.h
@@ -124,8 +124,10 @@ class AuctionHouseObject
class AuctionHouseMgr
{
friend class ACE_Singleton<AuctionHouseMgr, ACE_Null_Mutex>;
- AuctionHouseMgr();
- ~AuctionHouseMgr();
+
+ private:
+ AuctionHouseMgr();
+ ~AuctionHouseMgr();
public:
View
4 src/server/game/Server/WorldSession.cpp
@@ -885,7 +885,7 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data)
AddonInfo addon(addonName, enabled, crc, 2, true);
- SavedAddon const* savedAddon = sAddonMgr->GetAddonInfo(addonName);
+ SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addonName);
if (savedAddon)
{
bool match = true;
@@ -900,7 +900,7 @@ void WorldSession::ReadAddonsInfo(WorldPacket &data)
}
else
{
- sAddonMgr->SaveAddon(addon);
+ AddonMgr::SaveAddon(addon);
sLog->outDetail("ADDON: %s (0x%x) was not known, saving...", addon.Name.c_str(), addon.CRC);
}
View
2  src/server/game/Server/WorldSession.h 100755 → 100644
@@ -944,6 +944,8 @@ class WorldSession
uint32 _accountId;
uint8 m_expansion;
+ typedef std::list<AddonInfo> AddonsList;
+
// Warden
Warden* _warden; // Remains NULL if Warden system is not enabled by config
View
4 src/server/game/World/World.cpp
@@ -1394,7 +1394,7 @@ void World::SetInitialWorldSettings()
LoadRandomEnchantmentsTable();
sLog->outString("Loading Disables");
- DisableMgr::LoadDisables(); // must be before loading quests and items
+ DisableMgr::LoadDisables(); // must be before loading quests and items
sLog->outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
sObjectMgr->LoadItemTemplates();
@@ -1643,7 +1643,7 @@ void World::SetInitialWorldSettings()
sTicketMgr->LoadSurveys();
sLog->outString("Loading client addons...");
- sAddonMgr->LoadFromDB();
+ AddonMgr::LoadFromDB();
///- Handle outdated emails (delete/return)
sLog->outString("Returning old mails...");
Please sign in to comment.
Something went wrong with that request. Please try again.