unpack_private.c
Weapons.cpp
MacCompatibility.cpp
- logger/logger.cpp
- OpenGL_Windows.cpp
+ OpenGL_Windows.cpp
openal_wrapper.cpp
WinInput.cpp)
extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
+void LOG(const std::string &fmt, ...)
+{
+ // !!! FIXME: write me.
+}
+
+
Game::TextureList Game::textures;
void Game::Dispose()
LOGFUNC;
#ifndef WIN32 // this is in WinMain, too.
- logger.start(true);
memset( &g_theKeys, 0, sizeof( KeyMap));
#endif
std::string e = "Caught exception: ";
e += error.what();
- LOG(e, Logger::LOG_ERR);
+ LOG(e);
MessageBox(g_windowHandle, error.what(), "ERROR", MB_OK | MB_ICONEXCLAMATION);
}
}
}
- logger.start(true);
-
memset( &g_theKeys, 0, sizeof( KeyMap));
unsigned int i = 0;
using namespace std;
-#include "logger/logger.h"
+/* !!! FIXME: until we replace logger better. --ryan. */
+#define LOGFUNC
+void LOG(const std::string &fmt, ...);
#endif
+++ /dev/null
-// ---------------------------------------------------------------------------------------------------------------------------------
-// _
-// | |
-// | | ___ __ _ __ _ ___ _ __ ___ _ __ _ __
-// | |/ _ \ / _` |/ _` |/ _ \ '__| / __| '_ \| '_ \
-// | | (_) | (_| | (_| | __/ | _ | (__| |_) | |_) |
-// |_|\___/ \__, |\__, |\___|_| (_) \___| .__/| .__/
-// __/ | __/ | | | | |
-// |___/ |___/ |_| |_|
-//
-// Generic informational logging class
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-//
-// Restrictions & freedoms pertaining to usage and redistribution of this software:
-//
-// * This software is 100% free
-// * If you use this software (in part or in whole) you must credit the author.
-// * This software may not be re-distributed (in part or in whole) in a modified
-// form without clear documentation on how to obtain a copy of the original work.
-// * You may not use this software to directly or indirectly cause harm to others.
-// * This software is provided as-is and without warrantee. Use at your own risk.
-//
-// For more information, visit HTTP://www.FluidStudios.com
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Originally created on 07/06/2000 by Paul Nettle
-//
-// Copyright 2000, Fluid Studios, Inc., all rights reserved.
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-//#include "stdafx.h" // If this line gives you an error, comment it out
-#include <string>
-#include <list>
-#include <map>
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-//#include <strstream>
-#include <sstream>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctime>
-using namespace std;
-
-#include "logger.h"
-
-class LogFunc
-{
-public:
- LogFunc(void) {}
-
- void pushMessage(const std::string & str)
- {
- entries.push_back(str);
- }
-
- void dump(std::ostream & os)
- {
- std::list<std::string>::iterator it = entries.begin();
- for (; it != entries.end(); ++it)
- {
- os << *it;
- }
- }
-
-private:
- std::list<std::string> entries;
-};
-
-class LogStack
-{
-public:
- LogStack(void)
- {
- pushFunc();
- }
-
- void pushFunc(void)
- {
- entries.push_back(LogFunc());
- }
-
- void popFunc(void)
- {
- if (entries.size() > 1)
- {
- entries.pop_back();
- }
- }
-
- void logMessage(const std::string & str_)
- {
- entries.back().pushMessage(str_);
- }
-
- void dump(std::ostream & os)
- {
- std::list<LogFunc>::iterator it = entries.begin();
- for (; it != entries.end(); ++it)
- {
- it->dump(os);
- }
- }
-
-private:
- std::list<LogFunc> entries;
-};
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The global log stack object
-// ---------------------------------------------------------------------------------------------------------------------------------
-LogStack logStack;
-
-void pushFunc(void) {logStack.pushFunc();}
-void popFunc(void) {logStack.popFunc();}
-
-void dumpLog(void)
-{
- ofstream of(logger.logFile().c_str(), ios::out | ios::trunc);
- if (!of) return;
- logStack.dump(of);
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The global logger object
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-Logger logger;
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-#ifdef _DEBUG
-void Logger::limitFileSize() const
-{
- if (fileSizeLimit() < 0) return;
- struct _stat sbuf;
- _stat(logFile().c_str(), &sbuf);
- if (sbuf.st_size > fileSizeLimit())
- {
- unlink(logFile().c_str());
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::start(const bool reset)
-{
- std::stringstream ss;
-
- if (logStarted()) return;
- _logStarted = true;
-
- // Get the time
-
- time_t t = time(NULL);
- string ts = asctime(localtime(&t));
- ts[ts.length() - 1] = 0;
-
- // Start the log
-
- //limitFileSize();
- //ofstream of(logFile().c_str(), ios::out | (reset ? ios::trunc : ios::app));
- //if (!of) return;
-
- //of << "---------------------------------------------- Log begins on " << ts << " ----------------------------------------------" << endl;
- ss << "---------------------------------------------- Log begins on " << ts << " ----------------------------------------------" << endl;
- logStack.logMessage(ss.str());
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::stop()
-{
- std::stringstream ss;
-
- // Automatic One time only startup
-
- if (!logStarted()) return;
- _logStarted = false;
-
- // Get the time
-
- time_t t = time(NULL);
- string ts = asctime(localtime(&t));
- ts.erase(ts.length() - 1);
-
- // Stop the log
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- //of << "----------------------------------------------- Log ends on " << ts << " -----------------------------------------------" << endl << endl;
- ss << "----------------------------------------------- Log ends on " << ts << " -----------------------------------------------" << endl << endl;
- logStack.logMessage(ss.str());
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logTex(const string &s, const LogFlags logBits)
-{
- std::stringstream ss;
-
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Output to the log file
-
- //of << headerString(logBits) << s << endl;
- ss << headerString(logBits) << s << endl;
- logStack.logMessage(ss.str());
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logRaw(const string &s)
-{
- std::stringstream ss;
-
- // Open the file
-
- //limitFileSize();
- //ofstream of(logFile().c_str(), ios::out|ios::app);
- //if (!of) return;
-
- // Log the output
-
- //of << s << endl;
- ss << s << endl;
- logStack.logMessage(ss.str());
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logHex(const char *buffer, const unsigned int count, const LogFlags logBits)
-{
- std::stringstream ss;
-
- // No input? No output
-
- if (!buffer) return;
-
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- //limitFileSize();
- //ofstream of(logFile().c_str(), ios::out|ios::app);
- //if (!of) return;
-
- // Log the output
-
- unsigned int logged = 0;
- while(logged < count)
- {
- // One line at a time...
-
- string line;
-
- // The number of characters per line
-
- unsigned int hexLength = 20;
-
- // Default the buffer
-
- unsigned int i;
- for (i = 0; i < hexLength; i++)
- {
- line += "-- ";
- }
-
- for (i = 0; i < hexLength; i++)
- {
- line += ".";
- }
-
- // Fill it in with real data
-
- for (i = 0; i < hexLength && logged < count; i++, logged++)
- {
- unsigned char byte = buffer[logged];
- unsigned int index = i * 3;
-
- // The hex characters
-
- const string hexlist("0123456789ABCDEF");
- line[index+0] = hexlist[byte >> 4];
- line[index+1] = hexlist[byte & 0xf];
-
- // The ascii characters
-
- if (byte < 0x20 || byte > 0x7f) byte = '.';
- line[(hexLength*3)+i+0] = byte;
- }
-
- // Write it to the log file
-
- //of << headerString(logBits) << line << endl;
- ss << headerString(logBits) << line << endl;
- logStack.logMessage(ss.str());
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::indent(const string &s, const LogFlags logBits)
-{
- std::stringstream ss;
-
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- //limitFileSize();
- //ofstream of(logFile().c_str(), ios::out|ios::app);
- //if (!of) return;
-
- // Log the output
-
- //if (lineCharsFlag()) of << headerString(logBits) << "\xDA\xC4\xC4" << s << endl;
- //else of << headerString(logBits) << "+- " << s << endl;
-
- if (lineCharsFlag()) ss << headerString(logBits) << "\xDA\xC4\xC4" << s << endl;
- else ss << headerString(logBits) << "+- " << s << endl;
- logStack.logMessage(ss.str());
-
- // Indent...
-
- _indentCount += _indentChars;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::undent(const string &s, const LogFlags logBits)
-{
- std::stringstream ss;
-
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Undo the indentation
-
- _indentCount -= _indentChars;
- if (_indentCount < 0) _indentCount = 0;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Log the output
-
- //if (lineCharsFlag()) of << headerString(logBits) << "\xC0\xC4\xC4" << s << endl;
- //else of << headerString(logBits) << "+- " << s << endl;
-
- if (lineCharsFlag()) ss << headerString(logBits) << "\xC0\xC4\xC4" << s << endl;
- else ss << headerString(logBits) << "+- " << s << endl;
- logStack.logMessage(ss.str());
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-const string &Logger::headerString(const LogFlags logBits) const
-{
- static string headerString;
- headerString.erase();
-
- // Get the string that represents the bits
-
- switch(logBits)
- {
- case LOG_INDENT : headerString += "> "; break;
- case LOG_UNDENT : headerString += "< "; break;
- case LOG_ALL : headerString += "A "; break;
- case LOG_CRIT : headerString += "! "; break;
- case LOG_DATA : headerString += "D "; break;
- case LOG_ERR : headerString += "E "; break;
- case LOG_FLOW : headerString += "F "; break;
- case LOG_INFO : headerString += "I "; break;
- case LOG_WARN : headerString += "W "; break;
- default: headerString += " "; break;
- }
-
- // File string (strip out the path)
-
- char temp[1024];
- int ix = sourceFile().rfind('\\');
- ix = (ix == (int) string::npos ? 0: ix+1);
- sprintf(temp, "%25s[%04d]", sourceFile().substr(ix).c_str(), sourceLine());
- headerString += temp;
-
- // Time string (specially formatted to save room)
-
- time_t t = time(NULL);
- struct tm *tme = localtime(&t);
- sprintf(temp, "%02d/%02d %02d:%02d ", tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min);
- headerString += temp;
-
- // Spaces for indentation
-
- memset(temp, ' ', sizeof(temp));
- temp[_indentCount] = '\0';
-
- // Add the indentation markers
-
- int count = 0;
- while(count < _indentCount)
- {
- if (lineCharsFlag()) temp[count] = '\xB3';
- else temp[count] = '|';
- count += _indentChars;
- }
- headerString += temp;
-
- return headerString;
-}
-
-#else /*Release Build*/
- std::string release_Null;
- void Logger::limitFileSize() const {}
- const string &Logger::headerString(const LogFlags logBits) const{return release_Null;}
- void Logger::start(const bool reset){}
- void Logger::stop(){}
- void Logger::logTex(const string &s, const LogFlags logBits /*= LOG_INFO*/){}
- void Logger::logRaw(const string &s){}
- void Logger::logHex(const char *buffer, const unsigned int count, const LogFlags logBits /*= LOG_INFO*/){}
- void Logger::indent(const string &s, const LogFlags logBits /*= LOG_INDENT*/){}
- void Logger::undent(const string &s, const LogFlags logBits /*= LOG_UNDENT*/){}
-#endif
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// logger.cpp - End of file
-// ---------------------------------------------------------------------------------------------------------------------------------
-
+++ /dev/null
-// ---------------------------------------------------------------------------------------------------------------------------------
-// _ _
-// | | | |
-// | | ___ __ _ __ _ ___ _ __ | |__
-// | |/ _ \ / _` |/ _` |/ _ \ '__| | '_ \
-// | | (_) | (_| | (_| | __/ | _ | | | |
-// |_|\___/ \__, |\__, |\___|_| (_)|_| |_|
-// __/ | __/ |
-// |___/ |___/
-//
-// Generic informational logging class
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-//
-// Restrictions & freedoms pertaining to usage and redistribution of this software:
-//
-// * This software is 100% free
-// * If you use this software (in part or in whole) you must credit the author.
-// * This software may not be re-distributed (in part or in whole) in a modified
-// form without clear documentation on how to obtain a copy of the original work.
-// * You may not use this software to directly or indirectly cause harm to others.
-// * This software is provided as-is and without warrantee. Use at your own risk.
-//
-// For more information, visit HTTP://www.FluidStudios.com
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Originally created on 07/06/2000 by Paul Nettle
-//
-// Copyright 2000, Fluid Studios, Inc., all rights reserved.
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-#ifndef _H_LOGGER
-#define _H_LOGGER
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The global logger
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class Logger;
-extern Logger logger;
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Macros (necessary evil to take advantage of __LINE__ and __FILE__)
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-#define LOG logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logTex
-#define HEX logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logHex
-#define RAW logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logRaw
-#define INDENT logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.indent
-#define UNDENT logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.undent
-#define LOGBLOCK logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogBlock __lb__
-
-// If you compiler supports __FUNCTION__, then replace the "#if 1" with "#if 0". Note that this will change the usage of the macro
-
-#if 0
-#define LOGFUNC logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogFlow __lf__
-#else
-#define LOGFUNC logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogFlow __lf__(__FUNCTION__)
-#endif
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The logger class: does the actual logging
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class Logger
-{
-public:
- // Enumerations
-
- enum LogFlags
- {
- LOG_INDENT = 0x00000001,
- LOG_UNDENT = 0x00000002,
- LOG_FLOW = 0x00000004,
- LOG_BLOK = 0x00000008,
- LOG_DATA = 0x00000010,
- LOG_INFO = 0x00000012,
- LOG_WARN = 0x00000014,
- LOG_ERR = 0x00000018,
- LOG_CRIT = 0x00000020,
- LOG_ALL = 0xFFFFFFFF
- };
-
- // Construction/Destruction
-
-inline Logger()
- : _sourceLine(0), _indentCount(0), _indentChars(4), _fileSizeLimit(-1), _logMask(LOG_ALL),
- _logStarted(false), _lineCharsFlag(false), _logFile("logger.log")
- {
- }
-
-virtual ~Logger()
- {
- stop();
- }
-
- // Operators
-
-inline void operator +=(const string &s) {logTex(s);}
-
- // Accessors
-
-inline const bool &lineCharsFlag() const {return _lineCharsFlag;}
-inline bool &lineCharsFlag() {return _lineCharsFlag;}
-
-inline const int &fileSizeLimit() const {return _fileSizeLimit;}
-inline int &fileSizeLimit() {return _fileSizeLimit;}
-
-inline const unsigned int &logMask() const {return _logMask;}
-inline unsigned int &logMask() {return _logMask;}
-
-inline const string &logFile() const {return _logFile;}
-inline string &logFile() {return _logFile;}
-
-inline const unsigned int &sourceLine() const {return _sourceLine;}
-inline unsigned int &sourceLine() {return _sourceLine;}
-
-inline const string &sourceFile() const {return _sourceFile;}
-inline string &sourceFile() {return _sourceFile;}
-
-inline bool logStarted() const {return _logStarted;}
-
- // Utilitarian (public)
-
-virtual void start(const bool reset);
-virtual void stop();
-virtual void logTex(const string &s, const LogFlags logBits = LOG_INFO);
-virtual void logRaw(const string &s);
-virtual void logHex(const char *buffer, const unsigned int count, const LogFlags logBits = LOG_INFO);
-virtual void indent(const string &s, const LogFlags logBits = LOG_INDENT);
-virtual void undent(const string &s, const LogFlags logBits = LOG_UNDENT);
-
-private:
- // Utilitarian (private)
-
-virtual void limitFileSize() const;
-virtual const string &headerString(const LogFlags logBits) const;
-
- // Data
-
- string _logFile;
- string _sourceFile;
- unsigned int _sourceLine;
- int _indentCount;
- int _indentChars;
- int _fileSizeLimit;
- unsigned int _logMask;
- bool _logStarted;
- bool _lineCharsFlag;
-};
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The LogBlock class: used for automatic indentation
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class LogBlock
-{
-public:
-inline LogBlock(const string &s) {str = s;logger.indent("Begin block: " + str, Logger::LOG_INDENT);}
-inline ~LogBlock() {logger.undent("", Logger::LOG_UNDENT);}
-private:
- string str;
-};
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The LogFlow class: used for logging code flow
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void pushFunc(void);
-void popFunc(void);
-void dumpLog(void);
-
-class LogFlow
-{
-public:
-inline LogFlow(const string &function) {pushFunc(); str = function;logger.indent(str, Logger::LOG_FLOW);}
-inline ~LogFlow() {logger.undent("", Logger::LOG_FLOW); popFunc();}
-private:
- string str;
-};
-
-#endif // _H_LOGGER
-// ---------------------------------------------------------------------------------------------------------------------------------
-// logger.h - End of file
-// ---------------------------------------------------------------------------------------------------------------------------------
-
+++ /dev/null
-// ---------------------------------------------------------------------------------------------------------------------------------
-// _
-// | |
-// | | ___ __ _ __ _ ___ _ __ ___ _ __ _ __
-// | |/ _ \ / _` |/ _` |/ _ \ '__| / __| '_ \| '_ \
-// | | (_) | (_| | (_| | __/ | _ | (__| |_) | |_) |
-// |_|\___/ \__, |\__, |\___|_| (_) \___| .__/| .__/
-// __/ | __/ | | | | |
-// |___/ |___/ |_| |_|
-//
-// Generic informational logging class
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-//
-// Restrictions & freedoms pertaining to usage and redistribution of this software:
-//
-// * This software is 100% free
-// * If you use this software (in part or in whole) you must credit the author.
-// * This software may not be re-distributed (in part or in whole) in a modified
-// form without clear documentation on how to obtain a copy of the original work.
-// * You may not use this software to directly or indirectly cause harm to others.
-// * This software is provided as-is and without warrantee. Use at your own risk.
-//
-// For more information, visit HTTP://www.FluidStudios.com
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Originally created on 07/06/2000 by Paul Nettle
-//
-// Copyright 2000, Fluid Studios, Inc., all rights reserved.
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-//#include "stdafx.h" // If this line gives you an error, comment it out
-#include <string>
-#include <list>
-#include <map>
-#include <vector>
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-#include <strstream>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctime>
-using namespace std;
-
-#include "logger.h"
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The global logger object
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-Logger logger;
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-#ifdef _DEBUG
-void Logger::limitFileSize() const
-{
- if (fileSizeLimit() < 0) return;
- struct _stat sbuf;
- _stat(logFile().c_str(), &sbuf);
- if (sbuf.st_size > fileSizeLimit())
- {
- unlink(logFile().c_str());
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::start(const bool reset)
-{
- if (logStarted()) return;
- _logStarted = true;
-
- // Get the time
-
- time_t t = time(NULL);
- string ts = asctime(localtime(&t));
- ts[ts.length() - 1] = 0;
-
- // Start the log
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out | (reset ? ios::trunc : ios::app));
- if (!of) return;
-
- of << "---------------------------------------------- Log begins on " << ts << " ----------------------------------------------" << endl;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::stop()
-{
- // Automatic One time only startup
-
- if (!logStarted()) return;
- _logStarted = false;
-
- // Get the time
-
- time_t t = time(NULL);
- string ts = asctime(localtime(&t));
- ts.erase(ts.length() - 1);
-
- // Stop the log
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- of << "----------------------------------------------- Log ends on " << ts << " -----------------------------------------------" << endl << endl;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logTex(const string &s, const LogFlags logBits)
-{
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Output to the log file
-
- of << headerString(logBits) << s << endl;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logRaw(const string &s)
-{
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Log the output
-
- of << s << endl;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::logHex(const char *buffer, const unsigned int count, const LogFlags logBits)
-{
- // No input? No output
-
- if (!buffer) return;
-
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Log the output
-
- unsigned int logged = 0;
- while(logged < count)
- {
- // One line at a time...
-
- string line;
-
- // The number of characters per line
-
- unsigned int hexLength = 20;
-
- // Default the buffer
-
- unsigned int i;
- for (i = 0; i < hexLength; i++)
- {
- line += "-- ";
- }
-
- for (i = 0; i < hexLength; i++)
- {
- line += ".";
- }
-
- // Fill it in with real data
-
- for (i = 0; i < hexLength && logged < count; i++, logged++)
- {
- unsigned char byte = buffer[logged];
- unsigned int index = i * 3;
-
- // The hex characters
-
- const string hexlist("0123456789ABCDEF");
- line[index+0] = hexlist[byte >> 4];
- line[index+1] = hexlist[byte & 0xf];
-
- // The ascii characters
-
- if (byte < 0x20 || byte > 0x7f) byte = '.';
- line[(hexLength*3)+i+0] = byte;
- }
-
- // Write it to the log file
-
- of << headerString(logBits) << line << endl;
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::indent(const string &s, const LogFlags logBits)
-{
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Log the output
-
- if (lineCharsFlag()) of << headerString(logBits) << "\xDA\xC4\xC4" << s << endl;
- else of << headerString(logBits) << "+- " << s << endl;
-
- // Indent...
-
- _indentCount += _indentChars;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-void Logger::undent(const string &s, const LogFlags logBits)
-{
- // If the bits don't match the mask, then bail
-
- if (!(logBits & logMask())) return;
-
- // Undo the indentation
-
- _indentCount -= _indentChars;
- if (_indentCount < 0) _indentCount = 0;
-
- // Open the file
-
- limitFileSize();
- ofstream of(logFile().c_str(), ios::out|ios::app);
- if (!of) return;
-
- // Log the output
-
- if (lineCharsFlag()) of << headerString(logBits) << "\xC0\xC4\xC4" << s << endl;
- else of << headerString(logBits) << "+- " << s << endl;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-const string &Logger::headerString(const LogFlags logBits) const
-{
- static string headerString;
- headerString.erase();
-
- // Get the string that represents the bits
-
- switch(logBits)
- {
- case LOG_INDENT : headerString += "> "; break;
- case LOG_UNDENT : headerString += "< "; break;
- case LOG_ALL : headerString += "A "; break;
- case LOG_CRIT : headerString += "! "; break;
- case LOG_DATA : headerString += "D "; break;
- case LOG_ERR : headerString += "E "; break;
- case LOG_FLOW : headerString += "F "; break;
- case LOG_INFO : headerString += "I "; break;
- case LOG_WARN : headerString += "W "; break;
- default: headerString += " "; break;
- }
-
- // File string (strip out the path)
-
- char temp[1024];
- int ix = sourceFile().rfind('\\');
- ix = (ix == (int) string::npos ? 0: ix+1);
- sprintf(temp, "%25s[%04d]", sourceFile().substr(ix).c_str(), sourceLine());
- headerString += temp;
-
- // Time string (specially formatted to save room)
-
- time_t t = time(NULL);
- struct tm *tme = localtime(&t);
- sprintf(temp, "%02d/%02d %02d:%02d ", tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min);
- headerString += temp;
-
- // Spaces for indentation
-
- memset(temp, ' ', sizeof(temp));
- temp[_indentCount] = '\0';
-
- // Add the indentation markers
-
- int count = 0;
- while(count < _indentCount)
- {
- if (lineCharsFlag()) temp[count] = '\xB3';
- else temp[count] = '|';
- count += _indentChars;
- }
- headerString += temp;
-
- return headerString;
-}
-
-#else /*Release Build*/
- std::string release_Null;
- void Logger::limitFileSize() const {}
- const string &Logger::headerString(const LogFlags logBits) const{return release_Null;}
- void Logger::start(const bool reset){}
- void Logger::stop(){}
- void Logger::logTex(const string &s, const LogFlags logBits /*= LOG_INFO*/){}
- void Logger::logRaw(const string &s){}
- void Logger::logHex(const char *buffer, const unsigned int count, const LogFlags logBits /*= LOG_INFO*/){}
- void Logger::indent(const string &s, const LogFlags logBits /*= LOG_INDENT*/){}
- void Logger::undent(const string &s, const LogFlags logBits /*= LOG_UNDENT*/){}
-#endif
-// ---------------------------------------------------------------------------------------------------------------------------------
-// logger.cpp - End of file
-// ---------------------------------------------------------------------------------------------------------------------------------
-
+++ /dev/null
-// ---------------------------------------------------------------------------------------------------------------------------------
-// _ _
-// | | | |
-// | | ___ __ _ __ _ ___ _ __ | |__
-// | |/ _ \ / _` |/ _` |/ _ \ '__| | '_ \
-// | | (_) | (_| | (_| | __/ | _ | | | |
-// |_|\___/ \__, |\__, |\___|_| (_)|_| |_|
-// __/ | __/ |
-// |___/ |___/
-//
-// Generic informational logging class
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-//
-// Restrictions & freedoms pertaining to usage and redistribution of this software:
-//
-// * This software is 100% free
-// * If you use this software (in part or in whole) you must credit the author.
-// * This software may not be re-distributed (in part or in whole) in a modified
-// form without clear documentation on how to obtain a copy of the original work.
-// * You may not use this software to directly or indirectly cause harm to others.
-// * This software is provided as-is and without warrantee. Use at your own risk.
-//
-// For more information, visit HTTP://www.FluidStudios.com
-//
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Originally created on 07/06/2000 by Paul Nettle
-//
-// Copyright 2000, Fluid Studios, Inc., all rights reserved.
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-#ifndef _H_LOGGER
-#define _H_LOGGER
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The global logger
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class Logger;
-extern Logger logger;
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// Macros (necessary evil to take advantage of __LINE__ and __FILE__)
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-#define LOG logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logTex
-#define HEX logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logHex
-#define RAW logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.logRaw
-#define INDENT logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.indent
-#define UNDENT logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__,logger.undent
-#define LOGBLOCK logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogBlock __lb__
-
-// If you compiler supports __FUNCTION__, then replace the "#if 1" with "#if 0". Note that this will change the usage of the macro
-
-#if 0
-#define LOGFUNC logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogFlow __lf__
-#else
-#define LOGFUNC logger.sourceLine() = __LINE__, logger.sourceFile() = __FILE__;LogFlow __lf__(__FUNCTION__)
-#endif
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The logger class: does the actual logging
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class Logger
-{
-public:
- // Enumerations
-
- enum LogFlags
- {
- LOG_INDENT = 0x00000001,
- LOG_UNDENT = 0x00000002,
- LOG_FLOW = 0x00000004,
- LOG_BLOK = 0x00000008,
- LOG_DATA = 0x00000010,
- LOG_INFO = 0x00000012,
- LOG_WARN = 0x00000014,
- LOG_ERR = 0x00000018,
- LOG_CRIT = 0x00000020,
- LOG_ALL = 0xFFFFFFFF
- };
-
- // Construction/Destruction
-
-inline Logger()
- : _sourceLine(0), _indentCount(0), _indentChars(4), _fileSizeLimit(-1), _logMask(LOG_ALL),
- _logStarted(false), _lineCharsFlag(false), _logFile("logger.log")
- {
- }
-
-virtual ~Logger()
- {
- stop();
- }
-
- // Operators
-
-inline void operator +=(const string &s) {logTex(s);}
-
- // Accessors
-
-inline const bool &lineCharsFlag() const {return _lineCharsFlag;}
-inline bool &lineCharsFlag() {return _lineCharsFlag;}
-
-inline const int &fileSizeLimit() const {return _fileSizeLimit;}
-inline int &fileSizeLimit() {return _fileSizeLimit;}
-
-inline const unsigned int &logMask() const {return _logMask;}
-inline unsigned int &logMask() {return _logMask;}
-
-inline const string &logFile() const {return _logFile;}
-inline string &logFile() {return _logFile;}
-
-inline const unsigned int &sourceLine() const {return _sourceLine;}
-inline unsigned int &sourceLine() {return _sourceLine;}
-
-inline const string &sourceFile() const {return _sourceFile;}
-inline string &sourceFile() {return _sourceFile;}
-
-inline bool logStarted() const {return _logStarted;}
-
- // Utilitarian (public)
-
-virtual void start(const bool reset);
-virtual void stop();
-virtual void logTex(const string &s, const LogFlags logBits = LOG_INFO);
-virtual void logRaw(const string &s);
-virtual void logHex(const char *buffer, const unsigned int count, const LogFlags logBits = LOG_INFO);
-virtual void indent(const string &s, const LogFlags logBits = LOG_INDENT);
-virtual void undent(const string &s, const LogFlags logBits = LOG_UNDENT);
-
-private:
- // Utilitarian (private)
-
-virtual void limitFileSize() const;
-virtual const string &headerString(const LogFlags logBits) const;
-
- // Data
-
- string _logFile;
- string _sourceFile;
- unsigned int _sourceLine;
- int _indentCount;
- int _indentChars;
- int _fileSizeLimit;
- unsigned int _logMask;
- bool _logStarted;
- bool _lineCharsFlag;
-};
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The LogBlock class: used for automatic indentation
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class LogBlock
-{
-public:
-inline LogBlock(const string &s) {str = s;logger.indent("Begin block: " + str, Logger::LOG_INDENT);}
-inline ~LogBlock() {logger.undent("", Logger::LOG_UNDENT);}
-private:
- string str;
-};
-
-// ---------------------------------------------------------------------------------------------------------------------------------
-// The LogFlow class: used for logging code flow
-// ---------------------------------------------------------------------------------------------------------------------------------
-
-class LogFlow
-{
-public:
-inline LogFlow(const string &function) {str = function;logger.indent(str, Logger::LOG_FLOW);}
-inline ~LogFlow() {logger.undent("", Logger::LOG_FLOW);}
-private:
- string str;
-};
-
-#endif // _H_LOGGER
-// ---------------------------------------------------------------------------------------------------------------------------------
-// logger.h - End of file
-// ---------------------------------------------------------------------------------------------------------------------------------
-
unpack_private.c \
Weapons.cpp \
MacCompatibility.cpp \
- logger/logger.cpp \
WinInput.cpp \
OpenGL_Windows.cpp \
openal_wrapper.cpp \
clean:
rm -f $(BINDIR)/*.o
rm -f $(BINDIR)/$(SRCDIR)/*.o
- rm -f $(BINDIR)/$(SRCDIR)/logger/*.o
rm -f $(BINDIR)/$(GLUDIR)/*.o
rm -f $(BINDIR)/$(LIBPNGDIR)/*.o
rm -f $(BINDIR)/$(JPEGLIBDIR)/*.o