Skip to content

Commit

Permalink
Core/Common: Move singleton instances into compilation units
Browse files Browse the repository at this point in the history
* Fixes issues when building shared libraries
  (prevents gcc and clang from providing several instance)

(cherry picked from commit 5c91586)
  • Loading branch information
Naios committed Mar 11, 2016
1 parent d1efa0b commit 998607b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/common/Collision/Models/GameObjectModel.h
Expand Up @@ -84,4 +84,6 @@ class GameObjectModel /*, public Intersectable*/
std::unique_ptr<GameObjectModelOwnerBase> owner;
};

void LoadGameObjectModelList(std::string const& dataPath);

#endif // _GAMEOBJECT_MODEL_H
6 changes: 6 additions & 0 deletions src/common/Configuration/Config.cpp
Expand Up @@ -56,6 +56,12 @@ bool ConfigMgr::LoadInitial(std::string const& file, std::string& error)
return true;
}

ConfigMgr* ConfigMgr::instance()
{
static ConfigMgr instance;
return &instance;
}

bool ConfigMgr::Reload(std::string& error)
{
return LoadInitial(_filename, error);
Expand Down
6 changes: 1 addition & 5 deletions src/common/Configuration/Config.h
Expand Up @@ -33,11 +33,7 @@ class ConfigMgr
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
bool LoadInitial(std::string const& file, std::string& error);

static ConfigMgr* instance()
{
static ConfigMgr instance;
return &instance;
}
static ConfigMgr* instance();

bool Reload(std::string& error);

Expand Down
6 changes: 6 additions & 0 deletions src/common/Logging/Log.cpp
Expand Up @@ -320,6 +320,12 @@ void Log::Close()
appenders.clear();
}

Log* Log::instance()
{
static Log instance;
return &instance;
}

void Log::Initialize(boost::asio::io_service* ioService)
{
if (ioService)
Expand Down
6 changes: 1 addition & 5 deletions src/common/Logging/Log.h
Expand Up @@ -44,11 +44,7 @@ class Log

public:

static Log* instance()
{
static Log instance;
return &instance;
}
static Log* instance();

void Initialize(boost::asio::io_service* ioService);
void LoadFromConfig();
Expand Down
3 changes: 1 addition & 2 deletions src/server/game/World/World.cpp
Expand Up @@ -38,6 +38,7 @@
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "GameEventMgr.h"
#include "GameObjectModel.h"
#include "GridNotifiersImpl.h"
#include "GroupMgr.h"
#include "GuildMgr.h"
Expand Down Expand Up @@ -1305,8 +1306,6 @@ void World::LoadConfigSettings(bool reload)
sScriptMgr->OnConfigLoad(reload);
}

extern void LoadGameObjectModelList(std::string const& dataPath);

/// Initialize the World
void World::SetInitialWorldSettings()
{
Expand Down

0 comments on commit 998607b

Please sign in to comment.