diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 56149433..27f9c3d9 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -606,8 +606,13 @@ void Sapphire::Entity::Player::discover( int16_t map_id, int16_t sub_id ) int32_t offset = 4; - auto info = exdData.get< Sapphire::Data::Map >( - exdData.get< Sapphire::Data::TerritoryType >( getCurrentTerritory()->getTerritoryTypeId() )->map ); + auto info = exdData.get< Sapphire::Data::Map >( map_id ); + if ( !info ) + { + sendDebug( "discover(): Could not obtain map data for map_id == {0}", map_id ); + return; + } + if( info->discoveryArrayByte ) offset = 5 + 2 * info->discoveryIndex; else @@ -626,7 +631,28 @@ void Sapphire::Entity::Player::discover( int16_t map_id, int16_t sub_id ) gainExp( exp ); + // gain 10x additional EXP if entire map is completed + uint32_t mask = info->discoveryFlag; + uint32_t discoveredAreas; + if( info->discoveryArrayByte ) + { + discoveredAreas = ( m_discovery[ offset + 1 ] << 8 ) | + m_discovery[ offset ]; + } + else + { + discoveredAreas = ( m_discovery[ offset + 3 ] << 24 ) | + ( m_discovery[ offset + 2 ] << 16 ) | + ( m_discovery[ offset + 1 ] << 8 ) | + m_discovery[ offset ]; + } + bool allDiscovered = ( ( discoveredAreas & mask ) == mask ); + + if( allDiscovered ) + { + gainExp( exp * 10 ); + } } bool Sapphire::Entity::Player::isNewAdventurer() const