Merge branch 'master' into jgrpp

# Conflicts:
#	src/industry_cmd.cpp
#	src/landscape.cpp
#	src/object_cmd.cpp
#	src/rail_cmd.cpp
#	src/script/api/script_tile.cpp
#	src/table/settings/difficulty_settings.ini
#	src/table/settings/world_settings.ini
#	src/terraform_cmd.cpp
#	src/tilearea_type.h
#	src/tree_cmd.cpp
#	src/tree_cmd.h
#	src/tree_gui.cpp
#	src/water_cmd.cpp
pull/474/head
Jonathan G Rennison 1 year ago
commit 5b490b243d

@ -132,9 +132,9 @@ public:
return *this;
}
virtual TileIterator *Clone() const
virtual std::unique_ptr<TileIterator> Clone() const
{
return new BitmapTileIterator(*this);
return std::make_unique<BitmapTileIterator>(*this);
}
};

@ -1435,6 +1435,9 @@ static void CreateRivers()
}
}
/* Widening rivers may have left some tiles requiring to be watered. */
ConvertGroundTilesIntoWaterTiles();
/* Run tile loop to update the ground density. */
for (uint i = 0; i != 256; i++) {
if (i % 64 == 0) IncreaseGeneratingWorldProgress(GWP_RIVER);

@ -399,7 +399,7 @@ STR_SCENEDIT_TOOLBAR_TOWN_GENERATION :{BLACK}Town gen
STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION :{BLACK}Industry generation
STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION :{BLACK}Road construction
STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION :{BLACK}Tramway construction
STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Plant trees. Shift toggles building/showing cost estimate
STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Plant trees. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate
STR_SCENEDIT_TOOLBAR_PLACE_SIGN :{BLACK}Place sign
STR_SCENEDIT_TOOLBAR_PLACE_OBJECT :{BLACK}Place object. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate
STR_SCENEDIT_TOOLBAR_PLACE_HOUSE :{BLACK}Place house
@ -3776,7 +3776,7 @@ STR_SELECT_TOWN_LIST_ITEM :{BLACK}{TOWN}
STR_PLANT_TREE_CAPTION :{WHITE}Trees
STR_PLANT_TREE_TOOLTIP :{BLACK}Select tree type to plant. If the tile already has a tree, this will add more trees of mixed types independent of the selected type
STR_TREES_RANDOM_TYPE :{BLACK}Trees of random type
STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Place trees of random type. Shift toggles building/showing cost estimate
STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Place trees of random type. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate
STR_TREES_RANDOM_TREES_BUTTON :{BLACK}Random Trees
STR_TREES_RANDOM_TREES_TOOLTIP :{BLACK}Plant trees randomly throughout the landscape
STR_TREES_REMOVE_TREES_BUTTON :{BLACK}Remove all Trees

@ -1271,7 +1271,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
break;
case 0x2F: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_TRAIN, buf->ReadWord());
ei->variant_id = buf->ReadWord();
break;
case 0x30: // Extra miscellaneous flags
@ -1473,7 +1473,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
}
case 0x26: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_ROAD, buf->ReadWord());
ei->variant_id = buf->ReadWord();
break;
case 0x27: // Extra miscellaneous flags
@ -1653,7 +1653,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
}
case 0x20: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_SHIP, buf->ReadWord());
ei->variant_id = buf->ReadWord();
break;
case 0x21: // Extra miscellaneous flags
@ -1815,7 +1815,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
break;
case 0x20: // Engine variant
ei->variant_id = GetNewEngineID(_cur.grffile, VEH_AIRCRAFT, buf->ReadWord());
ei->variant_id = buf->ReadWord();
break;
case 0x21: // Extra miscellaneous flags
@ -10575,13 +10575,16 @@ static void FinaliseEngineArray()
}
}
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
/* Set appropriate flags on variant engine */
/* Do final mapping on variant engine ID and set appropriate flags on variant engine */
if (e->info.variant_id != INVALID_ENGINE) {
Engine::Get(e->info.variant_id)->display_flags |= EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded;
e->info.variant_id = GetNewEngineID(e->grf_prop.grffile, e->type, e->info.variant_id);
if (e->info.variant_id != INVALID_ENGINE) {
Engine::Get(e->info.variant_id)->display_flags |= EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded;
}
}
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
/* Skip wagons, there livery is defined via the engine */
if (e->type != VEH_TRAIN || e->u.rail.railveh_type != RAILVEH_WAGON) {
LiveryScheme ls = GetEngineLiveryScheme(e->index, INVALID_ENGINE, nullptr);

@ -58,9 +58,9 @@ public:
return this->att->gfx;
}
virtual AirportTileTableIterator *Clone() const
virtual std::unique_ptr<TileIterator> Clone() const
{
return new AirportTileTableIterator(*this);
return std::make_unique<AirportTileTableIterator>(*this);
}
};

