The International Simutrans Forum

 

Author Topic: Multi-tile attraction buildings can have 4 windows in each direction  (Read 529 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran jp

  • *
  • Posts: 471
  • Languages: ja
Hi, Ranran is here. (´・ω・`)

A multi-tile attraction building can open four dialogs even though it is the same building.

If rotate the camera, it will be treated as a different building and it can have a building dialog for each angle.
On the other hand, factories and stations can only have one window even if they are multi-tile.
This may be a minor issue with standard, but it seems to cause a major issue with extended.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2709
  • Languages: EN
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #1 on: August 08, 2019, 12:35:34 PM »
Fortunately one cannot rotate multiplayer games.

This likely stems from map rotation being a hack. It literally rotates the map and everything on it. As opposed to changing the way the graphics are drawn like any decent modern 3D game does.

Why does this mess up extended more than standard?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5525
  • Languages: EN, NO
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #2 on: August 08, 2019, 01:38:14 PM »
In addition, I think one of the tile locations is representative of the entire building, probably the lower-left corner. When rotating, the lower-left corner is at a different coordinate, and also a different corner of the building. I'm not sure which of these two facts matter, but it is probably at least one of them.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9514
  • Languages: De,EN,JP
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #3 on: August 08, 2019, 02:04:25 PM »
Indeed, the base tile of the corner stores the actual description and handles all action. Since it has a different memory location, it window id is different. Since the map rotation state is known. it could of course check for this too.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18696
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #4 on: August 10, 2019, 10:22:01 AM »
The critical code seems to be here (I post the Extended version but the important part of the code is, I believe, unchanged from Standard):

Code: [Select]
const gebaeude_t* gebaeude_t::get_first_tile() const
{
if (tile)
{
const building_desc_t* const building_desc = tile->get_desc();
const uint8 layout = tile->get_layout();
koord k;
for (k.x = 0; k.x<building_desc->get_x(layout); k.x++) {
for (k.y = 0; k.y<building_desc->get_y(layout); k.y++) {
const building_tile_desc_t *tile = building_desc->get_tile(layout, k.x, k.y);
if (tile == NULL || !tile->has_image()) {
continue;
}
if (grund_t *gr = welt->lookup(get_pos() - get_tile()->get_offset() + k))
{
gebaeude_t* gb;
if (tile->get_desc()->is_signalbox())
{
gb = gr->get_signalbox();
}
else
{
gb = gr->find<gebaeude_t>();
}
if (gb && gb->get_tile() == tile)
{
return gb;
}
}
}
}
}
return this;
}

The current rotation is can be retrieved with welt->get_settings().get_rotation(), and is either 0, 1, 2 or 3, 0 being the initial rotation and the others incrementing once with each rotation until the initial rotation is reached again.

What is not immediately clear to me is the numerical relationship between the position of the tile returned as the first and the rotation. The current code simply seems to iterate through all the tiles in numerical order as stored by the co-ordinates. Quite what alternative algorithm would be needed for any given non-zero value of get_rotation() in order that the same tile be returned whenever get_first_tile be called is unclear, as the geometric relationship between the numerically first tile in that iteration list and what would be the first tile in any given other rotation is also unclear.

Any assistance in this matter would be appreciated.

Offline Leartin at

  • Devotee
  • *
  • Posts: 1254
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #5 on: August 10, 2019, 11:19:23 AM »
Shot in the blue:
When rotated, it should not be iterated through all tiles the same way. Instead, of
Code: [Select]
for (k.x = 0; k.x<building_desc->get_x(layout); k.x++) {
for (k.y = 0; k.y<building_desc->get_y(layout); k.y++) {
It would be
Code: [Select]
for (k.y<building_desc->get_y(layout); k.y = 0; k.y--) {
for (k.x = 0; k.x<building_desc->get_x(layout); k.x++) {
Code: [Select]
for (k.x<building_desc->get_x(layout); k.x = 0; k.x--) {
for (k.y<building_desc->get_y(layout); k.y = 0; k.y--) {
and
Code: [Select]
for (k.y = 0; k.y<building_desc->get_y(layout); k.y++) {
for (k.x<building_desc->get_x(layout); k.x = 0; k.x--) {

Therefore, the list of tiles is identical to the list you would have in rotation zero, hence the first tile would always be the same - right?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18696
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #6 on: August 10, 2019, 02:25:12 PM »
That is a very interesting idea - thank you. Can anyone assist as to which of these alternative algorithms should match with which rotation states as numerically represented?

Offline Leartin at

  • Devotee
  • *
  • Posts: 1254
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Multi-tile attraction buildings can have 4 windows in each direction
« Reply #7 on: August 10, 2019, 08:43:50 PM »
Disclaimer: I posted (pseudo)code to get across the idea (decrementing instead of incrementing), but I don't even know what all of it means, so it's probably wrong. Perhaps it's so obvious that I don't even need to say this, but don't copypaste it - take the idea and write it yourself.

As for your new question, the one where you decrement both x and y would be rotation 2, you don't even need to know what x and y are and which direction you rotate. Since that leaves you a 50:50 chance, you are probably quicker just going with one option and switching them if it fails the first time, rather than waiting for an answer.