Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: NPC::Load() ---> ship->FinishLoading() too early? #2420

Closed
EndrosG opened this issue Apr 17, 2017 · 4 comments
Closed

bug: NPC::Load() ---> ship->FinishLoading() too early? #2420

EndrosG opened this issue Apr 17, 2017 · 4 comments
Labels
question A question re: how something works, or requesting support

Comments

@EndrosG
Copy link
Contributor

EndrosG commented Apr 17, 2017

I have a mission definition with a NPC inside which uses a customized ship definition.
That ship has an outfit which is defined in a different file (damage_outfits.txt).
Both are in the same data/ folder of the same plugin.

damage_outfits.txt
testing_mission_hull_breach.txt

If the outfit is not defined in the mission file but in the external outfit file, I get a soft error.

Unrecognized outfit in Freighter "Broken Hull"

The error does not show up, if the outfit in question is defined in the mission file. That's the reason for the outfit definition with some XX in the name - for quick testing.

After the mission had been offered to the player and became part of the savegame, I tested it again.
There was no error for the npc ship (inside a mission) in the savegame. Only for the ship in the mission definition file. I renamed the ship in the savegame to "Almost Broken Hull" for verification...
If I changed the outfit in the savegame to something unknown, I received (not surprisingly)

Unrecognized outfit in Freighter "Broken Hull"
Unrecognized outfit in Freighter "Almost Broken Hull"

So it seems that the ship->FinishLoading() is called too early for ships inside mission definitions (i.e. during NPC::Load)

@endless-sky
Copy link
Collaborator

If a ship has any outfits at all, you'll need to define it as a "ship" object and reference it in the mission, rather than defining it inline in the mission.

Really, inline ship definitions are only intended to be used in saved game files for reading back in the exact state of an NPC that has already been "instantiated." But, the same function is used for loading NPCs from a game data file or from a saved game, which is why it doesn't complain if a game data file defines a ship inline.

@EndrosG
Copy link
Contributor Author

EndrosG commented Apr 19, 2017

Because it is used in Terraforming 3 to define the asteroid, I never really thought that way.
I thought that defining an entire variant class would be "too much" for a single use.

@ReimeiSky
Copy link
Contributor

ReimeiSky commented Apr 19, 2017

[warning: just woke up]
Consider the Kestrel.
We define the Unknown Ship Type as an entire ship- not just a variant- to make the mission work properly.

@EndrosG
Copy link
Contributor Author

EndrosG commented Apr 19, 2017

@Bladewood : I know, that the Kestrel file has that Unknown Ship Type definition. But since the terraforming asteroid is defined "inline", I never thought that inline definitions were not supposed to be used in mission definitions.

But it's absolutely okay for me if this issue get's a unlikely or wontfix label assigned.

@endless-sky endless-sky added the question A question re: how something works, or requesting support label May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question re: how something works, or requesting support
Projects
None yet
Development

No branches or pull requests

2 participants