aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-06-11 19:14:25 +0200
committerEinar Johan Trøan Sømåen2012-06-11 19:14:25 +0200
commit819d16ea9b44476451c32933977278d80ce52def (patch)
treedb13c6d1f8b38cbd71f2b218899ef092c4b14d36 /engines
parent58b054ca970a8cb74d0e5549de522f98d7700801 (diff)
downloadscummvm-rg350-819d16ea9b44476451c32933977278d80ce52def.tar.gz
scummvm-rg350-819d16ea9b44476451c32933977278d80ce52def.tar.bz2
scummvm-rg350-819d16ea9b44476451c32933977278d80ce52def.zip
WINTERMUTE: Get rid of all but one FORBIDDEN SYMBOL in BGame.
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/Base/BGame.cpp75
-rw-r--r--engines/wintermute/Sys/SysClass.cpp7
-rw-r--r--engines/wintermute/Sys/SysClass.h4
-rw-r--r--engines/wintermute/Sys/SysClassRegistry.cpp3
-rw-r--r--engines/wintermute/Sys/SysClassRegistry.h3
5 files changed, 55 insertions, 37 deletions
diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp
index 60a2ee1f28..0bd1adddd4 100644
--- a/engines/wintermute/Base/BGame.cpp
+++ b/engines/wintermute/Base/BGame.cpp
@@ -25,17 +25,9 @@
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-#include <time.h>
-#undef FORBIDDEN_SYMBOL_ALLOW_ALL
+
#define FORBIDDEN_SYMBOL_EXCEPTION_srand
-#define FORBIDDEN_SYMBOL_EXCEPTION_time
-#define FORBIDDEN_SYMBOL_EXCEPTION_time
-#define FORBIDDEN_SYMBOL_EXCEPTION_localtime
-#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
-#define FORBIDDEN_SYMBOL_EXCEPTION_fopen
-#define FORBIDDEN_SYMBOL_EXCEPTION_fclose
-#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+
#include "engines/wintermute/dcgf.h"
#include "engines/wintermute/Base/BGame.h"
#include "engines/wintermute/Base/BFader.h"
@@ -81,6 +73,8 @@
#include "common/textconsole.h"
#include "common/util.h"
#include "common/keyboard.h"
+#include "common/system.h"
+#include "common/file.h"
#ifdef __IPHONEOS__
# include "ios_utils.h"
@@ -161,7 +155,7 @@ CBGame::CBGame(): CBObject(this) {
_useD3D = false;
- srand((unsigned)time(NULL));
+ srand(g_system->getMillis());
_registry = new CBRegistry(this);
_stringTable = new CBStringTable(this);
@@ -530,18 +524,19 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) {
_dEBUG_DebugMode = true;
#ifndef __IPHONEOS__
- if (Filename)_dEBUG_LogFile = fopen(Filename, "a+");
- else _dEBUG_LogFile = fopen("./zz_debug.log", "a+");
+ //if (Filename)_dEBUG_LogFile = fopen(Filename, "a+");
+ //else _dEBUG_LogFile = fopen("./zz_debug.log", "a+");
if (!_dEBUG_LogFile) {
AnsiString safeLogFileName = PathUtil::GetSafeLogFileName();
- _dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+");
+ //_dEBUG_LogFile = fopen(safeLogFileName.c_str(), "a+");
}
- if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n");
+ //if (_dEBUG_LogFile != NULL) fprintf((FILE *)_dEBUG_LogFile, "\n");
+ warning("BGame::DEBUG_DebugEnable - No logfile is currently created"); //TODO: Use a dumpfile?
#endif
- time_t timeNow;
+/* time_t timeNow;
time(&timeNow);
struct tm *tm = localtime(&timeNow);
@@ -549,6 +544,17 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) {
LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
#else
LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
+#endif*/
+ int secs = g_system->getMillis() / 1000;
+ int hours = secs % 3600;
+ secs -= hours * 3600;
+ int mins = secs / 60;
+ secs = secs % 60;
+
+#ifdef _DEBUG
+ LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs);
+#else
+ LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs);
#endif
LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX);
@@ -564,7 +570,7 @@ void CBGame::DEBUG_DebugEnable(const char *Filename) {
void CBGame::DEBUG_DebugDisable() {
if (_dEBUG_LogFile != NULL) {
LOG(0, "********** DEBUG LOG CLOSED ********************************************");
- fclose((FILE *)_dEBUG_LogFile);
+ //fclose((FILE *)_dEBUG_LogFile);
_dEBUG_LogFile = NULL;
}
_dEBUG_DebugMode = false;
@@ -576,9 +582,14 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) {
#ifndef __IPHONEOS__
if (!_dEBUG_DebugMode) return;
#endif
- time_t timeNow;
+/* time_t timeNow;
time(&timeNow);
- struct tm *tm = localtime(&timeNow);
+ struct tm *tm = localtime(&timeNow);*/
+ int secs = g_system->getMillis() / 1000;
+ int hours = secs % 3600;
+ secs -= hours * 3600;
+ int mins = secs / 60;
+ secs = secs % 60;
char buff[512];
va_list va;
@@ -599,9 +610,9 @@ void CBGame::LOG(HRESULT res, LPCSTR fmt, ...) {
}
if (_debugMgr) _debugMgr->OnLog(res, buff);
- warning("%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff);
- fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d: %s\n", tm->tm_hour, tm->tm_min, buff);
- fflush((FILE *)_dEBUG_LogFile);
+ warning("%02d:%02d:%02d: %s\n", hours, mins, secs, buff);
+ //fprintf((FILE *)_dEBUG_LogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff);
+ //fflush((FILE *)_dEBUG_LogFile);
#endif
//QuickMessage(buff);
@@ -1439,12 +1450,12 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS
// PlayTheora
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "PlayTheora") == 0) {
- /* Stack->CorrectParams(0);
+ Stack->CorrectParams(0);
Stack->PushBool(false);
return S_OK;
// TODO: ADDVIDEO
- */
+
Stack->CorrectParams(7);
const char* Filename = Stack->Pop()->GetString();
warning("PlayTheora: %s - not implemented yet", Filename);
@@ -1815,12 +1826,13 @@ HRESULT CBGame::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *ThisS
CScValue *Val = Stack->Pop();
+ warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO
int FileNum = 0;
+
while (true) {
sprintf(Filename, "%s%03d.bmp", Val->IsNULL() ? _name : Val->GetString(), FileNum);
- FILE *f = fopen(Filename, "rb");
- if (!f) break;
- else fclose(f);
+ if (!Common::File::exists(Filename))
+ break;
FileNum++;
}
@@ -4182,11 +4194,14 @@ HRESULT CBGame::ResetContent() {
//////////////////////////////////////////////////////////////////////////
void CBGame::DEBUG_DumpClassRegistry() {
- FILE *f = fopen("./zz_class_reg_dump.log", "wt");
+ warning("DEBUG_DumpClassRegistry - untested");
+ Common::DumpFile *f = new Common::DumpFile;
+ f->open("zz_class_reg_dump.log");
CSysClassRegistry::GetInstance()->DumpClasses(f);
-
- fclose(f);
+
+ f->close();
+ delete f;
Game->QuickMessage("Classes dump completed.");
}
diff --git a/engines/wintermute/Sys/SysClass.cpp b/engines/wintermute/Sys/SysClass.cpp
index 308287c436..30ccf3aa08 100644
--- a/engines/wintermute/Sys/SysClass.cpp
+++ b/engines/wintermute/Sys/SysClass.cpp
@@ -25,8 +25,6 @@
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
-#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
-#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
#include "engines/wintermute/persistent.h"
#include "SysInstance.h"
@@ -131,8 +129,9 @@ int CSysClass::GetNumInstances() {
}
//////////////////////////////////////////////////////////////////////////
-void CSysClass::Dump(void *stream) {
- fprintf((FILE *)stream, "%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances());
+void CSysClass::Dump(Common::WriteStream *stream) {
+ Common::String str = Common::String::format("%03d %c %-20s instances: %d\n", _iD, _persistent ? 'p' : ' ', _name.c_str(), GetNumInstances());
+ stream->writeString(str);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/Sys/SysClass.h b/engines/wintermute/Sys/SysClass.h
index 3d6200997b..82b612927e 100644
--- a/engines/wintermute/Sys/SysClass.h
+++ b/engines/wintermute/Sys/SysClass.h
@@ -36,6 +36,8 @@
//#include <map>
#include "common/hashmap.h"
#include "common/func.h"
+#include "common/stream.h"
+
namespace Common {
template<typename T> struct Hash;
@@ -93,7 +95,7 @@ public:
void ResetSavedIDs();
- void Dump(void *stream);
+ void Dump(Common::WriteStream *stream);
private:
int _numInst;
diff --git a/engines/wintermute/Sys/SysClassRegistry.cpp b/engines/wintermute/Sys/SysClassRegistry.cpp
index 25f271fab9..1a644c3a61 100644
--- a/engines/wintermute/Sys/SysClassRegistry.cpp
+++ b/engines/wintermute/Sys/SysClassRegistry.cpp
@@ -30,6 +30,7 @@
#include "engines/wintermute/PlatformSDL.h"
#include "SysInstance.h"
#include "SysClassRegistry.h"
+#include "common/stream.h"
namespace WinterMute {
@@ -279,7 +280,7 @@ HRESULT CSysClassRegistry::EnumInstances(SYS_INSTANCE_CALLBACK lpCallback, const
//////////////////////////////////////////////////////////////////////////
-void CSysClassRegistry::DumpClasses(void *stream) {
+void CSysClassRegistry::DumpClasses(Common::WriteStream *stream) {
Classes::iterator it;
for (it = _classes.begin(); it != _classes.end(); ++it)
(it->_value)->Dump(stream);
diff --git a/engines/wintermute/Sys/SysClassRegistry.h b/engines/wintermute/Sys/SysClassRegistry.h
index 5d437af324..870f07df20 100644
--- a/engines/wintermute/Sys/SysClassRegistry.h
+++ b/engines/wintermute/Sys/SysClassRegistry.h
@@ -37,6 +37,7 @@
#include "common/hashmap.h"
#include "common/hash-str.h"
#include "common/func.h"
+#include "common/stream.h"
#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
@@ -75,7 +76,7 @@ public:
bool UnregisterClass(CSysClass *classObj);
bool RegisterInstance(const char *className, void *instance);
bool UnregisterInstance(const char *className, void *instance);
- void DumpClasses(void *stream);
+ void DumpClasses(Common::WriteStream *stream);
int GetNextID();
void AddInstanceToTable(CSysInstance *instance, void *pointer);