Skip to content

Commit

Permalink
Add 3 new variants of Observation Tower object
Browse files Browse the repository at this point in the history
  • Loading branch information
ihhub committed Dec 25, 2024
1 parent 7ee9d84 commit 6d7033f
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 5 deletions.
Binary file modified files/data/resurrection.h2d
Binary file not shown.
33 changes: 30 additions & 3 deletions src/fheroes2/agg/agg_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5100,16 +5100,20 @@ namespace
LoadOriginalICN( id );
auto & images = _icnVsSprite[id];
if ( images.size() == 218 ) {
// Add 2 extra river deltas. Each delta has 7 parts.
// Add a new Stone Liths with 3 more images.
images.resize( 218 + 14 + 3 );
// Expand the existing set of Adventure Map objects:
// - 2 extra River Delta objects. Each object has 7 image parts.
// - 1 new Stone Liths with 3 image parts.
// - 3 new variants of Observation Tower object. In total, 6 new image parts.
images.resize( 218 + ( 7 * 2 ) + 3 + 6 );

// 2 River Deltas.
for ( size_t i = 0; i < 14; ++i ) {
images[218 + i].resize( images[i].height(), images[i].width() );
fheroes2::Transpose( images[i], images[218 + i] );
images[218 + i].setPosition( images[i].y(), images[i].x() );
}

// 1 Stone Liths.
fheroes2::Sprite temp;
fheroes2::h2d::readImage( "circular_stone_liths_center.image", temp );

Expand All @@ -5120,6 +5124,29 @@ namespace

fheroes2::h2d::readImage( "circular_stone_liths_left.image", images[233] );
fheroes2::h2d::readImage( "circular_stone_liths_top.image", images[234] );

// Generic Observation Tower.
images[235] = images[201];
fheroes2::h2d::readImage( "observation_tower_generic_bottom_part.image", temp );
Blit( temp, 0, 0, images[235], 0, temp.y() - images[235].y(), temp.width(), temp.height() );

// Desert Observation Tower.
images[236] = images[201];
fheroes2::h2d::readImage( "observation_tower_desert_bottom_part.image", temp );
Blit( temp, 0, 0, images[236], 0, temp.y() - images[236].y(), temp.width(), temp.height() );

fheroes2::h2d::readImage( "observation_tower_desert_right_part.image", images[237] );

// Snow Observation Tower.
images[238] = images[201];
fheroes2::h2d::readImage( "observation_tower_snow_bottom_part.image", temp );
Blit( temp, 0, 0, images[238], 0, temp.y() - images[238].y(), temp.width(), temp.height() );

fheroes2::h2d::readImage( "observation_tower_snow_right_part.image", images[239] );

images[240] = images[198];
fheroes2::h2d::readImage( "observation_tower_snow_top_part.image", temp );
Blit( temp, 0, 0, images[240], 0, 0, temp.width(), temp.height() );
}

return true;
Expand Down
21 changes: 20 additions & 1 deletion src/fheroes2/maps/map_format_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace
constexpr uint16_t minimumSupportedVersion{ 2 };

// Change the version when there is a need to expand map format functionality.
constexpr uint16_t currentSupportedVersion{ 7 };
constexpr uint16_t currentSupportedVersion{ 8 };

void convertFromV2ToV3( Maps::Map_Format::MapFormat & map )
{
Expand Down Expand Up @@ -196,6 +196,24 @@ namespace
}
}

void convertFromV7ToV8( Maps::Map_Format::MapFormat & map )
{
static_assert( minimumSupportedVersion <= 7, "Remove this function." );

if ( map.version > 7 ) {
return;
}

for ( Maps::Map_Format::TileInfo & tileInfo : map.tiles ) {
for ( Maps::Map_Format::TileObjectInfo & objInfo : tileInfo.objects ) {
if ( objInfo.group == Maps::ObjectGroup::ADVENTURE_MISCELLANEOUS && objInfo.index >= 43 ) {
// Shift the objects in the Adventure Miscellaneous group by 3 position "down" to add new Observation Tower variants.
objInfo.index += 3;
}
}
}
}

bool saveToStream( OStreamBase & stream, const Maps::Map_Format::BaseMapFormat & map )
{
stream << currentSupportedVersion << map.isCampaign << map.difficulty << map.availablePlayerColors << map.humanPlayerColors << map.computerPlayerColors
Expand Down Expand Up @@ -294,6 +312,7 @@ namespace
convertFromV4ToV5( map );
convertFromV5ToV6( map );
convertFromV6ToV7( map );
convertFromV7ToV8( map );

return !stream.fail();
}
Expand Down
45 changes: 44 additions & 1 deletion src/fheroes2/maps/map_object_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4474,7 +4474,7 @@ namespace
objects.emplace_back( std::move( object ) );
}

// Observation Tower, generic terrain.
// Observation Tower, grass terrain.
{
Maps::ObjectInfo object{ MP2::OBJ_OBSERVATION_TOWER };
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 201U, fheroes2::Point{ 0, 0 }, MP2::OBJ_OBSERVATION_TOWER, Maps::OBJECT_LAYER );
Expand All @@ -4487,6 +4487,49 @@ namespace
objects.emplace_back( std::move( object ) );
}

// Observation Tower, generic terrain.
{
Maps::ObjectInfo object{ MP2::OBJ_OBSERVATION_TOWER };
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 235U, fheroes2::Point{ 0, 0 }, MP2::OBJ_OBSERVATION_TOWER, Maps::OBJECT_LAYER );

object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 199U, fheroes2::Point{ -2, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 200U, fheroes2::Point{ -1, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );

object.topLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 198U, fheroes2::Point{ 0, -1 }, MP2::OBJ_NON_ACTION_OBSERVATION_TOWER );

objects.emplace_back( std::move( object ) );
}

// Observation Tower, desert terrain.
{
Maps::ObjectInfo object{ MP2::OBJ_OBSERVATION_TOWER };
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 236U, fheroes2::Point{ 0, 0 }, MP2::OBJ_OBSERVATION_TOWER, Maps::OBJECT_LAYER );

object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 199U, fheroes2::Point{ -2, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 200U, fheroes2::Point{ -1, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 237U, fheroes2::Point{ 1, 0 }, MP2::OBJ_NON_ACTION_OBSERVATION_TOWER,
Maps::BACKGROUND_LAYER );

object.topLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 198U, fheroes2::Point{ 0, -1 }, MP2::OBJ_NON_ACTION_OBSERVATION_TOWER );

objects.emplace_back( std::move( object ) );
}

// Observation Tower, snow terrain.
{
Maps::ObjectInfo object{ MP2::OBJ_OBSERVATION_TOWER };
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 238U, fheroes2::Point{ 0, 0 }, MP2::OBJ_OBSERVATION_TOWER, Maps::OBJECT_LAYER );

object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 199U, fheroes2::Point{ -2, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 200U, fheroes2::Point{ -1, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 239U, fheroes2::Point{ 1, 0 }, MP2::OBJ_NON_ACTION_OBSERVATION_TOWER,
Maps::BACKGROUND_LAYER );

object.topLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 240U, fheroes2::Point{ 0, -1 }, MP2::OBJ_NON_ACTION_OBSERVATION_TOWER );

objects.emplace_back( std::move( object ) );
}

// Alchemist's Tower, PoL object.
{
Maps::ObjectInfo object{ MP2::OBJ_ALCHEMIST_TOWER };
Expand Down

0 comments on commit 6d7033f

Please sign in to comment.