CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
571 stars 85 forks source link

Road selection panel to utilize base game memory of the road selections #710

Open kianzarrin opened 4 years ago

kianzarrin commented 4 years ago

In #631 I implemented basic road selection panel: Screenshot (346)

Introduction

Request

The TMPE should take advantage of the fact that games memorizes road selections and remember the state of the buttons based on road selection. (it can create a dictionary of road selection -> button state). what I want is:

  1. user makes a road selection and activates TMPE high-priority button.
  2. user plays the game for a while and makes other road selections.
  3. user selects the road from step 1.
  4. Expected behaviour: the high-priority button should be in active state. Current behaviour: TMPE forgets the state of the high-priority button at this stage.

Discussion about more possibilities:

Consider this scenario

  1. user makes a road selection and activates TMPE high-priority button.
  2. user modifies the road selection.
  3. user connects new roads to the road from step 1.
kianzarrin commented 4 years ago

The vanilla game memorizes past road selections. To observe/prove this follow these steps: A) modify road selection on one road (screenshot 1) B) modify road selection on another road (screenshot 2) C) click on the section from step A (screenshot 3) Observe) game has remembered modifications from step A (screenshot 3)

images... ![Screenshot (530)](https://user-images.githubusercontent.com/26344691/74737266-28e8c100-525d-11ea-9842-e03b103f470f.png) ![Screenshot (532)](https://user-images.githubusercontent.com/26344691/74737272-2be3b180-525d-11ea-868c-0cae764889fc.png) ![Screenshot (534)](https://user-images.githubusercontent.com/26344691/74737274-2e460b80-525d-11ea-980d-76519965d907.png)
kianzarrin commented 4 years ago

The game does not memorize the state of the priority road toggle but rather recalculates it every time you select a road. to test this out follow these steps: A1) create a road network and disable all traffic lights on incoming roads. B1) select the road, observe that tuning the priority toggle on and off will insert/remove stop sings on incoming roads. (screenshot 1 and 2- its a bit tricky to get the nice info view state I have on this screenshot: I selected a minor road -> clicked the road selection button -> selected the main road -> clicked on the Junctions tab) C1) select another road, then re-select the road from step B1. D1) Observe that the priority toggle is on. This is not because of memory but rather because all incoming roads have stop signs. To prove this: A2) make another road selection. observe that the priority toggle is off. B2) manually enable stop signs on incoming roads (screenshot 3) . Observe that the Priority toggle is still off because CS has not recalculated it yet. C2) Select another road and the select the road from Step A2. Observe that the priority toggle is on now (screenshot 4). CS has recalculated it.

images... ![Screenshot (545)](https://user-images.githubusercontent.com/26344691/74741083-dca17f00-5264-11ea-8371-5b7a15995747.png) ![Screenshot (546)](https://user-images.githubusercontent.com/26344691/74741089-df9c6f80-5264-11ea-9185-4ee81abb5b9b.png) ![Screenshot (547)](https://user-images.githubusercontent.com/26344691/74741096-e0cd9c80-5264-11ea-8800-02195d6e6e3f.png) ![Screenshot (548)](https://user-images.githubusercontent.com/26344691/74741102-e2976000-5264-11ea-885e-08e474569c29.png)
kianzarrin commented 4 years ago

Perk: The paths cannot overlap. To observe this follow these steps: A) create a road network that allows overlapping paths (screenshot 1) B) make a road selection (screen shot 1) C) click on a segment outside of the current selection,. then modify road selection in a way that it overlaps with step B. (screenshot 2) D) click on the road selection from step B (screenshot 3) Observe) road selection has changed to exclude segments from step C (screenshot 3)

