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

Factories don't save their 'production complete' flag when idle #50

Open
ldicker83 opened this issue Jun 25, 2018 · 2 comments
Open

Factories don't save their 'production complete' flag when idle #50

ldicker83 opened this issue Jun 25, 2018 · 2 comments
Labels
bug Something isn't working intermediate A task that doesn't require a deep understanding of the code base
Milestone

Comments

@ldicker83
Copy link
Collaborator

I have to investigate this further but the title basically states the issue. Upon save, a factory that is in an idle state with a completed product doesn't save its 'production complete' flag -- effectively it gets cleared. The product waiting flag is still saved correctly.

Not sure if this only happens with idle factories or if it affects factories in any state.

@ldicker83 ldicker83 added the bug Something isn't working label Jun 25, 2018
@ldicker83 ldicker83 added this to the v1.0.0 milestone Jun 25, 2018
@DanRStevens
Copy link
Member

DanRStevens commented Oct 19, 2021

This issue is a bit old now, so the source code structure has likely changed quite a bit since it was opened.

Currently the following fields are serialized:

NAS2D::Dictionary Factory::getDataDict() const
{
	auto dictionary = Structure::getDataDict();
	dictionary.set("production_completed", mTurnsCompleted);
	dictionary.set("production_type", mProduct);
	return dictionary;
}

The Factory class has other fields, which are not serialized.

private:
	int mTurnsCompleted = 0;
	int mTurnsToComplete = 0;

	ProductType mProduct = ProductType::PRODUCT_NONE;
	ProductType mProductWaiting = ProductType::PRODUCT_NONE; /**< Product that is waiting to be pulled from the factory. */

	ProductionTypeList mAvailableProducts; /**< List of products that the Factory can produce. */

	ProductionSignal mProductionComplete; /**< Signal used when production is complete. */

	const StorableResources* mResources = nullptr; /**< Pointer to the player's resource pool. UGLY. */

This case in particular would seem to suggest we need to serialize the mProductWaiting field:

dictionary.set("production_waiting", mProductWaiting);

Related to that, is we would need to add corresponding loading code. Loading is currently done in MapViewStateIO.cpp:
void MapViewState::readStructures(Xml::XmlElement* element)


Edit: Actually, I'm not quite sure what this issue is saying. There is save/load code for a "production_completed" field, but not for a "production_waiting" field, which seems to be the opposite of what the issue is saying. Perhaps things should be clarified a bit here.


Related: #830

It seems like we need an easier way to ensure all state fields are saved and loaded for each structure type.

@ldicker83
Copy link
Collaborator Author

The title doesn't explain it well, it's the mProductWaiting field that needs to be saved/loaded. I don't think there are other issues besides that.

It's been quiet some time since I noticed this and I haven't looked at it since then.

@ldicker83 ldicker83 added the intermediate A task that doesn't require a deep understanding of the code base label Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working intermediate A task that doesn't require a deep understanding of the code base
Projects
None yet
Development

No branches or pull requests

2 participants