diff --git a/SConscript b/SConscript index 5c64985ed..e7fb88a85 100644 --- a/SConscript +++ b/SConscript @@ -25,7 +25,7 @@ def SetupSpawn( env ): AddOption('--opengl-renderer',dest="opengl-renderer",action='store_true',default=False,help="Build with OpenGL renderer support. (requires --opengl)") AddOption('--opengl',dest="opengl",action='store_true',default=False,help="Build with OpenGL interface support.") -AddOption('--win32',dest="win32",action='store_true',default=False,help="32bit Windows platform target.") +AddOption('--win',dest="win",action='store_true',default=False,help="Windows platform target.") AddOption('--lin',dest="lin",action='store_true',default=False,help="Linux platform target") AddOption('--macosx',dest="macosx",action='store_true',default=False,help="Mac OS X platform target") AddOption('--64bit',dest="_64bit",action='store_true',default=False,help="64-bit platform target (Linux only at the moment)") @@ -47,11 +47,11 @@ AddOption('--minor-version',dest="minor-version",default=False,help="Minor versi AddOption('--build-number',dest="build-number",default=False,help="Build number.") AddOption('--snapshot',dest="snapshot",default=False,help="Snapshot build.") -if((not GetOption('lin')) and (not GetOption('win32')) and (not GetOption('macosx'))): +if((not GetOption('lin')) and (not GetOption('win')) and (not GetOption('macosx'))): print "You must specify a platform to target" raise SystemExit(1) -if(GetOption('win32')): +if(GetOption('win')): env = Environment(tools = ['mingw'], ENV = os.environ) else: env = Environment(ENV = os.environ) @@ -108,11 +108,11 @@ if GetOption("ptw32-static"): if(GetOption('static')): env.Append(LINKFLAGS=['-static-libgcc']) -if(GetOption('win32')): +if(GetOption('win')): openGLLibs = ['opengl32', 'glew32'] env.Prepend(LIBS=['mingw32', 'ws2_32', 'SDLmain', 'regex']) env.Append(LIBS=['winmm', 'gdi32']) - env.Append(CPPDEFINES=["WIN32"]) + env.Append(CPPDEFINES=["WIN"]) env.Append(LINKFLAGS=['-mwindows']) if(GetOption('lin'): openGLLibs = ['GL'] @@ -174,7 +174,7 @@ elif(GetOption('opengl-renderer')): raise SystemExit(1) sources=Glob("src/*.cpp") -if(GetOption('win32')): +if(GetOption('win')): sources += env.RES('resources/powder-res.rc') sources+=Glob("src/*/*.cpp") sources+=Glob("src/simulation/elements/*.cpp") @@ -187,7 +187,7 @@ SetupSpawn(env) programName = "powder" -if(GetOption('win32')): +if(GetOption('win')): programName = "Powder" if(GetOption('_64bit')): @@ -199,7 +199,7 @@ if(not (GetOption('sse2') or GetOption('sse3'))): if(GetOption('macosx')): programName += "-x" -if(GetOption('win32')): +if(GetOption('win')): programName += ".exe" env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), "python generator.py elements $TARGETS $SOURCES") diff --git a/src/Config.h b/src/Config.h index 52e5ae841..8b05f458f 100644 --- a/src/Config.h +++ b/src/Config.h @@ -9,7 +9,7 @@ //#define CONFIG_H_ -#ifdef WIN32 +#ifdef WIN #define PATH_SEP "\\" #else #define PATH_SEP "/" @@ -44,7 +44,7 @@ #define IDENT_RELTYPE "R" #endif -#ifdef WIN32 +#if defined(WIN) #define IDENT_PLATFORM "WIN32" #elif defined(MACOSX) #define IDENT_PLATFORM "MACOSX" @@ -173,17 +173,17 @@ extern unsigned char ZSIZE; #define GLASS_IOR 1.9 #define GLASS_DISP 0.07 -#ifdef WIN32 +#ifdef WIN #define strcasecmp stricmp #endif -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) #define fmin min #define fminf min #define fmax max #define fmaxf max #endif -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) #define TPT_INLINE _inline #else #define TPT_INLINE inline diff --git a/src/Misc.cpp b/src/Misc.cpp index 2c4f2e5cf..c7481ab13 100644 --- a/src/Misc.cpp +++ b/src/Misc.cpp @@ -8,7 +8,7 @@ #include "Config.h" #include "Misc.h" #include "icondoc.h" -#if defined WIN32 +#if defined(WIN) #include #include #include @@ -59,7 +59,7 @@ char *clipboard_text = NULL; char *exe_name(void) { -#if defined WIN32 +#if defined(WIN) char *name= (char *)malloc(64); DWORD max=64, res; while ((res = GetModuleFileName(NULL, name, max)) >= max) @@ -378,7 +378,7 @@ void clipboard_push_text(char * text) CFDataRef data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text)); PasteboardPutItemFlavor(newclipboard, (PasteboardItemID)1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0); -#elif defined WIN32 +#elif defined(WIN) if (OpenClipboard(NULL)) { HGLOBAL cbuffer; @@ -414,7 +414,7 @@ char * clipboard_pull_text() { #ifdef MACOSX printf("Not implemented: get text from clipboard\n"); -#elif defined WIN32 +#elif defined(WIN) if (OpenClipboard(NULL)) { HANDLE cbuffer; @@ -440,7 +440,7 @@ char * clipboard_pull_text() int register_extension() { -#if defined WIN32 +#if defined(WIN) int returnval; LONG rresult; HKEY newkey; @@ -661,7 +661,7 @@ void HSV_to_RGB(int h,int s,int v,int *r,int *g,int *b)//convert 0-255(0-360 for } void OpenURI(std::string uri) { -#ifdef WIN32 +#if defined(WIN) ShellExecute(0, "OPEN", uri.c_str(), NULL, NULL, 0); #elif defined(MACOSX) char *cmd = (char*)malloc(7+uri.length()); diff --git a/src/Misc.h b/src/Misc.h index 98f0e3181..f3f25a9b9 100644 --- a/src/Misc.h +++ b/src/Misc.h @@ -6,7 +6,7 @@ #include #include -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) #define x86_cpuid(func,af,bf,cf,df) \ do {\ __asm mov eax, func\ diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index f9901c1af..3123a4ba5 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -4,7 +4,7 @@ #include #include #include "SDL.h" -#ifdef WIN32 +#ifdef WIN #include "SDL_syswm.h" #endif #include @@ -35,7 +35,7 @@ using namespace std; -#ifdef WIN32 +#ifdef WIN extern "C" IMAGE_DOS_HEADER __ImageBase; #endif @@ -74,7 +74,7 @@ void blit(pixel * vid) SDL_Surface * SDLOpen() { SDL_Surface * surface; -#if defined(WIN32) && defined(WINCONSOLE) +#if defined(WIN) && defined(WINCONSOLE) FILE * console = fopen("CON", "w" ); #endif if (SDL_Init(SDL_INIT_VIDEO)<0) @@ -83,17 +83,16 @@ SDL_Surface * SDLOpen() return 0; } SDL_EnableUNICODE(1); -#if defined(WIN32) && defined(WINCONSOLE) +#if defined(WIN) && defined(WINCONSOLE) //On Windows, SDL redirects stdout to stdout.txt, which can be annoying when debugging, here we redirect back to the console if (console) { - freopen("CON", "w", stdout); freopen("CON", "w", stderr); //fclose(console); } #endif -#ifdef WIN32 +#ifdef WIN SDL_SysWMinfo SysInfo; SDL_VERSION(&SysInfo.version); if(SDL_GetWMInfo(&SysInfo) <= 0) { diff --git a/src/Update.cpp b/src/Update.cpp index d73eb7e21..853043d59 100644 --- a/src/Update.cpp +++ b/src/Update.cpp @@ -1,6 +1,6 @@ #include #include -#ifndef WIN32 +#ifndef WIN #include #endif #if !defined(MACOSX) && !defined(BSD) @@ -8,7 +8,7 @@ #endif #include -#ifdef WIN32 +#ifdef WIN #include #else #include @@ -24,7 +24,7 @@ /*char *exe_name(void) { -#if defined WIN32 +#if defined(WIN) char *name= (char *)malloc(64); DWORD max=64, res; while ((res = GetModuleFileName(NULL, name, max)) >= max) @@ -69,7 +69,7 @@ int update_start(char *data, int len) { char *self=exe_name(), *temp; -#ifdef WIN32 +#ifdef WIN char *p; #endif FILE *f; @@ -78,7 +78,7 @@ int update_start(char *data, int len) if (!self) return 1; -#ifdef WIN32 +#ifdef WIN temp = (char*)malloc(strlen(self)+12); strcpy(temp, self); p = temp + strlen(temp) - 4; @@ -146,7 +146,7 @@ fail: int update_finish(void) { -#ifdef WIN32 +#ifdef WIN char *temp, *self=exe_name(), *p; int timeout = 60, err; @@ -181,7 +181,7 @@ int update_finish(void) void update_cleanup(void) { -#ifdef WIN32 +#ifdef WIN update_finish(); #endif } diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 3dd9a5552..57ed1d944 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1971,7 +1971,7 @@ int luatpt_getscript(lua_State* l) filename = (char*)malloc(strlen(fileauthor)+strlen(fileid)+strlen(PATH_SEP)+strlen(LOCAL_LUA_DIR)+6); sprintf(filename, LOCAL_LUA_DIR PATH_SEP "%s_%s.lua", fileauthor, fileid); -#ifdef WIN32 +#ifdef WIN _mkdir(LOCAL_LUA_DIR); #else mkdir(LOCAL_LUA_DIR, 0755); diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 29f6a944b..2684689f4 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -8,7 +8,7 @@ #include #include -#ifdef WIN32 +#ifdef WIN #include #else #include @@ -30,7 +30,7 @@ extern "C" { -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) #include #else #include @@ -136,7 +136,7 @@ std::vector Client::DirectorySearch(std::string directory, std::str { //Get full file listing std::vector directoryList; -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) //Windows struct _finddata_t currentFile; intptr_t findFileHandle; @@ -591,7 +591,7 @@ string Client::AddStamp(GameSave * saveData) << std::setw(8) << std::setfill('0') << std::hex << lastStampTime << std::setw(2) << std::setfill('0') << std::hex << lastStampName; -#ifdef WIN32 +#ifdef WIN _mkdir(STAMPS_DIR); #else mkdir(STAMPS_DIR, 0755); @@ -615,7 +615,7 @@ string Client::AddStamp(GameSave * saveData) void Client::updateStamps() { -#ifdef WIN32 +#ifdef WIN _mkdir(STAMPS_DIR); #else mkdir(STAMPS_DIR, 0755); diff --git a/src/client/HTTP.cpp b/src/client/HTTP.cpp index 686a6ee28..43d5dcfec 100644 --- a/src/client/HTTP.cpp +++ b/src/client/HTTP.cpp @@ -25,14 +25,14 @@ #include #include #include -#ifndef WIN32 +#ifndef WIN #include #endif #if !defined(MACOSX) && !defined(BSD) #include #endif #include -#ifdef WIN32 +#ifdef WIN #define _WIN32_WINNT 0x0501 //#include #include @@ -52,7 +52,7 @@ #include "HTTP.h" #include "MD5.h" -#ifdef WIN32 +#ifdef WIN #define PERROR SOCKET_ERROR #define PERRNO WSAGetLastError() #define PEAGAIN WSAEWOULDBLOCK @@ -164,7 +164,7 @@ static int resolve(char *dns, char *srv, struct sockaddr_in *addr) void http_init(char *proxy) { char *host, *port; -#ifdef WIN32 +#ifdef WIN WSADATA wsadata; if (!WSAStartup(MAKEWORD(2,2), &wsadata)) http_up = 1; @@ -196,7 +196,7 @@ void http_init(char *proxy) void http_done(void) { -#ifdef WIN32 +#ifdef WIN WSACleanup(); #endif http_up = 0; @@ -413,7 +413,7 @@ int http_async_req_status(void *ctx) char *dns,*srv,buf[CHUNK]; int tmp, i; time_t now = time(NULL); -#ifdef WIN32 +#ifdef WIN unsigned long tmp2; #endif @@ -445,7 +445,7 @@ int http_async_req_status(void *ctx) if (cx->fd == PERROR) goto fail; cx->fdhost = mystrdup(cx->host); -#ifdef WIN32 +#ifdef WIN tmp2 = 1; if (ioctlsocket(cx->fd, FIONBIO, &tmp2) == SOCKET_ERROR) goto fail; @@ -459,7 +459,7 @@ int http_async_req_status(void *ctx) } if (!connect(cx->fd, (struct sockaddr *)&cx->addr, sizeof(cx->addr))) cx->state = HTS_IDLE; -#ifdef WIN32 +#ifdef WIN else if (PERRNO==WSAEISCONN) cx->state = HTS_IDLE; #endif @@ -468,7 +468,7 @@ int http_async_req_status(void *ctx) cx->state = HTS_IDLE; #endif else if (PERRNO!=PEINPROGRESS && PERRNO!=PEALREADY -#ifdef WIN32 +#ifdef WIN && PERRNO!=PEAGAIN && PERRNO!=WSAEINVAL #endif ) diff --git a/src/graphics/OpenGLHeaders.h b/src/graphics/OpenGLHeaders.h index 8a8347256..de692e0ef 100644 --- a/src/graphics/OpenGLHeaders.h +++ b/src/graphics/OpenGLHeaders.h @@ -10,7 +10,7 @@ #define GL_RGBA32F 0x8814 #endif -#elif defined(WIN32) +#elif defined(WIN) #include #include diff --git a/src/powdertoyjava/OpenGLCanvasWin32.cpp b/src/powdertoyjava/OpenGLCanvasWin32.cpp index 9df0a0bd3..7028d86ed 100644 --- a/src/powdertoyjava/OpenGLCanvasWin32.cpp +++ b/src/powdertoyjava/OpenGLCanvasWin32.cpp @@ -1,4 +1,4 @@ -#if defined(USE_JNI) && defined(WIN32) +#if defined(USE_JNI) && defined(WIN) #include "OpenGLCanvasWin32.h" static jfieldID ctxID = NULL; diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 2ac72b213..f1bea9431 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -3829,7 +3829,7 @@ killed: if (!parts[i].vx&&!parts[i].vy)//if its not moving, skip to next particle, movement code it next continue; -#if defined(WIN32) && !defined(__GNUC__) +#if defined(WIN) && !defined(__GNUC__) mv = max(fabsf(parts[i].vx), fabsf(parts[i].vy)); #else mv = fmaxf(fabsf(parts[i].vx), fabsf(parts[i].vy));