From 132db81381c29c590685824969cdfd8e0917b503 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 17 Aug 2008 09:01:31 +0000 Subject: [PATCH] Beginnings of support for selecting mods in the startup window... win32 only for now git-svn-id: https://svn.eduke32.com/eduke32@984 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/src/kplib.c | 3 +- polymer/build/src/lzfP.h | 2 +- polymer/build/src/mdsprite.c | 2 +- polymer/eduke32/source/config.c | 4 ++ polymer/eduke32/source/game.c | 3 +- polymer/eduke32/source/gamedef.c | 36 +++++++++++-- polymer/eduke32/source/gamedef.h | 1 + polymer/eduke32/source/gamevars.c | 2 +- polymer/eduke32/source/misc/gameres.rc | 74 +++++++++++++------------- polymer/eduke32/source/savegame.c | 4 +- polymer/eduke32/source/startwin.game.c | 68 +++++++++++++++++++++++ polymer/eduke32/source/startwin.game.h | 2 +- 12 files changed, 155 insertions(+), 46 deletions(-) diff --git a/polymer/build/src/kplib.c b/polymer/build/src/kplib.c index 73a05d4c3..0e43671de 100644 --- a/polymer/build/src/kplib.c +++ b/polymer/build/src/kplib.c @@ -1798,7 +1798,8 @@ static int kpegrend(const char *kfilebuf, int kfilength, { while (curbits < 24) //Getbits { - ch = *kfileptr++; if (ch == 255) kfileptr++; + ch = *kfileptr++; + if (ch == 255) kfileptr++; num = (num<<8)+((int)ch); curbits += 8; } i = ((num>>(curbits-10))&1023); diff --git a/polymer/build/src/lzfP.h b/polymer/build/src/lzfP.h index d533f1829..3781cac12 100644 --- a/polymer/build/src/lzfP.h +++ b/polymer/build/src/lzfP.h @@ -88,7 +88,7 @@ * deterministic/repeatable when the configuration otherwise is the same). */ #ifndef INIT_HTAB -# define INIT_HTAB 0 +# define INIT_HTAB 1 #endif /* diff --git a/polymer/build/src/mdsprite.c b/polymer/build/src/mdsprite.c index a361e2e17..c9982ce88 100644 --- a/polymer/build/src/mdsprite.c +++ b/polymer/build/src/mdsprite.c @@ -471,7 +471,7 @@ static int daskinloader(int filh, intptr_t *fptr, int *bpl, int *sizx, int *sizy int r, g, b; picfillen = kfilelength(filh); - picfil = (char *)malloc(picfillen); if (!picfil) { return -1; } + picfil = (char *)malloc(picfillen+1); if (!picfil) { return -1; } kread(filh, picfil, picfillen); // tsizx/y = replacement texture's natural size diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 6be9a7875..d99d51d39 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -594,6 +594,7 @@ extern char *duke3dgrp; extern void check_valid_color(int *color,int prev_color); extern palette_t crosshair_colors; extern palette_t default_crosshair_colors; +extern char mod_dir[BMAX_PATH]; int32 CONFIG_ReadSetup(void) { @@ -649,6 +650,8 @@ int32 CONFIG_ReadSetup(void) SCRIPT_GetString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]); } + SCRIPT_GetString(ud.config.scripthandle, "Misc","ModDir",&mod_dir[0]); + SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Shadows",&ud.shadows); if (!NAM) @@ -1110,6 +1113,7 @@ void CONFIG_WriteSetup(void) SCRIPT_PutString(ud.config.scripthandle, "Misc","SelectedGRP",&duke3dgrp[0]); + SCRIPT_PutString(ud.config.scripthandle, "Misc","ModDir",&mod_dir[0]); { char commmacro[] = "CommbatMacro# "; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 4dfe7c889..29849047f 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -112,7 +112,8 @@ char *duke3dgrp = defaultduke3dgrp; char *duke3dgrpstring = NULL; static char defaultconfilename[BMAX_PATH] = {"EDUKE.CON"}; static char *confilename = defaultconfilename; -static char *duke3ddef = "duke3d.def"; +char *duke3ddef = "duke3d.def"; +char mod_dir[BMAX_PATH] = ""; extern int lastvisinc; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 008482d59..9479545db 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -92,6 +92,7 @@ char *textptr; int error,warning; extern char *duke3dgrpstring; +extern char *duke3ddef; enum labeltypes { @@ -468,6 +469,7 @@ const char *keyw[] = "gettimedate", // 332 "activatecheat", // 333 "setgamepalette", // 334 + "setdefname", // 335 "" }; @@ -901,7 +903,6 @@ const memberlabel_t inputlabels[]= char *bitptr; - #define BITPTR_DONTFUCKWITHIT 0 #define BITPTR_POINTER 1 @@ -1660,7 +1661,7 @@ static int transnum(int type) Bfree(gl); } if (labeltype[i] != LABEL_DEFINE && labelcode[i] >= (intptr_t)&script[0] && labelcode[i] < (intptr_t)&script[g_ScriptSize]) - bitptr[(scriptptr-script)] = 1; + bitptr[(scriptptr-script)] = BITPTR_POINTER; else bitptr[(scriptptr-script)] = BITPTR_DONTFUCKWITHIT; *(scriptptr++) = labelcode[i]; textptr += l; @@ -2455,6 +2456,7 @@ static int parsecommand(void) for (j=0;j<4;j++) { + bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; *(parsing_actor+j) = 0; if (j == 3) { @@ -2499,6 +2501,10 @@ static int parsecommand(void) } break; } +// bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; + if (*(scriptptr-1) >= (intptr_t)&script[0] && *(scriptptr-1) < (intptr_t)&script[g_ScriptSize]) + bitptr[(parsing_actor+j-script)] = BITPTR_POINTER; + else bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; *(parsing_actor+j) = *(scriptptr-1); } } @@ -2664,7 +2670,10 @@ static int parsecommand(void) } break; } - bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; +// bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; + if (*(scriptptr-1) >= (intptr_t)&script[0] && *(scriptptr-1) < (intptr_t)&script[g_ScriptSize]) + bitptr[(parsing_actor+j-script)] = BITPTR_POINTER; + else bitptr[(parsing_actor+j-script)] = BITPTR_DONTFUCKWITHIT; *(parsing_actor+j) = *(scriptptr-1); } } @@ -4572,6 +4581,27 @@ repeatcase: } return 0; + case CON_SETDEFNAME: + { + scriptptr--; + while (isaltok(*textptr) == 0) + { + if (*textptr == 0x0a) line_number++; + textptr++; + if (*textptr == 0) break; + } + j = 0; + while (isaltok(*textptr)) + { + tempbuf[j] = *(textptr++); + j++; + } + tempbuf[j] = '\0'; + duke3ddef = Bstrdup(tempbuf); + initprintf("Using DEF file: %s.\n",duke3ddef); + } + return 0; + case CON_DEFINEGAMETYPE: scriptptr--; transnum(LABEL_DEFINE); diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index c4de00b8b..42dea5e06 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -845,4 +845,5 @@ enum keywords CON_GETTIMEDATE, // 332 CON_ACTIVATECHEAT, // 333 CON_SETGAMEPALETTE, // 334 + CON_SETDEFNAME, // 335 }; diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 675f31381..c15716f5a 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -683,7 +683,7 @@ void SetGameVarID(int id, int lValue, int iActor, int iPlayer) { if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) { - OSD_Printf(OSD_ERROR "SetGameVarID(): invalid player (%d) for per-player gamevar %s from sprite %d (%d), player %d\n",iPlayer,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); + OSD_Printf(OSD_ERROR "SetGameVarID(): invalid player (%d) for per-player gamevar %s from sprite %d, player %d\n",iPlayer,aGameVars[id].szLabel,g_i,g_p); return; } // for the current player diff --git a/polymer/eduke32/source/misc/gameres.rc b/polymer/eduke32/source/misc/gameres.rc index b39e6066c..65e8ab56c 100644 --- a/polymer/eduke32/source/misc/gameres.rc +++ b/polymer/eduke32/source/misc/gameres.rc @@ -50,44 +50,46 @@ FONT 8, "MS Shell Dlg" BEGIN CONTROL "&Game:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 5, 100, 8 CONTROL "", IDGDATA, "LISTBOX", LBS_NOINTEGRALHEIGHT | LBS_USETABSTOPS | LBS_STANDARD | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 10, 15, 226, 70 + CONTROL "&Mod:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 90, 100, 8 + CONTROL "", IDGGAMEDIR, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 10, 99, 226, 156 END -#define FILEVER 1,4,9,9 -#define PRODUCTVER 1,4,9,9 -#define STRFILEVER "1.5.0devel\0" -#define STRPRODUCTVER "1.5.0devel\0" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION FILEVER - PRODUCTVERSION PRODUCTVER - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x3L -#else - FILEFLAGS 0x2L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "EDuke32" - VALUE "FileVersion", STRFILEVER - VALUE "InternalName", "EDuke32" - VALUE "LegalCopyright", "Copyright © 1996, 2003 3D Realms Entertainment, 2004-2008 EDuke32 Team" - VALUE "LegalTrademarks", "Duke Nukem® is a Registered Trademark of Apogee Software, Ltd." - VALUE "OriginalFilename", "eduke32.exe" - VALUE "ProductName", "EDuke32" - VALUE "ProductVersion", STRPRODUCTVER - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END +#define FILEVER 1,4,9,9 +#define PRODUCTVER 1,4,9,9 +#define STRFILEVER "1.5.0devel\0" +#define STRPRODUCTVER "1.5.0devel\0" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION FILEVER + PRODUCTVERSION PRODUCTVER + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x3L +#else + FILEFLAGS 0x2L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "EDuke32" + VALUE "FileVersion", STRFILEVER + VALUE "InternalName", "EDuke32" + VALUE "LegalCopyright", "Copyright © 1996, 2003 3D Realms Entertainment, 2004-2008 EDuke32 Team" + VALUE "LegalTrademarks", "Duke Nukem® is a Registered Trademark of Apogee Software, Ltd." + VALUE "OriginalFilename", "eduke32.exe" + VALUE "ProductName", "EDuke32" + VALUE "ProductVersion", STRPRODUCTVER + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END END 1 24 "rsrc/manifest.game.xml" diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 4b51bcad2..aa959d5d4 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern char *bitptr; +#define BITPTR_POINTER 1 + void readsavenames(void) { int dummy,j; @@ -641,7 +643,7 @@ int saveplayer(int spot) scriptptrs = Bcalloc(1, g_ScriptSize * sizeof(scriptptrs)); for (i=0;i= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_ScriptSize])) { scriptptrs[i] = 1; diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index 1651aef24..bab775722 100644 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -35,6 +35,7 @@ static struct char selectedgrp[BMAX_PATH+1]; int game; int crcval; // for finding the grp in the list again + char *gamedir; } settings; @@ -45,9 +46,30 @@ static HWND pages[3] = }; static int done = -1, mode = TAB_CONFIG; +static CACHE1D_FIND_REC *finddirs=NULL; +static int numdirs=0; + +void clearfilenames(void) +{ + klistfree(finddirs); + finddirs = NULL; + numdirs = 0; +} + +int getfilenames(char *path) +{ + CACHE1D_FIND_REC *r; + + clearfilenames(); + finddirs = klistpath(path,"*",CACHE1D_FIND_DIR); + for (r = finddirs; r; r=r->next) numdirs++; + return(0); +} + #define POPULATE_VIDEO 1 #define POPULATE_CONFIG 2 #define POPULATE_GAME 4 +#define POPULATE_MODS 8 static void PopulateForm(int pgs) { @@ -148,6 +170,25 @@ static void PopulateForm(int pgs) if (!Bstrcasecmp(fg->name, settings.selectedgrp))(void)ListBox_SetCurSel(hwnd, j); } } + + if (pgs & POPULATE_MODS) + { + CACHE1D_FIND_REC *dirs = NULL; + + hwnd = GetDlgItem(pages[TAB_GAME], IDGGAMEDIR); + + getfilenames("/"); + (void)ComboBox_ResetContent(hwnd); + j = ComboBox_AddString(hwnd, "None"); + (void)ComboBox_SetItemData(hwnd, j, 0); + for (dirs=finddirs,i=1; dirs != NULL; dirs=dirs->next,i++) + { + Bsprintf(buf, "%s", dirs->name); + j = ComboBox_AddString(hwnd, buf); + (void)ComboBox_SetItemData(hwnd, j, i); + if (Bstrcmp(dirs->name,settings.gamedir) == 0)(void)ComboBox_SetCurSel(hwnd, j); + } + } } static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -216,6 +257,25 @@ static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA } return TRUE; } + case IDGGAMEDIR: + if (HIWORD(wParam) == CBN_SELCHANGE) + { + int i,j; + CACHE1D_FIND_REC *dir = NULL; + i = ComboBox_GetCurSel((HWND)lParam); + if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); + if (i != CB_ERR) + { + for (j=0,dir=finddirs;dir != NULL;dir=dir->next,j++) + if (j == i) + { + if (i==0) settings.gamedir = NULL; + else settings.gamedir = dir->prev->name; + break; + } + } + } + return TRUE; default: break; } @@ -252,6 +312,7 @@ static void EnableConfig(int n) EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), n); EnableWindow(GetDlgItem(pages[TAB_GAME], IDGDATA), n); + EnableWindow(GetDlgItem(pages[TAB_GAME], IDGGAMEDIR), n); } static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -567,6 +628,7 @@ int startwin_idle(void *v) } extern char *duke3dgrp, *duke3dgrpstring; +extern char mod_dir[BMAX_PATH]; int startwin_run(void) { @@ -591,6 +653,7 @@ int startwin_run(void) settings.game = g_GameType; // settings.crcval = 0; strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); + settings.gamedir = mod_dir; PopulateForm(-1); while (done < 0) @@ -625,6 +688,11 @@ int startwin_run(void) ud.config.UseJoystick = settings.usejoy; duke3dgrp = settings.selectedgrp; g_GameType = settings.game; + if (settings.gamedir) + { + addsearchpath(settings.gamedir); + Bstrcpy(mod_dir,settings.gamedir); + } for (i = 0; i