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

Do not allow to place "movable" action objects on a tile with other objects #9504

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions src/fheroes2/editor/editor_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ namespace
return false;
}

if ( MP2::isOffGameActionObject( objectPart.objectType ) && !Maps::isClearGround( tile ) ) {
// We are trying to place an action object on a tile that has some other objects.
if ( MP2::isOffGameActionObject( objectPart.objectType ) && MP2::getActionObjectPassability( objectPart.objectType ) == DIRECTION_ALL
&& !Maps::isClearGround( tile ) ) {
// We are trying to place a "movable" action object on a tile that has some other objects.
// Since, "movable" objects are tend to be removed we do not allow to put them on top of other objects.
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/maps/maps_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ int Maps::Tile::getTileIndependentPassability() const
if ( MP2::isOffGameActionObject( type ) ) {
// This is an action object part.
isActionObject = true;
return MP2::getActionObjectDirection( type );
return MP2::getActionObjectPassability( type );
}

if ( type == MP2::OBJ_REEFS ) {
Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/maps/mp2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
* fheroes2: https://github.com/ihhub/fheroes2 *
* Copyright (C) 2019 - 2024 *
* Copyright (C) 2019 - 2025 *
* *
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 *
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> *
Expand Down Expand Up @@ -799,7 +799,7 @@ bool MP2::isNeedStayFront( const MapObjectType objectType )
return isPickupObject( objectType );
}

int MP2::getActionObjectDirection( const MapObjectType objectType )
int MP2::getActionObjectPassability( const MapObjectType objectType )
{
switch ( objectType ) {
case OBJ_ARTIFACT:
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/maps/mp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ namespace MP2
bool isBattleLife( const MapObjectType objectType );

// Make sure that you pass a valid action object.
int getActionObjectDirection( const MapObjectType objectType );
int getActionObjectPassability( const MapObjectType objectType );

bool getDiggingHoleSprite( const int terrainType, ObjectIcnType & objectIcnType, uint8_t & index );
bool isDiggingHoleSprite( const int terrainType, const ObjectIcnType objectIcnType, const uint8_t index );
Expand Down
Loading