net-lisias-ksp / KourageousTourists

GNU General Public License v2.0
1 stars 1 forks source link

Prevent creating Contracts for absent Anomalies #2

Closed Lisias closed 2 years ago

Lisias commented 2 years ago

On JNSQ, some anomalies were removed.

This makes some Contracts not fulfillable . Not good.

Find a way to prevent Contracts from being issued for missing anomalies (being it JNSQ or not)

Lisias commented 2 years ago

Apparently, Kopernicus (the framework in which JNSQ is implemented) is not really removing the anomalies from the GameDatabase . The Contract Generator randomly selects one anomaly from the selected CelestialBody.

If an absent anomaly is being selected, it's because Kopernicus is not really removing the anomaly from the damned thing, only disabling it somehow.

Checkink Kopernicus' sources...

Lisias commented 2 years ago

Nah…. I was wrong.

The problem os KT assuming the anomaly exists if if finds the Body's name in the Reached Bodies. It thinks the anomaly is always there.

The problem is on KT for sure.

Lisias commented 2 years ago

Well, found a fix.

I learnt how to enumerate all PQSCities and PQSCities2 on the game, and by a happy "coincidence", the name of the Anomaly is also used on the thing.

So I think we can assume that if the Anomaly's name is not found on the PSystemManager, the Anomaly itself is absent.

Case (hopefully) closed. Implementing it.

Lisias commented 2 years ago

An interesting collateral effect of the solution is that one can simply create Anomalies for KT and forget about dependencies.

Just patch the new anomalies into KOURAGE's node, and let KT sort the mess on loading. Not a big deal.

Additionally, in the case anyone thinks it's a good idea to create/destroy Anomalies at runtime, the check is done on every Scene change (when needed - the thing is lazy run).

Lisias commented 2 years ago

Fixed on commit: https://github.com/net-lisias-ksp/KourageousTourists/commit/8ef78305f8f65ba58acb41d3568a9339a7152b9c