Fix windows compile and convert main.c to WZ_OS_ and WZ_CC_ defines.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@893 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2006-12-03 16:31:19 +00:00
parent 9188b707a6
commit cc5c9167e6
1 changed files with 15 additions and 13 deletions

View File

@ -7,12 +7,14 @@
#include <physfs.h> #include <physfs.h>
#include <string.h> #include <string.h>
/* For SHGetFolderPath */ // Get platform defines before checking for them!
#ifdef WIN32
# include <shlobj.h>
#endif // WIN32
#include "lib/framework/frame.h" #include "lib/framework/frame.h"
/* For SHGetFolderPath */
#ifdef WZ_OS_WIN
# include <shlobj.h>
#endif // WZ_OS_WIN
#include "lib/framework/configfile.h" #include "lib/framework/configfile.h"
#include "lib/gamelib/gtime.h" #include "lib/gamelib/gtime.h"
#include "lib/ivis_common/piestate.h" #include "lib/ivis_common/piestate.h"
@ -44,9 +46,9 @@
# define DEFAULT_DATADIR "/usr/share/warzone2100/" # define DEFAULT_DATADIR "/usr/share/warzone2100/"
#endif #endif
#if defined(WIN32) #if defined(WZ_OS_WIN)
# define WZ_WRITEDIR "Warzone 2100" # define WZ_WRITEDIR "Warzone 2100"
#elif defined(__APPLE__) #elif defined(WZ_OS_MAC)
# include <CoreServices/CoreServices.h> # include <CoreServices/CoreServices.h>
# define WZ_WRITEDIR "Warzone 2100" # define WZ_WRITEDIR "Warzone 2100"
#else #else
@ -189,11 +191,11 @@ static void initialize_PhysicsFS(void)
debug(LOG_WZ, "Linked against PhysFS version: %d.%d.%d", debug(LOG_WZ, "Linked against PhysFS version: %d.%d.%d",
linked.major, linked.minor, linked.patch); linked.major, linked.minor, linked.patch);
#if defined(WIN32) #if defined(WZ_OS_WIN)
if ( SUCCEEDED( SHGetFolderPathA( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, tmpstr ) ) ) // Use "Documents and Settings\Username\My Documents" ("Personal" data in local lang) if possible if ( SUCCEEDED( SHGetFolderPathA( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, tmpstr ) ) ) // Use "Documents and Settings\Username\My Documents" ("Personal" data in local lang) if possible
strcat( tmpstr, PHYSFS_getDirSeparator() ); strcat( tmpstr, PHYSFS_getDirSeparator() );
else else
#elif defined(__APPLE__) #elif defined(WZ_OS_MAC)
error = FindFolder(kUserDomain, kApplicationSupportFolderType, FALSE, &vol_ref, &dir_id); error = FindFolder(kUserDomain, kApplicationSupportFolderType, FALSE, &vol_ref, &dir_id);
if (!error) if (!error)
error = FSMakeFSSpec(vol_ref, dir_id, (const unsigned char *) "", &fsspec); error = FSMakeFSSpec(vol_ref, dir_id, (const unsigned char *) "", &fsspec);
@ -362,7 +364,7 @@ int main(int argc, char *argv[])
UDWORD pSize; UDWORD pSize;
/*** Initialize the debug subsystem ***/ /*** Initialize the debug subsystem ***/
#ifdef _MSC_VER #ifdef WZ_CC_MSVC
# ifdef DEBUG # ifdef DEBUG
int tmpDbgFlag; int tmpDbgFlag;
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG ); // Output CRT info to debugger _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG ); // Output CRT info to debugger
@ -375,16 +377,16 @@ int main(int argc, char *argv[])
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF; // Check for memleaks tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF; // Check for memleaks
_CrtSetDbgFlag( tmpDbgFlag ); _CrtSetDbgFlag( tmpDbgFlag );
# endif //DEBUG # endif //DEBUG
#endif // _MSC_VER #endif // WZ_CC_MSVC
debug_init(); debug_init();
atexit( debug_exit ); atexit( debug_exit );
debug_register_callback( debug_callback_stderr, NULL, NULL, NULL ); debug_register_callback( debug_callback_stderr, NULL, NULL, NULL );
#if defined WIN32 && defined DEBUG #if defined WZ_OS_WIN && defined DEBUG
// debug_register_callback( debug_callback_win32debug, NULL, NULL, NULL ); // debug_register_callback( debug_callback_win32debug, NULL, NULL, NULL );
#endif // WIN32 #endif // WZ_OS_WIN
// find early boot info // find early boot info
if ( !ParseCommandLineEarly(argc, argv) ) { if ( !ParseCommandLineEarly(argc, argv) ) {