Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Town generated on a hill having too many roads #3332

Closed
DorpsGek opened this issue Nov 28, 2009 · 2 comments
Closed

Town generated on a hill having too many roads #3332

DorpsGek opened this issue Nov 28, 2009 · 2 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

SirkoZ opened the ticket and wrote:

Revision: r18309.

When generating a map with the good ol' original terrain generator and using better_roads town layout this (as shown in the below screen-shot) happens.
If the mechanism for generation would only be set to not build roads next to each other but with one to three squares apart, that would be just lovely.
The same thing also sometimes happens during the progress of the game where better_roads leads to road next to road on the hills.
There was an interesting function in the trunk back in the day (rel. 0.6.3) - I don't know if it is still present but it could perhaps be used to
prevent the town mechanism to build roads too near each other. Here's that function:

/**
* Check if a neighboring tile has a road
*
* @param tile curent tile
* @param dir target direction
* @param dist_multi distance multiplier
* @return true if one of the neighboring tiles at the
* given distance is a road tile else false
*/
static bool IsNeighborRoadTile(TileIndex tile, const DiagDirection dir, uint dist_multi)
{
/* Lookup table for the used diff values */
const TileIndexDiff tid_lt[3] = {
TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT)),
TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT)),
TileOffsByDiagDir(ReverseDiagDir(dir)),
};

/* We add 1 to the distance because we want to get 1 for

  • the min distance multiplier and not 0.

  • Therefore we start at 4. The 4 is used because

  • there are 4 tiles per distance step to check. /
    dist_multi = (dist_multi + 1) * 4;
    for (uint pos = 4; pos < dist_multi; pos++) {
    TileIndexDiff cur = 0;
    /
    For each even value of pos add the right TileIndexDiff

    • for each uneven value the left TileIndexDiff
    • for each with 2nd bit set (2,3,6,7,..) add the reversed TileIndexDiff */
      cur += tid_lt[(pos & 1) ? 0 : 1];
      if (pos & 2) cur += tid_lt[2];

    cur = (uint)(pos / 4) * cur; // Multiply for the fitting distance
    if (GetBuiltRoadBits(TILE_ADD(tile, cur)) & DiagDirToRoadBits((pos & 2) ? dir : ReverseDiagDir(dir))) return true;
    }
    return false;
    }

Attachments

Reported version: trunk
Operating system: Windows


This issue was imported from FlySpray: https://bugs.openttd.org/task/3332
@DorpsGek
Copy link
Member Author

DorpsGek commented Dec 6, 2009

Rubidium wrote:

Can you add the savegame so we can actually reproduce OpenTTD doing that and thus fix the issue; I've generated a dozen maps with the original map generator and haven't seen any case of that.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3332#comment7031

@DorpsGek
Copy link
Member Author

DorpsGek commented Dec 6, 2009

Rubidium closed the ticket.

Reason for closing: Fixed

In r18415 (I hope)


This comment was imported from FlySpray: https://bugs.openttd.org/task/3332

@DorpsGek DorpsGek closed this as completed Dec 6, 2009
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant