diff --git a/src/twn_textures.c b/src/twn_textures.c index d4c69e3..6093d65 100644 --- a/src/twn_textures.c +++ b/src/twn_textures.c @@ -24,7 +24,7 @@ static int load_read_callback(void *user, char *data, int size) { int read = (int)SDL_RWread(context->rwops, data, 1, size); context->position += read; if (read == 0) - CRY_SDL( "Error in streamed texture load."); + CRY_SDL("Error in streamed texture load."); return read; } @@ -79,6 +79,9 @@ static SDL_Surface *gen_missing_texture_surface(void) { SDL_Surface *textures_load_surface(const char *path) { + if (SDL_strncmp(path, "!", 1) == 0) + goto GET_MISSING_TEXTURE; + SDL_RWops *handle = PHYSFSRWOPS_openRead(path); if (handle == NULL) goto ERR_CANNOT_OPEN_FILE; @@ -133,6 +136,7 @@ ERR_CANNOT_READ_IMAGE: ERR_CANNOT_OPEN_FILE: /* something didn't worked out, use a stub texture */ log_warn("Cannot open image: %s, using a stub", path); +GET_MISSING_TEXTURE: return gen_missing_texture_surface(); } @@ -465,7 +469,7 @@ void textures_update_atlas(TextureCache *cache) { TextureKey textures_get_key(TextureCache *cache, const char *path) { /* to prevent hashing errors */ - if (!path) path = ""; + if (!path) path = "!"; /* hash tables are assumed to be stable, so we just return indices */ const ptrdiff_t texture = shgeti(cache->hash, path);