From 49e46f8940d24926abf3fc396ea1d43bd3c3ef76 Mon Sep 17 00:00:00 2001 From: Richard Fine Date: Sun, 30 Dec 2018 11:47:30 +0000 Subject: [PATCH] Replace GetSurfaceStyleAtLocation with map_get_surface_element_at There exists a helper function map_get_surface_element_at which already searches a tile's element list for the surface element, so we can just use that. --- test/tests/Pathfinding.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 16d4bfe4f7..d1abec1e0f 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -122,7 +122,7 @@ protected: { const uint32_t forbiddenSurfaceStyle = 8u; - const uint32_t style = GetSurfaceStyleAtLocation(TileCoordsXY(location.x, location.y)); + const uint32_t style = map_get_surface_element_at(location.x, location.y)->AsSurface()->GetSurfaceStyle(); if (style == forbiddenSurfaceStyle) return ::testing::AssertionFailure() @@ -134,21 +134,9 @@ protected: private: - static uint32_t GetSurfaceStyleAtLocation(const TileCoordsXY& location) - { - TileElement* element = map_get_first_element_at(location.x, location.y); - - // Every tile *should* have a surface sprite, so we should be guaranteed to find - // something before we go off the end of the data. - while (element->GetType() != TILE_ELEMENT_TYPE_SURFACE) - element++; - - return element->AsSurface()->GetSurfaceStyle(); - } - static ::testing::AssertionResult AssertPositionIsSetUp(const char* positionKind, uint32_t expectedSurfaceStyle, const TileCoordsXYZ& location) { - const uint32_t style = GetSurfaceStyleAtLocation(TileCoordsXY(location.x, location.y)); + const uint32_t style = map_get_surface_element_at(location.x, location.y)->AsSurface()->GetSurfaceStyle(); if (style != expectedSurfaceStyle) return ::testing::AssertionFailure()