mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
packet send hook can no longer return new packet
This commit is contained in:
@@ -1880,13 +1880,8 @@ namespace LuaGlobalFunctions
|
|||||||
switch (banMode)
|
switch (banMode)
|
||||||
{
|
{
|
||||||
case BAN_ACCOUNT:
|
case BAN_ACCOUNT:
|
||||||
#ifdef CATA
|
|
||||||
if (!Utf8ToUpperOnlyLatin(nameOrIP))
|
if (!Utf8ToUpperOnlyLatin(nameOrIP))
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
|
||||||
if (!AccountMgr::normalizeString(nameOrIP))
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case BAN_CHARACTER:
|
case BAN_CHARACTER:
|
||||||
if (!normalizePlayerName(nameOrIP))
|
if (!normalizePlayerName(nameOrIP))
|
||||||
|
|||||||
@@ -402,9 +402,9 @@ public:
|
|||||||
void OnSpawn(GameObject* gameobject);
|
void OnSpawn(GameObject* gameobject);
|
||||||
|
|
||||||
/* Packet */
|
/* Packet */
|
||||||
bool OnPacketSend(WorldSession* session, WorldPacket& packet);
|
bool OnPacketSend(WorldSession* session, const WorldPacket& packet);
|
||||||
void OnPacketSendAny(Player* player, WorldPacket& packet, bool& result);
|
void OnPacketSendAny(Player* player, const WorldPacket& packet, bool& result);
|
||||||
void OnPacketSendOne(Player* player, WorldPacket& packet, bool& result);
|
void OnPacketSendOne(Player* player, const WorldPacket& packet, bool& result);
|
||||||
bool OnPacketReceive(WorldSession* session, WorldPacket& packet);
|
bool OnPacketReceive(WorldSession* session, WorldPacket& packet);
|
||||||
void OnPacketReceiveAny(Player* player, WorldPacket& packet, bool& result);
|
void OnPacketReceiveAny(Player* player, WorldPacket& packet, bool& result);
|
||||||
void OnPacketReceiveOne(Player* player, WorldPacket& packet, bool& result);
|
void OnPacketReceiveOne(Player* player, WorldPacket& packet, bool& result);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ using namespace Hooks;
|
|||||||
return;\
|
return;\
|
||||||
LOCK_ELUNA
|
LOCK_ELUNA
|
||||||
|
|
||||||
bool Eluna::OnPacketSend(WorldSession* session, WorldPacket& packet)
|
bool Eluna::OnPacketSend(WorldSession* session, const WorldPacket& packet)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
Player* player = NULL;
|
Player* player = NULL;
|
||||||
@@ -39,7 +39,7 @@ bool Eluna::OnPacketSend(WorldSession* session, WorldPacket& packet)
|
|||||||
OnPacketSendOne(player, packet, result);
|
OnPacketSendOne(player, packet, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void Eluna::OnPacketSendAny(Player* player, WorldPacket& packet, bool& result)
|
void Eluna::OnPacketSendAny(Player* player, const WorldPacket& packet, bool& result)
|
||||||
{
|
{
|
||||||
START_HOOK_SERVER(SERVER_EVENT_ON_PACKET_SEND);
|
START_HOOK_SERVER(SERVER_EVENT_ON_PACKET_SEND);
|
||||||
Push(new WorldPacket(packet));
|
Push(new WorldPacket(packet));
|
||||||
@@ -48,22 +48,18 @@ void Eluna::OnPacketSendAny(Player* player, WorldPacket& packet, bool& result)
|
|||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
{
|
{
|
||||||
int r = CallOneFunction(n--, 2, 2);
|
int r = CallOneFunction(n--, 2, 1);
|
||||||
|
|
||||||
if (lua_isboolean(L, r + 0) && !lua_toboolean(L, r + 0))
|
if (lua_isboolean(L, r + 0) && !lua_toboolean(L, r + 0))
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
if (lua_isuserdata(L, r + 1))
|
lua_pop(L, 1);
|
||||||
if (WorldPacket* data = CHECKOBJ<WorldPacket>(L, r + 1, false))
|
|
||||||
packet = *data;
|
|
||||||
|
|
||||||
lua_pop(L, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CleanUpStack(2);
|
CleanUpStack(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Eluna::OnPacketSendOne(Player* player, WorldPacket& packet, bool& result)
|
void Eluna::OnPacketSendOne(Player* player, const WorldPacket& packet, bool& result)
|
||||||
{
|
{
|
||||||
START_HOOK_PACKET(PACKET_EVENT_ON_PACKET_SEND, packet.GetOpcode());
|
START_HOOK_PACKET(PACKET_EVENT_ON_PACKET_SEND, packet.GetOpcode());
|
||||||
Push(new WorldPacket(packet));
|
Push(new WorldPacket(packet));
|
||||||
@@ -72,16 +68,12 @@ void Eluna::OnPacketSendOne(Player* player, WorldPacket& packet, bool& result)
|
|||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
{
|
{
|
||||||
int r = CallOneFunction(n--, 2, 2);
|
int r = CallOneFunction(n--, 2, 1);
|
||||||
|
|
||||||
if (lua_isboolean(L, r + 0) && !lua_toboolean(L, r + 0))
|
if (lua_isboolean(L, r + 0) && !lua_toboolean(L, r + 0))
|
||||||
result = false;
|
result = false;
|
||||||
|
|
||||||
if (lua_isuserdata(L, r + 1))
|
lua_pop(L, 1);
|
||||||
if (WorldPacket* data = CHECKOBJ<WorldPacket>(L, r + 1, false))
|
|
||||||
packet = *data;
|
|
||||||
|
|
||||||
lua_pop(L, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CleanUpStack(2);
|
CleanUpStack(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user