From d404dd8ead0d2e832b66c364222acdc148f6c019 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 22 Jul 2006 05:20:25 +0000 Subject: [PATCH] Fixes from JonoF git-svn-id: https://svn.eduke32.com/eduke32@241 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/duke3d.h | 7 +- polymer/eduke32/source/game.c | 73 ++++++++++++------- .../eduke32/source/{startdlg.c => grpscan.c} | 17 +++-- .../eduke32/source/{startdlg.h => grpscan.h} | 7 +- polymer/eduke32/source/menus.c | 10 ++- polymer/eduke32/source/startwin.game.c | 24 +++--- 6 files changed, 81 insertions(+), 57 deletions(-) rename polymer/eduke32/source/{startdlg.c => grpscan.c} (84%) rename polymer/eduke32/source/{startdlg.h => grpscan.h} (82%) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 3d496f79b..4518c51bf 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -38,12 +38,15 @@ extern "C" { #include "function.h" -extern int conversion, shareware, namversion; +extern int conversion, shareware, gametype; + +#define GAMEDUKE 0 +#define GAMENAM 1 #define VOLUMEALL (shareware==0) #define PLUTOPAK (conversion==14) #define VOLUMEONE (shareware==1) -#define NAM (namversion==1) +#define NAM (gametype==1) #define MAXSLEEPDIST 16384 #define SLEEPTIME 24*64 diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 53efe0283..c5010028f 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "osdfuncs.h" #include "osdcmds.h" #include "scriptfile.h" +#include "grpscan.h" //#include "crc32.h" @@ -7757,10 +7758,10 @@ void checkcommandline(int argc,char **argv) c = argv[i]; if (((*c == '/') || (*c == '-')) && (!firstnet)) { - if (!Bstrcasecmp(c+1,"nam")) { - i++; - continue; - } + if (!Bstrcasecmp(c+1,"nam")) { + i++; + continue; + } if (!Bstrcasecmp(c+1,"setup")) { i++; continue; @@ -8258,7 +8259,7 @@ void Logo(void) } KB_ClearKeysDown(); // JBF } - + fadepal(0,0,0, 0,64,7); clearview(0L); nextpage(); @@ -8797,7 +8798,7 @@ void backtomenu(void) } int shareware = 0; -int namversion = 0; +int gametype = 0; int load_script(char *szScript) { @@ -8876,10 +8877,9 @@ void app_main(int argc,char **argv) if (argv[i][0] != '-' && argv[i][0] != '/') continue; if (!Bstrcasecmp(argv[i]+1, "setup")) CommandSetup = TRUE; else if (!Bstrcasecmp(argv[i]+1, "net")) NoSetup = TRUE; - else if (!Bstrcasecmp(argv[i]+1, "nam")) { - strcpy(defaultduke3dgrp, "nam.grp"); - namversion = 1; - } + else if (!Bstrcasecmp(argv[i]+1, "nam")) { + strcpy(defaultduke3dgrp, "nam.grp"); + } else if (!Bstrcasecmp(argv[i]+1, "?")) { comlinehelp(argv); exit(0); @@ -8894,6 +8894,28 @@ void app_main(int argc,char **argv) exit(1); } + ScanGroups(); + { // try and identify the 'defaultduke3dgrp' in the set of GRPs. + // if it is found, set up the environment accordingly for the game it represents. + // if it is not found, choose the first GRP from the list of + struct grpfile *fg, *first = NULL; + int i; + for (fg = foundgrps; fg; fg=fg->next) { + for (i = 0; icrcval == grpfiles[i].crcval) break; + if (i == numgrpfiles) continue; // unrecognised grp file + fg->game = grpfiles[i].game; + if (!first) first = fg; + if (!Bstrcasecmp(fg->name, defaultduke3dgrp)) { + gametype = grpfiles[i].game; + break; + } + } + if (!fg && first) { + Bstrcpy(defaultduke3dgrp, first->name); + gametype = first->game; + } + } + #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) if (i < 0 || (!NoSetup && ForceSetup) || CommandSetup) { if (quitevent || !startwin_run()) { @@ -8903,22 +8925,21 @@ void app_main(int argc,char **argv) } #endif - if (namversion) { - // overwrite the default GRP and CON so that if the user chooses - // something different, they get what they asked for - Bsprintf(defaultduke3dgrp,"nam.grp"); - Bsprintf(confilename, "nam.con"); - } + FreeGroups(); - if (getenv("DUKE3DGRP")) { - duke3dgrp = getenv("DUKE3DGRP"); - initprintf("Using `%s' as main GRP file\n", duke3dgrp); + if (NAM) { + // overwrite the default GRP and CON so that if the user chooses + // something different, they get what they asked for + Bsprintf(defaultduke3dgrp,"nam.grp"); + Bsprintf(confilename, "nam.con"); } + if (getenv("DUKE3DGRP")) duke3dgrp = getenv("DUKE3DGRP"); + initprintf("GRP file: %s\n", duke3dgrp); initgroupfile(duke3dgrp); + i = kopen4load("DUKESW.BIN",1); // JBF 20030810 if (i!=-1) { - initprintf("Using Shareware GRP file.\n"); shareware = 1; kclose(i); } @@ -10845,7 +10866,7 @@ FRAGBONUS: { gametext(10,59+9,"Your Time:",0,2+8+16); gametext(10,69+9,"Par time:",0,2+8+16); - if (!NAM) + if (!NAM) gametext(10,78+9,"3D Realms' Time:",0,2+8+16); if(bonuscnt == 0) bonuscnt++; @@ -10868,11 +10889,11 @@ FRAGBONUS: (partime[ud.volume_number*11+ud.last_level-1]/26)%60); gametext((320>>2)+71,69+9,tempbuf,0,2+8+16); - if (!NAM) { - Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, - (designertime[ud.volume_number*11+ud.last_level-1]/(26*60)), - (designertime[ud.volume_number*11+ud.last_level-1]/26)%60); - gametext((320>>2)+71,78+9,tempbuf,0,2+8+16); + if (!NAM) { + Bsprintf(tempbuf,"%0*ld:%02ld",clockpad, + (designertime[ud.volume_number*11+ud.last_level-1]/(26*60)), + (designertime[ud.volume_number*11+ud.last_level-1]/26)%60); + gametext((320>>2)+71,78+9,tempbuf,0,2+8+16); } } } diff --git a/polymer/eduke32/source/startdlg.c b/polymer/eduke32/source/grpscan.c similarity index 84% rename from polymer/eduke32/source/startdlg.c rename to polymer/eduke32/source/grpscan.c index ca929b21d..1d8d709d8 100755 --- a/polymer/eduke32/source/startdlg.c +++ b/polymer/eduke32/source/grpscan.c @@ -5,16 +5,17 @@ #include "cache1d.h" #include "crc32.h" -#include "startdlg.h" +#include "duke3d.h" +#include "grpscan.h" struct grpfile grpfiles[numgrpfiles] = { - { "Registered Version 1.3d", 0xBBC9CE44, 26524524, GAMEDUKE, NULL }, - { "Registered Version 1.4", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, - { "Registered Version 1.5", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, - { "Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL }, - { "Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL }, - { "Mac Registered Version", 0x00000000, 0, GAMEDUKE, NULL }, - { "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, + { "Registered Version 1.3d", 0xBBC9CE44, 26524524, GAMEDUKE, NULL }, + { "Registered Version 1.4", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, + { "Registered Version 1.5", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, + { "Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL }, + { "Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL }, + { "Mac Registered Version", 0x00000000, 0, GAMEDUKE, NULL }, + { "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, }; struct grpfile *foundgrps = NULL; diff --git a/polymer/eduke32/source/startdlg.h b/polymer/eduke32/source/grpscan.h similarity index 82% rename from polymer/eduke32/source/startdlg.h rename to polymer/eduke32/source/grpscan.h index 78238fec3..72518a0fc 100755 --- a/polymer/eduke32/source/startdlg.h +++ b/polymer/eduke32/source/grpscan.h @@ -1,3 +1,6 @@ +#ifndef __grpscan_h__ +#define __grpscan_h__ + // List of internally-known GRP files #define numgrpfiles 7 struct grpfile { @@ -8,9 +11,7 @@ struct grpfile { struct grpfile *next; } grpfiles[numgrpfiles], *foundgrps; -#define GAMEDUKE 0 -#define GAMENAM 1 - int ScanGroups(void); void FreeGroups(void); +#endif diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 176acf76c..0a9996d76 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -442,7 +442,7 @@ static void modval(int min, int max,int *p,short dainc,char damodify) } } -#define MENUHIGHLIGHT(x) probey==x?-(sintable[(totalclock<<5)&2047]>>12):8 +#define MENUHIGHLIGHT(x) probey==x?-(sintable[(totalclock<<4)&2047]>>12):8 // #define MENUHIGHLIGHT(x) probey==x?-(sintable[(totalclock<<4)&2047]>>12):probey-x>=0?(probey-x)<<2:-((probey-x)<<2) #define SHX(X) 0 @@ -2334,8 +2334,7 @@ cheat_for_port_credits: "Send MP messages to all", "Display other player IDs", "-", - "-", - "-", + "Show startup window", "-", "-", "-", @@ -2392,7 +2391,10 @@ cheat_for_port_credits: case 5: if (x==io) ud.idplayers = 1-ud.idplayers; modval(0,1,(int *)&ud.idplayers,1,probey==io); gametextpal(d,yy, ud.idplayers ? "On" : "Off", MENUHIGHLIGHT(io), 0); break; - case 6: if (x==io) cmenu(200); break; + case 6: if (x==io) ForceSetup = 1-ForceSetup; + modval(0,1,(int *)&ForceSetup,1,probey==io); + gametextpal(d,yy, ForceSetup ? "On" : "Off", MENUHIGHLIGHT(io), 0); break; + case 7: if (x==io) cmenu(200); break; default: break; } gametextpal(c,yy, opts[ii], enabled?MENUHIGHLIGHT(io):15, 2); diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index f18cec4c1..ed2cc4308 100755 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -9,7 +9,7 @@ #include "winlayer.h" #include "compat.h" -#include "startdlg.h" +#include "grpscan.h" #define WIN32_LEAN_AND_MEAN #include @@ -32,7 +32,7 @@ static struct { int forcesetup; int usemouse, usejoy; char selectedgrp[BMAX_PATH+1]; - int game; + int game; } settings; static HWND startupdlg = NULL; @@ -117,12 +117,9 @@ static void PopulateForm(int pgs) hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA); for (fg = foundgrps; fg; fg=fg->next) { - for (i = 0; icrcval == grpfiles[i].crcval) break; + for (i = 0; icrcval == grpfiles[i].crcval) break; if (i == numgrpfiles) continue; // unrecognised grp file - Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name); - fg->game = grpfiles[i].game; j = ListBox_AddString(hwnd, buf); ListBox_SetItemData(hwnd, j, (LPARAM)fg); if (!Bstrcasecmp(fg->name, settings.selectedgrp)) ListBox_SetCurSel(hwnd, j); @@ -175,13 +172,13 @@ static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA switch (LOWORD(wParam)) { case IDGDATA: { int i; - if (HIWORD(wParam) != LBN_SELCHANGE) break; + if (HIWORD(wParam) != LBN_SELCHANGE) break; i = ListBox_GetCurSel((HWND)lParam); if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); - if (i != CB_ERR) { - strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); - settings.game = ((struct grpfile*)i)->game; - } + if (i != CB_ERR) { + strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); + settings.game = ((struct grpfile*)i)->game; + } return TRUE; } default: break; @@ -503,7 +500,6 @@ int startwin_run(void) done = -1; - ScanGroups(); #ifdef JFAUD EnumAudioDevs(&wavedevs, NULL, NULL); #endif @@ -517,7 +513,7 @@ int startwin_run(void) settings.forcesetup = ForceSetup; settings.usemouse = UseMouse; settings.usejoy = UseJoystick; - settings.game = namversion; + settings.game = gametype; strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); PopulateForm(-1); @@ -544,7 +540,7 @@ int startwin_run(void) UseMouse = settings.usemouse; UseJoystick = settings.usejoy; duke3dgrp = settings.selectedgrp; - namversion = settings.game; + gametype = settings.game; } if (wavedevs) {