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

Rename Addon into Object Part #9226

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fheroes2/castle/castle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ int32_t Castle::getTileIndexToPlaceBoat() const
return false;
}

// Mark the tile as worthy to a place a boat if the main addon does not exist on this tile.
// Mark the tile as worthy to a place a boat if the main object part does not exist on this tile.
// This means that all objects on this tile are not primary objects (like shadows or some parts of objects).
return ( tile.getMainObjectPart()._objectIcnType == MP2::OBJ_ICN_TYPE_UNKNOWN || tile.isPassabilityTransparent() );
};
Expand Down
18 changes: 9 additions & 9 deletions src/fheroes2/gui/interface_gamearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ namespace
// There is a tile below the current.
const Maps::Tiles & tileBelow = world.GetTiles( x, y + 1 );

for ( const auto & lowerAddon : tileBelow.getTopLayerAddons() ) {
if ( lowerAddon._uid == uid ) {
for ( const auto & lowerPart : tileBelow.getTopObjectParts() ) {
ihhub marked this conversation as resolved.
Show resolved Hide resolved
if ( lowerPart._uid == uid ) {
// This is a tall object.
return true;
}
Expand Down Expand Up @@ -646,7 +646,7 @@ void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle
// High priority images are drawn after any other object on this tile.
renderImagesOnTiles( dst, tileUnfit.highPriorityBottomImages, *this );

std::vector<const Maps::TilesAddon *> topLayerTallObjects;
std::vector<const Maps::ObjectPart *> topLayerTallObjects;

// Expand ROI to properly render very tall objects (1 tile - left and right; 2 tiles - bottom): Abandoned mine Ghosts, Flag on the Alchemist lab, and others.
const int32_t roiExtraObjectsMaxX = std::min( maxX + 1, world.w() );
Expand All @@ -672,19 +672,19 @@ void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle
// any other level 2 objects with the same UID.

topLayerTallObjects.clear();
for ( const auto & addon : tile.getTopLayerAddons() ) {
if ( isTallTopLayerObject( x, y, addon._uid ) ) {
topLayerTallObjects.emplace_back( &addon );
for ( const auto & part : tile.getTopObjectParts() ) {
if ( isTallTopLayerObject( x, y, part._uid ) ) {
topLayerTallObjects.emplace_back( &part );
}
else {
redrawTopLayerObject( tile, dst, isPuzzleDraw, *this, addon );
redrawTopLayerObject( tile, dst, isPuzzleDraw, *this, part );
}
}

redrawTopLayerExtraObjects( tile, dst, isPuzzleDraw, *this );

for ( const auto * addon : topLayerTallObjects ) {
redrawTopLayerObject( tile, dst, isPuzzleDraw, *this, *addon );
for ( const auto * part : topLayerTallObjects ) {
redrawTopLayerObject( tile, dst, isPuzzleDraw, *this, *part );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/heroes/heroes_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ namespace
objectUID = tile.getMainObjectPart()._uid;
}
else {
// In maps made by the original map editor the action object can be in the bottom layer addons.
for ( auto iter = tile.getBottomLayerAddons().rbegin(); iter != tile.getBottomLayerAddons().rend(); ++iter ) {
// In maps made by the original map editor the action object can be in the ground layer.
for ( auto iter = tile.getGroundObjectParts().rbegin(); iter != tile.getGroundObjectParts().rend(); ++iter ) {
if ( Maps::getObjectTypeByIcn( iter->_objectIcnType, iter->_imageIndex ) == objectType ) {
objectUID = iter->_uid;
break;
Expand Down
10 changes: 5 additions & 5 deletions src/fheroes2/maps/map_format_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ namespace Maps
streamParts.emplace( tile.getMainObjectPart()._uid, tile.getMainObjectPart()._imageIndex );
}

for ( const auto & addon : tile.getBottomLayerAddons() ) {
if ( addon._objectIcnType == MP2::OBJ_ICN_TYPE_ROAD ) {
roadParts.emplace( addon._uid, addon._imageIndex );
for ( const auto & part : tile.getGroundObjectParts() ) {
if ( part._objectIcnType == MP2::OBJ_ICN_TYPE_ROAD ) {
roadParts.emplace( part._uid, part._imageIndex );
}
else if ( addon._objectIcnType == MP2::OBJ_ICN_TYPE_STREAM ) {
streamParts.emplace( addon._uid, addon._imageIndex );
else if ( part._objectIcnType == MP2::OBJ_ICN_TYPE_STREAM ) {
streamParts.emplace( part._uid, part._imageIndex );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/maps/map_object_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace Maps
{
// An object usually contains of multiple parts / tiles. Each part has its own features like object layer type or image index.
// An object always contains a main object part (addon).
// An object always contains a main object part.
// All object's parts shares images from the same ICN source (MP2::ObjectIcnType).
struct ObjectPartInfo
{
Expand Down Expand Up @@ -71,7 +71,7 @@ namespace Maps
// Do nothing.
}

// A layer where this object part / addon sits on.
// A layer where this object part sits on.
// The layer is used for passability calculations as well as an order of rendering objects.
ObjectLayerType layerType{ OBJECT_LAYER };
};
Expand Down
14 changes: 7 additions & 7 deletions src/fheroes2/maps/maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ Maps::Indexes Maps::GetObjectPositions( const MP2::MapObjectType objectType )
return MapsIndexesObject( objectType, true );
}

std::vector<std::pair<int32_t, const Maps::TilesAddon *>> Maps::getObjectParts( const MP2::MapObjectType objectType )
std::vector<std::pair<int32_t, const Maps::ObjectPart *>> Maps::getObjectParts( const MP2::MapObjectType objectType )
{
std::vector<std::pair<int32_t, const TilesAddon *>> result;
std::vector<std::pair<int32_t, const ObjectPart *>> result;
const int32_t size = static_cast<int32_t>( world.getSize() );
for ( int32_t idx = 0; idx < size; ++idx ) {
const Maps::TilesAddon * objectPart = getObjectPartByActionType( world.GetTiles( idx ), objectType );
const Maps::ObjectPart * objectPart = getObjectPartByActionType( world.GetTiles( idx ), objectType );
if ( objectPart != nullptr ) {
result.emplace_back( idx, objectPart );
}
Expand Down Expand Up @@ -725,10 +725,10 @@ void Maps::UpdateCastleSprite( const fheroes2::Point & center, int race, bool is
tile.updateObjectImageIndex( castleID, MP2::OBJ_ICN_TYPE_OBJNTOWN, -16 );

if ( index == 0 ) {
TilesAddon * addon = tile.getTopLayerAddon( castleID );
if ( addon && addon->_objectIcnType == MP2::OBJ_ICN_TYPE_OBJNTWRD ) {
addon->_objectIcnType = MP2::OBJ_ICN_TYPE_OBJNTOWN;
addon->_imageIndex = fullTownIndex - 16;
ObjectPart * part = tile.getTopObjectPart( castleID );
if ( part && part->_objectIcnType == MP2::OBJ_ICN_TYPE_OBJNTWRD ) {
part->_objectIcnType = MP2::OBJ_ICN_TYPE_OBJNTOWN;
part->_imageIndex = fullTownIndex - 16;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/maps/maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using MapsIndexes = std::vector<int32_t>;

namespace Maps
{
struct TilesAddon;
struct ObjectPart;

enum mapsize_t : int
{
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace Maps
Indexes GetObjectPositions( const MP2::MapObjectType objectType );

// This is a very slow function by performance. Use it only while loading a map.
std::vector<std::pair<int32_t, const TilesAddon *>> getObjectParts( const MP2::MapObjectType objectType );
std::vector<std::pair<int32_t, const ObjectPart *>> getObjectParts( const MP2::MapObjectType objectType );

Indexes GetObjectPositions( int32_t center, const MP2::MapObjectType objectType, bool ignoreHeroes );

Expand Down
Loading
Loading