The International Simutrans Forum

 

Author Topic: [Bug] Rotating the map deletes the region info from the map  (Read 516 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran

  • Devotee
  • *
  • Posts: 1560
  • Languages: ja
[Bug] Rotating the map deletes the region info from the map
« on: December 06, 2020, 01:59:01 AM »
Most of the information about the region is masked in the master branch, and the range of the region is hard to recognize.

But I added a lot of display about region in addition to GUI overhaul.
When I was testing it, I noticed that rotating the map completely lost information about the region. Rotating it four times will not restore it. (´・ω・`)
Even if you save it and reload it, it will not be restored. All region information will be lost and all will be in the same region (Albion).

Originally the information in the region was hard to recognize, so I'm not sure if this was brought about by the patch or was it originally.

The zstd branch adds region information to many list dialogs. For example city list dialog and attraction list. You can see about this symptom.

EDIT:
I think region will be empty() instead of albion.
« Last Edit: December 07, 2020, 01:17:31 PM by Ranran »

Offline Ranran

  • Devotee
  • *
  • Posts: 1560
  • Languages: ja
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #1 on: December 07, 2020, 01:23:52 PM »

This bug turned out to be reproducible on the master branch.

Reproduction procedure
(1) Display the ground dialog with the inspection tool. You can see that region info is written.


(2) Keep it open and rotate the camera. You can see that the region info disappears.

(3) Save the game and reload it.

(4) Display the ground dialog with the inspection tool again. You can see that region info isn't anywhere.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20817
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #2 on: December 12, 2020, 04:58:15 PM »
Thank you for your report. I have now partly fixed this, in that region data are no longer deleted on rotation.

However, there is a more complex issue: when the map is rotated, what counts as 0,0 changes place and is no longer 0,0. The region code (karte_t::get_region()) assumes that all the regions are defined relative to a fixed 0,0, as regions are intended to be layered on top of one another. Thus, on rotation, the "Albion" region will take over the whole map until it is rotated back to its original orientation when the original regions are restored.

It is difficult to think of a straightforward solution to this.

Offline Vladki

  • Devotee
  • *
  • Posts: 3725
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #3 on: December 12, 2020, 06:39:53 PM »
How about evaluating the regions at map generation, and storing the region on each tile (similar to climate)?
Would that take too much space? Or, recalculating the region borders according to current rotation?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20817
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #4 on: December 12, 2020, 07:17:40 PM »
How about evaluating the regions at map generation, and storing the region on each tile (similar to climate)?
Would that take too much space? Or, recalculating the region borders according to current rotation?

I deliberately avoided doing this because of the memory requirements: the tile data already takes the most memory of any single data structure in the game.

As to recalculating the region borders based on rotation, it is exactly that that is difficult to think how to do.

Offline Vladki

  • Devotee
  • *
  • Posts: 3725
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #5 on: December 12, 2020, 09:10:00 PM »
So, the regions are defined by upper left, and lower right corner, with 0,0 - 100,100 being the whole map.
Lets mark upper left coordinates as x1,y1 and lower right as x2,y2. After rotation - clockwise, the new coordinates are X1,Y1 and X2, Y2
X1 = 100-y2
Y1 = x1
X2 = 100-y1
Y2 = x2


Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Bug] Rotating the map deletes the region info from the map
« Reply #6 on: December 13, 2020, 12:09:04 PM »
You could easily rotate the coordinates back; the scripting engine always uses fixed coordinates, regardless of rotation.