Skip to content

Commit

Permalink
Merge branch master into ems-render
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-derevenetz committed Jan 16, 2025
2 parents c7da3aa + c58f6eb commit 1d514a4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
29 changes: 19 additions & 10 deletions src/engine/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,36 @@ namespace Logging
#include <psp2/kernel/clib.h>
#define COUT( x ) \
{ \
std::ostringstream osss; \
osss << x << std::endl; \
sceClibPrintf( osss.str().c_str() ); \
std::ostringstream _log_strstream; /* The name was chosen on purpose to avoid name collisions with outer code blocks. */ \
_log_strstream << x << std::endl; \
sceClibPrintf( "%s", _log_strstream.str().c_str() ); \
}
#elif defined( MACOS_APP_BUNDLE )
#include <syslog.h>
#define COUT( x ) \
{ \
std::ostringstream logMessage; \
logMessage << x; \
syslog( LOG_WARNING, "fheroes2_log: %s", logMessage.str().c_str() ); \
std::ostringstream _log_strstream; /* The name was chosen on purpose to avoid name collisions with outer code blocks. */ \
_log_strstream << x; \
syslog( LOG_WARNING, "fheroes2_log: %s", _log_strstream.str().c_str() ); \
}
#elif defined( ANDROID )
#include <android/log.h>
#define COUT( x ) \
{ \
std::ostringstream osss; \
osss << x << std::endl; \
__android_log_print( ANDROID_LOG_INFO, "fheroes2", "%s", osss.str().c_str() ); \
std::ostringstream _log_strstream; /* The name was chosen on purpose to avoid name collisions with outer code blocks. */ \
_log_strstream << x; \
__android_log_print( ANDROID_LOG_INFO, "fheroes2", "%s", _log_strstream.str().c_str() ); \
}
#else // Default: log to STDERR
#elif defined( __EMSCRIPTEN__ )
#include <emscripten/console.h>
#define COUT( x ) \
{ \
std::ostringstream _log_strstream; /* The name was chosen on purpose to avoid name collisions with outer code blocks. */ \
_log_strstream << x; \
emscripten_out( _log_strstream.str().c_str() ); \
}
#else
// Default: log to stderr
#define COUT( x ) \
{ \
std::cerr << x << std::endl; \
Expand Down
4 changes: 2 additions & 2 deletions src/fheroes2/dialog/dialog_selectitems.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) 2011 by Andrey Afletdinov <[email protected]> *
Expand Down Expand Up @@ -1481,7 +1481,7 @@ void Dialog::selectMineType( int32_t & type, int32_t & color )
uint32_t selectedResourceType = 0;

const std::vector<Maps::ObjectInfo> & allObjectInfo = Maps::getObjectsByGroup( Maps::ObjectGroup::ADVENTURE_MINES );
if ( type > 0 ) {
if ( type >= 0 ) {
assert( static_cast<size_t>( type ) < allObjectInfo.size() );

if ( allObjectInfo[type].objectType == MP2::OBJ_ABANDONED_MINE ) {
Expand Down
6 changes: 3 additions & 3 deletions src/fheroes2/gui/interface_gamearea.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 @@ -473,8 +473,6 @@ void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle

TileUnfitRenderObjectInfo tileUnfit;

const Heroes * currentHero = drawHeroes ? GetFocusHeroes() : nullptr;

// TODO: Dragon City with Object ICN Type OBJ_ICN_TYPE_OBJNMUL2 and object index 46 is a bottom layer sprite.
// TODO: When a hero standing besides this turns a part of the hero is visible. This can be fixed only by some hack.

Expand Down Expand Up @@ -695,6 +693,8 @@ void Interface::GameArea::Redraw( fheroes2::Image & dst, int flag, bool isPuzzle
// Draw hero's route. It should be drawn on top of everything.
const bool drawRoutes = ( flag & LEVEL_ROUTES ) != 0;

const Heroes * currentHero = drawHeroes ? GetFocusHeroes() : nullptr;

if ( drawRoutes && ( currentHero != nullptr ) && currentHero->GetPath().isShow() ) {
const Route::Path & path = currentHero->GetPath();
int32_t greenColorSteps = path.GetAllowedSteps();
Expand Down
19 changes: 10 additions & 9 deletions src/fheroes2/maps/maps_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ void Maps::Tile::updatePassability()
return;
}

// If this assertion blows up then you are calling this method more than once!
assert( _tilePassabilityDirections == getTileIndependentPassability() );

// Verify the neighboring tiles.
// If a tile contains a tall object then it affects the passability of diagonal moves to the top from the current tile.
if ( ( _tilePassabilityDirections & Direction::TOP_LEFT ) && isValidDirection( _index, Direction::LEFT ) ) {
Expand Down Expand Up @@ -791,6 +794,13 @@ void Maps::Tile::updatePassability()
}
}

// If the tile below contains an action object and it allows access from top, nothing we need to change for passability
// as the object below does not affect it.
const MP2::MapObjectType bottomTileObjectType = bottomTile.getMainObjectType( false );
if ( MP2::isOffGameActionObject( bottomTileObjectType ) && ( bottomTile.getTileIndependentPassability() & Direction::TOP ) != 0 ) {
return;
}

// Count how many objects are there excluding shadows, roads and river streams.
const std::ptrdiff_t validBottomLayerObjects = std::count_if( _groundObjectPart.begin(), _groundObjectPart.end(), []( const auto & part ) {
if ( isObjectPartShadow( part ) ) {
Expand All @@ -805,18 +815,9 @@ void Maps::Tile::updatePassability()
// TODO: we might need to simplify the logic below as singleObjectTile might cover most of it.
if ( !singleObjectTile && !isDetachedObject() && ( bottomTile._mainObjectPart.icnType != MP2::OBJ_ICN_TYPE_UNKNOWN )
&& !bottomTile._mainObjectPart.isPassabilityTransparent() ) {
const MP2::MapObjectType bottomTileObjectType = bottomTile.getMainObjectType( false );
const MP2::MapObjectType correctedObjectType = MP2::getBaseActionObjectType( bottomTileObjectType );

if ( MP2::isOffGameActionObject( bottomTileObjectType ) || MP2::isOffGameActionObject( correctedObjectType ) ) {
if ( ( bottomTile.getTileIndependentPassability() & Direction::TOP ) != 0 ) {
// This is an action object with unrestricted access from top.

// Only main action object parts can have unrestricted access.
assert( MP2::isOffGameActionObject( bottomTileObjectType ) );
return;
}

if ( !isShortObject( bottomTileObjectType ) && !isShortObject( correctedObjectType ) ) {
// Since the object on the tile below is considered as tall we must mark this tile as impassable.
_tilePassabilityDirections = 0;
Expand Down

0 comments on commit 1d514a4

Please sign in to comment.