Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
552 changes: 552 additions & 0 deletions sql/migrations/20260825234315_world.sql

Large diffs are not rendered by default.

49 changes: 38 additions & 11 deletions src/game/Commands/CharacterCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "PlayerDump.h"
#include "CharacterDatabaseCache.h"
#include "Config/Config.h"
#include "Conditions.h"

#include <regex>
#include <iterator>
Expand Down Expand Up @@ -2819,32 +2820,58 @@ bool ChatHandler::HandleLearnAllTrainerCommand(char* args)
if (!(cInfo->npc_flags & UNIT_NPC_FLAG_TRAINER))
continue;

switch (cInfo->trainer_type)
uint32 gossipMenuId = cInfo->gossip_menu_id;
if (!gossipMenuId)
continue;

GossipMenuItemsMapBounds bounds = sObjectMgr.GetGossipMenuItemsMapBounds(gossipMenuId);
bool validTrainer = false;
for (auto itr = bounds.first; itr != bounds.second; ++itr)
{
case TRAINER_TYPE_CLASS:
GossipMenuItems const& gMenuItem = itr->second;
if (gMenuItem.menu_id && gMenuItem.option_id == GOSSIP_OPTION_TRAINER)
{
if (cInfo->trainer_class != pPlayer->GetClass())
continue;
break;
if (uint32 conditionId = gMenuItem.condition_id)
{
validTrainer = IsConditionSatisfied(conditionId, pPlayer, pPlayer->GetMap(), pPlayer, CONDITION_FROM_GOSSIP_OPTION);
break;
}
else
{
validTrainer = true;
break;
}
}
case TRAINER_TYPE_PETS:
else
{
if (pPlayer->GetClass() != CLASS_HUNTER)
continue;
validTrainer = true;
break;
}
}

if (TrainerSpellData const* cSpells = sObjectMgr.GetNpcTrainerSpells(itr.first))
if (!validTrainer)
continue;

TrainerSpellData const* cSpells = sObjectMgr.GetNpcTrainerSpells(itr.first);
TrainerSpellData const* tSpells = sObjectMgr.GetNpcTrainerTemplateSpells(trainerId);
TrainerSpellData const* trainerSpellList = cSpells ? cSpells : (tSpells ? tSpells : nullptr);

if (!trainerSpellList)
continue;

if (trainerSpellList->spellList.empty())
continue;

if (cSpells)
HandleLearnTrainerHelper(pPlayer, cSpells);

if (trainerId = cInfo->trainer_id) // assignment
if (trainerId = cInfo->trainer_id)
{
if (checkedTrainerTemplates.find(trainerId) != checkedTrainerTemplates.end())
continue;

checkedTrainerTemplates.insert(trainerId);
if (TrainerSpellData const* tSpells = sObjectMgr.GetNpcTrainerTemplateSpells(trainerId))
if (tSpells)
HandleLearnTrainerHelper(pPlayer, tSpells);
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/game/Handlers/NPCHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid)
}

// trainer list loaded at check;
if (!unit->IsTrainerOf(_player, true))
if (!unit->IsTrainerOf(_player))
return;

CreatureInfo const* ci = unit->GetCreatureInfo();
Expand All @@ -168,26 +168,28 @@ void WorldSession::SendTrainerList(ObjectGuid guid)
GetPlayer()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_INTERACTING_CANCELS);

uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0);
uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0);

uint32 trainerType;
std::string strTitle;
if (TrainerGreetingLocale const* trainerGreeting = sObjectMgr.GetTrainerGreetingLocale(guid.GetEntry()))
if (TrainerGreeting const* trainerGreeting = sObjectMgr.GetTrainerGreeting(guid.GetEntry()))
{
int locale_idx = GetSessionDbLocaleIndex();
trainerType = trainerGreeting->trainerType;

int locale_idx = GetSessionDbLocaleIndex();
if ((int32)trainerGreeting->Content.size() > locale_idx + 1 && !trainerGreeting->Content[locale_idx + 1].empty())
strTitle = trainerGreeting->Content[locale_idx + 1];
else
strTitle = trainerGreeting->Content[0];
}
else
{
strTitle = GetMangosString(LANG_NPC_TAINER_HELLO);
sLog.Out(LOG_BASIC, LOG_LVL_DEBUG, "WORLD: SendTrainerList - Trainer greeting not found for %s", guid.GetString().c_str());
return;
}

WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + maxcount * 38 + strTitle.size() + 1);
data << ObjectGuid(guid);
data << uint32(trainer_type);
data << uint32(trainerType);

size_t count_pos = data.wpos();
data << uint32(maxcount);
Expand Down Expand Up @@ -265,7 +267,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPackets::Npc::TrainerBuySpel

Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.guid, UNIT_NPC_FLAG_TRAINER);

if (!unit || !unit->IsTrainerOf(_player, true) || !unit->IsWithinLOSInMap(_player))
if (!unit || !unit->IsTrainerOf(_player) || !unit->IsWithinLOSInMap(_player))
{
SendTrainingFailure(packet.guid, packet.spellId, TRAIN_FAIL_UNAVAILABLE);
sLog.Out(LOG_BASIC, LOG_LVL_DEBUG, "WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", packet.guid.GetString().c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/game/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum MangosStrings
LANG_FRIEND_IGNORE_UNKNOWN = 48,
LANG_LEVEL_MINREQUIRED = 49,
LANG_COMMAND_UNAVAILABLE = 50,
LANG_NPC_TAINER_HELLO = 51,
// = 51, not used
LANG_COMMAND_INVALID_ITEM_COUNT = 52,
LANG_COMMAND_MAIL_ITEMS_LIMIT = 53,
LANG_NEW_PASSWORDS_NOT_MATCH = 54,
Expand Down
Loading
Loading