Skip to content

Commit

Permalink
Merge pull request #234 from DragonSlayer62/MapStuff
Browse files Browse the repository at this point in the history
Fixed Z
  • Loading branch information
Xoduz authored Nov 18, 2023
2 parents de9f082 + aa5f974 commit 44543b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
18/11/2023 - Xuri
Enhance the calculation of the average 'z' for movement.

15/11/2023 - Dragon Slayer
Added Christmas Items from differant years. (dfn christmas)
Added Christmas Npcs from differant years. (dfn christmascreatures)
Expand Down
18 changes: 9 additions & 9 deletions source/mapstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,15 +1031,15 @@ auto CMulHandler::DynamicElevation( std::int16_t x, std::int16_t y, std::int8_t
//| Purpose - Returns the map elevation at given coordinates, we'll assume since its land
//| the height is inherently 0
//o------------------------------------------------------------------------------------------------o
auto CMulHandler::MapElevation( std::int16_t x, std::int16_t y, std::uint8_t worldNumber ) -> std::int8_t
{
const auto &map = SeekMap( x, y, worldNumber );
// make sure nothing can move into black areas
if( map.isVoid() )
{
return ILLEGAL_Z;
}
return map.altitude;
auto CMulHandler::MapElevation( std::int16_t x, std::int16_t y, std::uint8_t worldNumber, bool ignoreVoid ) -> std::int8_t
{
const auto &map = SeekMap( x, y, worldNumber );
// make sure nothing can move into black areas
if( !ignoreVoid && map.isVoid() )
{
return ILLEGAL_Z;
}
return map.altitude;
}

//o------------------------------------------------------------------------------------------------o
Expand Down
2 changes: 1 addition & 1 deletion source/mapstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class CMulHandler
// height functions
auto StaticTop( std::int16_t x, std::int16_t y, std::int8_t z, std::uint8_t worldNumber, std::int8_t maxZ ) -> std::int8_t;
auto DynamicElevation( std::int16_t x, std::int16_t y, std::int8_t z, std::uint8_t worldNumber, std::uint16_t instanceId, std::int8_t maxZ ) -> std::int8_t;
auto MapElevation( std::int16_t x, std::int16_t y, std::uint8_t worldNumber ) -> std::int8_t;
auto MapElevation( std::int16_t x, std::int16_t y, std::uint8_t worldNumber, bool ignoreVoid = false ) -> std::int8_t;
auto TileHeight( std::uint16_t tileNum ) -> std::int8_t;
auto Height( std::int16_t x, std::int16_t y, std::int8_t z, std::uint8_t worldNumber, std::uint16_t instanceId ) -> std::int8_t;
auto InBuilding( std::int16_t x, std::int16_t y, std::int8_t z, std::uint8_t worldNumber, std::uint16_t instanceId ) -> bool;
Expand Down
8 changes: 4 additions & 4 deletions source/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2651,10 +2651,10 @@ void CMovement::NpcMovement( CChar& mChar )
//o------------------------------------------------------------------------------------------------o
void CMovement::GetAverageZ( UI08 nm, SI16 x, SI16 y, SI08& z, SI08& avg, SI08& top )
{
SI08 zTop = Map->MapElevation( x, y, nm );
SI08 zLeft = Map->MapElevation( x, y + 1, nm );
SI08 zRight = Map->MapElevation( x + 1, y, nm );
SI08 zBottom = Map->MapElevation( x + 1, y + 1, nm );
SI08 zTop = Map->MapElevation( x, y, nm, true );
SI08 zLeft = Map->MapElevation( x, y + 1, nm, true );
SI08 zRight = Map->MapElevation( x + 1, y, nm, true );
SI08 zBottom = Map->MapElevation( x + 1, y + 1, nm, true );

z = zTop;
if( zLeft < z )
Expand Down

0 comments on commit 44543b1

Please sign in to comment.