mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
Remove #ifdefs for USE_VFS
This commit is contained in:
@@ -252,10 +252,8 @@ namespace sgp
|
||||
// compatibility with std::exception
|
||||
Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION);
|
||||
|
||||
#if defined(USE_VFS)
|
||||
// compatibility with vfs::Exception
|
||||
Exception(WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION);
|
||||
#endif
|
||||
|
||||
virtual const char* what() const throw();
|
||||
|
||||
|
||||
@@ -562,7 +562,6 @@ sgp::Exception::Exception(sgp::WString const& msg, Exception& ex SGP_CALLER_LOCA
|
||||
_msg.push_back(excp);
|
||||
}
|
||||
|
||||
#if defined(USE_VFS)
|
||||
sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION_IMPL)
|
||||
{
|
||||
vfs::Exception::CALLSTACK::iterator it = ex.m_CallStack.begin();
|
||||
@@ -584,7 +583,6 @@ sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER
|
||||
|
||||
_msg.push_back(excp);
|
||||
}
|
||||
#endif
|
||||
|
||||
sgp::Exception::Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION_IMPL)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -204,23 +204,6 @@ void ShutdownMemoryManager( void )
|
||||
#ifndef EXTREME_MEMORY_DEBUGGING
|
||||
#ifdef JA2BETAVERSION
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
FILE *fp;
|
||||
fp = fopen( "MemLeakInfo.txt", "a" );
|
||||
if( fp )
|
||||
{
|
||||
fprintf( fp, "\n\n" );
|
||||
fprintf( fp, ">>>>> MEMORY LEAK DETECTED!!! <<<<<\n" );
|
||||
fprintf( fp, " %d bytes memory total was allocated\n", guiMemAlloced );
|
||||
fprintf( fp, "- %d bytes memory total was freed\n", guiMemFreed );
|
||||
fprintf( fp, "_______________________________________________\n" );
|
||||
fprintf( fp, "%d bytes memory total STILL allocated\n", guiMemTotal );
|
||||
fprintf( fp, "%d memory blocks still allocated\n", MemDebugCounter );
|
||||
fprintf( fp, "guiScreenExitedFrom = %S\n", gzJA2ScreenNames[ gMsgBox.uiExitScreen ] );
|
||||
fprintf( fp, "\n\n" );
|
||||
}
|
||||
fclose( fp );
|
||||
#else
|
||||
sgp::Logger_ID log_id = sgp::Logger::instance().createLogger();
|
||||
sgp::Logger::LogInstance memLeak = SGP_LOG(log_id);
|
||||
memLeak << sgp::endl << sgp::endl;
|
||||
@@ -232,7 +215,6 @@ void ShutdownMemoryManager( void )
|
||||
memLeak << MemDebugCounter << " memory blocks still allocated" << sgp::endl;
|
||||
memLeak << "guiScreenExitedFrom = " << gzJA2ScreenNames[ gMsgBox.uiExitScreen ] << sgp::endl;
|
||||
memLeak << sgp::endl << sgp::endl;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -141,15 +141,6 @@ typedef VECTOR4 COLOR; // rgba color array
|
||||
|
||||
inline void convert_string(std::wstring const& str_in, std::string &str_out)
|
||||
{
|
||||
#if !defined(USE_VFS)
|
||||
const wchar_t* src = str_in.c_str();
|
||||
size_t len = wcstombs(NULL, src, str_in.length());
|
||||
if(len > 0)
|
||||
{
|
||||
str_out.resize(len);
|
||||
wcstombs(&str_out[0], src, len);
|
||||
}
|
||||
#else
|
||||
if(vfs::Settings::getUseUnicode())
|
||||
{
|
||||
str_out = vfs::String::as_utf8(str_in);
|
||||
@@ -158,20 +149,10 @@ inline void convert_string(std::wstring const& str_in, std::string &str_out)
|
||||
{
|
||||
vfs::String::narrow(str_in, str_out);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void convert_string(std::string const& str_in, std::wstring &str_out)
|
||||
{
|
||||
#if !defined(USE_VFS)
|
||||
const char* src = str_in.c_str();
|
||||
size_t len = mbstowcs(NULL, src, str_in.length());
|
||||
if(len > 0)
|
||||
{
|
||||
str_out.resize(len);
|
||||
mbstowcs(&str_out[0], src, len);
|
||||
}
|
||||
#else
|
||||
if(vfs::Settings::getUseUnicode())
|
||||
{
|
||||
vfs::String::as_utf16(str_in, str_out);
|
||||
@@ -180,8 +161,7 @@ inline void convert_string(std::string const& str_in, std::wstring &str_out)
|
||||
{
|
||||
vfs::String::widen(str_in, str_out);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -189,21 +189,6 @@ Name=Tahoma
|
||||
Height=-20
|
||||
Weight=400
|
||||
*/
|
||||
#ifndef USE_VFS
|
||||
char INIFile[MAX_PATH];
|
||||
GetExecutableDirectory( INIFile );
|
||||
strcat(INIFile, "\\");
|
||||
strcat(INIFile, GAME_INI_FILE);
|
||||
|
||||
|
||||
gWinFontAdjust = GetPrivateProfileInt("Ja2 Settings", "WIN_FONT_ADJUST", 0, INIFile);
|
||||
for (UINT16 i=0; i<WIN_LASTFONT; i++)
|
||||
{
|
||||
GetPrivateProfileString(FontInfo[i].FontName, "Name", FontInfo[i].LogFont.lfFaceName, FontInfo[i].LogFont.lfFaceName, LF_FACESIZE, INIFile);
|
||||
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + GetPrivateProfileInt(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight, INIFile);
|
||||
FontInfo[i].LogFont.lfWeight = GetPrivateProfileInt(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight, INIFile);
|
||||
}
|
||||
#else
|
||||
vfs::PropertyContainer props;
|
||||
props.initFromIniFile(GAME_INI_FILE);
|
||||
|
||||
@@ -216,7 +201,6 @@ Weight=400
|
||||
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + (LONG)props.getIntProperty(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight);
|
||||
FontInfo[i].LogFont.lfWeight = (LONG)props.getIntProperty(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void InitWinFonts( )
|
||||
|
||||
@@ -144,9 +144,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
|
||||
|
||||
|
||||
#ifdef USE_VFS
|
||||
static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection);
|
||||
#endif
|
||||
|
||||
HINSTANCE ghInstance;
|
||||
|
||||
@@ -194,9 +192,7 @@ extern bool g_bUseXML_Strings;// = false;
|
||||
bool g_bUseXML_Structures = false;
|
||||
//bool g_bUseXML_Tilesets = false;
|
||||
|
||||
#ifdef USE_VFS
|
||||
static vfs::Path sp_force_load_jsd_xml_file;
|
||||
#endif
|
||||
|
||||
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@@ -497,7 +493,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef USE_VFS
|
||||
//vfs::Path exe_dir, exe_file;
|
||||
//os::getExecutablePath(exe_dir, exe_file);
|
||||
|
||||
@@ -545,41 +540,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
|
||||
}
|
||||
}
|
||||
#endif // USE_CODE_PAGE
|
||||
#else
|
||||
// Snap: moved the following from InitJA2SplashScreen for clarity
|
||||
STRING512 CurrentDir;
|
||||
STRING512 DataDir;
|
||||
|
||||
// Get Executable Directory
|
||||
GetExecutableDirectory( CurrentDir );
|
||||
|
||||
// Adjust Current Dir
|
||||
sprintf( DataDir, "%s\\Data", CurrentDir );
|
||||
if ( !SetFileManCurrentDirectory( DataDir ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not find data directory, shutting down");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//Initialize the file database
|
||||
//InitializeFileDatabase( gGameLibaries, NUMBER_OF_LIBRARIES ); // ?!?! doesn't take parameters (jonathanl)
|
||||
InitializeFileDatabase();
|
||||
|
||||
// Snap: Initialize the Data directory catalogue
|
||||
gDefaultDataCat.NewCat(DataDir);
|
||||
|
||||
STRING512 ja2INIfile;
|
||||
strcat(ja2INIfile, "..\\");
|
||||
strcat(ja2INIfile, GAME_INI_FILE);
|
||||
|
||||
// Snap: Get the custom Data directory location from GAME_INI_FILE (if any)
|
||||
// and initialize the custom catalogue
|
||||
char customDataPath[MAX_PATH];
|
||||
if ( GetPrivateProfileString( "Ja2 Settings","CUSTOM_DATA_LOCATION", "", customDataPath, MAX_PATH, ja2INIfile ) )
|
||||
{
|
||||
gCustomDataCat.NewCat(std::string(CurrentDir) + '\\' + customDataPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(g_bUseXML_Strings)
|
||||
{
|
||||
@@ -721,7 +681,6 @@ void ShutdownStandardGamingPlatform(void)
|
||||
vfs::ObjectAllocator::clear();
|
||||
}
|
||||
|
||||
#ifdef USE_VFS
|
||||
#include "MPJoinScreen.h"
|
||||
|
||||
vfs::String getGameID()
|
||||
@@ -735,7 +694,6 @@ vfs::String getGameID()
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "debug_util.h"
|
||||
#include <vfs/Aspects/vfs_logging.h>
|
||||
@@ -841,9 +799,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
|
||||
|
||||
|
||||
#ifdef USE_VFS
|
||||
vfs::Log::setSharedString( getGameID() );
|
||||
#endif
|
||||
//if(!vfs::Aspects::getMutexFactory())
|
||||
//{
|
||||
// vfs::Aspects::setMutexFactory( new VfsMutexFactory() );
|
||||
@@ -914,15 +870,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
|
||||
// ShowCursor(FALSE);
|
||||
|
||||
#ifdef USE_VFS
|
||||
//vfs::Path exe_dir, exe_file;
|
||||
//os::getExecutablePath(exe_dir, exe_file);
|
||||
//os::setCurrectDirectory(exe_dir);
|
||||
#else
|
||||
STRING512 sExecutableDir;
|
||||
GetExecutableDirectory( sExecutableDir );
|
||||
SetCurrentDirectory(sExecutableDir);
|
||||
#endif
|
||||
try
|
||||
{
|
||||
// Inititialize the SGP
|
||||
@@ -934,9 +881,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
||||
}
|
||||
HANDLE_FATAL_ERROR;
|
||||
|
||||
#ifdef USE_VFS
|
||||
vfs::Log::flushReleaseAll();
|
||||
#endif
|
||||
|
||||
#ifdef LUACONSOLE
|
||||
if (1==iScreenMode)
|
||||
@@ -1051,39 +996,10 @@ void GetRuntimeSettings( )
|
||||
/* Detect cnc-ddraw and disable windowed mode */
|
||||
BOOL bCncDdraw = GetProcAddress(GetModuleHandleW(L"ddraw.dll"), "GameHandlesClose") != NULL;
|
||||
|
||||
#ifndef USE_VFS
|
||||
CHAR8 zMaximize[ 50 ];
|
||||
CHAR8 zWindowedMode[ 50 ];
|
||||
|
||||
// Runtime settings - for now use INI file - later use registry
|
||||
STRING512 INIFile; // Path to the ini file
|
||||
CHAR8 zScreenResolution[ 50 ];
|
||||
|
||||
// Get Executable Directory
|
||||
GetExecutableDirectory( INIFile );
|
||||
|
||||
strcat(INIFile, "\\");
|
||||
strcat(INIFile, GAME_INI_FILE);
|
||||
#else
|
||||
vfs::PropertyContainer oProps;
|
||||
oProps.initFromIniFile(GAME_INI_FILE);
|
||||
PopulateSectionFromCommandLine(oProps, "Ja2 Settings");
|
||||
#endif
|
||||
|
||||
#ifndef USE_VFS
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile ))
|
||||
{
|
||||
iResolution = atoi(zScreenResolution);
|
||||
}
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED_MAXIMIZE", "", zMaximize, 50, INIFile ))
|
||||
{
|
||||
iMaximize = atoi(zMaximize);
|
||||
}
|
||||
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED", "", zWindowedMode, 50, INIFile ))
|
||||
{
|
||||
iWindowedMode = bCncDdraw ? 0 : atoi(zWindowedMode);
|
||||
}
|
||||
#else
|
||||
vfs::String loc = oProps.getStringProperty("Ja2 Settings", L"LOCALE");
|
||||
if(!loc.empty())
|
||||
{
|
||||
@@ -1142,9 +1058,7 @@ void GetRuntimeSettings( )
|
||||
CIniReader::RegisterFileForMerging(*it);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_VFS
|
||||
extern bool g_bUsePngItemImages;
|
||||
g_bUsePngItemImages = oProps.getBoolProperty(L"Ja2 Settings", L"USE_PNG_ITEM_IMAGES", false);
|
||||
g_bUseXML_Structures = oProps.getBoolProperty(L"Ja2 Settings", L"USE_XML_STRUCTURES", false);
|
||||
@@ -1164,17 +1078,9 @@ void GetRuntimeSettings( )
|
||||
s_bExportStrings = oProps.getBoolProperty(L"Ja2 Settings", L"EXPORT_STRINGS", false);
|
||||
|
||||
sp_force_load_jsd_xml_file = oProps.getStringProperty(L"Ja2 Settings", L"FORCE_LOAD_JSD_XML_FILE", L"");
|
||||
#endif
|
||||
|
||||
#ifdef JA2EDITOR
|
||||
#ifndef USE_VFS
|
||||
if (GetPrivateProfileString( "Ja2 Settings","EDITOR_SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile ))
|
||||
{
|
||||
iResolution = atoi(zScreenResolution);
|
||||
}
|
||||
#else
|
||||
iResolution = (int)oProps.getIntProperty("Ja2 Settings","EDITOR_SCREEN_RESOLUTION", -1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int iResX;
|
||||
@@ -1311,30 +1217,6 @@ void GetRuntimeSettings( )
|
||||
}
|
||||
|
||||
// Adjust again
|
||||
|
||||
#ifndef USE_VFS
|
||||
gbPixelDepth = GetPrivateProfileInt( "SGP", "PIXEL_DEPTH", PIXEL_DEPTH, INIFile );
|
||||
|
||||
SCREEN_WIDTH = GetPrivateProfileInt( "SGP", "WIDTH", iResX, INIFile );
|
||||
SCREEN_HEIGHT = GetPrivateProfileInt( "SGP", "HEIGHT", iResY, INIFile );
|
||||
|
||||
iScreenWidthOffset = (SCREEN_WIDTH - 640) / 2;
|
||||
iScreenHeightOffset = (SCREEN_HEIGHT - 480) / 2;
|
||||
|
||||
/* Sergeant_Kolja. 2007-02-20: runtime Windowed mode instead of compile-time */
|
||||
/* 1 for Windowed, 0 for Fullscreen */
|
||||
if( !bScreenModeCmdLine )
|
||||
iScreenMode = bCncDdraw ? 0 : (int) GetPrivateProfileInt( "Ja2 Settings","SCREEN_MODE_WINDOWED", iScreenMode, INIFile );
|
||||
|
||||
// WANNE: Should we play the intro?
|
||||
iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile );
|
||||
iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, INIFile,);
|
||||
fTooltipScaleFactor = ((int)GetPrivateProfileInt("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100, INIFile, )) / 100;
|
||||
if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1;
|
||||
|
||||
// haydent: mouse scrolling
|
||||
iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile );
|
||||
#else
|
||||
gbPixelDepth = PIXEL_DEPTH;
|
||||
|
||||
SCREEN_WIDTH = iResX;
|
||||
@@ -1388,8 +1270,6 @@ void GetRuntimeSettings( )
|
||||
// get timer/clock initialization state
|
||||
//SetHiSpeedClockMode( oProps.getBoolProperty("Ja2 Settings", "HIGHSPEED_TIMER", false) ? TRUE : FALSE );
|
||||
SetHiSpeedClockMode( TRUE );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1464,7 +1344,6 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine)
|
||||
MemFree(pCopy);
|
||||
}
|
||||
|
||||
#ifdef USE_VFS
|
||||
static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection)
|
||||
{
|
||||
const wchar_t* lpCommandLine = GetCommandLineW();
|
||||
@@ -1496,7 +1375,6 @@ static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static LONG __stdcall SGPExceptionFilter(int exceptionCount, EXCEPTION_POINTERS* pExceptInfo)
|
||||
{
|
||||
|
||||
@@ -16,16 +16,12 @@ static inline void flush_screen(std::wstringstream& stream)
|
||||
|
||||
int sgp::Logger::_next_log_id = -1;
|
||||
|
||||
#if defined(USE_VFS)
|
||||
//std::vector<sgp::Logger::STimeLog> sgp::Logger::_logs;
|
||||
std::vector<sgp::Logger::LogData> sgp::Logger::_logs;
|
||||
#endif
|
||||
|
||||
sgp::Logger::Logger()
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
connectFile(this->createLogger(), L"game_log.log", false, sgp::Logger::FLUSH_ON_ENDL);
|
||||
#endif
|
||||
}
|
||||
|
||||
sgp::Logger::~Logger()
|
||||
@@ -47,9 +43,7 @@ bool sgp::Logger::shutdown()
|
||||
{
|
||||
for(::size_t i=0; i < _logs.size(); ++i)
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
disconnectFile(i);
|
||||
#endif
|
||||
disconnectStream(i);
|
||||
disconnectScreen(i);
|
||||
}
|
||||
@@ -102,7 +96,6 @@ void sgp::Logger::flushMode(sgp::Logger_ID id, sgp::Logger::FlushMode fmode)
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_VFS)
|
||||
void sgp::Logger::connectFile(sgp::Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fmode)
|
||||
{
|
||||
if(id >= 0 && id < _logs.size())
|
||||
@@ -128,7 +121,6 @@ void sgp::Logger::disconnectFile(sgp::Logger_ID id)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void sgp::Logger::connectStream(sgp::Logger_ID id, std::ostream& stream)
|
||||
{
|
||||
@@ -170,29 +162,10 @@ void sgp::Logger::disconnectScreen(sgp::Logger_ID id)
|
||||
}
|
||||
|
||||
|
||||
//#if defined(USE_VFS)
|
||||
//int sgp::Logger::createLogger(vfs::Path const& log_file, bool append, FlushMode fp)
|
||||
//{
|
||||
// vfs::Log::EFlushMode fm;
|
||||
// if(fp == sgp::Logger::FLUSH_ON_DELETE) fm = vfs::Log::FLUSH_ON_DELETE;
|
||||
// else if(fp == sgp::Logger::FLUSH_IMMIDIATELY) fm = vfs::Log::FLUSH_IMMEDIATELY;
|
||||
// else if(fp == sgp::Logger::FLUSH_FULL_BUFFER) fm = vfs::Log::FLUSH_BUFFER;
|
||||
// else if(fp == sgp::Logger::FLUSH_ON_ENDL) fm = vfs::Log::FLUSH_ON_ENDL;
|
||||
// else fm = vfs::Log::FLUSH_IMMEDIATELY;
|
||||
//
|
||||
// _logs.push_back(STimeLog());
|
||||
// _next_log_id++;
|
||||
// _logs[_next_log_id]._log = vfs::Log::create(log_file,append,fm);
|
||||
// _logs[_next_log_id]._timer.startTimer();
|
||||
// return _next_log_id;
|
||||
//}
|
||||
//#endif
|
||||
|
||||
sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id)
|
||||
{
|
||||
if(id < _logs.size())
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
std::wstringstream tmp;
|
||||
tmp << L"[" << _logs[id].timer.running() << L"] : ";
|
||||
std::wstring str(tmp.str());
|
||||
@@ -208,7 +181,6 @@ sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id)
|
||||
if(ld.screen) {
|
||||
(*ld.screen) << str;
|
||||
}
|
||||
#endif
|
||||
return sgp::Logger::LogInstance(&ld);
|
||||
}
|
||||
SGP_THROW(L"Unknown log id");
|
||||
@@ -219,10 +191,8 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_flush>(sgp
|
||||
{
|
||||
if(_log.file)
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
(*_log.file).flush();
|
||||
(*_log.file).unlock();
|
||||
#endif
|
||||
}
|
||||
if(_log.stream)
|
||||
{
|
||||
@@ -240,14 +210,12 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_endl>(sgp:
|
||||
{
|
||||
if(_log.file)
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
(*_log.file) << vfs::Log::endl;
|
||||
if(_log.file->flushMode() == vfs::Log::FLUSH_ON_ENDL)
|
||||
{
|
||||
(*_log.file).flush();
|
||||
}
|
||||
(*_log.file).unlock();
|
||||
#endif
|
||||
}
|
||||
if(_log.stream)
|
||||
{
|
||||
@@ -263,8 +231,6 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_endl>(sgp:
|
||||
template <>
|
||||
sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_lock>(sgp::_lock const& l)
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
_log.file->lock();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
#define SGP_LOGGER_H
|
||||
|
||||
#include <vector>
|
||||
#if defined(USE_VFS)
|
||||
# include <vfs/Core/vfs_string.h>
|
||||
# include <vfs/Tools/vfs_log.h>
|
||||
# include <vfs/Tools/vfs_hp_timer.h>
|
||||
#else
|
||||
# include <iostream>
|
||||
#endif
|
||||
#include <vfs/Core/vfs_string.h>
|
||||
#include <vfs/Tools/vfs_log.h>
|
||||
#include <vfs/Tools/vfs_hp_timer.h>
|
||||
|
||||
namespace sgp
|
||||
{
|
||||
@@ -22,13 +18,9 @@ namespace sgp
|
||||
{
|
||||
struct LogData
|
||||
{
|
||||
#if defined(USE_VFS)
|
||||
LogData() : file(NULL), stream(NULL), screen(NULL) {};
|
||||
vfs::HPTimer timer;
|
||||
vfs::Log* file;
|
||||
#else
|
||||
LogData() : stream(NULL), screen(NULL) {};
|
||||
#endif
|
||||
std::wostream* stream;
|
||||
std::wstringstream* screen;
|
||||
};
|
||||
@@ -53,9 +45,7 @@ namespace sgp
|
||||
LogInstance& operator<<(T const& t){
|
||||
if(_log.stream) (*_log.stream) << t;
|
||||
if(_log.screen) (*_log.screen) << t;
|
||||
#if defined(USE_VFS)
|
||||
if(_log.file ) (*_log.file) << t;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
@@ -72,10 +62,8 @@ namespace sgp
|
||||
|
||||
Logger_ID createLogger();
|
||||
|
||||
#if defined(USE_VFS)
|
||||
void connectFile(Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fp);
|
||||
void disconnectFile(Logger_ID id);
|
||||
#endif
|
||||
void connectStream(Logger_ID id, std::ostream& stream);
|
||||
void disconnectStream(Logger_ID id);
|
||||
|
||||
@@ -102,44 +90,28 @@ namespace sgp
|
||||
Logger::LogInstance& Logger::LogInstance::operator<< <_flush>(_flush const& f);
|
||||
}
|
||||
|
||||
#if defined(USE_VFS)
|
||||
inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id, vfs::String const& str){
|
||||
#else
|
||||
inline sgp::Logger::LogInstance SGP_LOG(int id, const char* str){
|
||||
#endif
|
||||
return sgp::Logger::instance().logger(id) << (str) << sgp::endl;
|
||||
}
|
||||
inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id){
|
||||
return sgp::Logger::instance().logger(id);
|
||||
}
|
||||
|
||||
#if defined(USE_VFS)
|
||||
inline sgp::Logger::LogInstance SGP_INFO(vfs::String const& str){
|
||||
#else
|
||||
inline sgp::Logger::LogInstance SGP_INFO(const char* str){
|
||||
#endif
|
||||
return sgp::Logger::instance().logger(0) << str << sgp::endl;
|
||||
}
|
||||
inline sgp::Logger::LogInstance SGP_INFO(){
|
||||
return sgp::Logger::instance().logger(0);
|
||||
}
|
||||
|
||||
#if defined(USE_VFS)
|
||||
inline sgp::Logger::LogInstance SGP_WARNING(vfs::String const& str){
|
||||
#else
|
||||
inline sgp::Logger::LogInstance SGP_WARNING(const char* str){
|
||||
#endif
|
||||
return sgp::Logger::instance().logger(0) << "WARNING : " << str << sgp::endl;
|
||||
}
|
||||
inline sgp::Logger::LogInstance SGP_WARNING(){
|
||||
return sgp::Logger::instance().logger(0) << "WARNING : ";
|
||||
}
|
||||
|
||||
#if defined(USE_VFS)
|
||||
inline sgp::Logger::LogInstance SGP_ERROR(vfs::String const& str){
|
||||
#else
|
||||
inline sgp::Logger::LogInstance SGP_ERROR(const char* str){
|
||||
#endif
|
||||
return sgp::Logger::instance().logger(0) << "ERROR : " << str << sgp::endl;
|
||||
}
|
||||
inline sgp::Logger::LogInstance SGP_ERROR(){
|
||||
|
||||
@@ -1869,15 +1869,7 @@ void SoundLog(CHAR8 *strMessage)
|
||||
sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE);
|
||||
}
|
||||
} s_SoundLog;
|
||||
#ifndef USE_VFS
|
||||
if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL)
|
||||
{
|
||||
fprintf(SndDebug, "%s\n", strMessage);
|
||||
fclose(SndDebug);
|
||||
}
|
||||
#else
|
||||
SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage)));
|
||||
#endif
|
||||
}
|
||||
|
||||
//*****************************************************************************************
|
||||
@@ -1890,10 +1882,4 @@ void SoundLog(CHAR8 *strMessage)
|
||||
//*****************************************************************************************
|
||||
void InitLogging()
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL)
|
||||
{
|
||||
fclose(SndDebug);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1888,22 +1888,10 @@ void RefreshScreen(void *DummyVariable)
|
||||
LPDIRECTDRAWSURFACE _pTmpBuffer;
|
||||
LPDIRECTDRAWSURFACE2 pTmpBuffer;
|
||||
DDSURFACEDESC SurfaceDescription;
|
||||
#ifndef USE_VFS
|
||||
FILE *OutputFile;
|
||||
#endif
|
||||
CHAR8 FileName[64];
|
||||
INT32 iIndex;
|
||||
UINT16 *p16BPPData;
|
||||
|
||||
// Snap: save current directory
|
||||
#ifndef USE_VFS
|
||||
STRING512 DataDir;
|
||||
STRING512 ExecDir;
|
||||
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
GetExecutableDirectory( ExecDir );
|
||||
SetFileManCurrentDirectory( ExecDir );
|
||||
#endif
|
||||
//
|
||||
// Create temporary system memory surface. This is used to correct problems with the backbuffer
|
||||
// surface which can be interlaced or have a funky pitch
|
||||
@@ -1953,23 +1941,13 @@ void RefreshScreen(void *DummyVariable)
|
||||
{
|
||||
sprintf( FileName, "SCREEN%03d.TGA", guiPrintFrameBufferIndex++);
|
||||
}
|
||||
#ifndef USE_VFS
|
||||
while( (_access( FileName, 0 )) != -1 );
|
||||
#else
|
||||
while(FileExists(FileName));
|
||||
#endif
|
||||
|
||||
#ifndef USE_VFS
|
||||
if ((OutputFile = fopen( FileName, "wb")) != NULL)
|
||||
{
|
||||
fprintf(OutputFile, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0);
|
||||
#else
|
||||
try
|
||||
{
|
||||
vfs::COpenWriteFile wfile(FileName,true,true);
|
||||
char head[] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0};
|
||||
SGP_TRYCATCH_RETHROW(wfile->write(head,18), L"");
|
||||
#endif
|
||||
|
||||
//
|
||||
// Lock temp surface
|
||||
@@ -2006,19 +1984,11 @@ void RefreshScreen(void *DummyVariable)
|
||||
ConvertRGBDistribution565To555( p16BPPData, SCREEN_WIDTH );
|
||||
|
||||
// Write
|
||||
#ifndef USE_VFS
|
||||
fwrite( p16BPPData, SCREEN_WIDTH * 2, 1, OutputFile);
|
||||
#else
|
||||
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)p16BPPData, SCREEN_WIDTH * 2), L"");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
fwrite((void *)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, 1, OutputFile);
|
||||
#else
|
||||
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2), L"");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2027,9 +1997,6 @@ void RefreshScreen(void *DummyVariable)
|
||||
{
|
||||
MemFree( p16BPPData );
|
||||
}
|
||||
#ifndef USE_VFS
|
||||
fclose(OutputFile);
|
||||
#endif
|
||||
//
|
||||
// Unlock temp surface
|
||||
//
|
||||
@@ -2043,12 +2010,10 @@ void RefreshScreen(void *DummyVariable)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_VFS
|
||||
catch(std::exception& ex)
|
||||
{
|
||||
SGP_RETHROW(L"", ex);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Release temp surface
|
||||
@@ -2056,12 +2021,6 @@ void RefreshScreen(void *DummyVariable)
|
||||
|
||||
gfPrintFrameBuffer = FALSE;
|
||||
IDirectDrawSurface2_Release(pTmpBuffer);
|
||||
#ifndef USE_VFS
|
||||
// Snap: Restore the data directory once we are finished.
|
||||
SetFileManCurrentDirectory( DataDir );
|
||||
//strcat( ExecDir, "\\Data" );
|
||||
//SetFileManCurrentDirectory( ExecDir );
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3322,80 +3281,42 @@ void RefreshMovieCache( )
|
||||
{
|
||||
TARGA_HEADER Header;
|
||||
INT32 iCountX, iCountY;
|
||||
#ifndef USE_VFS
|
||||
FILE *disk;
|
||||
#endif
|
||||
CHAR8 cFilename[_MAX_PATH];
|
||||
static UINT32 uiPicNum=0;
|
||||
UINT16 *pDest;
|
||||
INT32 cnt;
|
||||
#ifndef USE_VFS
|
||||
STRING512 DataDir;
|
||||
STRING512 ExecDir;
|
||||
#endif
|
||||
PauseTime( TRUE );
|
||||
#ifndef USE_VFS
|
||||
// Snap: save current directory
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
|
||||
GetExecutableDirectory( ExecDir );
|
||||
SetFileManCurrentDirectory( ExecDir );
|
||||
#else
|
||||
try
|
||||
{
|
||||
#endif
|
||||
for ( cnt = 0; cnt < giNumFrames; cnt++ )
|
||||
{
|
||||
sprintf( cFilename, "JA%5.5d.TGA", uiPicNum++ );
|
||||
#ifndef USE_VFS
|
||||
if( ( disk = fopen(cFilename, "wb"))==NULL )
|
||||
return;
|
||||
#else
|
||||
vfs::COpenWriteFile wfile(cFilename, true, true);
|
||||
#endif
|
||||
memset(&Header, 0, sizeof(TARGA_HEADER));
|
||||
|
||||
Header.ubTargaType=2; // Uncompressed 16/24/32 bit
|
||||
Header.usImageWidth=SCREEN_WIDTH;
|
||||
Header.usImageHeight=SCREEN_HEIGHT;
|
||||
Header.ubBitsPerPixel=16;
|
||||
#ifndef USE_VFS
|
||||
fwrite(&Header, sizeof(TARGA_HEADER), 1, disk);
|
||||
#else
|
||||
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)&Header, sizeof(TARGA_HEADER)), L"");
|
||||
#endif
|
||||
pDest = gpFrameData[ cnt ];
|
||||
|
||||
for(iCountY=SCREEN_HEIGHT-1; iCountY >=0 ; iCountY-=1)
|
||||
{
|
||||
for(iCountX=0; iCountX < SCREEN_WIDTH; iCountX ++ )
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
fwrite( ( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16), 1, disk);
|
||||
#else
|
||||
SGP_TRYCATCH_RETHROW(wfile->write( (vfs::Byte*)( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16)), L"");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
#ifndef USE_VFS
|
||||
fclose(disk);
|
||||
#endif
|
||||
}
|
||||
|
||||
PauseTime( FALSE );
|
||||
|
||||
giNumFrames = 0;
|
||||
#ifndef USE_VFS
|
||||
// Snap: Restore the data directory once we are finished.
|
||||
SetFileManCurrentDirectory( DataDir );
|
||||
//strcat( ExecDir, "\\Data" );
|
||||
//SetFileManCurrentDirectory( ExecDir );
|
||||
#else
|
||||
}
|
||||
catch(std::exception& ex)
|
||||
{
|
||||
SGP_ERROR(ex.what());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user