Skip to content

Commit

Permalink
Let's not hide error messages, and add more debugging to track down a…
Browse files Browse the repository at this point in the history
… few

issues
  • Loading branch information
vexed committed Jun 26, 2012
1 parent 3c5e879 commit 3640b02
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lib/framework/debug.cpp
Expand Up @@ -204,7 +204,7 @@ bool debug_callback_file_init(void **data)
}

setbuf(logfile, NULL);
fprintf(logfile, "\n--- Starting log ---\n");
fprintf(logfile, "\n--- Starting log [%s]---\n", WZDebugfilename);
*data = logfile;

return true;
Expand Down Expand Up @@ -316,7 +316,7 @@ void debug_register_callback( debug_callback_fn callback, debug_callback_init in
if (tmpCallback->init
&& !tmpCallback->init(&tmpCallback->data))
{
debug(LOG_ERROR, "Failed to initialise debug callback");
fprintf(stderr, "Failed to initialise debug callback, debugfile set to [%s]!\n", WZDebugfilename);
free(tmpCallback);
return;
}
Expand Down
43 changes: 22 additions & 21 deletions src/game.cpp
Expand Up @@ -1936,7 +1936,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail23\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}

Expand All @@ -1946,7 +1946,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
{
if (!loadTerrainTypeMap(pFileData, fileSize))
{
debug( LOG_NEVER, "loadgame: Fail25\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand Down Expand Up @@ -1992,7 +1992,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
//load the data into apsTemplates
if (!loadSaveTemplate(aFileName))
{
debug(LOG_NEVER, "Failed to load templates from %s", aFileName);
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand All @@ -2015,7 +2015,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
strcat(aFileName, "mission.map");
if (!mapLoad(aFileName, false))
{
debug(LOG_ERROR, "Failed to load map");
debug(LOG_ERROR, "Failed with: %s", aFileName);
return false;
}

Expand All @@ -2026,7 +2026,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
// Load in the visibility data from the chosen file
if (!readVisibilityData(aFileName))
{
debug( LOG_NEVER, "loadgame: Fail33\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}

Expand All @@ -2044,12 +2044,12 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail14\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
if (!loadSaveFeature(pFileData, fileSize))
{
debug( LOG_NEVER, "loadgame: Fail16\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand All @@ -2067,13 +2067,13 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail17\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
//load the data into apsStructLists
if (!loadSaveStructure(pFileData, fileSize))
{
debug( LOG_NEVER, "loadgame: Fail19\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand Down Expand Up @@ -2130,7 +2130,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
strcat(aFileName, "game.map");
if (!mapLoad(aFileName, false))
{
debug( LOG_NEVER, "loadgame: Fail7\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
return(false);
}
}
Expand All @@ -2149,7 +2149,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
// load the fx data from the file
if (!readFXData(aFileName))
{
debug(LOG_ERROR, "loadgame: Fail33");
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand Down Expand Up @@ -2206,12 +2206,12 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail8\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
if (!loadSaveDroidInit(pFileData,fileSize))
{
debug( LOG_NEVER, "loadgame: Fail10\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
debug(LOG_SAVE, "Loaded old style droids");
Expand Down Expand Up @@ -2284,14 +2284,14 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail14\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}

//load the data into apsFeatureLists
if (!loadSaveFeature(pFileData, fileSize))
{
debug( LOG_NEVER, "loadgame: Fail16\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand All @@ -2308,13 +2308,13 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
pFileData = fileLoadBuffer;
if (!loadFileToBuffer(aFileName, pFileData, FILE_LOAD_BUFFER_SIZE, &fileSize))
{
debug( LOG_NEVER, "loadgame: Fail17\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
//load the data into apsStructLists
if (!loadSaveStructure(pFileData, fileSize))
{
debug( LOG_NEVER, "loadgame: Fail19\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand Down Expand Up @@ -2357,7 +2357,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
// Load in the visibility data from the chosen file
if (!readVisibilityData(aFileName))
{
debug( LOG_NEVER, "loadgame: Fail33\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand All @@ -2375,7 +2375,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
// Load the fx data from the chosen file
if (!readScoreData(aFileName))
{
debug( LOG_NEVER, "loadgame: Fail33\n" );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand All @@ -2393,7 +2393,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User

if (!readFiresupportDesignators(aFileName))
{
debug( LOG_NEVER, "loadMissionExtras: readFiresupportDesignators(%s) failed\n", aFileName );
debug(LOG_ERROR, "Failed with: %s", aFileName);
goto error;
}
}
Expand Down Expand Up @@ -2506,7 +2506,8 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
return true;

error:
debug(LOG_ERROR, "Game load failed");
debug(LOG_ERROR, "Game load failed for %s, FS:%s, params=%s,%s,%s", pGameToLoad, PHYSFS_getRealDir(pGameToLoad),
keepObjects ? "true":"false", freeMem ? "true":"false", UserSaveGame ? "true":"false");

/* Clear all the objects off the map and free up the map memory */
freeAllDroids();
Expand Down

0 comments on commit 3640b02

Please sign in to comment.