Removed SD2 database binding

This is no longer needed as SD2 is part of the world database, we can also drop the sd2_version table from the world database

Removed a couple unused files
This commit is contained in:
Foereaper 2015-08-27 19:44:11 +02:00
parent 59bc649250
commit 75a7274f66
7 changed files with 32 additions and 112 deletions

View File

@ -3,7 +3,7 @@
################################################################################
[MangosdConf]
ConfVersion=2015041202
ConfVersion=2015082701
################################################################################
# CONNECTIONS AND DIRECTORIES
@ -26,7 +26,6 @@ ConfVersion=2015041202
# LoginDatabaseInfo
# WorldDatabaseInfo
# CharacterDatabaseInfo
# ScriptDev2DatabaseInfo
# Database connection settings for the world server.
# Default:
# ---MYSQL---
@ -41,7 +40,6 @@ ConfVersion=2015041202
# LoginDatabaseConnections
# WorldDatabaseConnections
# CharacterDatabaseConnections
# ScriptDev2DatabaseConnections
# Amount of connections to database which will be used for SELECT queries. Maximum 16 connections per database.
# Please, note, for data consistency only one connection for each database is used for transactions and async SELECTs.
# So formula to find out how many connections will be established:
@ -68,11 +66,9 @@ LogsDir = ""
LoginDatabaseInfo = "127.0.0.1;3306;mangos;mangos;realmd"
WorldDatabaseInfo = "127.0.0.1;3306;mangos;mangos;mangos"
CharacterDatabaseInfo = "127.0.0.1;3306;mangos;mangos;characters"
ScriptDev2DatabaseInfo = "127.0.0.1;3306;mangos;mangos;mangos"
LoginDatabaseConnections = 1
WorldDatabaseConnections = 1
CharacterDatabaseConnections = 1
ScriptDev2DatabaseConnections= 1
MaxPingTime = 30
WorldServerPort = 8085
BindIP = "0.0.0.0"

View File

