git-svn-id: https://svn.eduke32.com/eduke32@556 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2007-08-17 03:16:46 +00:00
parent 9c6486025d
commit 4e0f8281c7
10 changed files with 145 additions and 174 deletions

View file

@ -10,7 +10,7 @@ extern "C" {
#endif
extern int _buildargc;
extern char **_buildargv;
extern const char **_buildargv;
extern char quitevent, appactive;

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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[]);

View file

@ -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

View file

@ -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);

View file

@ -31,6 +31,8 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#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

View file

@ -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 <dirent.h>
#include <errno.h>
#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);
}

View file

@ -39,8 +39,6 @@ extern "C" {
#if RENDERTYPEWIN
#include "winlayer.h"
#define _argc _buildargc
#define _argv _buildargv
#endif
void RegisterShutdownFunction( void (* sh) (void) );