From fe9004fafe1e5f2c25b10e96e81fe7c4a4ce39b4 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 21 Jan 2007 23:49:07 +0000 Subject: [PATCH] Support for -ww2gi, -nam, -cfg, -usecwd, -h, and -j in Mapster32. Because I am lazy, this is all code from game.c. git-svn-id: https://svn.eduke32.com/eduke32@464 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/include/editor.h | 4 +- polymer/build/src/build.c | 4 +- polymer/eduke32/source/astub.c | 131 +++++++++++++++++++++++++++++++-- 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/polymer/build/include/editor.h b/polymer/build/include/editor.h index 5b6265703..167271b97 100644 --- a/polymer/build/include/editor.h +++ b/polymer/build/include/editor.h @@ -26,6 +26,7 @@ extern long ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d, forcesetup; extern int ExtInit(void); +extern int ExtPreInit(int argc,char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); #ifdef SUPERBUILD @@ -45,7 +46,8 @@ extern void ExtShowSpriteData(short spritenum); extern void ExtEditSectorData(short sectnum); extern void ExtEditWallData(short wallnum); extern void ExtEditSpriteData(short spritenum); - +extern char ExtCustomSpriteColor(short picnum); +extern void ExtSetupSpecialSpriteCols(void); int loadsetup(const char *fn); // from config.c int writesetup(const char *fn); // from config.c diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index c45d304f5..e5bb43031 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -27,7 +27,7 @@ static long crctable[256]; static char kensig[24]; extern int ExtInit(void); -extern int ExtPreInit(int *argc,char ***argv); +extern int ExtPreInit(int argc,char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); #ifdef SUPERBUILD @@ -257,7 +257,7 @@ int app_main(int argc, char **argv) wm_setapptitle("Mapster32"); - if ((i = ExtPreInit(&argc,&argv)) < 0) return -1; + if ((i = ExtPreInit(argc,argv)) < 0) return -1; #ifdef RENDERTYPEWIN backgroundidle = 1; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 4fedd8738..49a88a3c1 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -45,7 +45,18 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) short floor_over_floor; -char *startwin_labeltext = "Starting Mapster32..."; +static char *startwin_labeltext = "Starting Mapster32..."; +static char setupfilename[BMAX_PATH]= "build.cfg"; +static char defaultduke3dgrp[BMAX_PATH] = "duke3d.grp"; +static char *duke3dgrp = defaultduke3dgrp; +static int usecwd = 0; + +static struct strllist +{ + struct strllist *next; + char *str; +} +*CommandPaths = NULL; #define MAXHELP2D (signed int)(sizeof(Help2d)/sizeof(Help2d[0])) char *Help2d[]= { @@ -3606,7 +3617,7 @@ static void Keys2d(void) {if(keystatus[i]==1) {Bsprintf(tempbuf,"key %ld",i); printmessage16(tempbuf); }} */ - + Bsprintf(tempbuf, "Mapster32"VERSION""); printext16(9L,ydim-STATUS2DSIZ+9L,4,-1,tempbuf,0); printext16(8L,ydim-STATUS2DSIZ+8L,12,-1,tempbuf,0); @@ -4298,7 +4309,92 @@ void ExtPreSaveMap(void) void ExtPreLoadMap(void) {} -int ExtPreInit(int *argc,char ***argv) +static void checkcommandline(int argc,char **argv) +{ + int i = 1; + char *c; + + if (argc > 1) + { + while (i < argc) + { + c = argv[i]; + if (((*c == '/') || (*c == '-'))) + { + if (!Bstrcasecmp(c+1,"cfg")) + { + if (argc > i+1) + { + Bstrcpy(setupfilename,argv[i+1]); + i++; + } + i++; + continue; + } + if (!Bstrcasecmp(c+1,"nam")) + { + strcpy(duke3dgrp, "nam.grp"); + i++; + continue; + } + if (!Bstrcasecmp(c+1,"ww2gi")) + { + strcpy(duke3dgrp, "ww2gi.grp"); + i++; + continue; + } +#if !defined(_WIN32) + if (!Bstrcasecmp(c+1,"usecwd")) + { + usecwd = 1; + i++; + continue; + } +#endif + } + + if ((*c == '/') || (*c == '-')) + { + c++; + switch (*c) + { + case 'h': + case 'H': + c++; + if (*c) + { + defsfilename = c; + initprintf("Using DEF file: %s.\n",defsfilename); + } + break; + case 'j': + case 'J': + c++; + if (!*c) break; + { + struct strllist *s; + s = (struct strllist *)calloc(1,sizeof(struct strllist)); + s->str = strdup(c); + if (CommandPaths) + { + struct strllist *t; + for (t = CommandPaths; t->next; t=t->next) ; + t->next = s; + } + else + { + CommandPaths = s; + } + } + break; + } + } + i++; + } + } +} + +int ExtPreInit(int argc,char **argv) { wm_setapptitle("Mapster32"VERSION); @@ -4306,6 +4402,9 @@ int ExtPreInit(int *argc,char ***argv) OSD_SetVersionString("Mapster32"VERSION); initprintf("Mapster32"VERSION" ("__DATE__" "__TIME__")\n"); initprintf("Copyright (c) 2006 EDuke32 team\n\n"); + + checkcommandline(argc,argv); + return 0; } @@ -4401,10 +4500,28 @@ int loadgroupfiles(char *fn) int ExtInit(void) { long rv = 0; - char *duke3dgrp = "duke3d.grp"; + char cwd[BMAX_PATH]; + + if (getcwd(cwd,BMAX_PATH)) addsearchpath(cwd); + + if (CommandPaths) + { + struct strllist *s; + while (CommandPaths) + { + s = CommandPaths->next; + addsearchpath(CommandPaths->str); + + free(CommandPaths->str); + free(CommandPaths); + CommandPaths = s; + } + } #if defined(_WIN32) if (!access("user_profiles_enabled", F_OK)) +#else + if (usecwd == 0) #endif { char cwd[BMAX_PATH]; @@ -4458,12 +4575,14 @@ int ExtInit(void) initprintf("Using %s as definitions file\n", defsfilename); } loadgroupfiles(defsfilename); + bpp = 32; #if defined(POLYMOST) && defined(USE_OPENGL) glusetexcache = glusetexcachecompression = -1; - if (loadsetup("build.cfg") < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; + initprintf("Using config file %s.\n",setupfilename); + if (loadsetup(setupfilename) < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; if (glusetexcache == -1 || glusetexcachecompression == -1) { @@ -4517,7 +4636,7 @@ void ExtUnInit(void) { // setvmode(0x03); uninitgroupfile(); - writesetup("build.cfg"); + writesetup(setupfilename); } void ExtPreCheckKeys(void) // just before drawrooms