@ -23,7 +23,7 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#include "precompiled.h"//..\bindings\scripts\include\precompiled.h"
#include "precompiled.h"
#include "Config/Config.h"
#include "SystemConfig.h"
#include "Database/DatabaseEnv.h"
@ -42,35 +42,12 @@ Config SD2Config;
void FillSpellSummary();
void LoadDatabase()
void LoadSD2Bindings()
{
std::string strSD2DBinfo = SD2Config.GetStringDefault("ScriptDev2DatabaseInfo", "");
if (strSD2DBinfo.empty())
{
script_error_log("Missing Scriptdev2 database info from configuration file. Load database aborted.");
return;
}
// Initialize connection to DB
if (SD2Database.Initialize(strSD2DBinfo.c_str()))
{
outstring_log("SD2: ScriptDev2 database initialized.");
outstring_log("\n");
pSystemMgr.LoadVersion();
pSystemMgr.LoadScriptTexts();
pSystemMgr.LoadScriptTextsCustom();
pSystemMgr.LoadScriptGossipTexts();
pSystemMgr.LoadScriptWaypoints();
}
else
{
script_error_log("Unable to connect to Database. Load database aborted.");
return;
}
SD2Database.HaltDelayThread();
pSystemMgr.LoadScriptTexts();
pSystemMgr.LoadScriptTextsCustom();
pSystemMgr.LoadScriptGossipTexts();
pSystemMgr.LoadScriptWaypoints();
}
struct TSpellSummary
@ -230,7 +207,7 @@ void SD2::InitScriptLibrary()
}
else
{
outstring_log("SD2: Using configuration file %s", MANGOSD_CONFIG_LOCATION);
outstring_log("[SD2]: Using configuration file %s", MANGOSD_CONFIG_LOCATION);
}
// Set SD2 Error Log File
@ -239,21 +216,15 @@ void SD2::InitScriptLibrary()
if (configFailure)
{
script_error_log("Unable to open configuration file. Database will be unaccessible. Configuration values will use default.");
}
// Check config file version
if (SD2Config.GetIntDefault("ConfVersion", 0) != MANGOSD_CONFIG_VERSION)
{
script_error_log("Configuration file version doesn't match expected version. Some config variables may be wrong or missing.");
script_error_log("[SD2]: Unable to open configuration file. Configuration values will use default.");
}
outstring_log("\n");
// Load database (must be called after SD2Config.SetSource).
LoadDatabase();
// Load SD2 Script Bindings from the database
LoadSD2Bindings();
outstring_log("SD2: Loading C++ scripts");
outstring_log("[SD2]: Loading C++ scripts");
BarGoLink bar(1);
bar.step();
@ -269,7 +240,7 @@ void SD2::InitScriptLibrary()
{
if (!m_scripts[i])
{
script_error_log("No script found for ScriptName '%s'.", GetScriptName(i));
script_error_log("[SD2]: No script found for ScriptName '%s'.", GetScriptName(i));
}
}
@ -278,7 +249,7 @@ void SD2::InitScriptLibrary()
char const* SD2::GetScriptLibraryVersion()
{
return strSD2Version.c_str();
return "[SD2] for MaNGOS";
}
bool SD2::GossipHello(Player* pPlayer, Creature* pCreature)
@ -311,7 +282,7 @@ bool SD2::GOGossipHello(Player* pPlayer, GameObject* pGo)
bool SD2::GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
debug_log("SD2: Gossip selection, sender: %u, action: %u", uiSender, uiAction);
debug_log("[SD2]: Gossip selection, sender: %u, action: %u", uiSender, uiAction);
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
@ -325,7 +296,7 @@ bool SD2::GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, ui
bool SD2::GOGossipSelect(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint32 uiAction)
{
debug_log("SD2: GO Gossip selection, sender: %u, action: %u", uiSender, uiAction);
debug_log("[SD2]: GO Gossip selection, sender: %u, action: %u", uiSender, uiAction);
Script* pTempScript = m_scripts[pGo->GetScriptId()];
@ -339,7 +310,7 @@ bool SD2::GOGossipSelect(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint
bool SD2::GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction, const char* sCode)
{
debug_log("SD2: Gossip selection with code, sender: %u, action: %u", uiSender, uiAction);
debug_log("[SD2]: Gossip selection with code, sender: %u, action: %u", uiSender, uiAction);
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
@ -355,7 +326,7 @@ bool SD2::GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSe
bool SD2::GOGossipSelectWithCode(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint32 uiAction, const char* sCode)
{
debug_log("SD2: GO Gossip selection with code, sender: %u, action: %u", uiSender, uiAction);
debug_log("[SD2]: GO Gossip selection with code, sender: %u, action: %u", uiSender, uiAction);
Script* pTempScript = m_scripts[pGo->GetScriptId()];
@ -630,11 +601,3 @@ InstanceData* SD2::CreateInstanceData(Map* pMap)
return pTempScript->ToInstanceScript()->GetInstanceData(pMap);
}
//#ifdef WIN32
//# include <windows.h>
//BOOL APIENTRY DllMain(HANDLE /*hModule*/, DWORD /*ul_reason_for_call*/, LPVOID /*lpReserved*/)
//{
// return true;
//}
//#endif

View File

@ -28,14 +28,8 @@
#include "ProgressBar.h"
#include "ObjectMgr.h"
#include "Database/DatabaseEnv.h"
#include "SystemConfig.h"
DatabaseType SD2Database;
std::string strSD2Version;
SystemMgr::SystemMgr()
{
}
SystemMgr::SystemMgr() { }
SystemMgr& SystemMgr::Instance()
{
@ -43,51 +37,22 @@ SystemMgr& SystemMgr::Instance()
return pSysMgr;
}
void SystemMgr::LoadVersion()
{
// Get Version information
QueryResult* pResult = SD2Database.PQuery("SELECT version FROM sd2_db_version LIMIT 1");
if (pResult)
{
Field* pFields = pResult->Fetch();
strSD2Version = pFields[0].GetCppString();
delete pResult;
}
else
{
script_error_log("Missing `sd2_db_version` information.");
}
// Setup version info and display it
if (strSD2Version.empty())
{
strSD2Version.append("ScriptDev2 ");
}
strSD2Version.append(MANGOS_FULLVERSION("*", "*", "*", "*"));
outstring_log("Loading %s", strSD2Version.c_str());
}
void SystemMgr::LoadScriptTexts()
{
outstring_log("SD2: Loading Script Texts...");
LoadMangosStrings(SD2Database, "script_texts", TEXT_SOURCE_TEXT_START, TEXT_SOURCE_TEXT_END, true);
outstring_log("[SD2]: Loading Script Texts...");
LoadMangosStrings(WorldDatabase, "script_texts", TEXT_SOURCE_TEXT_START, TEXT_SOURCE_TEXT_END, true);
}
void SystemMgr::LoadScriptTextsCustom()
{
outstring_log("SD2: Loading Custom Texts...");
LoadMangosStrings(SD2Database, "custom_texts", TEXT_SOURCE_CUSTOM_START, TEXT_SOURCE_CUSTOM_END, true);
outstring_log("[SD2]: Loading Custom Texts...");
LoadMangosStrings(WorldDatabase, "custom_texts", TEXT_SOURCE_CUSTOM_START, TEXT_SOURCE_CUSTOM_END, true);
}
void SystemMgr::LoadScriptGossipTexts()
{
outstring_log("SD2: Loading Gossip Texts...");
LoadMangosStrings(SD2Database, "gossip_texts", TEXT_SOURCE_GOSSIP_START, TEXT_SOURCE_GOSSIP_END);
outstring_log("[SD2]: Loading Gossip Texts...");
LoadMangosStrings(WorldDatabase, "gossip_texts", TEXT_SOURCE_GOSSIP_START, TEXT_SOURCE_GOSSIP_END);
}
void SystemMgr::LoadScriptWaypoints()
@ -98,16 +63,16 @@ void SystemMgr::LoadScriptWaypoints()
uint64 uiCreatureCount = 0;
// Load Waypoints
QueryResult* pResult = SD2Database.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
QueryResult* pResult = WorldDatabase.PQuery("SELECT COUNT(entry) FROM script_waypoint GROUP BY entry");
if (pResult)
{
uiCreatureCount = pResult->GetRowCount();
delete pResult;
}
outstring_log("SD2: Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
outstring_log("[SD2]: Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
pResult = SD2Database.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
pResult = WorldDatabase.PQuery("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
if (pResult)
{
@ -132,13 +97,13 @@ void SystemMgr::LoadScriptWaypoints()
if (!pCInfo)
{
error_db_log("SD2: DB table script_waypoint has waypoint for nonexistent creature entry %u", pTemp.uiCreatureEntry);
error_db_log("[SD2]: DB table script_waypoint has waypoint for nonexistent creature entry %u", pTemp.uiCreatureEntry);
continue;
}
if (!sScriptMgr.GetBoundScriptId(SCRIPTED_UNIT, pTemp.uiCreatureEntry))
{
error_db_log("SD2: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);
error_db_log("[SD2]: DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", pTemp.uiCreatureEntry);
}
m_mPointMoveMap[uiEntry].push_back(pTemp);

View File

@ -26,9 +26,6 @@
#ifndef SC_SYSTEM_H
#define SC_SYSTEM_H
extern DatabaseType SD2Database;
extern std::string strSD2Version; // version info: database entry and revision
#define TEXT_SOURCE_RANGE -1000000 // the amount of entries each text source has available
#define TEXT_SOURCE_TEXT_START TEXT_SOURCE_RANGE
@ -60,8 +57,7 @@ class SystemMgr
typedef UNORDERED_MAP<uint32, std::vector<ScriptPointMove> > PointMoveMap;
// Database
void LoadVersion();
// SD2 Database Bindings
void LoadScriptTexts();
void LoadScriptTextsCustom();
void LoadScriptGossipTexts();

View File

@ -42,7 +42,7 @@
// Format is YYYYMMDDRR where RR is the change in the conf file
// for that day.
#ifndef MANGOSD_CONFIG_VERSION
# define MANGOSD_CONFIG_VERSION 2015041202
# define MANGOSD_CONFIG_VERSION 2015082701
#endif
#ifndef REALMD_CONFIG_VERSION
# define REALMD_CONFIG_VERSION 2010062001