Skip to content

Commit

Permalink
Core/Common: Converted the common library to a shared library.
Browse files Browse the repository at this point in the history
* There is still the possibility to static link against common.

(cherry picked from commit 501fd9b)
  • Loading branch information
Naios committed Mar 24, 2016
1 parent 77aa9ae commit 1a1c0d1
Show file tree
Hide file tree
Showing 38 changed files with 130 additions and 109 deletions.
14 changes: 14 additions & 0 deletions src/common/CMakeLists.txt
Expand Up @@ -30,6 +30,8 @@ endif (USE_COREPCH)

GroupSources(${CMAKE_CURRENT_SOURCE_DIR})

add_definitions(-DTRINITY_API_EXPORT_COMMON)

add_library(common
${PRIVATE_SOURCES}
${PRIVATE_PCH_SOURCE}
Expand Down Expand Up @@ -78,6 +80,18 @@ set_target_properties(common
FOLDER
"server")

if( BUILD_SHARED_LIBS )
if( UNIX )
install(TARGETS common
LIBRARY
DESTINATION lib)
elseif( WIN32 )
install(TARGETS common
RUNTIME
DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
endif()

# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(common ${PRIVATE_PCH_HEADER} ${PRIVATE_PCH_SOURCE})
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/BoundingIntervalHierarchy.h
Expand Up @@ -67,7 +67,7 @@ struct AABound
Copyright (c) 2003-2007 Christopher Kulla
*/

class BIH
class TC_COMMON_API BIH
{
private:
void init_empty()
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/DynamicTree.h
Expand Up @@ -31,7 +31,7 @@ namespace G3D
class GameObjectModel;
struct DynTreeImpl;

class DynamicMapTree
class TC_COMMON_API DynamicMapTree
{
DynTreeImpl *impl;

Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/Management/IVMapManager.h
Expand Up @@ -42,7 +42,7 @@ namespace VMAP
#define VMAP_INVALID_HEIGHT_VALUE -200000.0f // real assigned value in unknown height case

//===========================================================
class IVMapManager
class TC_COMMON_API IVMapManager
{
private:
bool iEnableLineOfSightCalc;
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/Management/MMapFactory.h
Expand Up @@ -38,7 +38,7 @@ namespace MMAP
// static class
// holds all mmap global data
// access point to MMapManager singleton
class MMapFactory
class TC_COMMON_API MMapFactory
{
public:
static MMapManager* createOrGetMMapManager();
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/Management/MMapManager.h
Expand Up @@ -58,7 +58,7 @@ namespace MMAP

// singleton class
// holds all all access to mmap loading unloading and meshes
class MMapManager
class TC_COMMON_API MMapManager
{
public:
MMapManager() : loadedTiles(0), thread_safe_environment(true) {}
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/Management/VMapFactory.h
Expand Up @@ -29,7 +29,7 @@ namespace VMAP
{
//===========================================================

class VMapFactory
class TC_COMMON_API VMapFactory
{
public:
static IVMapManager* createOrGetVMapManager();
Expand Down
4 changes: 2 additions & 2 deletions src/common/Collision/Management/VMapManager2.h
Expand Up @@ -51,7 +51,7 @@ namespace VMAP
class StaticMapTree;
class WorldModel;

class ManagedModel
class TC_COMMON_API ManagedModel
{
public:
ManagedModel() : iModel(nullptr), iRefCount(0) { }
Expand All @@ -75,7 +75,7 @@ namespace VMAP
VMAP_DISABLE_LIQUIDSTATUS = 0x8
};

class VMapManager2 : public IVMapManager
class TC_COMMON_API VMapManager2 : public IVMapManager
{
protected:
// Tree to check collision
Expand Down
6 changes: 3 additions & 3 deletions src/common/Collision/Maps/MapTree.h
Expand Up @@ -29,15 +29,15 @@ namespace VMAP
class GroupModel;
class VMapManager2;

struct LocationInfo
struct TC_COMMON_API LocationInfo
{
LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
const ModelInstance* hitInstance;
const GroupModel* hitModel;
float ground_Z;
};

class StaticMapTree
class TC_COMMON_API StaticMapTree
{
typedef std::unordered_map<uint32, bool> loadedTileMap;
typedef std::unordered_map<uint32, uint32> loadedSpawnMap;
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace VMAP
StaticMapTree& operator=(StaticMapTree const& right) = delete;
};

struct AreaInfo
struct TC_COMMON_API AreaInfo
{
AreaInfo(): result(false), ground_Z(-G3D::finf()), flags(0), adtId(0),
rootId(0), groupId(0) { }
Expand Down
10 changes: 5 additions & 5 deletions src/common/Collision/Maps/TileAssembler.h
Expand Up @@ -35,7 +35,7 @@ namespace VMAP
*/
//===============================================

class ModelPosition
class TC_COMMON_API ModelPosition
{
private:
G3D::Matrix3 iRotation;
Expand All @@ -55,7 +55,7 @@ namespace VMAP
typedef std::map<uint32, ModelSpawn> UniqueEntryMap;
typedef std::multimap<uint32, uint32> TileMap;

struct MapSpawns
struct TC_COMMON_API MapSpawns
{
UniqueEntryMap UniqueEntries;
TileMap TileEntries;
Expand All @@ -64,7 +64,7 @@ namespace VMAP
typedef std::map<uint32, MapSpawns*> MapData;
//===============================================

struct GroupModel_Raw
struct TC_COMMON_API GroupModel_Raw
{
uint32 mogpflags;
uint32 GroupWMOID;
Expand All @@ -82,15 +82,15 @@ namespace VMAP
bool Read(FILE* f);
};

struct WorldModel_Raw
struct TC_COMMON_API WorldModel_Raw
{
uint32 RootWMOID;
std::vector<GroupModel_Raw> groupsArray;

bool Read(const char * path);
};

class TileAssembler
class TC_COMMON_API TileAssembler
{
private:
std::string iDestDir;
Expand Down
6 changes: 3 additions & 3 deletions src/common/Collision/Models/GameObjectModel.h
Expand Up @@ -35,7 +35,7 @@ namespace VMAP
class GameObject;
struct GameObjectDisplayInfoEntry;

class GameObjectModelOwnerBase
class TC_COMMON_API GameObjectModelOwnerBase
{
public:
virtual bool IsSpawned() const { return false; }
Expand All @@ -47,7 +47,7 @@ class GameObjectModelOwnerBase
virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const { }
};

class GameObjectModel /*, public Intersectable*/
class TC_COMMON_API GameObjectModel /*, public Intersectable*/
{
GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(NULL) { }
public:
Expand Down Expand Up @@ -84,6 +84,6 @@ class GameObjectModel /*, public Intersectable*/
std::unique_ptr<GameObjectModelOwnerBase> owner;
};

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

#endif // _GAMEOBJECT_MODEL_H
4 changes: 2 additions & 2 deletions src/common/Collision/Models/ModelInstance.h
Expand Up @@ -39,7 +39,7 @@ namespace VMAP
MOD_HAS_BOUND = 1<<2
};

class ModelSpawn
class TC_COMMON_API ModelSpawn
{
public:
//mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name
Expand All @@ -60,7 +60,7 @@ namespace VMAP
static bool writeToFile(FILE* rw, const ModelSpawn &spawn);
};

class ModelInstance: public ModelSpawn
class TC_COMMON_API ModelInstance: public ModelSpawn
{
public:
ModelInstance(): iInvScale(0.0f), iModel(nullptr) { }
Expand Down
8 changes: 4 additions & 4 deletions src/common/Collision/Models/WorldModel.h
Expand Up @@ -33,7 +33,7 @@ namespace VMAP
struct AreaInfo;
struct LocationInfo;

class MeshTriangle
class TC_COMMON_API MeshTriangle
{
public:
MeshTriangle() : idx0(0), idx1(0), idx2(0) { }
Expand All @@ -44,7 +44,7 @@ namespace VMAP
uint32 idx2;
};

class WmoLiquid
class TC_COMMON_API WmoLiquid
{
public:
WmoLiquid(uint32 width, uint32 height, const G3D::Vector3 &corner, uint32 type);
Expand All @@ -70,7 +70,7 @@ namespace VMAP
};

/*! holding additional info for WMO group files */
class GroupModel
class TC_COMMON_API GroupModel
{
public:
GroupModel() : iBound(), iMogpFlags(0), iGroupWMOID(0), iLiquid(NULL) { }
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace VMAP
};

/*! Holds a model (converted M2 or WMO) in its original coordinate space */
class WorldModel
class TC_COMMON_API WorldModel
{
public:
WorldModel(): RootWMOID(0) { }
Expand Down
2 changes: 1 addition & 1 deletion src/common/Collision/RegularGrid.h
Expand Up @@ -20,7 +20,7 @@ class NodeCreatorFunc = NodeCreator<Node>,
/*class BoundsFunc = BoundsTrait<T>,*/
class PositionFunc = PositionTrait<T>
>
class RegularGrid2D
class TC_COMMON_API RegularGrid2D
{
public:

Expand Down
4 changes: 2 additions & 2 deletions src/common/Common.h
Expand Up @@ -130,9 +130,9 @@ enum LocaleConstant
#define MAX_LOCALES 8
#define MAX_ACCOUNT_TUTORIAL_VALUES 8

extern char const* localeNames[TOTAL_LOCALES];
TC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];

LocaleConstant GetLocaleByName(const std::string& name);
TC_COMMON_API LocaleConstant GetLocaleByName(const std::string& name);

typedef std::vector<std::string> StringVector;

Expand Down
9 changes: 5 additions & 4 deletions src/common/Configuration/BuiltInConfig.h
Expand Up @@ -19,23 +19,24 @@
#define BUILT_IN_CONFIG_H

#include <string>
#include "Define.h"

/// Provides helper functions to access built-in values
/// which can be overwritten in config
namespace BuiltInConfig
{
/// Returns the CMake command when any is specified in the config,
/// returns the built-in path otherwise
std::string GetCMakeCommand();
TC_COMMON_API std::string GetCMakeCommand();
/// Returns the build directory path when any is specified in the config,
/// returns the built-in one otherwise
std::string GetBuildDirectory();
TC_COMMON_API std::string GetBuildDirectory();
/// Returns the source directory path when any is specified in the config,
/// returns the built-in one otherwise
std::string GetSourceDirectory();
TC_COMMON_API std::string GetSourceDirectory();
/// Returns the path to the mysql executable (`mysql`) when any is specified
/// in the config, returns the built-in one otherwise
std::string GetMySQLExecutable();
TC_COMMON_API std::string GetMySQLExecutable();

} // namespace BuiltInConfig

Expand Down
4 changes: 3 additions & 1 deletion src/common/Configuration/Config.h
Expand Up @@ -19,12 +19,14 @@
#ifndef CONFIG_H
#define CONFIG_H

#include "Define.h"

#include <string>
#include <list>
#include <mutex>
#include <boost/property_tree/ptree.hpp>

class ConfigMgr
class TC_COMMON_API ConfigMgr
{
ConfigMgr() { }
~ConfigMgr() { }
Expand Down
2 changes: 1 addition & 1 deletion src/common/Cryptography/ARC4.h
Expand Up @@ -22,7 +22,7 @@
#include <openssl/evp.h>
#include "Define.h"

class ARC4
class TC_COMMON_API ARC4
{
public:
ARC4(uint8 len);
Expand Down
2 changes: 1 addition & 1 deletion src/common/Cryptography/Authentication/AuthCrypt.h
Expand Up @@ -23,7 +23,7 @@

class BigNumber;

class AuthCrypt
class TC_COMMON_API AuthCrypt
{
public:
AuthCrypt();
Expand Down
2 changes: 1 addition & 1 deletion src/common/Cryptography/BigNumber.h
Expand Up @@ -24,7 +24,7 @@

struct bignum_st;

class BigNumber
class TC_COMMON_API BigNumber
{
public:
BigNumber();
Expand Down
2 changes: 1 addition & 1 deletion src/common/Cryptography/HMACSHA1.h
Expand Up @@ -28,7 +28,7 @@ class BigNumber;

#define SEED_KEY_SIZE 16

class HmacHash
class TC_COMMON_API HmacHash
{
public:
HmacHash(uint32 len, uint8 *seed);
Expand Down
8 changes: 5 additions & 3 deletions src/common/Cryptography/OpenSSLCrypto.h
Expand Up @@ -18,16 +18,18 @@
#ifndef OPENSSL_CRYPTO_H
#define OPENSSL_CRYPTO_H

#include "Define.h"

/**
* A group of functions which setup openssl crypto module to work properly in multithreaded enviroment
* If not setup properly - it will crash
*/
namespace OpenSSLCrypto
{
/// Needs to be called before threads using openssl are spawned
void threadsSetup();
TC_COMMON_API void threadsSetup();
/// Needs to be called after threads using openssl are despawned
void threadsCleanup();
TC_COMMON_API void threadsCleanup();
}

#endif
#endif
2 changes: 1 addition & 1 deletion src/common/Cryptography/SHA1.h
Expand Up @@ -25,7 +25,7 @@

class BigNumber;

class SHA1Hash
class TC_COMMON_API SHA1Hash
{
public:
SHA1Hash();
Expand Down

0 comments on commit 1a1c0d1

Please sign in to comment.