Fix mapster's command-line parsing and copy over some of the 'custom mod dir' logic, currently used in the sound board to also find files outside of GRPs.

git-svn-id: https://svn.eduke32.com/eduke32@1904 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-06-16 19:39:22 +00:00
parent dd355636ff
commit 116ab2ed99
5 changed files with 248 additions and 220 deletions

View file

@ -91,7 +91,7 @@ extern int32_t editorgridextent; // in engine.c
extern char game_executable[BMAX_PATH]; extern char game_executable[BMAX_PATH];
extern char program_origcwd[BMAX_PATH]; extern char program_origcwd[BMAX_PATH];
extern char *mapster32_fullpath; extern const char *mapster32_fullpath;
extern char *testplay_addparam; extern char *testplay_addparam;
extern const char *g_namesFileName; extern const char *g_namesFileName;
@ -114,6 +114,8 @@ extern int32_t autogray;
int32_t yax_is121(int16_t bunchnum, int16_t getfloor); int32_t yax_is121(int16_t bunchnum, int16_t getfloor);
#endif #endif
extern int32_t kopen4loadfrommod(const char *filename, char searchfirst);
extern int32_t map_revision; extern int32_t map_revision;
extern int32_t map_undoredo(int32_t dir); extern int32_t map_undoredo(int32_t dir);
extern void map_undoredo_free(void); extern void map_undoredo_free(void);

View file

@ -110,7 +110,7 @@ int32_t revertCTRL=0,scrollamount=3;
int32_t unrealedlook=1, quickmapcycling=1; //PK int32_t unrealedlook=1, quickmapcycling=1; //PK
char program_origcwd[BMAX_PATH]; char program_origcwd[BMAX_PATH];
char *mapster32_fullpath; const char *mapster32_fullpath;
char *testplay_addparam = 0; char *testplay_addparam = 0;
static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH]; static char boardfilename[BMAX_PATH], selectedboardfilename[BMAX_PATH];
@ -8483,8 +8483,8 @@ int32_t loadnames(const char *namesfile)
} }
number = p; number = p;
while (*p != 0) p++; while (*p != 0 && *p != 32) p++;
if (*p != 0) *p = 0; *p = 0;
// add to list // add to list
num = Bstrtol(number, &endptr, 10); num = Bstrtol(number, &endptr, 10);
@ -8509,7 +8509,6 @@ int32_t loadnames(const char *namesfile)
syms++; syms++;
continue; continue;
} }
else // #define_NAME with no number else // #define_NAME with no number
{ {
@ -8526,9 +8525,11 @@ int32_t loadnames(const char *namesfile)
} }
else if (*p == '*' && p[1] == '/') else if (*p == '*' && p[1] == '/')
{ {
comment--; continue; comment--;
continue;
} }
else if (comment)continue; else if (comment)
continue;
badline: badline:
initprintf("Error: Invalid statement found at character %d on line %d\n", (int32_t)(p-buffer), line-1); initprintf("Error: Invalid statement found at character %d on line %d\n", (int32_t)(p-buffer), line-1);
} }

View file

@ -167,13 +167,13 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
if (tilesizx[picnum]<=0 || tilesizy[picnum]<=0) if (tilesizx[picnum]<=0 || tilesizy[picnum]<=0)
{ {
static int32_t first=1; static int32_t first=1;
initprintf("Warning: defined hightile replacement for empty tile %d.", picnum);
if (first) if (first)
{ {
initprintf("Warning: defined hightile replacement for empty tile %d.", picnum);
initprintf(" Maybe some tilesXXX.art are not loaded?"); initprintf(" Maybe some tilesXXX.art are not loaded?");
initprintf("\n");
first = 0; first = 0;
} }
initprintf("\n");
} }
//printf("Replacement [%d,%d]: %s\n", picnum, palnum, hicreplc[i]->filename); //printf("Replacement [%d,%d]: %s\n", picnum, palnum, hicreplc[i]->filename);

View file

