diff --git a/include/ZE_ZError.h b/include/ZE_ZError.h index b11cb49..ad47a49 100755 --- a/include/ZE_ZError.h +++ b/include/ZE_ZError.h @@ -13,7 +13,7 @@ File: ZE_ZError.h
Description: Header file for ZEngine Error Object.
Author(s): James Turk
-$Id: ZE_ZError.h,v 1.4 2003/01/16 05:46:39 cozman Exp $
+$Id: ZE_ZError.h,v 1.5 2003/01/26 00:55:52 cozman Exp $
\file ZE_ZError.h \brief Definition file for ZError. @@ -66,7 +66,7 @@ class ZError { protected: //! Static Array of Error Identifiers - static string sErrorDesc[ZERR_LAST]; + static string *sErrorDesc; //! Error ID. ZErrorCode rCode; //! Error Description. @@ -77,6 +77,20 @@ class ZError unsigned int rLine; public: + /*! + \brief Construct string table for error strings. + + Constructs a string table for errors, enabling ZEngine to properly delete the table on exit. + **/ + static void CreateStringTable(); + + /*! + \brief Destroy string table of error strings. + + Properly delete the string table, freeing all memory used by the strings. + **/ + static void DestroyStringTable(); + /*! \brief Default constructor for ZError. diff --git a/src/ZE_ZEngine.cpp b/src/ZE_ZEngine.cpp index bc12ebb..25380a4 100644 --- a/src/ZE_ZEngine.cpp +++ b/src/ZE_ZEngine.cpp @@ -13,7 +13,7 @@ File: ZE_ZEngine.cpp
Description: Implementation source file for ZEngine library main singleton class.
Author(s): James Turk
-$Id: ZE_ZEngine.cpp,v 1.23 2003/01/25 19:55:13 cozman Exp $
+$Id: ZE_ZEngine.cpp,v 1.24 2003/01/26 00:55:52 cozman Exp $
\file ZE_ZEngine.cpp \brief Central source file for ZEngine. @@ -56,6 +56,7 @@ ZEngine::ZEngine() mNextUpdate = mLastPause = mPausedTime = mLastTime = 0; mSecPerFrame = 0.0; + ZError::CreateStringTable(); mLogAllErrors = true; mErrlog = stderr; } @@ -72,6 +73,7 @@ void ZEngine::ReleaseInstance() { if(sInstance) { + ZError::DestroyStringTable(); sInstance->CloseDisplay(); delete sInstance; } diff --git a/src/ZE_ZError.cpp b/src/ZE_ZError.cpp index 6e1cd49..dcc034b 100755 --- a/src/ZE_ZError.cpp +++ b/src/ZE_ZError.cpp @@ -13,7 +13,7 @@ File: ZE_ZError.cpp
Description: Implementation source file for core ZEngine Error Object.
Author(s): James Turk
-$Id: ZE_ZError.cpp,v 1.2 2003/01/16 05:45:58 cozman Exp $
+$Id: ZE_ZError.cpp,v 1.3 2003/01/26 00:55:52 cozman Exp $
\file ZE_ZError.cpp \brief Source file for ZError. @@ -26,16 +26,39 @@ $Id: ZE_ZError.cpp,v 1.2 2003/01/16 05:45:58 cozman Exp $
namespace ZE { -string ZError::sErrorDesc[] = +string *ZError::sErrorDesc = NULL; + + +void ZError::CreateStringTable() { - "No Error. [%s]", - "SDL Error. [%s]", - "Error Initializing SDL: %s", "Error Initializing SDL_mixer: %s", "Error Initializing SDL_ttf: %s", - "Error Creating Display: %s", - "Failed to load Image: %s", "Failed to load Sound: %s", "Failed to load Music: %s", "Failed to load Font: %s", - "Called ZImage::%s with no Image loaded.", "Called ZSound::%s with no Sound loaded.", - "Called ZMusic::%s with no Music loaded.", "Called ZFont::%s with no Font loaded." -}; + if(!sErrorDesc) + { + sErrorDesc = new string[ZERR_LAST]; + sErrorDesc[ZERR_NONE] = "No Error. [%s]"; + sErrorDesc[ZERR_SDL_INTERNAL] = "SDL Error. [%s]"; + sErrorDesc[ZERR_SDL_INIT] = "Error Initializing SDL: %s"; + sErrorDesc[ZERR_MIX_INIT] = "Error Initializing SDL_mixer: %s"; + sErrorDesc[ZERR_TTF_INIT] = "Error Initializing SDL_ttf: %s"; + sErrorDesc[ZERR_VIDMODE] = "Error Creating Display: %s"; + sErrorDesc[ZERR_LOAD_IMAGE] = "Failed to load Image: %s"; + sErrorDesc[ZERR_LOAD_SOUND] = "Failed to load Sound: %s"; + sErrorDesc[ZERR_LOAD_MUSIC] = "Failed to load Music: %s"; + sErrorDesc[ZERR_LOAD_FONT] = "Failed to load Font: %s"; + sErrorDesc[ZERR_NOIMAGE] = "Called ZImage::%s with no Image loaded."; + sErrorDesc[ZERR_NOSOUND] = "Called ZSound::%s with no Sound loaded."; + sErrorDesc[ZERR_NOMUSIC] = "Called ZMusic::%s with no Music loaded."; + sErrorDesc[ZERR_NOFONT] = "Called ZFont::%s with no Font loaded."; + } +} + +void ZError::DestroyStringTable() +{ + if(sErrorDesc) + { + delete []sErrorDesc; + sErrorDesc = NULL; + } +} ZError::ZError(ZErrorCode code, string desc, string file, int line) {