From 8568fd1c4635dead85ecfa6db1e6118608d8a38b Mon Sep 17 00:00:00 2001 From: dongresource Date: Sat, 19 Oct 2024 04:26:09 +0200 Subject: [PATCH] Restore the check that makes sure mob paths start from their spawn point This was added in 599bbedd and accidentally removed during the TableData refactor in c960b062. --- src/Transport.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Transport.cpp b/src/Transport.cpp index 0c43d9c..db249c8 100644 --- a/src/Transport.cpp +++ b/src/Transport.cpp @@ -388,8 +388,21 @@ NPCPath* Transport::findApplicablePath(int32_t id, int32_t type, int taskID) { void Transport::constructPathNPC(int32_t id, NPCPath* path) { BaseNPC* npc = NPCManager::NPCs[id]; - if (npc->kind == EntityKind::MOB) - ((Mob*)(npc))->staticPath = true; + + if (npc->kind == EntityKind::MOB) { + auto mob = (Mob*)npc; + mob->staticPath = true; + + Vec3 firstPoint = path->points.front(); + + // Ensure that the first point coincides with the mob's spawn point. + if (mob->spawnX != firstPoint.x || mob->spawnY != firstPoint.y) { + std::cout << "[FATAL] The first point of the route for mob " << mob->id << " (type " << mob->type + << ") does not correspond with its spawn point." << std::endl; + exit(1); + } + } + npc->loopingPath = path->isLoop; // Interpolate