aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/archive.cpp3
-rw-r--r--common/config-file.cpp4
-rw-r--r--common/config-manager.cpp2
-rw-r--r--common/fs.cpp1
-rw-r--r--common/mutex.cpp1
-rw-r--r--common/util.cpp11
6 files changed, 15 insertions, 7 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index d8b2c61dd1..9299d8e495 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -460,7 +460,8 @@ void SearchManager::clear() {
// Always keep system specific archives in the SearchManager.
// But we give them a lower priority than the default priority (which is 0),
// so that archives added by client code are searched first.
- g_system->addSysArchivesToSearchSet(*this, -1);
+ if (g_system)
+ g_system->addSysArchivesToSearchSet(*this, -1);
// Add the current dir as a very last resort.
// See also bug #2137680.
diff --git a/common/config-file.cpp b/common/config-file.cpp
index a05a9ee0d3..61437a60ab 100644
--- a/common/config-file.cpp
+++ b/common/config-file.cpp
@@ -65,9 +65,11 @@ bool ConfigFile::loadFromFile(const String &filename) {
}
bool ConfigFile::loadFromSaveFile(const char *filename) {
+ assert(g_system);
SaveFileManager *saveFileMan = g_system->getSavefileManager();
SeekableReadStream *loadFile;
+ assert(saveFileMan);
if (!(loadFile = saveFileMan->openForLoading(filename)))
return false;
@@ -189,9 +191,11 @@ bool ConfigFile::saveToFile(const String &filename) {
}
bool ConfigFile::saveToSaveFile(const char *filename) {
+ assert(g_system);
SaveFileManager *saveFileMan = g_system->getSavefileManager();
WriteStream *saveFile;
+ assert(saveFileMan);
if (!(saveFile = saveFileMan->openForSaving(filename)))
return false;
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 88e5e8512a..7ea59b65d3 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -62,6 +62,7 @@ ConfigManager::ConfigManager()
void ConfigManager::loadDefaultConfigFile() {
// Open the default config file
+ assert(g_system);
SeekableReadStream *stream = g_system->createConfigReadStream();
_filename.clear(); // clear the filename to indicate that we are using the default config file
@@ -190,6 +191,7 @@ void ConfigManager::flushToDisk() {
if (_filename.empty()) {
// Write to the default config file
+ assert(g_system);
stream = g_system->createConfigWriteStream();
if (!stream) // If writing to the config file is not possible, do nothing
return;
diff --git a/common/fs.cpp b/common/fs.cpp
index f911b544b0..fed0669f3f 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -37,6 +37,7 @@ FSNode::FSNode(AbstractFSNode *realNode)
}
FSNode::FSNode(const Common::String &p) {
+ assert(g_system);
FilesystemFactory *factory = g_system->getFilesystemFactory();
AbstractFSNode *tmp = 0;
diff --git a/common/mutex.cpp b/common/mutex.cpp
index 7a2601477d..6205de405b 100644
--- a/common/mutex.cpp
+++ b/common/mutex.cpp
@@ -29,6 +29,7 @@
namespace Common {
Mutex::Mutex() {
+ assert(g_system);
_mutex = g_system->createMutex();
}
diff --git a/common/util.cpp b/common/util.cpp
index 944d4fc192..a1a6568579 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -472,17 +472,16 @@ static void debugHelper(const char *in_buf, bool caret = true) {
g_engine->errorString(in_buf, buf, STRINGBUFLEN);
} else {
strncpy(buf, in_buf, STRINGBUFLEN);
- buf[STRINGBUFLEN-1] = '\0';
}
+ buf[STRINGBUFLEN-2] = '\0';
+ buf[STRINGBUFLEN-1] = '\0';
if (caret)
- printf("%s\n", buf);
- else
- printf("%s", buf);
+ strcat(buf, "\n");
+
+ fprintf(stdout, "%s", buf); // FIXME: Use fputs instead
#if defined( USE_WINDBG )
- if (caret)
- strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));