Skip to content

Commit

Permalink
[TextureAtlas] Now displaying 'undefined' texture for blocks with wro…
Browse files Browse the repository at this point in the history
…ng texture definition.
  • Loading branch information
Unarelith committed Feb 25, 2020
1 parent bcc3f65 commit 1d4fe0a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/source/graphics/TextureAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ void TextureAtlas::addFile(const std::string &path, const std::string &filename)
return;

SurfacePtr surface{IMG_Load((path + filename).c_str()), &SDL_FreeSurface};
if(!surface)
throw EXCEPTION("Failed to load texture:", path + filename);
if(!surface) {
DEBUG("WARNING: Failed to load texture:", path + filename);
return;
}

if (!m_tileSize)
m_tileSize = surface->w;
Expand Down Expand Up @@ -104,6 +106,8 @@ void TextureAtlas::packTextures() {
}

void TextureAtlas::loadFromRegistry() {
addFile("mods/default/textures/blocks/", "undefined.png");

for (auto &block : Registry::getInstance().blocks()) {
const TilesDef &tiles = block->tiles();
for (auto &textureFilename : tiles.textureFilenames())
Expand All @@ -128,7 +132,7 @@ void TextureAtlas::loadFromRegistry() {
u16 TextureAtlas::getTextureID(const std::string &filename) const {
auto it = m_textureMap.find(filename);
if (it == m_textureMap.end()) {
throw EXCEPTION("Unable to find texture in atlas:", filename);
return 0;
}

return it->second;
Expand Down
Binary file added mods/default/textures/blocks/undefined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mods/default/textures_mc/blocks/undefined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d4fe0a

Please sign in to comment.