images... ![Screenshot (539)](https://user-images.githubusercontent.com/26344691/74737350-5a618c80-525d-11ea-92d4-03b965c89fc3.png) ![Screenshot (540)](https://user-images.githubusercontent.com/26344691/74737357-5d5c7d00-525d-11ea-8868-abd01482f59d.png) ![Screenshot (541)](https://user-images.githubusercontent.com/26344691/74737359-60f00400-525d-11ea-97ef-d609ab8119e0.png)
originalfoo commented 4 years ago

I think there's possibly some additional stuff going on here.

For example, if I create short road and name it "Steve", then I start extending that road, the new segments will often adopt the same road name, like the route is being automatically extended.

originalfoo commented 4 years ago

Roads can also be "joined", for example this scenario:

  A     B     A
----- ----- -----

So if I've got a segment named A, then one named B, then another named A; game sees 3 routes (A, B, and another A). If I rename B to A the game now sees 1 route consisting of 3 x A segments.

I notice this a lot when editing bridges (or tunnels, etc) on highways. For example, I bulldoze part of my highway to build new bridge or something, place bridge whch gets auto-named, the game sees break in the route due to change in road name. When I rename the bridge to same as highway, game now sees it all as one route again.

kianzarrin commented 4 years ago

I see. So that is where all this is stored.

kianzarrin commented 4 years ago

@aubergine10 So if I've got a segment named A, then one named B, then another named A; game sees 3 routes (A, B, and another A). If I rename B to A the game now sees 1 route consisting of 3 x A segments.

Can you please test this again to see if it works the same sense the Sunset Harbour update? If so please tell me how to reproduce this.

originalfoo commented 4 years ago

Doing quick test...

images etc... First I get a road like so: ![image](https://user-images.githubusercontent.com/1386719/79823370-8c8d8880-838b-11ea-88da-522a06bec5aa.png) Now I rename the middle segment (just drag route from side road in to the main road): ![image](https://user-images.githubusercontent.com/1386719/79823411-a5963980-838b-11ea-8896-11786c42b397.png) As can be seen, two ends of road are Nancy Adams street, but they are not connected (due to middle segment renamed): ![image](https://user-images.githubusercontent.com/1386719/79823440-bfd01780-838b-11ea-9106-380c6fe4f18b.png) ![image](https://user-images.githubusercontent.com/1386719/79823489-dbd3b900-838b-11ea-983b-dd48ad975187.png) So now I rename middle segment to Nancy Adams Street: ![image](https://user-images.githubusercontent.com/1386719/79823537-f017b600-838b-11ea-8619-201946c3dc06.png) And I was certainly not expecting this: ![image](https://user-images.githubusercontent.com/1386719/79823589-12113880-838c-11ea-92c1-fa5b586961bd.png) ![image](https://user-images.githubusercontent.com/1386719/79823601-16d5ec80-838c-11ea-8975-7c0d0877a925.png) ![image](https://user-images.githubusercontent.com/1386719/79823607-1b9aa080-838c-11ea-8705-28e407fffc8e.png) So yeah, looks like something did in fact change in SH. I have no idea how it's remembering the middle segment is connected to top side-road. Or even how that's possible. So then I remove top side road from middle segment route: ![image](https://user-images.githubusercontent.com/1386719/79823695-44bb3100-838c-11ea-8cfa-1a9c000c50b1.png) And now I have three segments (left, ceter, right) all named Nancy Adams Street but the game is no longer seeing them as the same road.

So... I have no idea how this is happening. Like, prior to SH, those would have become single road.

Is there now actually some internal store somewhere of 'roads' which allows adjacent but separate roads of same name to coexist?

originalfoo commented 4 years ago

It's like the "green line" thing is now the single source of truth for what a "road" is, rather than the segment names.

It might be worth doing some digging in to that green line thing if you have time, see what code it triggers. Because the game is definitely now remembering the green line (as far as I can tell from some basic testing).

kianzarrin commented 4 years ago

Green Line is a single continuous line and cannot have branches. I was unable to change Road names without creating branch so maybe what really has changed is the mechanism to change Road names but this is just a speculation I should really read the code

kianzarrin commented 4 years ago

It might be annoying to people (I for one don't care but I think @aubergine10 does) that the only way to adjust which portion of the road will the road selection panel affects is to change road names.

I guess in most cases it does not matter as people usually change rules for the whole road but what about the scenario where someone wants to change rules only for a portion of a named road? he has to change road name. (EDIT: I mean road name gets modified when he adjusts the green adjustment path).

originalfoo commented 4 years ago

I'm fine with it working based on road names (acutally, that's how I'd expect it to work).

I'm just confused by the fact that the green bar no longer seems to follow the road names.

More specifically, I am assuming there is at least a cache, perhaps even a persisted list/dictionary, that the green bars are using to remember which segments they applied to regardless of road name.

And if such a thing exists, maybe we could find use for it :) Also, I want to know why CO would make that sort of change - seems odd to do something like that just for the sake of it. It merits further investigation.

But in my digging so far, I've not found it. Which entry points should I be starting from to work out how that green bar is rememembering segments without the aid of road names?

kianzarrin commented 4 years ago

It's like the "green line" thing is now the single source of truth for what a "road" is, rather than the segment names.

conducting some tests I can confirm that the behavior has indeed changed and its not due to a change in naming mechanism.

Screenshot (899)

originalfoo commented 4 years ago

Have you found the entry point for where that green bar gets initialised? I've found pretty much all the stuff regarding naming but haven't found the green bar stuff yet. It will be interesting to see what it's using.

There are some bufffers on segments, etc., for temporary use, but they wouldn't facilitate multiple 'roads' that the green bar now seems to be remembering. So there must be some dictionary (or similar) that's collecting the segments associated with each "green bar" defined road.

yackimoff commented 4 years ago

And now I have three segments (left, ceter, right) all named Nancy Adams Street but the game is no longer seeing them as the same road.

Might custom name flag be at play here?