Skip to content

Commit

Permalink
Fixed a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Znurre committed Dec 15, 2015
1 parent cb962e6 commit 19ac8ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tiled/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ Layer& Layer::setProperty(const std::string &name, bool isSet)

int Layer::tileAt(int x, int y) const
{
return m_tileData[x + y * m_size.x];
const auto index = x + y * m_size.x;

if (index > 0 && m_tileData.size() > index)
{
return m_tileData[index];
}

return 0;
}

void Layer::draw(sf::RenderTarget &target, sf::RenderStates states) const
Expand Down

0 comments on commit 19ac8ca

Please sign in to comment.