@ -446,9 +446,9 @@ int MacOSStringCompare(const char *s1, const char *s2)
return this->utf16_to_utf8[this->cur_pos];
}
/* static */ StringIterator *OSXStringIterator::Create()
/* static */ std::unique_ptr<StringIterator> OSXStringIterator::Create()
{
if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
return new OSXStringIterator();
return std::make_unique<OSXStringIterator>();
}

@ -33,7 +33,7 @@ public:
size_t Next(IterType what) override;
size_t Prev(IterType what) override;
static StringIterator *Create();
static std::unique_ptr<StringIterator> Create();
};
/**

@ -3019,8 +3019,8 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
CommandCost error = CommandCost((rtt == RTT_TRAM) ? STR_ERROR_NO_SUITABLE_TRAMWAY : STR_ERROR_NO_SUITABLE_ROAD); // by default, there is no road to convert.
bool found_convertible_road = false; // whether we actually did convert any road/tram (see bug #7633)
TileIterator *iter = new OrthogonalTileIterator(area_start, area_end);
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
OrthogonalTileIterator iter(area_start, area_end);
for (; (tile = *iter) != INVALID_TILE; ++iter) {
/* Is road present on tile? */
if (!MayHaveRoad(tile)) continue;
@ -3209,7 +3209,6 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
}
delete iter;
return found_convertible_road ? cost : error;
}

@ -416,6 +416,7 @@ struct GameCreationSettings {
byte landscape; ///< the landscape we're currently in
byte water_borders; ///< bitset of the borders that are water
uint16 custom_town_number; ///< manually entered number of towns
uint16 custom_industry_number; ///< manually entered number of industries
byte variety; ///< variety level applied to TGP
byte custom_terrain_type; ///< manually entered height for TGP to aim for
byte custom_sea_level; ///< manually entered percentage of water in the map
@ -431,7 +432,6 @@ struct GameCreationSettings {
uint8 amount_of_rocks; ///< the amount of rocks
uint8 height_affects_rocks; ///< the affect that map height has on rocks
uint8 build_public_roads; ///< build public roads connecting towns
uint16 custom_industry_number; ///< manually entered number of industries
};
/** Settings related to construction in-game */

@ -924,9 +924,9 @@ public:
return *this;
}
virtual TileIterator *Clone() const
virtual std::unique_ptr<TileIterator> Clone() const
{
return new AirportTileIterator(*this);
return std::make_unique<AirportTileIterator>(*this);
}
};

@ -905,9 +905,9 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
#ifdef WITH_UNISCRIBE
/* static */ StringIterator *StringIterator::Create()
/* static */ std::unique_ptr<StringIterator> StringIterator::Create()
{
return new UniscribeStringIterator();
return std::make_unique<UniscribeStringIterator>();
}
#elif defined(WITH_ICU_I18N)
@ -1061,9 +1061,9 @@ public:
}
};
/* static */ StringIterator *StringIterator::Create()
/* static */ std::unique_ptr<StringIterator> StringIterator::Create()
{
return new IcuStringIterator();
return std::make_unique<IcuStringIterator>();
}
#else
@ -1172,17 +1172,17 @@ public:
};
#if defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN)
/* static */ StringIterator *StringIterator::Create()
/* static */ std::unique_ptr<StringIterator> StringIterator::Create()
{
StringIterator *i = OSXStringIterator::Create();
std::unique_ptr<StringIterator> i = OSXStringIterator::Create();
if (i != nullptr) return i;
return new DefaultStringIterator();
return std::make_unique<DefaultStringIterator>();
}
#else
/* static */ StringIterator *StringIterator::Create()
/* static */ std::unique_ptr<StringIterator> StringIterator::Create()
{
return new DefaultStringIterator();
return std::make_unique<DefaultStringIterator>();
}
#endif /* defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN) */

