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

@@ -1,84 +0,0 @@
/*
* 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

@@ -1,46 +0,0 @@
/*
* 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

@@ -115,10 +115,10 @@ include_directories(
${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
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/Management
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/Models
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/Maps
${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
@@ -132,10 +132,10 @@ include_directories(
${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_SOURCE_DIR}/modules/acore/game-framework/src/Addons
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Accounts
${CMAKE_CURRENT_SOURCE_DIR}/Achievements
${CMAKE_CURRENT_SOURCE_DIR}/Addons
${CMAKE_CURRENT_SOURCE_DIR}/AI
${CMAKE_CURRENT_SOURCE_DIR}/AI/CoreAI
${CMAKE_CURRENT_SOURCE_DIR}/AI/ScriptedAI
@@ -217,6 +217,10 @@ add_library(game STATIC
${game_STAT_PCH_SRC}
)
target_link_libraries(game
gamefw
)
add_dependencies(game revision.h)
# Generate precompiled header

View File

@@ -48,9 +48,9 @@ include_directories(
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/gsoap
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/sockets/include
${CMAKE_SOURCE_DIR}/modules/worldengine/deps/SFMT
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/Management
${CMAKE_SOURCE_DIR}/modules/worldengine/lib-collision/Models
${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/nucleus/src
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Configuration
${CMAKE_SOURCE_DIR}/modules/worldengine/nucleus/src/Cryptography