Project restructuring [PART.3]

This commit is contained in:
Yehonal
2016-08-23 13:30:41 +02:00
parent 0355064321
commit 85b8aa7ce8
46 changed files with 2073 additions and 15 deletions

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "AddonMgr.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "Timer.h"
#include <list>
namespace 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 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!");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
std::string name = fields[0].GetString();
uint32 crc = fields[1].GetUInt32();
m_knownAddons.push_back(SavedAddon(name, crc));
++count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
void SaveAddon(AddonInfo const& addon)
{
std::string name = addon.Name;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ADDON);
stmt->setString(0, name);
stmt->setUInt32(1, addon.CRC);
CharacterDatabase.Execute(stmt);
m_knownAddons.push_back(SavedAddon(addon.Name, addon.CRC));
}
SavedAddon const* GetAddonInfo(const std::string& name)
{
for (SavedAddonsList::const_iterator it = m_knownAddons.begin(); it != m_knownAddons.end(); ++it)
{
SavedAddon const& addon = (*it);
if (addon.Name == name)
return &addon;
}
return NULL;
}
} // Namespace

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#ifndef _ADDONMGR_H
#define _ADDONMGR_H
#include "Define.h"
#include <string>
struct AddonInfo
{
AddonInfo(const std::string& name, uint8 enabled, uint32 crc, uint8 state, bool crcOrPubKey)
: Name(name), Enabled(enabled), CRC(crc), State(state), UsePublicKeyOrCRC(crcOrPubKey) {}
std::string Name;
uint8 Enabled;
uint32 CRC;
uint8 State;
bool UsePublicKeyOrCRC;
};
struct SavedAddon
{
SavedAddon(const std::string& name, uint32 crc) : Name(name)
{
CRC = crc;
}
std::string Name;
uint32 CRC;
};
#define STANDARD_ADDON_CRC 0x4c1c776d
namespace AddonMgr
{
void LoadFromDB();
void SaveAddon(AddonInfo const& addon);
SavedAddon const* GetAddonInfo(const std::string& name);
}
#endif

View File

@@ -0,0 +1,63 @@
if( USE_COREPCH )
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB sources_localdir *.cpp *.h)
# Build gamefw sourcelist
#
if (USE_COREPCH)
set(gamefw_STAT_PCH_HDR PrecompiledHeaders/gamefwPCH.h)
set(gamefw_STAT_PCH_SRC PrecompiledHeaders/gamefwPCH.cpp)
endif()
set(gamefw_STAT_SRCS
${gamefw_STAT_SRCS}
${sources_localdir}
)
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/recastnavigation/Detour
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/recastnavigation/Recast
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/g3dlite/include
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/SFMT
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/zlib
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/src/
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/src/Management
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/src/Models
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/src/Maps
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Configuration
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Cryptography
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Cryptography/Authentication
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Database
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/DataStores
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Debugging
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Dynamic/LinkedReference
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Dynamic
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Logging
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Packets
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Threading
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Utilities
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Addons
${ACE_INCLUDE_DIR}
${MYSQL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
)
add_library(gamefw STATIC
${gamefw_STAT_SRCS}
${gamefw_STAT_PCH_SRC}
)
target_link_libraries(gamefw
${ACE_LIBRARY}
)
# Generate precompiled header
if (USE_COREPCH)
add_cxx_pch(gamefw ${gamefw_STAT_PCH_HDR} ${gamefw_STAT_PCH_SRC})
endif ()

View File

@@ -0,0 +1 @@
#include "gamefwPCH.h"

View File

@@ -0,0 +1,3 @@
//add here most rarely modified headers to speed up debug build compilation