joaofarias / csl-traffic

A WIP mod for Cities: Skylines to improve traffic.
91 stars 30 forks source link

Suggestion: Revert to vanilla roads on save #17

Closed originalfoo closed 9 years ago

originalfoo commented 9 years ago

I've been trying to track down the relentless assumption that all bugs in the game are caused by Traffic++. For example, I've seen error messages that clearly indicate they are caused by other mods such as 81 Tiles, and yet people still say it's Traffic++ and then get angry when unsubscribing Traffic++ doesn't solve the problem.

The I realised the root of this issue is one simple statement on the T++ description page:

This mod adds new components to the game which means that maps saved with this mod CANNOT be opened without it! You don't need to start a new game to use this mod but you should backup your save file beforehand.

Everyone assumes that whatever error they get is because of that.

So....

Is it possible to revert the custom roads to vanilla roads on save, and then back to custom roads on load?

A list of the affected roads would be included with the save, to allow fast re-customisation on load. It's a shame you can't just edit the segments directly to change their type at the data level, as that would remove the need to destroy/rebuild roads on upgrade. :/

This would eradicate the long running issue of T++ breaking saves that used T++ if when loaded T++ is not there. More importantly it will break the perception that all errors are caused by T++.

joaofarias commented 9 years ago

The amount of work that that would imply is not worth it. Here's the steps I would have to take:

1- (On save) Find all custom roads 2- Replace them with their respective vanilla road (implies destroying and bulding anew) 2a - For each road replaced, map the old lane Ids to the new ones as to not break intersection routing 2b - Update the list of lanes with their new Ids 3- Save the segment Ids to be able to switch on load 4- (On load) Replace all segments with the cusom types (implies destroying and building anew) 4a - For each road replaced, map the old lane Ids to the new ones as to not break intersection routing 4b - Update the list of lanes with their new Ids

And this is from the top of my head. I don't know what other problems I would run into to make this happen.

If you can think of a better statement to put in the description, let me know.

originalfoo commented 9 years ago

Now that there's vehicle restrictions and speed restrictions, is the only remaining hard-coded aspect of the roads their skin?

...If so, could they be added to menus in same way as your first test of vehicle restriction UI (where you added a bus to roads menu) - sort of a virtual road. And when placed, a normal road is placed but then see if there's a way to change the skin of just that road (and keep a list of such roads that gets saved with game do repeat process on-load without needing to scan all roads)...? The lane vehicle/speed restrictions are already stored separately, so is there a way to store the skinning separately? (I guess it has something to do with prefabs and that makes things more complex?)

... doing it this way removes the need to do anything on save, all the work is done on load and then intermittently when roads are built/upgraded/etc.

originalfoo commented 9 years ago

Better warning text:

CAUTION: If you use custom roads (bus lanes, pedestrian road, small gravel path) those are stored in your saves and will need Traffic++ running when those saves are loaded to avoid errors. If you want to load a save with custom roads, but not activate Traffic++, you can run Traffic++ in Ghost Mode.

(Ghost mode text would be hyperlinked to dedicated forum topic about ghost mode).

Doesn't ghost mode already revert roads to default states?

originalfoo commented 9 years ago

Now that we have Moo's attention, maybe we could speak to him to see if CO can give us something that makes custom roads easier to deal with?

joaofarias commented 9 years ago

I don't see a way that could work without rewriting the render methods and possibly the render manager to use different meshes and textures.

Ghost mode does not change any road. Let me try to explain how it works with an example:

The normal two-lane road is called "Basic Road" in-game. To make my busway, I clone this road, make the appropriate changes and call it "Busway". These are the names the game uses when saving and loading - it fetches the appropriate prefab by name. When Ghost Mode is active, instead of cloning the two-lane road, I add it again to the prefab list but with a different name ("Busway" in this case). So, when the game is loading, both "Basic Road" and "Busway" reference the same prefab - the vanilla "Basic Road".

I hope that's clear.

I'm still waiting for an answer from TotallyMoo. I guess not today, since there's an AMA starting soon.

originalfoo commented 9 years ago

Great - and very clear - explanation of Ghost Mode!

Perhaps if CO could add a new property to roads, a sort of "fallback default" - so custom road prefab says "If you don't know what I am, use this prefab instead" or something like that? So rather than game borking on unknown prefab, it just reverts to one of the standard prefabs automagically.

joaofarias commented 9 years ago

That would be ideal, yes.