thepeacockproject / Peacock

The Peacock Project is a HITMAN™ World of Assassination trilogy server replacement.
https://thepeacockproject.org
GNU Affero General Public License v3.0
367 stars 57 forks source link

controller.challengeService.removeChallenge unable to remove global challenges #437

Closed Burn-the-w1tch closed 4 months ago

Burn-the-w1tch commented 5 months ago

Describe the bug controller.challengeService.removeChallenge is unable to remove global challenges. Returns the error: TypeError: Cannot read properties of undefined (reading 'get') To reproduce Put this in a script to repro, this is to remove a challenge from the escalation track: controller.challengeService.removeChallenge("7c4e7906-ad19-46c0-96f4-4fc301a562b4", "h3")

RDIL commented 5 months ago

Global challenges are special and aren't handled by the challenge system - they are a config.

Burn-the-w1tch commented 5 months ago

Is there any way to handle them via plugin?

RDIL commented 5 months ago

You can modify the list by accessingcontroller.configManager.configs.GlobalChallenges

Burn-the-w1tch commented 5 months ago

Gotcha, thanks.

Burn-the-w1tch commented 5 months ago

Actually, this doesn't work as 7c4e7906-ad19-46c0-96f4-4fc301a562b4 is not in that config. It is only in contractdata/GLOBAL /_ESCALATION_CHALLENGES.json

Yanrishatum commented 4 months ago

This bug is caused by global challenge ParentLocationId being "", while they are registered under GLOBAL_* virtual location id.

For example: When _ESCALATION_CHALLENGES.json is being registered by Peacock, it will register their groups challenges inside a GLOBAL_ESCALATION_CHALLENGES "location". However all those challenges have a ParentLocationId value set to "", and that value is being used to determine the location id that holds the global challenge group during removeChallenge call.

Additionally, this also affects reBatchIntoSwitchedData: If challenge group first registered challenge is a global challenge, it will return an empty challenge list. (This bug prevents ability to register global-only challenge packs)

Refs:

Yanrishatum commented 4 months ago

Solutions:

My general proposal:

  1. Introduce inLocation field.
  2. Introduce an API when registering groups to make them globally visible.
    • Can be done by extra argument for registerGroup, a custom field of group definition or separate markGlobal method or along the lines.
    • During getGroupByIdLoc check if request group is global, and return merged challenge group, as with Classics.

I can prepare a PR with fix and global marker myself, as long as consensus on API is met.