Add: [Script] Let random road layout be a choice

This commit is contained in:
SamuXarick 2023-02-01 18:21:00 +00:00 committed by rubidium42
parent 184ff92057
commit 4fc4874a30
4 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,9 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li AITown::ROAD_LAYOUT_RANDOM
*
* \b 13.0
*
* API additions:

View File

@ -17,6 +17,9 @@
*
* This version is not yet released. The following changes are not set in stone yet.
*
* API additions:
* \li GSTown::ROAD_LAYOUT_RANDOM
*
* \b 13.0
*
* API additions:

View File

@ -288,7 +288,7 @@
EnforcePrecondition(false, size == TOWN_SIZE_SMALL || size == TOWN_SIZE_MEDIUM || size == TOWN_SIZE_LARGE)
EnforcePrecondition(false, size != TOWN_SIZE_LARGE || ScriptObject::GetCompany() == OWNER_DEITY);
if (ScriptObject::GetCompany() == OWNER_DEITY || _settings_game.economy.found_town == TF_CUSTOM_LAYOUT) {
EnforcePrecondition(false, layout == ROAD_LAYOUT_ORIGINAL || layout == ROAD_LAYOUT_BETTER_ROADS || layout == ROAD_LAYOUT_2x2 || layout == ROAD_LAYOUT_3x3);
EnforcePrecondition(false, layout >= ROAD_LAYOUT_ORIGINAL && layout <= ROAD_LAYOUT_RANDOM);
} else {
/* The layout parameter is ignored for AIs when custom layouts is disabled. */
layout = (RoadLayout) (byte)_settings_game.economy.town_layout;

View File

@ -98,6 +98,7 @@ public:
ROAD_LAYOUT_BETTER_ROADS = ::TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads).
ROAD_LAYOUT_2x2 = ::TL_2X2_GRID, ///< Geometric 2x2 grid algorithm
ROAD_LAYOUT_3x3 = ::TL_3X3_GRID, ///< Geometric 3x3 grid algorithm
ROAD_LAYOUT_RANDOM = ::TL_RANDOM, ///< Random road layout
/* Custom added value, only valid for this API */
ROAD_LAYOUT_INVALID = -1, ///< The layout for invalid towns.