New cheat "noassert" and new command line option "--noassert" turns off the abort functionality in ASSERT() calls.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6527 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-01-02 11:16:40 +00:00
parent c10ffeb2ec
commit 0881493713
6 changed files with 30 additions and 1 deletions

View File

@ -41,6 +41,7 @@ UDWORD traceID = -1;
static debug_callback * callbackRegistry = NULL;
BOOL enabled_debug[LOG_LAST]; // global
bool assertEnabled = true;
/*
* This list _must_ match the enum in debug.h!
@ -382,3 +383,8 @@ bool debugPartEnabled(code_part codePart)
{
return enabled_debug[codePart];
}
void debugDisableAssert()
{
assertEnabled = false;
}

View File

@ -51,6 +51,9 @@ extern "C"
/** Stores name of the last function or event called by scripts. */
extern char last_called_script_event[MAX_EVENT_NAME_LEN];
/** Whether asserts are currently enabled. */
extern bool assertEnabled;
/**
* ASSERT helper macro to allow some debug functions to use an alternate
* calling location.
@ -78,7 +81,7 @@ extern char last_called_script_event[MAX_EVENT_NAME_LEN];
location_description, (#expr), last_called_script_event) \
) \
), \
assert(expr) \
assertEnabled ? assert(expr) : (void)0 \
)
/**
@ -226,4 +229,6 @@ static inline void objTraceDisable(void) { traceID = (UDWORD)-1; }
/** Checks if a particular debub flag was enabled */
extern bool debugPartEnabled(code_part codePart);
void debugDisableAssert(void);
#endif // __INCLUDED_LIB_FRAMEWORK_DEBUG_H__

View File

@ -44,6 +44,7 @@ static CHEAT_ENTRY cheatCodes[] =
// {"PJKSVQZ,",kf_ToggleOutline},
// {"L\\MZZQ[JRO",kf_ScreenDump}, //screendump
{"noassert", kf_NoAssert}, // turn off asserts
{"count me", kf_ShowNumObjects}, // give a count of objects in the world
{"give all", kf_AllAvailable}, // give all
{"research all", kf_FinishAllResearch}, // research everything at once

View File

@ -43,6 +43,7 @@
#include "wrappers.h"
#include "cheat.h"
#include "init.h"
#include "keybind.h"
// To set the shadow config:
#include "display.h"
#include "version.h"
@ -86,6 +87,7 @@ typedef enum
CLI_SELFTEST,
CLI_CONNECTTOIP,
CLI_HOSTLAUNCH,
CLI_NOASSERT,
} CLI_OPTIONS;
static const struct poptOption* getOptionsTable(void)
@ -104,6 +106,7 @@ static const struct poptOption* getOptionsTable(void)
{ "mod", '\0', POPT_ARG_STRING, NULL, CLI_MOD_GLOB, N_("Enable a global mod"), N_("mod") },
{ "mod_ca", '\0', POPT_ARG_STRING, NULL, CLI_MOD_CA, N_("Enable a campaign only mod"), N_("mod") },
{ "mod_mp", '\0', POPT_ARG_STRING, NULL, CLI_MOD_MP, N_("Enable a multiplay only mod"), N_("mod") },
{ "noassert", '\0', POPT_ARG_NONE, NULL, CLI_NOASSERT, N_("Disable asserts"), NULL },
{ "savegame", '\0', POPT_ARG_STRING, NULL, CLI_SAVEGAME, N_("Load a saved game"), N_("savegame") },
{ "usage", '\0', POPT_ARG_NONE
| POPT_ARGFLAG_DOC_HIDDEN, NULL, CLI_USAGE, NULL, NULL, },
@ -283,6 +286,10 @@ bool ParseCommandLine(int argc, const char** argv)
// These options are parsed in ParseCommandLineEarly() already, so ignore them
break;
case CLI_NOASSERT:
kf_NoAssert();
break;
case CLI_CHEAT:
printf(" ** DEBUG MODE UNLOCKED! **\n");
bAllowDebugMode = true;

View File

@ -2599,3 +2599,10 @@ void kf_AddHelpBlip( void )
}
}
}
void kf_NoAssert()
{
debugDisableAssert();
console("Asserts turned off");
debug(LOG_ERROR, "Asserts turned off");
}

View File

@ -21,6 +21,7 @@
#ifndef __INCLUDED_SRC_KEYBIND_H__
#define __INCLUDED_SRC_KEYBIND_H__
#include "console.h"
#include "lib/ivis_common/piefixedpoint.h"
// --------------- All those keyboard mappable functions */
@ -234,6 +235,8 @@ void kf_ToggleRadarAllyEnemy( void ); //enemy/ally color toggle
void kf_TileInfo(void);
void kf_NoAssert(void);
extern void kf_ToggleWatchWindow( void );
bool runningMultiplayer(void);