mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 08:23:15 +00:00
Fix for bug #1091748 (DIG: Starting new games takes a long time); turns out querying the debuglevel from the config-manager very often is too slow
svn-id: r16345
This commit is contained in:
parent
2eb17ef322
commit
d138a880bf
@ -158,50 +158,6 @@ void CDECL warning(const char *s, ...) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void debugHelper(char *buf) {
|
||||
#ifndef _WIN32_WCE
|
||||
printf("%s\n", buf);
|
||||
#endif
|
||||
|
||||
#if defined( USE_WINDBG )
|
||||
strcat(buf, "\n");
|
||||
#if defined( _WIN32_WCE )
|
||||
TCHAR buf_unicode[1024];
|
||||
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
|
||||
OutputDebugString(buf_unicode);
|
||||
#else
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void CDECL debug(int level, const char *s, ...) {
|
||||
char buf[STRINGBUFLEN];
|
||||
va_list va;
|
||||
|
||||
if (level > ConfMan.getInt("debuglevel"))
|
||||
return;
|
||||
|
||||
va_start(va, s);
|
||||
vsprintf(buf, s, va);
|
||||
va_end(va);
|
||||
|
||||
debugHelper(buf);
|
||||
}
|
||||
|
||||
void CDECL debug(const char *s, ...) {
|
||||
char buf[STRINGBUFLEN];
|
||||
va_list va;
|
||||
|
||||
va_start(va, s);
|
||||
vsprintf(buf, s, va);
|
||||
va_end(va);
|
||||
|
||||
debugHelper(buf);
|
||||
}
|
||||
|
||||
void checkHeap() {
|
||||
#if defined(_MSC_VER)
|
||||
if (_heapchk() != _HEAPOK) {
|
||||
|
@ -333,9 +333,9 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
|
||||
DO_OPTION_OPT('d', "debuglevel")
|
||||
if (option != NULL)
|
||||
ConfMan.set("debuglevel", (int)strtol(option, 0, 10), kTransientDomain);
|
||||
int debuglevel = ConfMan.getInt("debuglevel");
|
||||
if (debuglevel)
|
||||
printf("Debuglevel (from command line): %d\n", debuglevel);
|
||||
gDebugLevel = ConfMan.getInt("debuglevel");
|
||||
if (gDebugLevel)
|
||||
printf("Debuglevel (from command line): %d\n", gDebugLevel);
|
||||
else
|
||||
printf("Debuglevel (from command line): 0 - Game only\n");
|
||||
END_OPTION
|
||||
@ -510,6 +510,7 @@ ShowHelpAndExit:
|
||||
void GameDetector::setTarget(const String &name) {
|
||||
_targetName = name;
|
||||
ConfMan.setActiveDomain(name);
|
||||
gDebugLevel = ConfMan.getInt("debuglevel");
|
||||
}
|
||||
|
||||
bool GameDetector::detectGame() {
|
||||
|
@ -38,6 +38,8 @@ enum {
|
||||
GF_DEFAULT_TO_1X_SCALER = 1 << 30
|
||||
};
|
||||
|
||||
extern int gDebugLevel;
|
||||
|
||||
struct GameSettings {
|
||||
const char *name;
|
||||
const char *description;
|
||||
|
@ -119,7 +119,7 @@ const char *gScummVMFeatures = ""
|
||||
#ifdef USE_MPEG2
|
||||
"MPEG2 "
|
||||
#endif
|
||||
;
|
||||
;
|
||||
|
||||
#if defined(WIN32) && defined(NO_CONSOLE)
|
||||
#include <cstdio>
|
||||
@ -184,6 +184,9 @@ static void do_memory_test(void) {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int gDebugLevel = 0;
|
||||
|
||||
static bool launcherDialog(GameDetector &detector, OSystem *system) {
|
||||
|
||||
system->beginGFXTransaction();
|
||||
@ -349,6 +352,8 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
|
||||
else
|
||||
ConfMan.loadDefaultConfigFile();
|
||||
|
||||
gDebugLevel = ConfMan.getInt("debuglevel");
|
||||
|
||||
// Update the config file
|
||||
ConfMan.set("versioninfo", gScummVMVersion, Common::ConfigManager::kApplicationDomain);
|
||||
|
||||
@ -417,6 +422,50 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
|
||||
END_OF_MAIN();
|
||||
#endif
|
||||
|
||||
static void debugHelper(char *buf) {
|
||||
#ifndef _WIN32_WCE
|
||||
printf("%s\n", buf);
|
||||
#endif
|
||||
|
||||
#if defined( USE_WINDBG )
|
||||
strcat(buf, "\n");
|
||||
#if defined( _WIN32_WCE )
|
||||
TCHAR buf_unicode[1024];
|
||||
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
|
||||
OutputDebugString(buf_unicode);
|
||||
#else
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void CDECL debug(int level, const char *s, ...) {
|
||||
char buf[STRINGBUFLEN];
|
||||
va_list va;
|
||||
|
||||
if (level > gDebugLevel)
|
||||
return;
|
||||
|
||||
va_start(va, s);
|
||||
vsprintf(buf, s, va);
|
||||
va_end(va);
|
||||
|
||||
debugHelper(buf);
|
||||
}
|
||||
|
||||
void CDECL debug(const char *s, ...) {
|
||||
char buf[STRINGBUFLEN];
|
||||
va_list va;
|
||||
|
||||
va_start(va, s);
|
||||
vsprintf(buf, s, va);
|
||||
va_end(va);
|
||||
|
||||
debugHelper(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
#if !defined(__PALM_OS__) && !defined(_WIN32_WCE)
|
||||
void *operator new(size_t size) {
|
||||
|
@ -44,7 +44,7 @@ void CDECL debugC(int channel, const char *s, ...) {
|
||||
|
||||
// FIXME: Still spew all debug at -d9, for crashes in startup etc.
|
||||
// Add setting from commandline ( / abstract channel interface)
|
||||
if (!(g_scumm->_debugFlags & channel) && (ConfMan.getInt("debuglevel") < 9))
|
||||
if (!(g_scumm->_debugFlags & channel) && (gDebugLevel < 9))
|
||||
return;
|
||||
|
||||
va_start(va, s);
|
||||
@ -596,6 +596,7 @@ bool ScummDebugger::Cmd_DebugLevel(int argc, const char **argv) {
|
||||
} else { // set level
|
||||
int level = atoi(argv[1]);
|
||||
ConfMan.set("debuglevel", level, Common::ConfigManager::kTransientDomain);
|
||||
gDebugLevel = ConfMan.getInt("debuglevel");
|
||||
if (level > 0) {
|
||||
_vm->_debugMode = true;
|
||||
DebugPrintf("Debug level set to level %d\n", level);
|
||||
|
@ -91,6 +91,7 @@ bool Debugger::Cmd_DebugLevel(int argc, const char **argv) {
|
||||
} else { // set level
|
||||
int level = atoi(argv[1]);
|
||||
ConfMan.set("debuglevel", level, Common::ConfigManager::kTransientDomain);
|
||||
gDebugLevel = ConfMan.getInt("debuglevel");
|
||||
if (level > 0 && level < 10) {
|
||||
_vm->_debugMode = true;
|
||||
DebugPrintf("Debug level set to level %d\n", level);
|
||||
|
Loading…
x
Reference in New Issue
Block a user