@ -26,7 +26,7 @@ public:
* Create a new iterator instance.
* @return New iterator instance.
*/
static StringIterator *Create();
static std::unique_ptr<StringIterator> Create();
virtual ~StringIterator() {}

@ -371,13 +371,11 @@ bool Textbuf::MovePos(uint16 keycode)
* @param max_chars maximum size in chars, including terminating '\0'
*/
Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
: buf(MallocT<char>(max_bytes))
: buf(MallocT<char>(max_bytes)), char_iter(StringIterator::Create())
{
assert(max_bytes != 0);
assert(max_chars != 0);
this->char_iter = StringIterator::Create();
this->afilter = CS_ALPHANUMERAL;
this->max_bytes = max_bytes;
this->max_chars = max_chars == UINT16_MAX ? max_bytes : max_chars;
@ -387,7 +385,6 @@ Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars)
Textbuf::~Textbuf()
{
delete this->char_iter;
free(this->buf);
}

@ -67,7 +67,7 @@ struct Textbuf {
void DiscardMarkedText(bool update = true);
private:
StringIterator *char_iter;
std::unique_ptr<StringIterator> char_iter;
bool CanDelChar(bool backspace);

@ -280,3 +280,18 @@ TileIterator &DiagonalTileIterator::operator++()
if (this->b_max == this->b_cur) this->tile = INVALID_TILE;
return *this;
}
/**
* Create either an OrthogonalTileIterator or DiagonalTileIterator given the diagonal parameter.
* @param corner1 Tile from where to begin iterating.
* @param corner2 Tile where to end the iterating.
* @param diagonal Whether to create a DiagonalTileIterator or OrthogonalTileIterator.
* @return unique_ptr to the allocated TileIterator.
*/
/* static */ std::unique_ptr<TileIterator> TileIterator::Create(TileIndex corner1, TileIndex corner2, bool diagonal)
{
if (diagonal) {
return std::make_unique<DiagonalTileIterator>(corner1, corner2);
}
return std::make_unique<OrthogonalTileIterator>(corner1, corner2);
}

@ -154,7 +154,9 @@ public:
/**
* Allocate a new iterator that is a copy of this one.
*/
virtual TileIterator *Clone() const = 0;
virtual std::unique_ptr<TileIterator> Clone() const = 0;
static std::unique_ptr<TileIterator> Create(TileIndex corner1, TileIndex corner2, bool diagonal);
};
/** Iterator to iterate over a tile area (rectangle) of the map. */
@ -201,9 +203,9 @@ public:
return *this;
}
virtual TileIterator *Clone() const
virtual std::unique_ptr<TileIterator> Clone() const
{
return new OrthogonalTileIterator(*this);
return std::make_unique<OrthogonalTileIterator>(*this);
}
};
@ -227,11 +229,6 @@ public:
PREFETCH_NTA(&_m[ta.tile]);
}
/** Some compilers really like this. */
virtual ~OrthogonalPrefetchTileIterator()
{
}
/**
* Get the tile we are currently at.
* @return The tile we are at, or INVALID_TILE when we're done.
@ -259,11 +256,6 @@ public:
}
return *this;
}
virtual OrthogonalPrefetchTileIterator *Clone() const
{
return new OrthogonalPrefetchTileIterator(*this);
}
};
/** Iterator to iterate over a diagonal area of the map. */
@ -299,9 +291,9 @@ public:
TileIterator& operator ++();
virtual TileIterator *Clone() const
virtual std::unique_ptr<TileIterator> Clone() const
{
return new DiagonalTileIterator(*this);
return std::make_unique<DiagonalTileIterator>(*this);
}
};

Loading…
Cancel
Save