Skip to content

Commit

Permalink
Merge branch 'bugfixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
automerge authored and cybersphinx committed Jun 29, 2012
2 parents 40fcab0 + ef2b236 commit 59cb281
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 49 deletions.
4 changes: 2 additions & 2 deletions lib/framework/debug.cpp
Original file line number Diff line number Diff line change
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
16 changes: 15 additions & 1 deletion lib/ivis_opengl/piestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

static bool shadersAvailable = false;
static bool shaderUsage = false;
static bool fallbackAvailable = true;
static GLuint shaderProgram[SHADER_MAX];
static GLfloat shaderStretch = 0;
static GLint locTeam, locStretch, locTCMask, locFog, locNormalMap, locEcm, locTime;
Expand Down Expand Up @@ -140,14 +141,27 @@ void pie_SetShaderAvailability(bool availability)
shadersAvailable = availability;
}

bool pie_GetFallbackAvailability(void)
{
return fallbackAvailable;
}

void pie_SetFallbackAvailability(bool availability)
{
fallbackAvailable = availability;
}

bool pie_GetShaderUsage(void)
{
return shaderUsage;
}

void pie_SetShaderUsage(bool usage)
{
shaderUsage = pie_GetShaderAvailability() && usage;
bool valid = !usage && pie_GetFallbackAvailability();
valid = valid || (usage && pie_GetShaderAvailability());
if (valid)
shaderUsage = usage;
}

// Read shader into text buffer
Expand Down
2 changes: 2 additions & 0 deletions lib/ivis_opengl/piestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ extern void pie_SetRendMode(REND_MODE rendMode);
// Shaders control center
extern bool pie_GetShaderAvailability(void);
extern void pie_SetShaderAvailability(bool);
extern bool pie_GetFallbackAvailability(void);
extern void pie_SetFallbackAvailability(bool);
extern bool pie_GetShaderUsage(void);
extern void pie_SetShaderUsage(bool);

Expand Down
8 changes: 5 additions & 3 deletions lib/ivis_opengl/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ bool screenInitialise()

bool haveARB_vertex_buffer_object = GLEW_ARB_vertex_buffer_object || GLEW_VERSION_1_5;
bool haveARB_texture_env_crossbar = GLEW_ARB_texture_env_crossbar || GLEW_NV_texture_env_combine4 || GLEW_VERSION_1_4;
bool canRunAtAll = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && haveARB_texture_env_crossbar;
bool canRunShaders = canRunAtAll && glslVersion >= std::make_pair(1, 20); // glGetString(GL_SHADING_LANGUAGE_VERSION) >= "1.20"
bool canRunFallback = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && haveARB_texture_env_crossbar;
bool canRunShaders = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && glslVersion >= std::make_pair(1, 20); // glGetString(GL_SHADING_LANGUAGE_VERSION) >= "1.20"

pie_SetFallbackAvailability(canRunFallback);

if (canRunShaders)
{
Expand All @@ -179,7 +181,7 @@ bool screenInitialise()
pie_SetShaderAvailability(true);
}
}
else if (canRunAtAll)
else if (canRunFallback)
{
// corner cases: vbo(core 1.5 or ARB ext), texture crossbar (core 1.4 or ARB ext)
debug(LOG_POPUP, _("OpenGL GLSL shader version 1.20 is not supported by your system. Some things may look wrong. Please upgrade your graphics driver/hardware, if possible."));
Expand Down
2 changes: 1 addition & 1 deletion lib/netplay/netplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ UBYTE NETrecvFile(NETQUEUE queue)
}
snprintf(fileName, sizeof(fileName), "maps/%dc-%s-%s.wz", game.maxPlayers, mapName, fileHash.toString().c_str()); // Wonder whether game.maxPlayers is initialised already?

debug(LOG_NET, "Creating new file %s hash %s", fileName, fileHash.toString().c_str());
debug(LOG_INFO, "Creating new file %s hash %s", fileName, fileHash.toString().c_str());

if (PHYSFS_exists(fileName))
{
Expand Down
6 changes: 4 additions & 2 deletions src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ static bool startVideoOptionsMenu(void)
// Shaders
addTextButton(FRONTEND_SHADERS, FRONTEND_POS6X-35, FRONTEND_POS7Y, _("Shaders"), 0);

if (war_GetShaders() == SHADERS_ON)
if (war_GetShaders() == SHADERS_ON || war_GetShaders() == SHADERS_ONLY)
{
addTextButton(FRONTEND_SHADERS_R, FRONTEND_POS6M-55, FRONTEND_POS7Y, _("On"), 0);
}
Expand Down Expand Up @@ -1063,16 +1063,18 @@ bool runVideoOptionsMenu(void)
{
case SHADERS_ON:
war_SetShaders(SHADERS_OFF);
pie_SetShaderUsage(false);
widgSetString(psWScreen, FRONTEND_SHADERS_R, _("Off"));
break;
case SHADERS_OFF:
war_SetShaders(SHADERS_ON);
pie_SetShaderUsage(true);
widgSetString(psWScreen, FRONTEND_SHADERS_R, _("On"));
break;
case FALLBACK:
case SHADERS_ONLY:
break;
}
pie_SetShaderUsage(war_GetShaders()==SHADERS_ON);
break;
}

Expand Down
43 changes: 22 additions & 21 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,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 @@ -1943,7 +1943,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 @@ -1989,7 +1989,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 @@ -2012,7 +2012,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 @@ -2023,7 +2023,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 @@ -2041,12 +2041,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 @@ -2064,13 +2064,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 @@ -2127,7 +2127,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 @@ -2146,7 +2146,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 @@ -2203,12 +2203,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 @@ -2281,14 +2281,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 @@ -2305,13 +2305,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 @@ -2354,7 +2354,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 @@ -2372,7 +2372,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 @@ -2390,7 +2390,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 @@ -2503,7 +2503,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
Loading

0 comments on commit 59cb281

Please sign in to comment.