The International Simutrans Forum

 

Author Topic: Destruction of the trolley bus wire by barbarian city  (Read 732 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran jp

  • *
  • Posts: 483
  • Languages: ja
Destruction of the trolley bus wire by barbarian city
« on: September 09, 2019, 12:46:21 PM »
Hi there, Ranran's back from the summer vacation!  :)


Anyway, Ranran's trolleybus company has long suffered from damage caused by barbarians destroying overhead wire.
A trolley bus that had been operating normally for a long time suddenly showed "No route" and got stuck. It was a mystery. (´・ω・`)
Detective Ranran searched for the cause and found that someone had cut the trolley wire that was previously connected. This is a criminal act.
This happened over and over again. Scotland Yard is famous for incompetence. Their notoriety has reached as far as Jalapagos. They do not work this time too.
However, fortunately, detective Ranran finally succeeded in capturing the video of the criminal destroying the overhead wire.
Check it out.





OH MY PIG! See? The barbarians are the people of the city hall!
The city destroyed my trolley wire and road to make an intersection without my permission. IT'S MINE! (´・ω・`)らんらんのー
Not only that, that devil stole its removal cost from me. NO WAY! (´・ω・`)そんなー


This time I used the "Grow city tool" to reproduce, but this should also occur in natural city growth. Because I have suffered many times from this barbarism. Silly vandalism also paralyzes road traffic and sometimes blocks bus and truck routes.
The name of the city is simcity, but this game is not simcity. So I cannot build a new police station and increase their budget.  :::)
If this is Civilization I will definitely bring that city back to the ash though...  ::(
Anyway, we must always monitor the occurrence of disasters and deal with abnormalities manually.
Thus it is difficult to operate a trolley bus. (´・ω・`)

Offline Phystam jp

  • *
  • Posts: 246
  • Pak256.Ex developer
  • Languages: JP, EN, EO
Re: Destruction of the trolley bus wire by barbarian city
« Reply #1 on: September 09, 2019, 04:01:44 PM »
I don't know why the diagonal roads are replaced to the other rectangle route when the city growth.
I thought that the issue came from cityrule.tab, but I couldn't find it...

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2720
  • Languages: EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #2 on: September 09, 2019, 05:48:11 PM »
This is not the only act of barbarism that the city councils do! Cities think nothing of build low bridges over rivers and so blocking most river traffic that needs double clearance.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #3 on: September 13, 2019, 11:50:53 AM »
Thank you for your report. In principle, this code should be unchanged from Standard, as I have not altered the city growth code, although there may be some peripheral parts of code that do not appear to be city growth code that are used by it in this connexion.

Can anyone confirm whether this can be reproduced in Standard (with Pak128.Britain, as the pakset cityrules.tab may make a difference)?

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2700
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: Destruction of the trolley bus wire by barbarian city
« Reply #4 on: September 13, 2019, 12:34:45 PM »
I remember there was a recent (maybe a few years?) change in city growth regarding diagonal roads. Cities growing over diagonal roads were quite ugly, so the algorithm was modified to rebuild them to be more rectangular. I'm not sure it it was modified in standard or extended (experimental at that time).

Offline Freahk

  • *
  • Posts: 133
  • Languages: DE, EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #5 on: September 13, 2019, 12:51:41 PM »
Replacing diagonals is not a bad idea, however it should consider trolley bus catenaries and optimally place these on the new road tiles, replacing the diagonals. Alternatively, it could simply prevent destructing those roads.

Additionally, there needs to be some consideration for other objects that can be placed on the same tile as a (diagonal) road. E.g. tramways or roadsigns.

Offline Ranran jp

  • *
  • Posts: 483
  • Languages: ja
Re: Destruction of the trolley bus wire by barbarian city
« Reply #6 on: September 13, 2019, 01:05:51 PM »
I think this bug is unrelated to cityrules.tab.
In cityrules we can define road and building construction conditions, but not destructive conditions.

I tried to reproduce this bug in standard, but this behavior doesn't seem to be in the standard.


On the other hand, Extended will remove roads that are no longer needed when an intersection is made. And at the same time as the road is removed, the trolley wire is also removed.
I think this behavior is specific to extended.

EDIT:
Roads on tiles outlined in red will be destroyed automatically in Extended.


Certainly the intersection is not beautiful.
« Last Edit: September 13, 2019, 01:21:06 PM by Ranran »

Offline Ranran jp

  • *
  • Posts: 483
  • Languages: ja
Re: Destruction of the trolley bus wire by barbarian city
« Reply #7 on: September 14, 2019, 09:58:32 AM »
I read the code and identified a function that does this, also I found the thread at the time it was implemented.
Yes, this is a feature that only existed in extended. This function is remove_excessive_roads.
This feature is currently flawed as I reported as a bug. Also Freahk pointed out the possibility of road signs being removed.
But this was not correct. At that time, the barbarians somehow leave it without destroying the road sign. And if the player clicks on that left sign, Simutrans crashes!
Ughhhhh! Ranran stepped on a landmine set up by Barbarian. (´・ω・`)


In any case, it is necessary to correctly implement the processing related to the road of the tile d3 and the objects on the road.
Currently, city road expansion is performed in this way:

Yellow is an electrified road; Blue arrow is road sign; Red tiles are about to build a new road; Gray is a non-electrified road
 :warning: NOTE: A landmine in the form of a sign is placed in d3. Don't click it!  ;)

As Freahk suggested,
A. Don't destroy roads with overhead wire and road sign
B. Reposition overhead lines and signs to new routes



I think we should choose either method and add it.
B may be a little more work.
It is necessary to deal individually with the relocation of overhead wires and relocation of signs.
« Last Edit: September 14, 2019, 10:11:57 AM by Ranran »

Offline Freahk

  • *
  • Posts: 133
  • Languages: DE, EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #8 on: September 14, 2019, 10:34:49 AM »
Another point that just came in mind are waypoints. These also have to either prevent road destruction or have to be moved automatically.

I guess a mix of A and B would be best, except if someone wants to do some really careful thoughts about the roadsigns.
For your simple example, moving the sign one tile ahead should work but what happens if one tile ahead already is a T crosssing?
as simply moving these one tile ahead or placing these on the newly constructed tile, whic is a T crossing, will for some setups create unexpected behavior.
Moving overhead catenaries should not be a problem as these road destructions always happens to a 2x2 square of roads.
e.g.
r r
r r
will become
r -
r r

So the only thing we have to do is moving trolleybus wires and waypoints from the road tile that should be removed over to the tile on the opposite side of that square.

Offline wlindley us

  • Devotee
  • *
  • Posts: 975
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Destruction of the trolley bus wire by barbarian city
« Reply #9 on: September 14, 2019, 12:24:24 PM »
In the example shown above, if the roadsign ribi points 'east' it should be moved down; if the ribi points 'south' it should be moved left -- is that correct?

Also, could it be problematic that neighboring tiles can now be one-way?
I do hope Ranran's "B" can be implemented.

Offline Ranran jp

  • *
  • Posts: 483
  • Languages: ja
Re: Destruction of the trolley bus wire by barbarian city
« Reply #10 on: September 14, 2019, 02:29:28 PM »
Quote
Another point that just came in mind are waypoints.
You've made a good point. Road destruction that is unrelated to the player's will may cause "no route" regardless of electrification.
When I tried it, I couldn't reach the coordinates specified in wyapoint so it caused "no route".
Is it easy to reposition scheduled coordinates automatically?

Quote
In the example shown above, if the roadsign ribi points 'east' it should be moved down; if the ribi points 'south' it should be moved left -- is that correct?
Yes. Sorry, my image shown above was misleading.  :-[
Strictly speaking, a sign placed on the diagonal is specified as an image facing the exit.


In the case of B, it may not be possible to move the sign because the another tile is already occupied by another sign.
That said, it doesn't make sense to leave a sign on the excessive road, because vehicles can avoid it.

Offline Freahk

  • *
  • Posts: 133
  • Languages: DE, EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #11 on: September 14, 2019, 03:02:56 PM »
Quote
Is it easy to reposition scheduled coordinates automatically?

I don't know, but it is possible to programmatically create and delete waypoints, so if you know the location of the new and the old waypoint and you know all waypoints on the old location, this should not be too hard.
We know the old location as this is the one to be destructed. Calculating the new one in that square is also not a problem.
However, I don't know if there is any location->waypoint map in the game. If not we have to look into all lines, which could potentially be too slow.
On the other hand, stations know which lines use them and when you place a new stop on a tile that has a waypoint on it, the stop will immediately know of this line serving that stop, so this also should not be an issue.

As I got Simutrans integrated into CLion IDE (creating the cmake files was awful for a cmake newbie), I'll have a look at it and will try to fix this.
« Last Edit: September 14, 2019, 05:05:41 PM by Freahk »

Offline Freahk

  • *
  • Posts: 133
  • Languages: DE, EN
Re: Destruction of the trolley bus wire by barbarian city
« Reply #12 on: September 17, 2019, 11:09:05 AM »
Function names are quite confusing as two out of thre remove_excessive_roads functions do not actually remove any roads from the map. The only one that does is never used. The others only mark roads around the current groundas "to be removed" in the passed road network plan by adding a koord=>false entry to the road network plan.
Same goes for fixup_road_network_plan, which does the same for multiple grounds.
So I propose refactoring this to something like locate_excessive_roads and locate_road_network_fixes.
This is just some cosmetics however, I consider it to be very important for code readability.
As there is only exactly one external usage for fixup_road_network_plan and remove_excessive_roads, refactoring should be safe.

Also, removal/fixup itself does not have a function on it's own but exactly the same code is used twice. This is done at two places:
https://github.com/jamespetts/simutrans-extended/blob/59f9d9d7de60c2bdd66610be8d194a82d6f319bd/simcity.cc#L3395
https://github.com/jamespetts/simutrans-extended/blob/59f9d9d7de60c2bdd66610be8d194a82d6f319bd/simcity.cc#L5050
We should move this to an apply_road_network function, removing (koord=>false) and adding(koord=>true) roads on the map, otherwise it is very likely that a bug in these will be fixed in the future at only oe place, leaving the other bug intact.
I guess such a function would be best placed in karte_t, as it makes changes to the map and is not related to an instance of any ground as it affects many.
Alternatively, maybe add it statically to the grund_t class?
I don't know what fits best to simutrans conventions.

The falsy roadsign itself is caused in weg_entfernen as it does not check at all if there is still something on that way.
So we should either remove anything related to that way when removing the way or the function should fail if there is still something on it.


So far, I've got that trolleybus wire fixed by adding it to the new road but for further fixing (e.g. roadsign bug) I want to discuss the above.
« Last Edit: September 17, 2019, 02:04:12 PM by Freahk »