Skip to content

Commit

Permalink
Update debug mode logging to include hero role (ihhub#5586)
Browse files Browse the repository at this point in the history
  • Loading branch information
idshibanov authored Jul 4, 2022
1 parent cb1c510 commit 04d1b8c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/fheroes2/ai/normal/ai_normal_kingdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ namespace AI
_neutralMonsterStrengthCache.clear();

DEBUG_LOG( DBG_AI, DBG_INFO, Color::String( myColor ) << " starts the turn: " << castles.size() << " castles, " << heroes.size() << " heroes" )
DEBUG_LOG( DBG_AI, DBG_TRACE, "Funds: " << kingdom.GetFunds().String() )
DEBUG_LOG( DBG_AI, DBG_INFO, "Funds: " << kingdom.GetFunds().String() )

// Step 1. Scan visible map (based on game difficulty), add goals and threats
bool underViewSpell = false;
Expand Down
2 changes: 1 addition & 1 deletion src/fheroes2/army/army.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ std::string Army::String() const
os << "color(" << Color::String( commander ? commander->GetColor() : color ) << "), ";

if ( GetCommander() )
os << "commander(" << GetCommander()->GetName() << "), ";
os << "commander(" << GetCommander()->GetName() << ")";

os << ": ";

Expand Down
37 changes: 28 additions & 9 deletions src/fheroes2/heroes/heroes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ namespace

return result;
}

std::string GetHeroRoleString( const Heroes & hero )
{
switch ( hero.getAIRole() ) {
case Heroes::Role::SCOUT:
return "Scout";
case Heroes::Role::COURIER:
return "Courier";
case Heroes::Role::HUNTER:
return "Hunter";
case Heroes::Role::FIGHTER:
return "Fighter";
case Heroes::Role::CHAMPION:
return "Champion";
default:
// Did you add a new AI hero role? Add the appropriate logic for it!
assert( 0 );
break;
}

return "Unknown";
}
}

const char * Heroes::GetName( int heroid )
Expand Down Expand Up @@ -1614,17 +1636,13 @@ std::string Heroes::String() const
{
std::ostringstream os;

os << "name : " << name << std::endl
<< "race : " << Race::String( _race ) << std::endl
os << "name : " << name << " (" << Race::String( _race ) << ")" << std::endl
<< "color : " << Color::String( GetColor() ) << std::endl
<< "experience : " << experience << std::endl
<< "level : " << GetLevel() << std::endl
<< "magic point : " << GetSpellPoints() << std::endl
<< "position x : " << GetCenter().x << std::endl
<< "position y : " << GetCenter().y << std::endl
<< "move point : " << move_point << std::endl
<< "max magic point : " << GetMaxSpellPoints() << std::endl
<< "max move point : " << GetMaxMovePoints() << std::endl
<< "magic points : " << GetSpellPoints() << " / " << GetMaxSpellPoints() << std::endl
<< "position x, y : " << GetCenter().x << ", " << GetCenter().y << std::endl
<< "move points : " << move_point << " / " << GetMaxMovePoints() << std::endl
<< "direction : " << Direction::String( direction ) << std::endl
<< "index sprite : " << sprite_index << std::endl
<< "in castle : " << ( inCastle() ? "true" : "false" ) << std::endl
Expand All @@ -1646,7 +1664,8 @@ std::string Heroes::String() const
os << "skills : " << secondary_skills.String() << std::endl
<< "artifacts : " << bag_artifacts.String() << std::endl
<< "spell book : " << ( HaveSpellBook() ? spell_book.String() : "disabled" ) << std::endl
<< "army dump : " << army.String() << std::endl;
<< "army dump : " << army.String() << std::endl
<< "ai role : " << GetHeroRoleString( *this ) << std::endl;

os << AI::Get().HeroesString( *this );
}
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 @@ -2742,7 +2742,7 @@ int32_t Maps::Tiles::getIndexOfMainTile( const Maps::Tiles & tile )
}

// Most likely we have a broken object put by an editor.
DEBUG_LOG( DBG_GAME, DBG_WARN, "Tile " << tileIndex << " of type " << MP2::StringObject( objectType ) << " has no parent tile." )
DEBUG_LOG( DBG_GAME, DBG_TRACE, "Tile " << tileIndex << " of type " << MP2::StringObject( objectType ) << " has no parent tile." )
return -1;
}

Expand Down

0 comments on commit 04d1b8c

Please sign in to comment.