Merge branch 'bugfixes'
commit
ba99a063fd
|
@ -33,8 +33,15 @@ void cocoaInit(void);
|
|||
* \param message Summary of the issue
|
||||
* \param information A more detailed explanation of the issue
|
||||
* \param style 0 is a warning, 1 is informational, and 2 is critical. (NSAlertStyle)
|
||||
* \param buttonTitles A null-terminated list of button titles, displayed from right to left.
|
||||
* \returns The index of the selected button. (0-indexed from leftmost argument, rightmost displayed button.)
|
||||
*/
|
||||
void cocoaShowAlert(const char *message, const char *information, unsigned style);
|
||||
int cocoaShowAlert(const char *message, const char *information, unsigned style,
|
||||
const char *buttonTitles, ...) __attribute__ ((sentinel));
|
||||
|
||||
void cocoaSelectFileInFinder(const char *filename);
|
||||
void cocoaOpenURL(const char *url);
|
||||
void cocoaOpenUserCrashReportFolder();
|
||||
|
||||
#endif // WZ_OS_MAC
|
||||
|
||||
|
|
|
@ -22,22 +22,69 @@
|
|||
|
||||
#ifdef WZ_OS_MAC
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <stdarg.h>
|
||||
|
||||
void cocoaInit()
|
||||
{
|
||||
NSApplicationLoad();
|
||||
}
|
||||
|
||||
void cocoaShowAlert(const char *message, const char *information, unsigned style)
|
||||
static inline NSString *nsstringify(const char *str)
|
||||
{
|
||||
return [NSString stringWithUTF8String:str];
|
||||
}
|
||||
|
||||
int cocoaShowAlert(const char *message, const char *information, unsigned style,
|
||||
const char *buttonTitle, ...)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
[alert addButtonWithTitle:@"OK"];
|
||||
[alert setMessageText:[NSString stringWithUTF8String:message]];
|
||||
[alert setInformativeText:[NSString stringWithUTF8String:information]];
|
||||
[alert setMessageText:nsstringify(message)];
|
||||
[alert setInformativeText:nsstringify(information)];
|
||||
[alert setAlertStyle:style];
|
||||
[alert runModal];
|
||||
|
||||
va_list args;
|
||||
va_start(args, buttonTitle);
|
||||
const char *currentButtonTitle = buttonTitle;
|
||||
do {
|
||||
[alert addButtonWithTitle:nsstringify(currentButtonTitle)];
|
||||
} while ((currentButtonTitle = va_arg(args, const char *)));
|
||||
va_end(args);
|
||||
|
||||
NSInteger buttonID = [alert runModal];
|
||||
[pool release];
|
||||
return buttonID - NSAlertFirstButtonReturn;
|
||||
}
|
||||
|
||||
void cocoaSelectFileInFinder(const char *filename)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[[NSWorkspace sharedWorkspace] selectFile:nsstringify(filename) inFileViewerRootedAtPath:nil];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void cocoaOpenURL(const char *url)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:nsstringify(url)]];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void cocoaOpenUserCrashReportFolder()
|
||||
{
|
||||
SInt32 maj, min;
|
||||
if (Gestalt(gestaltSystemVersionMajor, &maj) == noErr
|
||||
&& Gestalt(gestaltSystemVersionMinor, &min) == noErr)
|
||||
{
|
||||
if (maj == 10 && min <= 5)
|
||||
{
|
||||
cocoaOpenURL("file://~/Library/Logs/CrashReporter");
|
||||
}
|
||||
else
|
||||
{
|
||||
cocoaOpenURL("file://~/Library/Logs/DiagnosticReports");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // WZ_OS_MAC
|
||||
|
|
|
@ -190,14 +190,15 @@ void debug_callback_file( void ** data, const char * outputBuffer )
|
|||
* \param[in,out] data In: The filename to output to.
|
||||
* Out: The filehandle.
|
||||
*/
|
||||
bool debug_callback_file_init(void ** data)
|
||||
const char *WZDebugfilename;
|
||||
bool debug_callback_file_init(void **data)
|
||||
{
|
||||
const char * filename = (const char *)*data;
|
||||
WZDebugfilename = (const char *)*data;
|
||||
|
||||
FILE* const logfile = fopen(filename, "w");
|
||||
FILE* const logfile = fopen(WZDebugfilename, "w");
|
||||
if (!logfile)
|
||||
{
|
||||
fprintf(stderr, "Could not open %s for appending!\n", filename);
|
||||
fprintf(stderr, "Could not open %s for appending!\n", WZDebugfilename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -460,21 +461,26 @@ void _debug( int line, code_part part, const char *function, const char *str, ..
|
|||
{
|
||||
#if defined(WZ_OS_WIN)
|
||||
char wbuf[512];
|
||||
ssprintf(wbuf, "%s\n\nPlease check your stderr.txt file in the same directory as the program file for more details. \
|
||||
\nDo not forget to upload both the stderr.txt file and the warzone2100.rpt file in your bug reports!", useInputBuffer1 ? inputBuffer[1] : inputBuffer[0]);
|
||||
MessageBoxA( NULL,
|
||||
wbuf,
|
||||
"Warzone has terminated unexpectedly", MB_OK|MB_ICONERROR);
|
||||
ssprintf(wbuf, "%s\n\nPlease check the file (%s) in your configuration directory for more details. \
|
||||
\nDo not forget to upload the %s file, WZdebuginfo.txt and the warzone2100.rpt files in your bug reports at http://developer.wz2100.net/newticket!", useInputBuffer1 ? inputBuffer[1] : inputBuffer[0], WZDebugfilename, WZDebugfilename);
|
||||
MessageBoxA( NULL, wbuf, "Warzone has terminated unexpectedly", MB_OK|MB_ICONERROR);
|
||||
#elif defined(WZ_OS_MAC)
|
||||
cocoaShowAlert("Warzone has terminated unexpectedly.",
|
||||
"Please check your logs for more details."
|
||||
"\n\nRun Console.app, search for \"wz2100\", and copy that to a file."
|
||||
"\n\nIf you are on 10.4 (Tiger) or 10.5 (Leopard) the crash report"
|
||||
" is in ~/Library/Logs/CrashReporter."
|
||||
" If you are on 10.6 (Snow Leopard), it is in"
|
||||
"\n~/Library/Logs/DiagnosticReports."
|
||||
"\n\nDo not forget to upload and attach those to a bug report at http://developer.wz2100.net/newticket"
|
||||
"\nThanks!", 2);
|
||||
int clickedIndex = \
|
||||
cocoaShowAlert("Warzone has quit unexpectedly.",
|
||||
"Please check your logs and attach them along with a bug report. Thanks!",
|
||||
2, "Show Log Files & Open Bug Reporter", "Ignore", NULL);
|
||||
if (clickedIndex == 0)
|
||||
{
|
||||
if (WZDebugfilename == NULL) {
|
||||
cocoaShowAlert("Unable to open debug log.",
|
||||
"The debug log subsystem has not yet been initialised.",
|
||||
2, "Continue", NULL);
|
||||
} else {
|
||||
cocoaSelectFileInFinder(WZDebugfilename);
|
||||
}
|
||||
cocoaOpenUserCrashReportFolder();
|
||||
cocoaOpenURL("http://developer.wz2100.net/newticket");
|
||||
}
|
||||
#else
|
||||
const char* popupBuf = useInputBuffer1 ? inputBuffer[1] : inputBuffer[0];
|
||||
wzFatalDialog(popupBuf);
|
||||
|
@ -492,7 +498,7 @@ void _debug( int line, code_part part, const char *function, const char *str, ..
|
|||
wbuf,
|
||||
"Warzone has detected a problem.", MB_OK|MB_ICONINFORMATION);
|
||||
#elif defined(WZ_OS_MAC)
|
||||
cocoaShowAlert("Warzone has detected a problem.", inputBuffer[useInputBuffer1 ? 1 : 0], 0);
|
||||
cocoaShowAlert("Warzone has detected a problem.", inputBuffer[useInputBuffer1 ? 1 : 0], 0, "OK", NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,12 @@ static int preview_width = 0, preview_height = 0;
|
|||
static Vector2i player_pos[MAX_PLAYERS];
|
||||
static bool mappreview = false;
|
||||
static char mapname[256];
|
||||
OPENGL_DATA opengl;
|
||||
extern bool writeGameInfo(const char *pFileName); // Used to help debug issues when we have fatal errors.
|
||||
|
||||
/* Initialise the double buffered display */
|
||||
bool screenInitialise()
|
||||
{
|
||||
char buf[256];
|
||||
GLint glMaxTUs;
|
||||
GLenum err;
|
||||
|
||||
|
@ -74,18 +75,18 @@ bool screenInitialise()
|
|||
}
|
||||
|
||||
/* Dump general information about OpenGL implementation to the console and the dump file */
|
||||
ssprintf(buf, "OpenGL Vendor: %s", glGetString(GL_VENDOR));
|
||||
addDumpInfo(buf);
|
||||
debug(LOG_3D, "%s", buf);
|
||||
ssprintf(buf, "OpenGL Renderer: %s", glGetString(GL_RENDERER));
|
||||
addDumpInfo(buf);
|
||||
debug(LOG_3D, "%s", buf);
|
||||
ssprintf(buf, "OpenGL Version: %s", glGetString(GL_VERSION));
|
||||
addDumpInfo(buf);
|
||||
debug(LOG_3D, "%s", buf);
|
||||
ssprintf(buf, "GLEW Version: %s", glewGetString(GLEW_VERSION));
|
||||
addDumpInfo(buf);
|
||||
debug(LOG_3D, "%s", buf);
|
||||
ssprintf(opengl.vendor, "OpenGL Vendor: %s", glGetString(GL_VENDOR));
|
||||
addDumpInfo(opengl.vendor);
|
||||
debug(LOG_3D, "%s", opengl.vendor);
|
||||
ssprintf(opengl.renderer, "OpenGL Renderer: %s", glGetString(GL_RENDERER));
|
||||
addDumpInfo(opengl.renderer);
|
||||
debug(LOG_3D, "%s", opengl.renderer);
|
||||
ssprintf(opengl.version, "OpenGL Version: %s", glGetString(GL_VERSION));
|
||||
addDumpInfo(opengl.version);
|
||||
debug(LOG_3D, "%s", opengl.version);
|
||||
ssprintf(opengl.GLEWversion, "GLEW Version: %s", glewGetString(GLEW_VERSION));
|
||||
addDumpInfo(opengl.GLEWversion);
|
||||
debug(LOG_3D, "%s", opengl.GLEWversion);
|
||||
|
||||
/* Dump extended information about OpenGL implementation to the console */
|
||||
debug(LOG_3D, "OpenGL Extensions : %s", glGetString(GL_EXTENSIONS)); // FIXME This is too much for MAX_LEN_LOG_LINE
|
||||
|
@ -119,8 +120,8 @@ bool screenInitialise()
|
|||
GLint glMaxTIUs, glMaxTCs, glMaxTIUAs, glmaxSamples, glmaxSamplesbuf;
|
||||
|
||||
debug(LOG_3D, " * OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
ssprintf(buf, "OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
addDumpInfo(buf);
|
||||
ssprintf(opengl.GLSLversion, "OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
addDumpInfo(opengl.GLSLversion);
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &glMaxTIUs);
|
||||
debug(LOG_3D, " * Total number of Texture Image Units (TIUs) supported is %d.", (int) glMaxTIUs);
|
||||
|
@ -145,7 +146,7 @@ bool screenInitialise()
|
|||
}
|
||||
else // less than 1.5
|
||||
{
|
||||
// Check if VBO extension available for haxx
|
||||
// Check if VBO extension available for hacks
|
||||
if (GLEW_VERSION_1_4 && GLEW_ARB_vertex_buffer_object)
|
||||
{
|
||||
debug(LOG_POPUP, _("OpenGL 1.5/2.0 is not supported by your system. Some things may look wrong. Please upgrade your graphics driver/hardware, if possible."));
|
||||
|
@ -153,6 +154,8 @@ bool screenInitialise()
|
|||
}
|
||||
else
|
||||
{
|
||||
// We wite this file in hopes that people will upload the information in it to us.
|
||||
writeGameInfo("WZdebuginfo.txt");
|
||||
debug(LOG_FATAL, _("OpenGL 1.4 + VBO extension is not supported by your system. The game requires this. Please upgrade your graphics drivers/hardware, if possible."));
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -65,5 +65,13 @@ void screen_disableMapPreview(void);
|
|||
bool screen_getMapPreview(void);
|
||||
|
||||
void screen_EnableVBO();
|
||||
|
||||
struct OPENGL_DATA
|
||||
{
|
||||
char vendor[256];
|
||||
char renderer[256];
|
||||
char version[256];
|
||||
char GLEWversion[256];
|
||||
char GLSLversion[256];
|
||||
};
|
||||
extern OPENGL_DATA opengl;
|
||||
#endif
|
||||
|
|
|
@ -132,6 +132,7 @@ static PIELIGHT getBlueprintColour(STRUCT_STATES state);
|
|||
static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours);
|
||||
static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours);
|
||||
void NotifyUserOfError(char *msg);
|
||||
extern bool writeGameInfo(const char *pFileName); // Used to help debug issues when we have fatal errors & crash handler testing.
|
||||
/******************** Variables ********************/
|
||||
// Should be cleaned up properly and be put in structures.
|
||||
|
||||
|
@ -858,6 +859,7 @@ void draw3DScene( void )
|
|||
ASSERT(false, "Yes, this is a assert. This should not happen on release builds! Use --noassert to bypass in debug builds.");
|
||||
debug(LOG_WARNING, " *** Warning! You have compiled in debug mode! ***");
|
||||
#endif
|
||||
writeGameInfo("WZdebuginfo.txt"); //also test writing out this file.
|
||||
debug(LOG_FATAL, "Forcing a segfault! (crash handler test)");
|
||||
// and here comes the crash
|
||||
*crash = 0x3;
|
||||
|
|
51
src/game.cpp
51
src/game.cpp
|
@ -31,6 +31,7 @@
|
|||
#include "lib/framework/frameint.h"
|
||||
#include "lib/framework/physfs_ext.h"
|
||||
#include "lib/framework/strres.h"
|
||||
#include "lib/framework/opengl.h"
|
||||
|
||||
#include "lib/gamelib/gtime.h"
|
||||
#include "lib/ivis_opengl/ivisdef.h"
|
||||
|
@ -85,6 +86,10 @@
|
|||
#include "challenge.h"
|
||||
#include "combat.h"
|
||||
#include "template.h"
|
||||
#include "version.h"
|
||||
#include "lib/ivis_opengl/screen.h"
|
||||
#include "keymap.h"
|
||||
#include <ctime>
|
||||
|
||||
#define MAX_SAVE_NAME_SIZE_V19 40
|
||||
#define MAX_SAVE_NAME_SIZE 60
|
||||
|
@ -105,6 +110,7 @@ static const UDWORD NULL_ID = UDWORD_MAX;
|
|||
|
||||
static UDWORD RemapPlayerNumber(UDWORD OldNumber);
|
||||
static void plotFeature(char *backDropSprite);
|
||||
bool writeGameInfo(const char *pFileName);
|
||||
|
||||
struct GAME_SAVEHEADER
|
||||
{
|
||||
|
@ -2548,6 +2554,11 @@ bool saveGame(char *aFileName, GAME_TYPE saveType)
|
|||
goto error;
|
||||
}
|
||||
|
||||
// Save labels
|
||||
CurrentFileName[fileExtension] = '\0';
|
||||
strcat(CurrentFileName, "gameinfo.ini");
|
||||
writeGameInfo(CurrentFileName);
|
||||
|
||||
// Save labels
|
||||
CurrentFileName[fileExtension] = '\0';
|
||||
strcat(CurrentFileName, "labels.ini");
|
||||
|
@ -4956,6 +4967,46 @@ static bool loadSaveStructure2(const char *pFileName, STRUCTURE **ppList)
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------
|
||||
/*
|
||||
Writes some version info
|
||||
*/
|
||||
bool writeGameInfo(const char *pFileName)
|
||||
{
|
||||
WzConfig ini(pFileName);
|
||||
if (ini.status() != QSettings::NoError)
|
||||
{
|
||||
debug(LOG_ERROR, "Could not open %s", pFileName);
|
||||
return false;
|
||||
}
|
||||
char ourtime[100] = {'\0'};
|
||||
const time_t currentTime = time(NULL);
|
||||
std::string time(ctime(¤tTime));
|
||||
ini.beginGroup("GameProperties");
|
||||
ini.setValue("current_time", time.data());
|
||||
getAsciiTime(ourtime, graphicsTime);
|
||||
ini.setValue("graphics_time", ourtime);
|
||||
getAsciiTime(ourtime, gameTime);
|
||||
ini.setValue("game_time", ourtime);
|
||||
getAsciiTime( ourtime, gameTime - missionData.missionStarted);
|
||||
ini.setValue("playing_time", ourtime);
|
||||
ini.setValue("version", version_getVersionString());
|
||||
ini.setValue("full_version", version_getFormattedVersionString());
|
||||
ini.setValue("cheated", Cheated);
|
||||
ini.setValue("debug", getDebugMappingStatus());
|
||||
ini.setValue("level/map", getLevelName());
|
||||
ini.setValue("mods", getModList() ? getModList() : "None");
|
||||
ini.setValue("openGL_vendor", opengl.vendor);
|
||||
ini.setValue("openGL_renderer", opengl.renderer);
|
||||
ini.setValue("openGL_version", opengl.version);
|
||||
ini.setValue("openGL_GLEW_version", opengl.GLEWversion);
|
||||
ini.setValue("openGL_GLSL_version", opengl.GLSLversion);
|
||||
// NOTE: deprecated for GL 3+. Needed this to check what extensions some chipsets support for the openGL hacks
|
||||
std::string extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||
ini.setValue("GL_EXTENSIONS", extensions.data());
|
||||
ini.endGroup();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the linked list of structure for each player to a file
|
||||
*/
|
||||
|
|
|
@ -182,7 +182,7 @@ static void dispAdditionalInfo( void );
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
/* The present mission data */
|
||||
static MISSION_DATA missionData;
|
||||
MISSION_DATA missionData;
|
||||
static UDWORD dispST;
|
||||
static bool bDispStarted = false;
|
||||
static char text[255];
|
||||
|
|
|
@ -52,7 +52,7 @@ struct MISSION_DATA
|
|||
uint32_t shotsOffTarget; // How many misses
|
||||
uint32_t babasMowedDown; // How many barbarians did we mow down?
|
||||
};
|
||||
|
||||
extern MISSION_DATA missionData;
|
||||
// Could use widgets, but hey.....
|
||||
struct STAT_BAR
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue