fix: racing meta missions and undefined behavior in mission progression

Tested that missions can still be completed
Tested that racing meta tasks are now actually possible
TODO: Tested that old characters with incomplete meta missions are brought up to speed with their current progress
This commit is contained in:
David Markowitz
2025-11-19 22:18:57 -08:00
parent a713216540
commit 4a9971d182
7 changed files with 66 additions and 14 deletions

View File

@@ -407,9 +407,7 @@ void Mission::Catchup() {
task->Progress(target);
}
}
}
if (type == eMissionTaskType::PLAYER_FLAG) {
} else if (type == eMissionTaskType::PLAYER_FLAG) {
for (int32_t target : task->GetAllTargets()) {
const auto flag = GetCharacter()->GetPlayerFlag(target);
@@ -423,6 +421,24 @@ void Mission::Catchup() {
break;
}
}
} else if (type == eMissionTaskType::RACING) {
// check if its a racing meta task ("4") and then set its progress to the current completed missions in all tasks
const auto& clientInfo = task->GetClientInfo();
if (clientInfo.taskParam1.starts_with("4")) {
// Each target is racing mission that needs to be completed.
// If its completed, progress the meta task by 1.
// at the end set the task progress to avoid sending excess msgs across the wire
uint32_t progress = 0;
for (const auto& target : task->GetAllTargets()) {
if (target == 0) continue;
auto* racingMission = m_MissionComponent->GetMission(target);
if (racingMission != nullptr && racingMission->IsComplete()) {
progress++;
}
}
task->SetProgress(progress);
}
}
}
}

View File

@@ -92,7 +92,7 @@ PrerequisiteExpression::PrerequisiteExpression(const std::string& str) {
}
bool PrerequisiteExpression::Execute(const std::unordered_map<uint32_t, Mission*>& missions) const {
bool PrerequisiteExpression::Execute(const std::map<uint32_t, Mission*>& missions) const {
auto a = this->a == 0;
auto b = this->b == nullptr;
@@ -129,7 +129,7 @@ PrerequisiteExpression::~PrerequisiteExpression() {
}
bool MissionPrerequisites::CanAccept(const uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions) {
bool MissionPrerequisites::CanAccept(const uint32_t missionId, const std::map<uint32_t, Mission*>& missions) {
const auto& missionIndex = missions.find(missionId);
if (missionIndex != missions.end()) {
@@ -155,7 +155,7 @@ bool MissionPrerequisites::CanAccept(const uint32_t missionId, const std::unorde
return CheckPrerequisites(missionId, missions);
}
bool MissionPrerequisites::CheckPrerequisites(uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions) {
bool MissionPrerequisites::CheckPrerequisites(uint32_t missionId, const std::map<uint32_t, Mission*>& missions) {
const auto& index = expressions.find(missionId);
if (index != expressions.end()) {
return index->second->Execute(missions);

View File

@@ -21,7 +21,7 @@ public:
* @param missions the list of missions to check the prerequisites against (f.e. whether they're completed)
* @return whether or not all the prerequisites are met
*/
bool Execute(const std::unordered_map<uint32_t, Mission*>& missions) const;
bool Execute(const std::map<uint32_t, Mission*>& missions) const;
explicit PrerequisiteExpression(const std::string& str);
~PrerequisiteExpression();
@@ -40,7 +40,7 @@ public:
* @param missions the mission inventory to check the prerequisites against
* @return whether or not the mission identified by the specified ID can be accepted
*/
static bool CanAccept(uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions);
static bool CanAccept(uint32_t missionId, const std::map<uint32_t, Mission*>& missions);
private:
/**
@@ -54,5 +54,5 @@ private:
* @param missions the mission inventory to check the prerequisites against
* @return whether or not the mission identified by the specified ID can be accepted
*/
static bool CheckPrerequisites(uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions);
static bool CheckPrerequisites(uint32_t missionId, const std::map<uint32_t, Mission*>& missions);
};