Skip to content

[Fix] Purge orphaned achievement criteria progress at startup#291

Merged
billy1arm merged 1 commit into
mangosthree:masterfrom
r-log:fix/achievement-progress-startup-cleanup
Jul 4, 2026
Merged

[Fix] Purge orphaned achievement criteria progress at startup#291
billy1arm merged 1 commit into
mangosthree:masterfrom
r-log:fix/achievement-progress-startup-cleanup

Conversation

@r-log

@r-log r-log commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Paired with mangostwo/server#238 and billy1arm/MangosFour-M3#2 (same fix across the WotLK/MoP-M3 forks).

Adds a global, unconditional startup purge of orphaned character_achievement_progress rows (criteria no longer present in DBC), mirroring the existing completed-achievement purge.

Startup already drops orphaned completed achievements in LoadCompletedAchievements() (a nonexistent achievement id is deleted for all characters). Progress rows had no equivalent: an invalid criteria was removed only lazily, per-character, when an affected character logs in (AchievementMgr::LoadFromDB). Orphaned progress rows belonging to characters that never log in therefore persisted indefinitely.

New AchievementGlobalMgr::CleanupOrphanedCriteriaProgress() runs once at startup, right after LoadCompletedAchievements() (criteria/DBC stores are already loaded by then): SELECT DISTINCT criteria, validate each against sAchievementCriteriaStore, delete invalid ones for all characters. No-op when the table is empty or nothing is orphaned; same log wording as the existing per-character purge. Code-only, no schema change.

Note (separate, not addressed here): CharacterDatabaseCleaner — which had the only other global progress purge — never runs on any core, because nothing ever sets cleaning_flags in saved_variables (schema-default 0, only ever read and reset). That's a latent design question (what should set the flags) worth its own discussion.


This change is Reviewable

Startup already removes orphaned rows from `character_achievement`
(LoadCompletedAchievements), but `character_achievement_progress` rows
whose criteria no longer exists in Achievement_Criteria.dbc were only
deleted lazily, one character at a time, when the owning character logs
in (AchievementMgr::LoadFromDB). Rows belonging to dormant characters
therefore persisted indefinitely.

Add AchievementGlobalMgr::CleanupOrphanedCriteriaProgress(), called once
at startup right after LoadCompletedAchievements, which deletes progress
rows for any criteria id no longer present in the criteria store. Same
lookup and log wording as the existing per-character purge; no-op when
nothing is orphaned.
@billy1arm
billy1arm merged commit 6960a5d into mangosthree:master Jul 4, 2026
6 checks passed
@r-log
r-log deleted the fix/achievement-progress-startup-cleanup branch July 5, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants