Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve error handling

  • Loading branch information...
commit 430ab559184ff505b7e7c69f650aafa05eb7b465 1 parent 32d6f69
@igorko igorko authored
View
2  src/Avatar.cpp
@@ -186,6 +186,7 @@ void Avatar::loadGraphics(std::vector<Layer_gfx> _img_gfx) {
if (sprites == NULL) {
fprintf(stderr, "Couldn't load body image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
for (unsigned int i=0; i<layer_def.size(); i++) {
@@ -834,6 +835,7 @@ void Avatar::transform() {
if(!transformed_sprites) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
last_transform = charmed_stats->gfx_prefix;
}
View
6 src/GameStateLoad.cpp
@@ -191,6 +191,7 @@ void GameStateLoad::loadGraphics() {
if(!background || !selection || !portrait_border) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
SDL_SetColorKey( selection, SDL_SRCCOLORKEY, SDL_MapRGB(selection->format, 255, 0, 255) );
@@ -305,6 +306,11 @@ void GameStateLoad::loadPreview(int slot) {
short body = -1;
for (unsigned int i=0; i<equipped[slot].size(); i++) {
+ if ((unsigned)equipped[slot][i] > items->items.size()-1){
+ fprintf(stderr, "Item with id=%d not found. Your savegame is broken or you might use incompatible savegame/mod\nQuitting to avoid savegame rewriting\n", equipped[slot][i]);
+ SDL_Quit();
+ exit(1);
+ }
if ((equipped[slot][i] != 0) && (items->items[equipped[slot][i]].type == "body")) {
img_gfx.push_back(items->items[equipped[slot][i]].gfx);
body = img_gfx.size()-1;
View
1  src/GameStateNew.cpp
@@ -148,6 +148,7 @@ void GameStateNew::loadGraphics() {
if(!portrait_border) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
SDL_SetColorKey( portrait_border, SDL_SRCCOLORKEY, SDL_MapRGB(portrait_border->format, 255, 0, 255) );
View
1  src/GameStatePlay.cpp
@@ -94,6 +94,7 @@ GameStatePlay::GameStatePlay() : GameState() {
if(!loading_bg) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
SDL_Surface *cleanup = loading_bg;
loading_bg = SDL_DisplayFormatAlpha(loading_bg);
View
1  src/GameStateTitle.cpp
@@ -64,6 +64,7 @@ void GameStateTitle::loadGraphics() {
if(!cleanup) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/ItemManager.cpp
@@ -367,6 +367,7 @@ void ItemManager::loadIcons() {
if(!icons_small || !icons_large) {
fprintf(stderr, "Couldn't load icons: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuActionBar.cpp
@@ -227,6 +227,7 @@ void MenuActionBar::loadGraphics() {
if(!emptyslot || !background || !disabled || !attention) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuActiveEffects.cpp
@@ -65,6 +65,7 @@ void MenuActiveEffects::loadGraphics() {
if(!timer) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuCharacter.cpp
@@ -240,6 +240,7 @@ void MenuCharacter::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuConfirm.cpp
@@ -45,6 +45,7 @@ void MenuConfirm::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuEnemy.cpp
@@ -72,6 +72,7 @@ void MenuEnemy::loadGraphics() {
if(!background || !bar_hp) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuExit.cpp
@@ -40,6 +40,7 @@ void MenuExit::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuInventory.cpp
@@ -105,6 +105,7 @@ void MenuInventory::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuLog.cpp
@@ -96,6 +96,7 @@ void MenuLog::loadGraphics() {
if(!background) {
fprintf(stderr, "Could not load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuManager.cpp
@@ -170,6 +170,7 @@ void MenuManager::loadIcons() {
if(!icons) {
fprintf(stderr, "Couldn't load icons: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
3  src/MenuPowers.cpp
@@ -145,9 +145,11 @@ MenuPowers::MenuPowers(StatBlock *_stats, PowerManager *_powers, SDL_Surface *_i
if((tabs_count == 1) && (tree_image_files.size() > 0 || tab_titles.size() > 0)) {
fprintf(stderr, "menu/powers.txt error: you don't have tabs, but tab_tree_image and tab_title counts are not 0\n");
SDL_Quit();
+ exit(1);
} else if((tabs_count > 1) && (tree_image_files.size() != (unsigned)tabs_count || tab_titles.size() != (unsigned)tabs_count)) {
fprintf(stderr, "menu/powers.txt error: tabs count, tab_tree_image and tab_name counts do not match\n");
SDL_Quit();
+ exit(1);
}
menuPowers = this;
@@ -201,6 +203,7 @@ void MenuPowers::loadGraphics() {
if(!background || !tree_surf[i] || !powers_unlock || !overlay_disabled) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
}
View
1  src/MenuStash.cpp
@@ -73,6 +73,7 @@ void MenuStash::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuStatBar.cpp
@@ -80,6 +80,7 @@ void MenuStatBar::loadGraphics(std::string type) {
if(!background || !bar) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuTalker.cpp
@@ -110,6 +110,7 @@ void MenuTalker::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image dialog_box.png: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/MenuVendor.cpp
@@ -84,6 +84,7 @@ void MenuVendor::loadGraphics() {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/PowerManager.cpp
@@ -430,6 +430,7 @@ void PowerManager::loadGraphics() {
if(!runes) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
}
View
1  src/TileSet.cpp
@@ -62,6 +62,7 @@ void TileSet::loadGraphics(const std::string& filename) {
if (!sprites) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
} else {
alpha_background = false;
View
1  src/WidgetInput.cpp
@@ -52,6 +52,7 @@ void WidgetInput::loadGraphics(const string& filename) {
if(!background) {
fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
// optimize
View
1  src/WidgetTabControl.cpp
@@ -126,6 +126,7 @@ void WidgetTabControl::loadGraphics()
if(!activeTabSurface || !inactiveTabSurface) {
fprintf(stderr, "Could not load image: %s\n", IMG_GetError());
SDL_Quit();
+ exit(1);
}
SDL_Surface *cleanup;
Please sign in to comment.
Something went wrong with that request. Please try again.