Core/Housing: stage 37 harden tutorial transition fallback

This commit is contained in:
Gexo91
2026-09-12 18:39:20 +03:00
parent cffc448890
commit 370ff3c2b6
@@ -3,10 +3,13 @@
*/
#include "HousingTutorialSession.h"
#include "DatabaseEnv.h"
#include "HousingMgr.h"
#include "HousingTutorialPackets.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "SpellMgr.h"
#include "WorldSession.h"
namespace Housing
@@ -16,6 +19,37 @@ namespace Housing
constexpr uint32 HousingTutorialQuestId = 91863;
constexpr uint32 HousingTutorialAllianceSpellId = 1258476;
constexpr uint32 HousingTutorialHordeSpellId = 1258484;
bool TeleportToTutorialFallback(Player* player)
{
if (!player)
return false;
uint32 const exteriorMapId = sHousingMgr.GetExteriorMapId(player);
QueryResult plotResult = CharacterDatabase.PQuery(
"SELECT PlotID FROM housing_plot_template WHERE ExteriorMapID = {} "
"ORDER BY PlotID, VerifiedBuild DESC LIMIT 1",
exteriorMapId);
if (!plotResult)
{
TC_LOG_ERROR("housing", "Housing tutorial fallback has no plot template for exterior map {}",
exteriorMapId);
return false;
}
uint8 const plotId = plotResult->Fetch()[0].GetUInt8();
PlotState plot;
if (sHousingMgr.LoadPlot(player, plotId, plot) != Result::Success)
{
TC_LOG_ERROR("housing", "Housing tutorial fallback failed to load plot {} on exterior map {}",
uint32(plotId), exteriorMapId);
return false;
}
player->TeleportTo(plot.ExteriorMapId, plot.DestinationX, plot.DestinationY,
plot.DestinationZ, plot.DestinationO);
return true;
}
}
void HandleStartTutorial(WorldSession* session,
@@ -54,12 +88,23 @@ namespace Housing
? HousingTutorialHordeSpellId
: HousingTutorialAllianceSpellId;
// Sniff/reference-backed retail entry point. The spell owns the faction
// specific transition to Razorwind Shores / Founder's Point and keeps
// tutorial travel behavior in the normal spell pipeline.
player->CastSpell(player, spellId, false);
// Sniff/reference-backed retail entry point. If this server's spell data
// does not contain the retail transition spell, fall back to a verified
// Housing plot-template destination instead of leaving the dashboard action
// with no visible effect.
if (sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
{
player->CastSpell(player, spellId, false);
TC_LOG_INFO("housing", "Started Housing tutorial transition for player {} using spell {}",
player->GetGUID().ToString(), spellId);
return;
}
TC_LOG_INFO("housing", "Started Housing tutorial transition for player {} using spell {}",
player->GetGUID().ToString(), spellId);
TC_LOG_WARN("housing", "Housing tutorial transition spell {} is missing; using plot-template fallback for player {}",
spellId, player->GetGUID().ToString());
if (!TeleportToTutorialFallback(player))
TC_LOG_ERROR("housing", "Housing tutorial transition could not be started for player {}",
player->GetGUID().ToString());
}
}