mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-16 16:55:27 +00:00
fix: check the mission state before completing it from a dialogue
MissionDialogueOK accepted or completed the mission for whichever object the message named as the responder. The responder now has to be the player that sent the message, the object the dialogue belongs to has to give or take the mission (on its own or through a random mission's pool), a mission is only accepted when the player can accept it and only completed when it is ready to complete. The object's script runs after these checks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,21 @@ std::vector<uint32_t> MissionOfferComponent::ParseRandomPool(const std::string&
|
||||
return pool;
|
||||
}
|
||||
|
||||
bool MissionOfferComponent::HasMission(const uint32_t missionId) const {
|
||||
for (const auto& offeredMission : this->offeredMissions) {
|
||||
if (offeredMission.GetMissionId() == missionId) return true;
|
||||
|
||||
// A random mission stands for the missions in its pool
|
||||
CDMissions info{};
|
||||
if (!Mission::IsValidMission(offeredMission.GetMissionId(), info) || !info.isRandom) continue;
|
||||
|
||||
const auto randomMissionPool = ParseRandomPool(info.randomPool);
|
||||
if (std::ranges::find(randomMissionPool, missionId) != randomMissionPool.end()) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const OfferedMission* MissionOfferComponent::GetOfferedMission(const uint32_t missionID) const {
|
||||
const auto offered = std::ranges::find_if(offeredMissions, [missionID](const OfferedMission& other) { return other.GetMissionId() == missionID; });
|
||||
return offered == offeredMissions.end() ? nullptr : &*offered;
|
||||
|
||||
Reference in New Issue
Block a user