*** New core <-> script library interface - complete rewrite of the old one.

* Removed the misdesigned on_events script/hooks.
* Lots of related cleanups and assertions.
* The interface is now fully object-oriented.
** Scripts no longer use function pointers.
** Scripts no longer use the general-purpose Script struct for everything.
** Script types are split into separate classes which must be inherited depending on what functionality is desired.
* Several script types have been added to allow extending functionality in a code-only manner (some script types require
  assignment in the recently added ScriptName columns in the database, though).
** SpellHandlerScript: Wrapper around spell scripts (returns new SpellScript objects (`spell_script_names`.`ScriptName`)).
** ServerScript: Allows scripting events that occur in the network layer.
** WorldScript: Allows scripting certain world-global events.
** FormulaScript: Allows hooking and interfering with core formulas.
** *MapScript: Allows hooking different map types (including world, instance, and battleground maps (`instance_template`.`ScriptName`)).
** ItemScript: Allows scripting of items (like the old interface (`item_template`.`ScriptName`)).
** CreatureScript: Allows scripting of creatures/AI (like the old interface (`creature_template`.`ScriptName`)).
** GameObjectScript: Allows scripting of gameobjects (like the old interface (`gameobject_template`.`ScriptName`)).
** AreaTriggerScript: Allows scripting triggered area triggers (like the old interface (`areatrigger_scripts`.`ScriptName`)).
** OutdoorPvPScript: Script which should return OutdoorPvP objects for use by OutdoorPvPMgr (`outdoorpvp_template`.`ScriptName`).
** CommandScript: Allows extending the in-core command table.
** WeatherScript: Allows scripting of weather changes (`game_weather`.`ScriptName`).
** AuctionHouseScript: Allows scripting of auction events.
** ConditionScript: Allows scripting of conditions (`conditions`.`ScriptName`).
** DynamicObjectScript: Allows scripting of dynamicobjects.
** TransportScript: Allows scripting of transport events (`transports`.`ScriptName`).
* OutdoorPvP objects are now created through scripts. This effectively means that they'll need to be moved to scripts
  before the they're functional again.
* The whole idea with this new interface is to allow expanding core functionality without touching core code. If further
  hooks are needed to expand functionality of the core, let us know; we'll add them, if we agree that it is appropriate
  to do so.
*** NOTE: The scripts project will _not_ build before it has been adapted to the new interface.
*** Thanks to everyone who helped out with related preparations and suggestions!

--HG--
branch : trunk
This commit is contained in:
XTZGZoReX
2010-08-06 19:23:43 +02:00
parent 2562a4651f
commit 946adf469c
48 changed files with 2444 additions and 1263 deletions
+1 -2
View File
@@ -33,10 +33,9 @@ enum OutdoorPvPTypes
OUTDOOR_PVP_ZM = 4,
OUTDOOR_PVP_SI = 5,
OUTDOOR_PVP_EP = 6,
OUTDOOR_PVP_NR = 7,
};
#define MAX_OUTDOORPVP_TYPES 8
#define MAX_OUTDOORPVP_TYPES 7
const uint8 CapturePointArtKit[3] = {2, 1, 21};
+28 -78
View File
@@ -27,6 +27,7 @@
#include "Player.h"
#include "ProgressBar.h"
#include "DisableMgr.h"
#include "ScriptMgr.h"
OutdoorPvPMgr::OutdoorPvPMgr()
{
@@ -40,91 +41,39 @@ OutdoorPvPMgr::~OutdoorPvPMgr()
for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
delete *itr;
for (OutdoorPvPDataSet::iterator itr = m_OutdoorPvPDatas.begin(); itr != m_OutdoorPvPDatas.end(); ++itr)
delete *itr;
for (OutdoorPvPDataMap::iterator itr = m_OutdoorPvPDatas.begin(); itr != m_OutdoorPvPDatas.end(); ++itr)
delete itr->second;
}
void OutdoorPvPMgr::InitOutdoorPvP()
{
LoadTemplates();
// create new opvp
OutdoorPvP * pOP = new OutdoorPvPHP;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
OutdoorPvP* pvp;
for (uint8 i = 0; i < MAX_OUTDOORPVP_TYPES; ++i)
{
sLog.outDebug("OutdoorPvP : HP init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : HP successfully initiated.");
}
OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
if (iter == m_OutdoorPvPDatas.end())
{
sLog.outErrorDb("Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(iter->first));
continue;
}
pOP = new OutdoorPvPNA;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
{
sLog.outDebug("OutdoorPvP : NA init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : NA successfully initiated.");
}
pvp = sScriptMgr.CreateOutdoorPvP(iter->second);
if (!pvp)
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(iter->first));
continue;
}
pOP = new OutdoorPvPTF;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
{
sLog.outDebug("OutdoorPvP : TF init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : TF successfully initiated.");
}
if (!pvp->SetupOutdoorPvP())
{
sLog.outError("Could not initialize OutdoorPvP object for type ID %u; SetupOutdoorPvP failed.", uint32(iter->first));
delete pvp;
continue;
}
pOP = new OutdoorPvPZM;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
{
sLog.outDebug("OutdoorPvP : ZM init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : ZM successfully initiated.");
}
pOP = new OutdoorPvPSI;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
{
sLog.outDebug("OutdoorPvP : SI init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : SI successfully initiated.");
}
pOP = new OutdoorPvPEP;
// respawn, init variables
if (!pOP->SetupOutdoorPvP())
{
sLog.outDebug("OutdoorPvP : EP init failed.");
delete pOP;
}
else
{
m_OutdoorPvPSet.push_back(pOP);
sLog.outDebug("OutdoorPvP : EP successfully initiated.");
m_OutdoorPvPSet.push_back(pvp);
}
}
@@ -161,14 +110,15 @@ void OutdoorPvPMgr::LoadTemplates()
if (typeId >= MAX_OUTDOORPVP_TYPES)
{
sLog.outError("Invalid OutdoorPvPTypes value %u in outdoorpvp_template; skipped.", typeId);
sLog.outErrorDb("Invalid OutdoorPvPTypes value %u in outdoorpvp_template; skipped.", typeId);
continue;
}
OutdoorPvPData data;
data.TypeId = OutdoorPvPTypes(typeId);
OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
data.TypeId = realTypeId;
data.ScriptId = objmgr.GetScriptId(fields[1].GetString());
m_OutdoorPvPDatas.push_back(&data);
m_OutdoorPvPDatas[realTypeId] = &data;
++count;
}
+2 -2
View File
@@ -85,7 +85,7 @@ class OutdoorPvPMgr
typedef std::vector<OutdoorPvP*> OutdoorPvPSet;
typedef std::map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap;
typedef std::vector<OutdoorPvPData*> OutdoorPvPDataSet;
typedef std::map<OutdoorPvPTypes, OutdoorPvPData*> OutdoorPvPDataMap;
private:
@@ -98,7 +98,7 @@ class OutdoorPvPMgr
OutdoorPvPMap m_OutdoorPvPMap;
// Holds the outdoor PvP templates
OutdoorPvPDataSet m_OutdoorPvPDatas;
OutdoorPvPDataMap m_OutdoorPvPDatas;
// update interval
uint32 m_UpdateTimer;