Vehicle Wagon 2


Take with you a fully charged and battle-ready vehicle and take it on a rail trip. --------------------------------------------------------------------------------- Возьмите с собой полностью заряженный и готовый к бою транспорт и отправьте его в путешествие по железной дороге.

Content
21 hours ago
0.17 - 2.0
20.2K
Transportation Trains Combat

i [Implemented] Wagons removed from train

3 years ago

While testing Autodrive with 1.1, I've loaded one of the old save games I made when we worked on making our mods compatible. That save had vehicles from different mods, among them Heavy trucks.

I had set up a piece of rail with 6 vehicle wagons. The heavy truck was loaded on the second wagon from the right. Now, the mod hasn't been updated for Factorio 1.1 yet, so the prototype doesn't exist in the game, you didn't create loaded-vehicle-wagon-truck, and the entity was removed by the json migration. Now, I have 4 wagons on the tracks, then a gap where this removed wagon used to be, and then the last wagon. This doesn't look nice in my case, but I guess it could seriously mess up real games where all of a sudden lone wagons block the rails because a they were disconnected from a train by removal of non-existing entities. Even worse: think of a train with locomotives on both ends. By removing one wagon from the train, you'd get two shorter trains, and I suppose that they might move in opposite directions …

Do you think it would be possible in on_configuration_changed? I guess you keep a list of your wagons, so when a mod has been removed, couldn't you check that all wagons in your list are still valid and replace them with an empty vehicle wagon otherwise? I've no idea if this would really work, though. It may be problematic to place a wagon on a curved rail, for example, and train IDs will change if you couple/decouple wagons. Still, you may want to consider this. :-)

3 years ago

Thanks for the suggestion, but I'm not really eager to handle a case like that. I just recently fixed that it would simply crash if a mod was removed while its vehicle was loaded, and if you are removing mods without unloading affected wagons first then some manual repair seems reasonable. It's not a JSON migration removing them, it's that I don't include the entity at all in the data phase.

Just magicking new wagons into gaps left by migration-purged ones is going to have problems. It would be really nice if you could make a JSON migration to convert orphaned entities to the unloaded one, but that will only run once per VW version per save. I might instead include the unused loaded-wagon entities regardless, then scan for missing vehicles and replace them with empties. (It actually does this replacement automatically when you try to unload an orphan where the wagon is still there.) But it seems like a lot of bloat for very rare cases.

Multiple Unit Train Control has a similar scenario, because uninstalling it cold turkey means basically all your locomotives disappear. The user has to set the mod setting to "disabled" and wait a while before saving the game and uninstalling it.

3 years ago

I had a second thought, and just pushed an update with a new startup setting. This will replace all the custom-sprite wagons with tarp wagons, even if the other vehicle mods are not installed. This way they will not be deleted when you load a save without all the mods installed. If you do not try to unload these "dummy tarp" wagons, the data will remain in the game, and later on you can reinstall that vehicle mod and unload it correctly. I think this will meet your needs :-D

3 years ago

Yes, it does. Thank you! Of course, I tried to unload the vehicle, and was glad to see that it just removed the tarp, leaving the wagon intact. Now I'm thinking about a similar setting in GCKI, so that data for vehicles from removed mods can be kept until that mod becomes available again. It's not as easy as checking for invalid entities, though, because they can become invalid for various reasons (removed prototype and destroyed/mined entity). Is there any way to get at the prototype history? The prototype browser does show it, but I don't see yet how it could be read in the game.

3 years ago

I wonder how the prototype browser does it. Does it save the entire prototype structure into a global entry so it can tell when things are removed?

In my case it's easy because the vehicle in question doesn'tactually exist in the game when the mod is removed so it can't be deleted. What good would saving data for entities that are deleted do, unless they are "virtual" like in my case? They will not be recreated automatically if you reinstall the mod after having saved it without the mod first.

3 years ago

I wonder how the prototype browser does it. Does it save the entire prototype structure into a global entry so it can tell when things are removed?

I've no idea. But it's not only about things that have been removed, but also about things that have been modified by mods. You can see what's called "prototype history" in the prototype browser directly in the game: It's just below the title bar of entity tooltips, in a bluish color, so you can see the order in which what mods changed the entity. The data must exist somewhere, but I don't know where.

What good would saving data for entities that are deleted do, unless they are "virtual" like in my case? They will not be recreated automatically if you reinstall the mod after having saved it without the mod first.

Ooops, you're right! It seemed to make sense at the time, but it obviously was a thinko. :-/

New response