@ -59,6 +59,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int32_t floor_over_floor; static int32_t floor_over_floor;
static int32_t g_fillCurSector = 0; static int32_t g_fillCurSector = 0;
static char g_modDir[BMAX_PATH];
// static char *startwin_labeltext = "Starting Mapster32..."; // static char *startwin_labeltext = "Starting Mapster32...";
static char setupfilename[]= "mapster32.cfg"; static char setupfilename[]= "mapster32.cfg";
static char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp"; static char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp";
@ -669,6 +671,23 @@ static const char *Help3d[]=
" END = PGUP/PGDN MODIFIER (512 UNITS)", " END = PGUP/PGDN MODIFIER (512 UNITS)",
}; };
int32_t kopen4loadfrommod(const char *filename, char searchfirst)
{
static char fn[BMAX_PATH];
int32_t r=-1;
if (g_modDir[0])
{
Bsnprintf(fn,sizeof(fn),"%s/%s",g_modDir,filename);
r = kopen4load(fn,searchfirst);
}
if (r < 0)
r = kopen4load(filename,searchfirst);
return r;
}
static void clearfilenames(void) static void clearfilenames(void)
{ {
klistfree(finddirs); klistfree(finddirs);
@ -8355,260 +8374,266 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
int32_t i = 1, j, maxlen=0, *lengths; int32_t i = 1, j, maxlen=0, *lengths;
char *c, *k; char *c, *k;
mapster32_fullpath = (char *)argv[0]; mapster32_fullpath = argv[0];
if (argc > 1) if (argc <= 1)
return;
lengths = Bmalloc(argc*sizeof(int32_t));
for (j=1; j<argc; j++)
{ {
lengths = Bmalloc(argc*sizeof(int32_t)); lengths[j] = Bstrlen(argv[j]);
for (j=1; j<argc; j++) maxlen += lengths[j];
{ }
lengths[j] = Bstrlen(argv[j]);
maxlen += lengths[j];
}
testplay_addparam = Bmalloc(maxlen+argc); testplay_addparam = Bmalloc(maxlen+argc);
testplay_addparam[0] = 0; testplay_addparam[0] = 0;
j = 0; j = 0;
while (i < argc) while (i < argc)
{ {
c = (char *)argv[i]; c = (char *)argv[i];
if ((*c == '-')
if ((*c == '-')
#ifdef _WIN32 #ifdef _WIN32
|| (*c == '/') || (*c == '/')
#endif #endif
) )
{
if (!Bstrcasecmp(c+1,"?") || !Bstrcasecmp(c+1,"help") || !Bstrcasecmp(c+1,"-help"))
{ {
if (!Bstrcasecmp(c+1,"?") || !Bstrcasecmp(c+1,"help") || !Bstrcasecmp(c+1,"-help")) G_ShowParameterHelp();
{ exit(0);
G_ShowParameterHelp(); }
exit(0);
}
if (!Bstrcasecmp(c+1, "g") || !Bstrcasecmp(c+1, "grp")) if (!Bstrcasecmp(c+1, "g") || !Bstrcasecmp(c+1, "grp"))
{
if (argc > i+1)
{ {
if (argc > i+1) G_AddGroup(argv[i+1]);
{ COPYARG(i);
G_AddGroup(argv[i+1]); COPYARG(i+1);
COPYARG(i);
COPYARG(i+1);
i++;
}
i++; i++;
continue;
} }
i++;
continue;
}
if (!Bstrcasecmp(c+1,"game_dir")) if (!Bstrcasecmp(c+1,"game_dir"))
{
if (argc > i+1)
{ {
if (argc > i+1)
{
#ifdef USE_OPENGL #ifdef USE_OPENGL
extern char TEXCACHEFILE[BMAX_PATH]; extern char TEXCACHEFILE[BMAX_PATH];
Bsprintf(tempbuf,"%s/%s",argv[i+1],TEXCACHEFILE); Bsnprintf(tempbuf,sizeof(tempbuf),"%s/%s",argv[i+1],TEXCACHEFILE);
Bstrcpy(TEXCACHEFILE,tempbuf); Bstrncpy(TEXCACHEFILE,tempbuf, sizeof(TEXCACHEFILE));
TEXCACHEFILE[sizeof(TEXCACHEFILE)-1] = 0;
#endif #endif
AddGamePath(argv[i+1]); Bstrncpy(g_modDir, argv[i+1], sizeof(g_modDir));
g_modDir[sizeof(g_modDir)-1] = 0;
AddGamePath(argv[i+1]);
COPYARG(i);
COPYARG(i+1);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1,"cachesize"))
{
if (argc > i+1)
{
int32_t sz = atoi_safe(argv[i+1]);
if (sz >= 16<<10 && sz <= 1024<<10)
{
g_maxCacheSize = sz<<10;
initprintf("Cache size: %dkB\n",sz);
COPYARG(i); COPYARG(i);
COPYARG(i+1); COPYARG(i+1);
i++;
} }
i++; i++;
continue;
} }
if (!Bstrcasecmp(c+1,"cachesize")) i++;
continue;
}
if (!Bstrcasecmp(c+1,"cfg"))
{
if (argc > i+1)
{ {
if (argc > i+1) Bstrcpy(setupfilename,argv[i+1]);
{
int32_t sz = atoi_safe(argv[i+1]);
if (sz >= 16<<10 && sz <= 1024<<10)
{
g_maxCacheSize = sz<<10;
initprintf("Cache size: %dkB\n",sz);
COPYARG(i);
COPYARG(i+1);
}
i++;
}
i++; i++;
continue;
} }
if (!Bstrcasecmp(c+1,"cfg")) i++;
continue;
}
if (!Bstrcasecmp(c+1,"gamegrp"))
{
if (argc > i+1)
{ {
if (argc > i+1) Bstrcpy(defaultduke3dgrp,argv[i+1]);
{
Bstrcpy(setupfilename,argv[i+1]);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1,"gamegrp"))
{
if (argc > i+1)
{
Bstrcpy(defaultduke3dgrp,argv[i+1]);
COPYARG(i);
COPYARG(i+1);
i++;
}
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nam"))
{
Bstrcpy(g_grpNamePtr, "nam.grp");
COPYARG(i); COPYARG(i);
COPYARG(i+1);
i++; i++;
continue;
}
if (!Bstrcasecmp(c+1,"namesfile"))
{
g_namesFileName = argv[i+1];
i++;
continue;
}
if (!Bstrcasecmp(c+1,"-nm") || Bstrcasecmp(c+1,"-ns"))
{
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"ww2gi"))
{
Bstrcpy(g_grpNamePtr, "ww2gi.grp");
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"check"))
{
initprintf("Map pointer checking on saving enabled\n");
fixmapbeforesaving = 1;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nocheck"))
{
initprintf("Map pointer checking disabled\n");
fixmapbeforesaving = 0;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"noautoload"))
{
initprintf("Autoload disabled\n");
NoAutoLoad = 1;
COPYARG(i);
i++;
continue;
} }
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nam"))
{
Bstrcpy(g_grpNamePtr, "nam.grp");
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"namesfile"))
{
g_namesFileName = argv[i+1];
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nm") || !Bstrcasecmp(c+1,"ns"))
{
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"ww2gi"))
{
Bstrcpy(g_grpNamePtr, "ww2gi.grp");
COPYARG(i);
i++;
continue;
}
if (!Bstrcasecmp(c+1,"check"))
{
initprintf("Map pointer checking on saving enabled\n");
fixmapbeforesaving = 1;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"nocheck"))
{
initprintf("Map pointer checking disabled\n");
fixmapbeforesaving = 0;
i++;
continue;
}
if (!Bstrcasecmp(c+1,"noautoload"))
{
initprintf("Autoload disabled\n");
NoAutoLoad = 1;
COPYARG(i);
i++;
continue;
}
#if !defined(_WIN32) #if !defined(_WIN32)
if (!Bstrcasecmp(c+1,"usecwd")) if (!Bstrcasecmp(c+1,"usecwd"))
{ {
usecwd = 1; usecwd = 1;
COPYARG(i); COPYARG(i);
i++; i++;
continue; continue;
} }
#endif #endif
#if defined(RENDERTYPEWIN) && defined(USE_OPENGL) #if defined(RENDERTYPEWIN) && defined(USE_OPENGL)
if (!Bstrcasecmp(c+1,"forcegl")) if (!Bstrcasecmp(c+1,"forcegl"))
{
forcegl = 1;
i++;
continue;
}
#endif
}
if ((*c == '-')
#ifdef _WIN32
|| (*c == '/')
#endif
)
{ {
c++; forcegl = 1;
switch (*c) i++;
{ continue;
case 'h':
case 'H':
c++;
if (*c)
{
defsfilename = c;
COPYARG(i);
initprintf("Using DEF file: %s.\n",defsfilename);
}
break;
case 'j':
case 'J':
c++;
if (!*c) break;
AddGamePath(c);
COPYARG(i);
break;
case 'g':
case 'G':
c++;
if (!*c) break;
G_AddGroup(c);
COPYARG(i);
break;
case 'x':
case 'X':
c++;
if (!*c) break;
gamecon = c;
COPYARG(i);
break;
}
} }
else #endif
{
k = Bstrrchr(c,'.');
if (k)
{
if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip"))
{
COPYARG(i);
G_AddGroup(argv[i++]);
continue;
}
else if (!Bstrcasecmp(k,".def"))
{
COPYARG(i);
defsfilename = (char *)argv[i++];
initprintf("Using DEF file: %s.\n",defsfilename);
continue;
}
else if (!Bstrcasecmp(k,".con"))
{
COPYARG(i);
gamecon = (char *)argv[i++];
continue;
}
}
}
i++;
} }
Bfree(lengths);
if (j > 0) if ((*c == '-')
#ifdef _WIN32
|| (*c == '/')
#endif
)
{ {
testplay_addparam[j-1] = 0; c++;
testplay_addparam = Brealloc(testplay_addparam, j*sizeof(char)); switch (*c)
{
case 'h':
case 'H':
c++;
if (*c)
{
defsfilename = c;
COPYARG(i);
initprintf("Using DEF file: %s.\n",defsfilename);
}
break;
case 'j':
case 'J':
c++;
if (!*c) break;
AddGamePath(c);
COPYARG(i);
break;
case 'g':
case 'G':
c++;
if (!*c) break;
G_AddGroup(c);
COPYARG(i);
break;
case 'x':
case 'X':
c++;
if (!*c) break;
gamecon = c;
COPYARG(i);
break;
}
} }
else else
{ {
Bfree(testplay_addparam); k = Bstrrchr(c,'.');
testplay_addparam = NULL; if (k)
{
if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip"))
{
COPYARG(i);
G_AddGroup(argv[i++]);
continue;
}
else if (!Bstrcasecmp(k,".def"))
{
COPYARG(i);
defsfilename = (char *)argv[i++];
initprintf("Using DEF file: %s.\n",defsfilename);
continue;
}
else if (!Bstrcasecmp(k,".con"))
{
COPYARG(i);
gamecon = (char *)argv[i++];
continue;
}
}
} }
i++;
} }
Bfree(lengths);
if (j > 0)
{
testplay_addparam[j-1] = 0;
testplay_addparam = Brealloc(testplay_addparam, j*sizeof(char));
}
else
{
Bfree(testplay_addparam);
testplay_addparam = NULL;
}
} }
#undef COPYARG #undef COPYARG

View file

@ -137,8 +137,8 @@ int32_t S_LoadSound(uint32_t num)
return 0; return 0;
} }
if (g_sounds[num].filename1) fp = kopen4load(g_sounds[num].filename1,pathsearchmode); if (g_sounds[num].filename1) fp = kopen4loadfrommod(g_sounds[num].filename1,0);//pathsearchmode
if (fp == -1) fp = kopen4load(g_sounds[num].filename,pathsearchmode); if (fp == -1) fp = kopen4loadfrommod(g_sounds[num].filename,0);
if (fp == -1) if (fp == -1)
{ {
OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num); OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);