mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
refactor(Core/Creature): port TC handling of Trainers (#23040)
Co-authored-by: Shauren <shauren.trinity@gmail.com> Co-authored-by: Ghaster <defscam@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "ItemPackets.h"
|
||||
#include "LFGPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "NPCPackets.h"
|
||||
#include "PetPackets.h"
|
||||
#include "QueryPackets.h"
|
||||
#include "TotemPackets.h"
|
||||
|
||||
69
src/server/game/Server/Packets/NPCPackets.cpp
Normal file
69
src/server/game/Server/Packets/NPCPackets.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "NPCPackets.h"
|
||||
|
||||
void WorldPackets::NPC::Hello::Read()
|
||||
{
|
||||
_worldPacket >> Unit;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::NPC::TrainerList::Write()
|
||||
{
|
||||
_worldPacket << TrainerGUID;
|
||||
_worldPacket << int32(TrainerType);
|
||||
|
||||
_worldPacket << int32(Spells.size());
|
||||
for (TrainerListSpell const& spell : Spells)
|
||||
{
|
||||
_worldPacket << int32(spell.SpellID);
|
||||
_worldPacket << uint8(spell.Usable);
|
||||
_worldPacket << int32(spell.MoneyCost);
|
||||
_worldPacket.append(spell.PointCost.data(), spell.PointCost.size());
|
||||
_worldPacket << uint8(spell.ReqLevel);
|
||||
_worldPacket << int32(spell.ReqSkillLine);
|
||||
_worldPacket << int32(spell.ReqSkillRank);
|
||||
_worldPacket.append(spell.ReqAbility.data(), spell.ReqAbility.size());
|
||||
}
|
||||
|
||||
_worldPacket << Greeting;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::NPC::TrainerBuySpell::Read()
|
||||
{
|
||||
_worldPacket >> TrainerGUID;
|
||||
_worldPacket >> SpellID;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::NPC::TrainerBuyFailed::Write()
|
||||
{
|
||||
_worldPacket << TrainerGUID;
|
||||
_worldPacket << int32(SpellID);
|
||||
_worldPacket << int32(TrainerFailedReason);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::NPC::TrainerBuySucceeded::Write()
|
||||
{
|
||||
_worldPacket << TrainerGUID;
|
||||
_worldPacket << int32(SpellID);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
103
src/server/game/Server/Packets/NPCPackets.h
Normal file
103
src/server/game/Server/Packets/NPCPackets.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NPCPackets_h__
|
||||
#define NPCPackets_h__
|
||||
|
||||
#include "Packet.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <array>
|
||||
|
||||
namespace WorldPackets::NPC
|
||||
{
|
||||
// CMSG_BANKER_ACTIVATE
|
||||
// CMSG_BATTLEMASTER_HELLO
|
||||
// CMSG_BINDER_ACTIVATE
|
||||
// CMSG_GOSSIP_HELLO
|
||||
// CMSG_LIST_INVENTORY
|
||||
// CMSG_TRAINER_LIST
|
||||
class Hello final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
explicit Hello(WorldPacket&& packet) : ClientPacket(std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid Unit;
|
||||
};
|
||||
|
||||
struct TrainerListSpell
|
||||
{
|
||||
int32 SpellID = 0;
|
||||
uint8 Usable = 0;
|
||||
int32 MoneyCost = 0;
|
||||
std::array<int32, 2> PointCost = { }; // compared with PLAYER_CHARACTER_POINTS in Lua
|
||||
uint8 ReqLevel = 0;
|
||||
int32 ReqSkillLine = 0;
|
||||
int32 ReqSkillRank = 0;
|
||||
std::array<int32, 3> ReqAbility = { };
|
||||
};
|
||||
|
||||
class TrainerList final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
TrainerList() : ServerPacket(SMSG_TRAINER_LIST) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid TrainerGUID;
|
||||
int32 TrainerType = 0;
|
||||
std::vector<TrainerListSpell> Spells;
|
||||
std::string Greeting;
|
||||
};
|
||||
|
||||
class TrainerBuySpell final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
explicit TrainerBuySpell(WorldPacket&& packet) : ClientPacket(CMSG_TRAINER_BUY_SPELL, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid TrainerGUID;
|
||||
int32 SpellID = 0;
|
||||
};
|
||||
|
||||
class TrainerBuyFailed final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
TrainerBuyFailed() : ServerPacket(SMSG_TRAINER_BUY_FAILED, 8 + 4 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid TrainerGUID;
|
||||
int32 SpellID = 0;
|
||||
int32 TrainerFailedReason = 0;
|
||||
};
|
||||
|
||||
class TrainerBuySucceeded final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
TrainerBuySucceeded() : ServerPacket(SMSG_TRAINER_BUY_SUCCEEDED, 8 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid TrainerGUID;
|
||||
int32 SpellID = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NPCPackets_h__
|
||||
@@ -198,6 +198,12 @@ namespace WorldPackets
|
||||
class ArenaTeam;
|
||||
class CalendarComplain;
|
||||
}
|
||||
|
||||
namespace NPC
|
||||
{
|
||||
class Hello;
|
||||
class TrainerBuySpell;
|
||||
}
|
||||
}
|
||||
|
||||
enum AccountDataType
|
||||
@@ -478,8 +484,7 @@ public:
|
||||
//void SendTestCreatureQueryOpcode(uint32 entry, ObjectGuid guid, uint32 testvalue);
|
||||
void SendNameQueryOpcode(ObjectGuid guid);
|
||||
|
||||
void SendTrainerList(ObjectGuid guid);
|
||||
void SendTrainerList(ObjectGuid guid, std::string const& strTitle);
|
||||
void SendTrainerList(Creature* npc);
|
||||
void SendListInventory(ObjectGuid guid, uint32 vendorEntry = 0);
|
||||
void SendShowBank(ObjectGuid guid);
|
||||
bool CanOpenMailBox(ObjectGuid guid);
|
||||
@@ -785,8 +790,8 @@ public: // opcodes handlers
|
||||
void SendActivateTaxiReply(ActivateTaxiReply reply);
|
||||
|
||||
void HandleTabardVendorActivateOpcode(WorldPacket& recvPacket);
|
||||
void HandleTrainerListOpcode(WorldPacket& recvPacket);
|
||||
void HandleTrainerBuySpellOpcode(WorldPacket& recvPacket);
|
||||
void HandleTrainerListOpcode(WorldPackets::NPC::Hello& packet);
|
||||
void HandleTrainerBuySpellOpcode(WorldPackets::NPC::TrainerBuySpell& packet);
|
||||
void HandlePetitionShowListOpcode(WorldPacket& recvPacket);
|
||||
void HandleGossipHelloOpcode(WorldPacket& recvPacket);
|
||||
void HandleGossipSelectOptionOpcode(WorldPacket& recvPacket);
|
||||
|
||||
Reference in New Issue
Block a user