Skip to content

Commit 2817b51

Browse files
authored
Add a new variant of Stone Liths object (#9335)
1 parent 284c036 commit 2817b51

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

files/data/resurrection.h2d

2.54 KB
Binary file not shown.

src/fheroes2/agg/agg_image.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5101,13 +5101,25 @@ namespace
51015101
auto & images = _icnVsSprite[id];
51025102
if ( images.size() == 218 ) {
51035103
// Add 2 extra river deltas. Each delta has 7 parts.
5104-
images.resize( 218 + 14 );
5104+
// Add a new Stone Liths with 3 more images.
5105+
images.resize( 218 + 14 + 3 );
51055106

51065107
for ( size_t i = 0; i < 14; ++i ) {
51075108
images[218 + i].resize( images[i].height(), images[i].width() );
51085109
fheroes2::Transpose( images[i], images[218 + i] );
51095110
images[218 + i].setPosition( images[i].y(), images[i].x() );
51105111
}
5112+
5113+
fheroes2::Sprite temp;
5114+
fheroes2::h2d::readImage( "circular_stone_liths_center.image", temp );
5115+
5116+
images[232].resize( 32, 32 );
5117+
images[232].reset();
5118+
Copy( temp, 0, 0, images[232], 0, 0, temp.width(), temp.height() );
5119+
Copy( images[116], 0, temp.height(), images[232], 0, temp.height(), images[116].width(), images[116].height() - temp.height() );
5120+
5121+
fheroes2::h2d::readImage( "circular_stone_liths_left.image", images[233] );
5122+
fheroes2::h2d::readImage( "circular_stone_liths_top.image", images[234] );
51115123
}
51125124

51135125
return true;

src/fheroes2/maps/map_format_info.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace
7272
constexpr uint16_t minimumSupportedVersion{ 2 };
7373

7474
// Change the version when there is a need to expand map format functionality.
75-
constexpr uint16_t currentSupportedVersion{ 6 };
75+
constexpr uint16_t currentSupportedVersion{ 7 };
7676

7777
void convertFromV2ToV3( Maps::Map_Format::MapFormat & map )
7878
{
@@ -178,6 +178,24 @@ namespace
178178
}
179179
}
180180

181+
void convertFromV6ToV7( Maps::Map_Format::MapFormat & map )
182+
{
183+
static_assert( minimumSupportedVersion <= 6, "Remove this function." );
184+
185+
if ( map.version > 6 ) {
186+
return;
187+
}
188+
189+
for ( Maps::Map_Format::TileInfo & tileInfo : map.tiles ) {
190+
for ( Maps::Map_Format::TileObjectInfo & objInfo : tileInfo.objects ) {
191+
if ( objInfo.group == Maps::ObjectGroup::ADVENTURE_MISCELLANEOUS && objInfo.index >= 38 ) {
192+
// Shift the objects in the Adventure Miscellaneous group by 1 position "down" to add new Stone Liths object.
193+
objInfo.index += 1;
194+
}
195+
}
196+
}
197+
}
198+
181199
bool saveToStream( OStreamBase & stream, const Maps::Map_Format::BaseMapFormat & map )
182200
{
183201
stream << currentSupportedVersion << map.isCampaign << map.difficulty << map.availablePlayerColors << map.humanPlayerColors << map.computerPlayerColors
@@ -275,6 +293,7 @@ namespace
275293
convertFromV3ToV4( map );
276294
convertFromV4ToV5( map );
277295
convertFromV5ToV6( map );
296+
convertFromV6ToV7( map );
278297

279298
return !stream.fail();
280299
}

src/fheroes2/maps/map_object_info.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4426,6 +4426,18 @@ namespace
44264426
objects.emplace_back( std::move( object ) );
44274427
}
44284428

4429+
// A new variant (Resurrection expansion) of Stone Liths.
4430+
{
4431+
Maps::ObjectInfo object{ MP2::OBJ_STONE_LITHS };
4432+
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 232U, fheroes2::Point{ 0, 0 }, MP2::OBJ_STONE_LITHS, Maps::OBJECT_LAYER );
4433+
4434+
object.groundLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 233U, fheroes2::Point{ -1, 0 }, MP2::OBJ_NONE, Maps::SHADOW_LAYER );
4435+
4436+
object.topLevelParts.emplace_back( MP2::OBJ_ICN_TYPE_OBJNMUL2, 234U, fheroes2::Point{ 0, -1 }, MP2::OBJ_NON_ACTION_STONE_LITHS );
4437+
4438+
objects.emplace_back( std::move( object ) );
4439+
}
4440+
44294441
// Event, generic terrain.
44304442
{
44314443
Maps::ObjectInfo object{ MP2::OBJ_EVENT };

0 commit comments

Comments
 (0)