diff --git a/polymer/build/include/baselayer.h b/polymer/build/include/baselayer.h index c463952a8..e070ab7da 100644 --- a/polymer/build/include/baselayer.h +++ b/polymer/build/include/baselayer.h @@ -10,7 +10,7 @@ extern "C" { #endif extern int _buildargc; -extern char **_buildargv; +extern const char **_buildargv; extern char quitevent, appactive; diff --git a/polymer/build/include/editor.h b/polymer/build/include/editor.h index 81488a4fe..bb5126228 100644 --- a/polymer/build/include/editor.h +++ b/polymer/build/include/editor.h @@ -26,7 +26,7 @@ extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup; extern int ExtInit(void); -extern int ExtPreInit(int argc,char **argv); +extern int ExtPreInit(int argc,const char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); #ifdef SUPERBUILD diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index 57529150a..61d727e1e 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -27,7 +27,7 @@ static long crctable[256]; static char kensig[32]; extern int ExtInit(void); -extern int ExtPreInit(int argc,char **argv); +extern int ExtPreInit(int argc,const char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); #ifdef SUPERBUILD @@ -243,7 +243,7 @@ extern int startwin_run(void); extern char *defsfilename; // set in bstub.c -int app_main(int argc, char **argv) +int app_main(int argc, const char **argv) { char ch, quitflag, cmdsetup = 0; long i, j, k; diff --git a/polymer/build/src/sdlayer.c b/polymer/build/src/sdlayer.c index 2989ac258..fa20ad920 100644 --- a/polymer/build/src/sdlayer.c +++ b/polymer/build/src/sdlayer.c @@ -44,7 +44,7 @@ int startwin_settitle(const char *s) { s=s; return 0; } static unsigned long mwheelup, mwheeldown; int _buildargc = 1; -char **_buildargv = NULL; +const char **_buildargv = NULL; extern long app_main(long argc, char *argv[]); char quitevent=0, appactive=1; @@ -167,9 +167,7 @@ int main(int argc, char *argv[]) startwin_open(); _buildargc = argc; - _buildargv = (char**)argv; - //_buildargv = (char**)malloc(argc * sizeof(char*)); - //memcpy(_buildargv, argv, sizeof(char*)*argc); + _buildargv = (const char**)argv; baselayer_init(); r = app_main(argc, argv); diff --git a/polymer/build/src/winlayer.c b/polymer/build/src/winlayer.c index a520d4e10..758e143b1 100644 --- a/polymer/build/src/winlayer.c +++ b/polymer/build/src/winlayer.c @@ -44,7 +44,7 @@ #define ANY_WINDOWED_SIZE int _buildargc = 0; -char **_buildargv = NULL; +const char **_buildargv = NULL; static char *argvbuf = NULL; extern long app_main(long argc, char *argv[]); diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 7f642605f..689cf8766 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -51,12 +51,17 @@ EXESUFFIX= include $(EROOT)/Makefile.shared ifeq ($(PLATFORM),LINUX) - OBJ=obj.nix - EOBJ=eobj.nix - NASMFLAGS+= -f elf -else OBJ=obj EOBJ=eobj + NASMFLAGS+= -f elf +else + ifeq ($(PLATFORM),WINDOWS) + OBJ=obj_win + EOBJ=eobj_win + else + OBJ=obj + EOBJ=eobj + endif endif JMACTOBJ=$(OBJ)/util_lib.$o \ @@ -78,8 +83,7 @@ AUDIOLIB_FX_SDL=$(OBJ)/mv_mix.$o \ $(OBJ)/dsl.$o \ $(OBJ)/pitch.$o \ $(OBJ)/multivoc.$o -AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o \ - $(OBJ)/unixglob.$o +AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o AUDIOLIB_JFAUD=$(OBJ)/jfaud_sounds.$o diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 0804069bb..3fd10f4d4 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -5066,7 +5066,7 @@ static void buildaddgroup(const char *buffer) grps[grpstoadd++] = strdup(buffer); } -static void checkcommandline(int argc,char **argv) +static void checkcommandline(int argc,const char **argv) { int i = 1; char *c; @@ -5075,7 +5075,7 @@ static void checkcommandline(int argc,char **argv) { while (i < argc) { - c = argv[i]; + c = (char *)argv[i]; if (((*c == '/') || (*c == '-'))) { if (!Bstrcasecmp(c+1,"?") || !Bstrcasecmp(c+1,"help") || !Bstrcasecmp(c+1,"-help")) @@ -5194,7 +5194,7 @@ static void checkcommandline(int argc,char **argv) } } -int ExtPreInit(int argc,char **argv) +int ExtPreInit(int argc,const char **argv) { wm_setapptitle("Mapster32"VERSION); @@ -6192,7 +6192,7 @@ static void Keys2d3d(void) if ((keystatus[0x1d]|keystatus[0x9d]) > 0) //CTRL if (keystatus[0x1f] > 0) // S { - if (levelname) + if (levelname[0]) { fixspritesectors(); //Do this before saving! updatesector(startposx,startposy,&startsectnum); diff --git a/polymer/eduke32/source/jaudiolib/sdlmusic.c b/polymer/eduke32/source/jaudiolib/sdlmusic.c index 171af6558..12857f781 100755 --- a/polymer/eduke32/source/jaudiolib/sdlmusic.c +++ b/polymer/eduke32/source/jaudiolib/sdlmusic.c @@ -31,6 +31,8 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) #include #include #include +#include +#include #include "duke3d.h" #include "cache1d.h" @@ -65,8 +67,6 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) #define max(a, b) (((a) > (b)) ? (a) : (b)) #endif -void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename); - int MUSIC_ErrorCode = MUSIC_Ok; static char warningMessage[80]; @@ -76,6 +76,128 @@ static int initialized_debugging = 0; static char *midifn = NULL; +static char ApogeePath[256] = "/tmp/"; + +#define PATH_SEP_CHAR '/' +#define PATH_SEP_STR "/" +#define ROOTDIR "/" +#define CURDIR "./" + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + +void FixFilePath(char *filename) +{ + char *ptr; + char *lastsep = filename; + + if ((!filename) || (*filename == '\0')) + return; + + if (access(filename, F_OK) == 0) /* File exists; we're good to go. */ + return; + + for (ptr = filename; 1; ptr++) + { + if (*ptr == '\\') + *ptr = PATH_SEP_CHAR; + + if ((*ptr == PATH_SEP_CHAR) || (*ptr == '\0')) + { + char pch = *ptr; + struct dirent *dent = NULL; + DIR *dir; + + if ((pch == PATH_SEP_CHAR) && (*(ptr + 1) == '\0')) + return; /* eos is pathsep; we're done. */ + + if (lastsep == ptr) + continue; /* absolute path; skip to next one. */ + + *ptr = '\0'; + if (lastsep == filename) + { + dir = opendir((*lastsep == PATH_SEP_CHAR) ? ROOTDIR : CURDIR); + + if (*lastsep == PATH_SEP_CHAR) + { + lastsep++; + } + } + else + { + *lastsep = '\0'; + dir = opendir(filename); + *lastsep = PATH_SEP_CHAR; + lastsep++; + } + + if (dir == NULL) + { + *ptr = PATH_SEP_CHAR; + return; /* maybe dir doesn't exist? give up. */ + } + + while ((dent = readdir(dir)) != NULL) + { + if (strcasecmp(dent->d_name, lastsep) == 0) + { + /* found match; replace it. */ + strcpy(lastsep, dent->d_name); + break; + } + } + + closedir(dir); + *ptr = pch; + lastsep = ptr; + + if (dent == NULL) + return; /* no match. oh well. */ + + if (pch == '\0') /* eos? */ + return; + } + } +} + +int32 SafeOpenWrite(const char *_filename, int32 filetype) +{ + int handle; + char filename[MAX_PATH]; + strncpy(filename, _filename, sizeof(filename)); + filename[sizeof(filename) - 1] = '\0'; + FixFilePath(filename); + + handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC + , S_IREAD | S_IWRITE); + + if (handle == -1) + Error("Error opening %s: %s",filename,strerror(errno)); + + return handle; +} + +void SafeWrite(int32 handle, void *buffer, int32 count) +{ + unsigned iocount; + + while (count) + { + iocount = count > 0x8000 ? 0x8000 : count; + if (write(handle,buffer,iocount) != (int)iocount) + Error("File write failure writing %ld bytes",count); + buffer = (void *)((byte *)buffer + iocount); + count -= iocount; + } +} + +void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename) +{ + snprintf(fullname, length-1, "%s%s", ApogeePath, filename); +} + // This gets called all over the place for information and debugging messages. // If the user set the DUKESND_DEBUG environment variable, the messages // go to the file that is specified in that variable. Otherwise, they diff --git a/polymer/eduke32/source/jaudiolib/unixglob.c b/polymer/eduke32/source/jaudiolib/unixglob.c deleted file mode 100755 index 5941a31c9..000000000 --- a/polymer/eduke32/source/jaudiolib/unixglob.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -Copyright (C) 2003-2004 Ryan C. Gordon. and James Bentler - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Originally written by Ryan C. Gordon. (icculus@clutteredmind.org) -Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) - -*/ - -static char ApogeePath[256] = "/tmp/"; - -#define PATH_SEP_CHAR '/' -#define PATH_SEP_STR "/" -#define ROOTDIR "/" -#define CURDIR "./" - -#include "duke3d.h" -#include -#include - -#ifndef MAX_PATH -#define MAX_PATH 256 -#endif - -void FixFilePath(char *filename) -{ - char *ptr; - char *lastsep = filename; - - if ((!filename) || (*filename == '\0')) - return; - - if (access(filename, F_OK) == 0) /* File exists; we're good to go. */ - return; - - for (ptr = filename; 1; ptr++) - { - if (*ptr == '\\') - *ptr = PATH_SEP_CHAR; - - if ((*ptr == PATH_SEP_CHAR) || (*ptr == '\0')) - { - char pch = *ptr; - struct dirent *dent = NULL; - DIR *dir; - - if ((pch == PATH_SEP_CHAR) && (*(ptr + 1) == '\0')) - return; /* eos is pathsep; we're done. */ - - if (lastsep == ptr) - continue; /* absolute path; skip to next one. */ - - *ptr = '\0'; - if (lastsep == filename) - { - dir = opendir((*lastsep == PATH_SEP_CHAR) ? ROOTDIR : CURDIR); - - if (*lastsep == PATH_SEP_CHAR) - { - lastsep++; - } - } - else - { - *lastsep = '\0'; - dir = opendir(filename); - *lastsep = PATH_SEP_CHAR; - lastsep++; - } - - if (dir == NULL) - { - *ptr = PATH_SEP_CHAR; - return; /* maybe dir doesn't exist? give up. */ - } - - while ((dent = readdir(dir)) != NULL) - { - if (strcasecmp(dent->d_name, lastsep) == 0) - { - /* found match; replace it. */ - strcpy(lastsep, dent->d_name); - break; - } - } - - closedir(dir); - *ptr = pch; - lastsep = ptr; - - if (dent == NULL) - return; /* no match. oh well. */ - - if (pch == '\0') /* eos? */ - return; - } - } -} - -int32 SafeOpenWrite(const char *_filename, int32 filetype) -{ - int handle; - char filename[MAX_PATH]; - strncpy(filename, _filename, sizeof(filename)); - filename[sizeof(filename) - 1] = '\0'; - FixFilePath(filename); - - handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC - , S_IREAD | S_IWRITE); - - if (handle == -1) - Error("Error opening %s: %s",filename,strerror(errno)); - - return handle; -} - - -void SafeWrite(int32 handle, void *buffer, int32 count) -{ - unsigned iocount; - - while (count) - { - iocount = count > 0x8000 ? 0x8000 : count; - if (write(handle,buffer,iocount) != (int)iocount) - Error("File write failure writing %ld bytes",count); - buffer = (void *)((byte *)buffer + iocount); - count -= iocount; - } -} - - - -void GetUnixPathFromEnvironment(char *fullname, int32 length, const char *filename) -{ - snprintf(fullname, length-1, "%s%s", ApogeePath, filename); -} diff --git a/polymer/eduke32/source/jmact/util_lib.h b/polymer/eduke32/source/jmact/util_lib.h index 8e1e631c9..499921d41 100644 --- a/polymer/eduke32/source/jmact/util_lib.h +++ b/polymer/eduke32/source/jmact/util_lib.h @@ -39,8 +39,6 @@ extern "C" { #if RENDERTYPEWIN #include "winlayer.h" -#define _argc _buildargc -#define _argv _buildargv #endif void RegisterShutdownFunction( void (* sh) (void) );