From a12d306b8b881fc7c69f6b42fe2842bc0790223e Mon Sep 17 00:00:00 2001 From: avolkov Date: Mon, 28 Feb 2011 20:02:38 +0000 Subject: [PATCH] Basic content sanity checks and exit w/o crashing on check failure git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3572 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/uqm.c | 2 -- sc2/src/uqm/setup.c | 5 ++++- sc2/src/uqm/starcon.c | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sc2/src/uqm.c b/sc2/src/uqm.c index 1e4cea27a..a96f97a5a 100644 --- a/sc2/src/uqm.c +++ b/sc2/src/uqm.c @@ -476,8 +476,6 @@ main (int argc, char *argv[]) UnInitThreadSystem (); mem_uninit (); } - - log_showBox (false, false); return EXIT_SUCCESS; } diff --git a/sc2/src/uqm/setup.c b/sc2/src/uqm/setup.c index b07cd7601..00984b304 100644 --- a/sc2/src/uqm/setup.c +++ b/sc2/src/uqm/setup.c @@ -110,7 +110,8 @@ LoadKernel (int argc, char *argv[]) return FALSE; /* Load base content. */ - loadIndices (contentDir); + if (loadIndices (contentDir) == 0) + return FALSE; // Must have at least one index in content dir /* Load addons demanded by the current configuration. */ if (opt3doMusic) @@ -139,6 +140,8 @@ LoadKernel (int argc, char *argv[]) COLORMAP ColorMapTab; ColorMapTab = CaptureColorMap (LoadColorMap (STARCON_COLOR_MAP)); + if (ColorMapTab == NULL) + return FALSE; // The most basic resource is missing SetColorMap (GetColorMapAddress (ColorMapTab)); DestroyColorMap (ReleaseColorMap (ColorMapTab)); } diff --git a/sc2/src/uqm/starcon.c b/sc2/src/uqm/starcon.c index 1a7e4ebb8..6fcdec049 100644 --- a/sc2/src/uqm/starcon.c +++ b/sc2/src/uqm/starcon.c @@ -177,10 +177,13 @@ while (--ac > 0) if (!LoadKernel (0,0)) { log_add (log_Fatal, "\n *** FATAL ERROR: Could not load basic content ***\n\nUQM requires at least the base content pack to run properly."); - log_add (log_Fatal, "This file is typically called uqm-%d.%d.0.uqm. UQM was expecting it", UQM_MAJOR_VERSION, UQM_MINOR_VERSION); - log_add (log_Fatal, "in the %s/packages directory.", baseContentPath); + log_add (log_Fatal, "This file is typically called uqm-%d.%d.0-content.uqm. UQM was expecting", UQM_MAJOR_VERSION, UQM_MINOR_VERSION); + log_add (log_Fatal, "it in the %s/packages directory.", baseContentPath); log_add (log_Fatal, "Either your installation did not install the content pack at all, or it\ninstalled it in a different directory.\n\nFix your installation and rerun UQM.\n\n *******************\n"); - exit (EXIT_FAILURE); + log_showBox (true, true); + + MainExited = TRUE; + return EXIT_FAILURE; } log_add (log_Info, "We've loaded the Kernel"); @@ -300,6 +303,7 @@ while (--ac > 0) FreeMasterShipList (); FreeKernel (); + log_showBox (false, false); MainExited = TRUE; (void) threadArg; /* Satisfying compiler (unused parameter) */