Made textures fail harder when given bad config.
This commit is contained in:
parent
7cdd96ef73
commit
a4fdfb779f
1 changed files with 17 additions and 7 deletions
14
textures.cpp
14
textures.cpp
|
|
@ -13,6 +13,7 @@ namespace textures {
|
|||
|
||||
static TextureManager TMGR;
|
||||
static bool initialized = false;
|
||||
static bool failure = false;
|
||||
|
||||
void load_sprite_textures(SpriteTextureMap &mapping, json &config, bool smooth) {
|
||||
for(auto& [name, settings] : config.items()) {
|
||||
|
|
@ -25,8 +26,10 @@ namespace textures {
|
|||
|
||||
int width = settings["frame_width"];
|
||||
int height = settings["frame_height"];
|
||||
dbc::check(width % 2 == 0,
|
||||
fmt::format("sprite {} has invalid frame size {}", name, width));
|
||||
|
||||
dbc::check(width % 2 == 0 && height % 2 == 0,
|
||||
fmt::format("sprite {}:{} has invalid frame size {}:{}",
|
||||
path, name, width, height));
|
||||
|
||||
sf::Vector2i frame_size{width, height};
|
||||
|
||||
|
|
@ -113,12 +116,19 @@ namespace textures {
|
|||
}
|
||||
|
||||
void init() {
|
||||
dbc::check(!failure, "YOU HAD A CATASTROPHIC TEXTURES FAILURE, FIX IT");
|
||||
|
||||
try {
|
||||
if(!initialized) {
|
||||
load_tiles();
|
||||
load_sprites();
|
||||
load_map_tiles();
|
||||
initialized = true;
|
||||
}
|
||||
} catch(...) {
|
||||
failure = true;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
SpriteTexture& get(const string& name, SpriteTextureMap& mapping) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue