From 4fc4874a3060eee727f277de21af4c9626ea296d Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:21:00 +0000 Subject: [PATCH] Add: [Script] Let random road layout be a choice --- src/script/api/ai_changelog.hpp | 3 +++ src/script/api/game_changelog.hpp | 3 +++ src/script/api/script_town.cpp | 2 +- src/script/api/script_town.hpp | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index e69408926f..27ad40e79f 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -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: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 1512a6ea7c..46a8e4904f 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -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: diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index eafb9106fc..047cbe1a69 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -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; diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 6e7fc67781..d64d12ef6b 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -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.