*** 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:
@@ -806,8 +806,6 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
|
||||
|
||||
m_playerLoading = false;
|
||||
|
||||
//Hook for OnLogin Event
|
||||
sScriptMgr.OnLogin(pCurrChar);
|
||||
delete holder;
|
||||
}
|
||||
|
||||
@@ -1360,48 +1358,3 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recv_data)
|
||||
data << uint8(0); // 4 - equipment swap failed - inventory is full
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnPVPKill(Player *killed)
|
||||
{
|
||||
sScriptMgr.OnPVPKill(GetPlayer(), killed);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnPlayerChat(const char *text)
|
||||
{
|
||||
return sScriptMgr.OnPlayerChat(GetPlayer(), text);
|
||||
}
|
||||
|
||||
uint32 WorldSession::HandleOnGetXP(uint32 amount)
|
||||
{
|
||||
return sScriptMgr.OnGetXP(GetPlayer(), amount);
|
||||
}
|
||||
|
||||
int32 WorldSession::HandleOnGetMoney(int32 amount)
|
||||
{
|
||||
return sScriptMgr.OnGetMoney(GetPlayer(), amount);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnAreaChange(AreaTableEntry const *pArea)
|
||||
{
|
||||
sScriptMgr.OnAreaChange(GetPlayer(), pArea);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnItemClick(Item *pItem)
|
||||
{
|
||||
return sScriptMgr.OnItemClick(GetPlayer(), pItem);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnItemOpen(Item *pItem)
|
||||
{
|
||||
return sScriptMgr.OnItemOpen(GetPlayer(), pItem);
|
||||
}
|
||||
|
||||
bool WorldSession::HandleOnGoClick(GameObject *pGameObject)
|
||||
{
|
||||
return sScriptMgr.OnGoClick(GetPlayer(), pGameObject);
|
||||
}
|
||||
|
||||
void WorldSession::HandleOnCreatureKill(Creature *pCreature)
|
||||
{
|
||||
sScriptMgr.OnCreatureKill(GetPlayer(), pCreature);
|
||||
}
|
||||
|
||||
@@ -140,21 +140,21 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
if (unit)
|
||||
{
|
||||
if (!sScriptMgr.GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str()))
|
||||
if (!sScriptMgr.OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str()))
|
||||
_player->OnGossipSelect(unit, gossipListId, menuId);
|
||||
}
|
||||
else
|
||||
sScriptMgr.GOSelectWithCode(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str());
|
||||
sScriptMgr.OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (unit)
|
||||
{
|
||||
if (!sScriptMgr.GossipSelect(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId)))
|
||||
if (!sScriptMgr.OnGossipSelect(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId)))
|
||||
_player->OnGossipSelect(unit, gossipListId, menuId);
|
||||
}
|
||||
else
|
||||
sScriptMgr.GOSelect(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId));
|
||||
sScriptMgr.OnGossipSelect(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,7 +884,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (sScriptMgr.AreaTrigger(GetPlayer(), atEntry))
|
||||
if (sScriptMgr.OnTrigger(GetPlayer(), atEntry))
|
||||
return;
|
||||
|
||||
uint32 quest_id = objmgr.GetQuestForAreaTrigger(Trigger_ID);
|
||||
|
||||
@@ -340,7 +340,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (!sScriptMgr.GossipHello(_player, unit))
|
||||
if (!sScriptMgr.OnGossipHello(_player, unit))
|
||||
{
|
||||
// _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID());
|
||||
_player->PrepareGossipMenu(unit, unit->GetCreatureInfo()->GossipMenuId, true);
|
||||
|
||||
@@ -56,7 +56,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
|
||||
Creature* cr_questgiver=questgiver->ToCreature();
|
||||
if (!cr_questgiver->IsHostileTo(_player)) // not show quest status to enemies
|
||||
{
|
||||
questStatus = sScriptMgr.NPCDialogStatus(_player, cr_questgiver);
|
||||
questStatus = sScriptMgr.GetDialogStatus(_player, cr_questgiver);
|
||||
if (questStatus > 6)
|
||||
questStatus = getDialogStatus(_player, cr_questgiver, defstatus);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject guid = %u",uint32(GUID_LOPART(guid)));
|
||||
GameObject* go_questgiver=(GameObject*)questgiver;
|
||||
questStatus = sScriptMgr.GODialogStatus(_player, go_questgiver);
|
||||
questStatus = sScriptMgr.GetDialogStatus(_player, go_questgiver);
|
||||
if (questStatus > 6)
|
||||
questStatus = getDialogStatus(_player, go_questgiver, defstatus);
|
||||
break;
|
||||
@@ -101,7 +101,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
|
||||
// Stop the npc if moving
|
||||
pCreature->StopMoving();
|
||||
|
||||
if (sScriptMgr.GossipHello(_player, pCreature))
|
||||
if (sScriptMgr.OnGossipHello(_player, pCreature))
|
||||
return;
|
||||
|
||||
_player->PrepareGossipMenu(pCreature, pCreature->GetCreatureInfo()->GossipMenuId, true);
|
||||
@@ -188,12 +188,12 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
|
||||
switch(pObject->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
sScriptMgr.QuestAccept(_player, (pObject->ToCreature()), qInfo);
|
||||
sScriptMgr.OnQuestAccept(_player, (pObject->ToCreature()), qInfo);
|
||||
break;
|
||||
case TYPEID_ITEM:
|
||||
case TYPEID_CONTAINER:
|
||||
{
|
||||
sScriptMgr.ItemQuestAccept(_player, ((Item*)pObject), qInfo);
|
||||
sScriptMgr.OnQuestAccept(_player, ((Item*)pObject), qInfo);
|
||||
|
||||
// destroy not required for quest finish quest starting item
|
||||
bool destroyItem = true;
|
||||
@@ -212,7 +212,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
|
||||
break;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
sScriptMgr.GOQuestAccept(_player, ((GameObject*)pObject), qInfo);
|
||||
sScriptMgr.OnQuestAccept(_player, ((GameObject*)pObject), qInfo);
|
||||
break;
|
||||
}
|
||||
_player->PlayerTalkClass->CloseGossip();
|
||||
@@ -307,7 +307,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
|
||||
switch(pObject->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if (!(sScriptMgr.ChooseReward(_player, (pObject->ToCreature()), pQuest, reward)))
|
||||
if (!(sScriptMgr.OnQuestReward(_player, (pObject->ToCreature()), pQuest, reward)))
|
||||
{
|
||||
// Send next quest
|
||||
if (Quest const* nextquest = _player->GetNextQuest(guid ,pQuest))
|
||||
@@ -315,7 +315,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
if (!sScriptMgr.GOChooseReward(_player, ((GameObject*)pObject), pQuest, reward))
|
||||
if (!sScriptMgr.OnQuestReward(_player, ((GameObject*)pObject), pQuest, reward))
|
||||
{
|
||||
// Send next quest
|
||||
if (Quest const* nextquest = _player->GetNextQuest(guid ,pQuest))
|
||||
@@ -672,7 +672,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
|
||||
continue;
|
||||
if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
|
||||
continue;
|
||||
questStatus = sScriptMgr.NPCDialogStatus(_player, questgiver);
|
||||
questStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
|
||||
if (questStatus > 6)
|
||||
questStatus = getDialogStatus(_player, questgiver, defstatus);
|
||||
|
||||
@@ -687,7 +687,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
|
||||
continue;
|
||||
if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
continue;
|
||||
questStatus = sScriptMgr.GODialogStatus(_player, questgiver);
|
||||
questStatus = sScriptMgr.GetDialogStatus(_player, questgiver);
|
||||
if (questStatus > 6)
|
||||
questStatus = getDialogStatus(_player, questgiver, defstatus);
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
|
||||
//Note: If script stop casting it must send appropriate data to client to prevent stuck item in gray state.
|
||||
if (!sScriptMgr.ItemUse(pUser,pItem,targets))
|
||||
if (!sScriptMgr.OnItemUse(pUser,pItem,targets))
|
||||
{
|
||||
// no script or script not process request by self
|
||||
pUser->CastItemUseSpell(pItem,targets,cast_count,glyphIndex);
|
||||
@@ -199,9 +199,6 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pUser->GetSession()->HandleOnItemOpen(pItem))
|
||||
return;
|
||||
|
||||
// locked item
|
||||
uint32 lockId = proto->LockID;
|
||||
if (lockId)
|
||||
@@ -266,7 +263,7 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recv_data)
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
if (sScriptMgr.GOHello(_player, obj))
|
||||
if (sScriptMgr.OnGossipHello(_player, obj))
|
||||
return;
|
||||
|
||||
obj->Use(_player);
|
||||
|
||||
@@ -196,6 +196,8 @@ bool WorldSession::Update(uint32 diff)
|
||||
sLog.outError("SESSION: received non-existed opcode %s (0x%.4X)",
|
||||
LookupOpcodeName(packet->GetOpcode()),
|
||||
packet->GetOpcode());
|
||||
|
||||
sScriptMgr.OnUnknownPacketReceive(m_Socket, WorldPacket(*packet));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -213,6 +215,7 @@ bool WorldSession::Update(uint32 diff)
|
||||
}
|
||||
else if (_player->IsInWorld())
|
||||
{
|
||||
sScriptMgr.OnPacketReceive(m_Socket, WorldPacket(*packet));
|
||||
(this->*opHandle.handler)(*packet);
|
||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
||||
LogUnprocessedTail(packet);
|
||||
@@ -227,6 +230,7 @@ bool WorldSession::Update(uint32 diff)
|
||||
else
|
||||
{
|
||||
// not expected _player or must checked in packet hanlder
|
||||
sScriptMgr.OnPacketReceive(m_Socket, WorldPacket(*packet));
|
||||
(this->*opHandle.handler)(*packet);
|
||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
||||
LogUnprocessedTail(packet);
|
||||
@@ -239,6 +243,7 @@ bool WorldSession::Update(uint32 diff)
|
||||
LogUnexpectedOpcode(packet, "the player is still in world");
|
||||
else
|
||||
{
|
||||
sScriptMgr.OnPacketReceive(m_Socket, WorldPacket(*packet));
|
||||
(this->*opHandle.handler)(*packet);
|
||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
||||
LogUnprocessedTail(packet);
|
||||
@@ -256,7 +261,8 @@ bool WorldSession::Update(uint32 diff)
|
||||
// and before other STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes.
|
||||
if (packet->GetOpcode() != CMSG_SET_ACTIVE_VOICE_CHANNEL)
|
||||
m_playerRecentlyLogout = false;
|
||||
|
||||
|
||||
sScriptMgr.OnPacketReceive(m_Socket, WorldPacket(*packet));
|
||||
(this->*opHandle.handler)(*packet);
|
||||
if (sLog.IsOutDebug() && packet->rpos() < packet->wpos())
|
||||
LogUnprocessedTail(packet);
|
||||
@@ -471,9 +477,6 @@ void WorldSession::LogoutPlayer(bool Save)
|
||||
sLog.outDebug("SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
|
||||
}
|
||||
|
||||
//Hook for OnLogout Event
|
||||
sScriptMgr.OnLogout(_player);
|
||||
|
||||
m_playerLogout = false;
|
||||
m_playerSave = false;
|
||||
m_playerRecentlyLogout = true;
|
||||
|
||||
@@ -785,15 +785,6 @@ class WorldSession
|
||||
void HandleReadyForAccountDataTimes(WorldPacket& recv_data);
|
||||
void HandleQueryQuestsCompleted(WorldPacket& recv_data);
|
||||
void HandleQuestPOIQuery(WorldPacket& recv_data);
|
||||
void HandleOnPVPKill(Player *killed);
|
||||
bool HandleOnPlayerChat(const char *text);
|
||||
uint32 HandleOnGetXP(uint32 amount);
|
||||
int32 HandleOnGetMoney(int32 amount);
|
||||
void HandleOnAreaChange(AreaTableEntry const *pArea);
|
||||
bool HandleOnItemClick(Item *pItem);
|
||||
bool HandleOnItemOpen(Item *pItem);
|
||||
bool HandleOnGoClick(GameObject *pGameObject);
|
||||
void HandleOnCreatureKill(Creature *pCreature);
|
||||
void HandleEjectPasenger(WorldPacket &data);
|
||||
void HandleEnterPlayerVehicle(WorldPacket &data);
|
||||
private:
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "WorldSocketMgr.h"
|
||||
#include "Log.h"
|
||||
#include "WorldLog.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
@@ -186,6 +187,9 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
|
||||
sWorldLog.outLog("\n");
|
||||
}
|
||||
|
||||
// Create a copy of the original packet; this is to avoid issues if a hook modifies it.
|
||||
sScriptMgr.OnPacketSend(this, WorldPacket(pct));
|
||||
|
||||
ServerPktHeader header(pct.size()+2, pct.GetOpcode());
|
||||
m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength());
|
||||
|
||||
@@ -705,7 +709,8 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
|
||||
sWorldLog.outLog ("\n");
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
switch(opcode)
|
||||
{
|
||||
case CMSG_PING:
|
||||
@@ -716,11 +721,12 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
|
||||
sLog.outError ("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
sScriptMgr.OnPacketReceive(this, WorldPacket(*new_pct));
|
||||
return HandleAuthSession (*new_pct);
|
||||
case CMSG_KEEP_ALIVE:
|
||||
DEBUG_LOG ("CMSG_KEEP_ALIVE ,size: %d", new_pct->size());
|
||||
|
||||
sScriptMgr.OnPacketReceive(this, WorldPacket(*new_pct));
|
||||
return 0;
|
||||
default:
|
||||
{
|
||||
@@ -747,7 +753,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(ByteBufferException &)
|
||||
catch (ByteBufferException &)
|
||||
{
|
||||
sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.",
|
||||
opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
/**
|
||||
* This is a helper class to WorldSocketMgr ,that manages
|
||||
@@ -116,6 +117,8 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
sock->reactor (m_Reactor);
|
||||
m_NewSockets.insert (sock);
|
||||
|
||||
sScriptMgr.OnSocketOpen(sock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,6 +142,8 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
|
||||
if (sock->IsClosed())
|
||||
{
|
||||
sScriptMgr.OnSocketClose(sock, true);
|
||||
|
||||
sock->RemoveReference();
|
||||
--m_Connections;
|
||||
}
|
||||
@@ -176,7 +181,11 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
{
|
||||
t = i;
|
||||
++i;
|
||||
|
||||
(*t)->CloseSocket();
|
||||
|
||||
sScriptMgr.OnSocketClose((*t), false);
|
||||
|
||||
(*t)->RemoveReference();
|
||||
--m_Connections;
|
||||
m_Sockets.erase (t);
|
||||
@@ -279,6 +288,8 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, const char* address)
|
||||
if (StartReactiveIO(port, address) == -1)
|
||||
return -1;
|
||||
|
||||
sScriptMgr.OnNetworkStart();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -300,6 +311,8 @@ WorldSocketMgr::StopNetwork()
|
||||
}
|
||||
|
||||
Wait();
|
||||
|
||||
sScriptMgr.OnNetworkStop();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user