static void LoadGameList(void) { for (size_t i = 0; i < ARRAY_SIZE(internalgrpfiles); i++) { grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t)); fg->name = Xstrdup(internalgrpfiles[i].name); fg->crcval = internalgrpfiles[i].crcval; fg->size = internalgrpfiles[i].size; fg->game = internalgrpfiles[i].game; fg->dependency = internalgrpfiles[i].dependency; if (internalgrpfiles[i].scriptname) fg->scriptname = dup_filename(internalgrpfiles[i].scriptname); if (internalgrpfiles[i].defname) fg->defname = dup_filename(internalgrpfiles[i].defname); fg->postprocessing = internalgrpfiles[i].postprocessing; fg->next = listgrps; listgrps = fg; } CACHE1D_FIND_REC * const srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE); for (CACHE1D_FIND_REC *sidx = srch; sidx; sidx = sidx->next) LoadList(sidx->name); klistfree(srch); }
static void LoadGameList(void) { struct grpfile *fg; CACHE1D_FIND_REC *srch, *sidx; int32_t i; for (i = 0; i<NUMGRPFILES; i++) { fg = (struct grpfile *)Bcalloc(1, sizeof(struct grpfile)); fg->name = Bstrdup(internalgrpfiles[i].name); fg->crcval = internalgrpfiles[i].crcval; fg->size = internalgrpfiles[i].size; fg->game = internalgrpfiles[i].game; fg->dependency = internalgrpfiles[i].dependency; if (internalgrpfiles[i].scriptname) fg->scriptname = dup_filename(internalgrpfiles[i].scriptname); if (internalgrpfiles[i].defname) fg->defname = dup_filename(internalgrpfiles[i].defname); fg->next = listgrps; listgrps = fg; } srch = klistpath("/", "*.grpinfo", CACHE1D_FIND_FILE); for (sidx = srch; sidx; sidx = sidx->next) LoadList(srch->name); klistfree(srch); }
static void LoadList(const char * filename) { scriptfile *script = scriptfile_fromfile(filename); if (!script) return; scriptfile_addsymbolvalue("GAMEFLAG_DUKE", GAMEFLAG_DUKE); scriptfile_addsymbolvalue("GAMEFLAG_ADDON", GAMEFLAG_DUKE|GAMEFLAG_ADDON); scriptfile_addsymbolvalue("GAMEFLAG_NAM", GAMEFLAG_NAM); scriptfile_addsymbolvalue("GAMEFLAG_NAPALM", GAMEFLAG_NAM|GAMEFLAG_NAPALM); scriptfile_addsymbolvalue("GAMEFLAG_WW2GI", GAMEFLAG_NAM|GAMEFLAG_WW2GI); scriptfile_addsymbolvalue("DUKE15_CRC", DUKE15_CRC); scriptfile_addsymbolvalue("DUKEPP_CRC", DUKEPP_CRC); scriptfile_addsymbolvalue("DUKE13_CRC", DUKE13_CRC); scriptfile_addsymbolvalue("DUKEDC13_CRC", DUKEDC13_CRC); scriptfile_addsymbolvalue("DUKEDCPP_CRC", DUKEDCPP_CRC); scriptfile_addsymbolvalue("DUKEDC_CRC", DUKEDC_CRC); scriptfile_addsymbolvalue("VACA13_CRC", VACA13_CRC); scriptfile_addsymbolvalue("VACAPP_CRC", VACAPP_CRC); scriptfile_addsymbolvalue("VACA15_CRC", VACA15_CRC); scriptfile_addsymbolvalue("DUKECB_CRC", DUKECB_CRC); scriptfile_addsymbolvalue("DUKENW_CRC", DUKENW_CRC); scriptfile_addsymbolvalue("DZ2_13_CRC", DZ2_13_CRC); scriptfile_addsymbolvalue("DZ2_PP_CRC", DZ2_PP_CRC); scriptfile_addsymbolvalue("NAM_CRC", NAM_CRC); scriptfile_addsymbolvalue("NAPALM_CRC", NAPALM_CRC); scriptfile_addsymbolvalue("WW2GI_CRC", WW2GI_CRC); while (!scriptfile_eof(script)) { enum { T_GRPINFO, T_GAMENAME, T_CRC, T_SIZE, T_DEPCRC, T_SCRIPTNAME, T_DEFNAME, T_FLAGS, }; static const tokenlist profiletokens[] = { { "grpinfo", T_GRPINFO }, }; int32_t token = getatoken(script,profiletokens,ARRAY_SIZE(profiletokens)); switch (token) { case T_GRPINFO: { int32_t gsize = 0, gcrcval = 0, gflags = GAMEFLAG_DUKE, gdepcrc = DUKE15_CRC; char *gname = NULL, *gscript = NULL, *gdef = NULL; char *grpend = NULL; static const tokenlist grpinfotokens[] = { { "name", T_GAMENAME }, { "scriptname", T_SCRIPTNAME }, { "defname", T_DEFNAME }, { "crc", T_CRC }, { "dependency", T_DEPCRC }, { "size", T_SIZE }, { "flags", T_FLAGS }, }; if (scriptfile_getbraces(script,&grpend)) break; while (script->textptr < grpend) { int32_t token = getatoken(script,grpinfotokens,ARRAY_SIZE(grpinfotokens)); switch (token) { case T_GAMENAME: scriptfile_getstring(script,&gname); break; case T_SCRIPTNAME: scriptfile_getstring(script,&gscript); break; case T_DEFNAME: scriptfile_getstring(script,&gdef); break; case T_FLAGS: scriptfile_getsymbol(script,&gflags); gflags &= GAMEFLAGMASK; break; case T_DEPCRC: scriptfile_getsymbol(script,&gdepcrc); break; case T_CRC: scriptfile_getsymbol(script,&gcrcval); break; case T_SIZE: scriptfile_getnumber(script,&gsize); break; default: break; } grpinfo_t * const fg = (grpinfo_t *)Xcalloc(1, sizeof(grpinfo_t)); fg->next = listgrps; listgrps = fg; if (gname) fg->name = Xstrdup(gname); fg->size = gsize; fg->crcval = gcrcval; fg->dependency = gdepcrc; fg->game = gflags; if (gscript) fg->scriptname = dup_filename(gscript); if (gdef) fg->defname = dup_filename(gdef); } break; } default: break; } } scriptfile_close(script); scriptfile_clearsymbols(); }
void G_AddDef(const char *buffer) { clearDefNamePtr(); g_defNamePtr = dup_filename(buffer); initprintf("Using DEF file \"%s\".\n",g_defNamePtr); }
int32_t startwin_run(void) { if (!gtkenabled) return 1; if (!stwidgets.startwin) return 1; SetPage(TAB_CONFIG); settings.xdim3d = ud.config.ScreenWidth; settings.ydim3d = ud.config.ScreenHeight; settings.bpp3d = ud.config.ScreenBPP; settings.fullscreen = ud.config.ScreenMode; settings.usemouse = ud.config.UseMouse; settings.usejoy = ud.config.UseJoystick; settings.custommoddir = g_modDir; settings.forcesetup = ud.config.ForceSetup; settings.game = g_gameType; Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH); if (ud.config.NoAutoLoad) settings.autoload = FALSE; else settings.autoload = TRUE; #ifdef POLYMER if (glrendmode == REND_POLYMER) { if (settings.bpp3d == 8) settings.bpp3d = 32; settings.polymer = TRUE; } #endif PopulateForm(ALL); gtk_main(); SetPage(TAB_MESSAGES); if (retval) // launch the game with these parameters { ud.config.ScreenWidth = settings.xdim3d; ud.config.ScreenHeight = settings.ydim3d; ud.config.ScreenBPP = settings.bpp3d; ud.config.ScreenMode = settings.fullscreen; ud.config.UseMouse = settings.usemouse; ud.config.UseJoystick = settings.usejoy; ud.config.ForceSetup = settings.forcesetup; clearGrpNamePtr(); g_grpNamePtr = dup_filename(settings.selectedgrp); g_gameType = settings.game; if (settings.custommoddir != NULL) Bstrcpy(g_modDir, settings.custommoddir); else Bsprintf(g_modDir, "/"); if (settings.autoload) ud.config.NoAutoLoad = FALSE; else ud.config.NoAutoLoad = TRUE; { struct grpfile *grp; for (grp = listgrps; grp; grp=grp->next) if (settings.crcval == grp->crcval) break; if (grp) { g_gameNamePtr = grp->name; g_dependencyCRC = grp->dependency; if (grp->scriptname && g_scriptNamePtr == NULL) g_scriptNamePtr = dup_filename(grp->scriptname); if (grp->defname && g_defNamePtr == NULL) g_defNamePtr = dup_filename(grp->defname); } } } return retval; }
int32_t startwin_run(void) { MSG msg; if (!startupdlg) return 1; done = -1; #ifdef JFAUD EnumAudioDevs(&wavedevs, NULL, NULL); #endif SetPage(TAB_CONFIG); EnableConfig(1); settings.flags = 0; if (ud.config.ScreenMode) settings.flags |= 1; #ifdef POLYMER if (glrendmode == REND_POLYMER) settings.flags |= 2; #endif if (ud.config.NoAutoLoad) settings.flags |= 4; settings.xdim = ud.config.ScreenWidth; settings.ydim = ud.config.ScreenHeight; settings.bpp = ud.config.ScreenBPP; settings.forcesetup = ud.config.ForceSetup; settings.usemouse = ud.config.UseMouse; settings.usejoy = ud.config.UseJoystick; settings.game = g_gameType; // settings.crcval = 0; Bstrncpyz(settings.selectedgrp, G_GrpFile(), BMAX_PATH); settings.gamedir = g_modDir; PopulateForm(-1); while (done < 0) { switch (GetMessage(&msg, NULL, 0,0)) { case 0: done = 1; break; case -1: return -1; default: if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; TranslateMessage(&msg); DispatchMessage(&msg); break; } } SetPage(TAB_MESSAGES); EnableConfig(0); if (done) { ud.config.ScreenMode = (settings.flags&1); #ifdef POLYMER if (settings.flags & 2) glrendmode = REND_POLYMER; else glrendmode = REND_POLYMOST; #endif if (settings.flags & 4) ud.config.NoAutoLoad = 1; else ud.config.NoAutoLoad = 0; ud.config.ScreenWidth = settings.xdim; ud.config.ScreenHeight = settings.ydim; ud.config.ScreenBPP = settings.bpp; ud.config.ForceSetup = settings.forcesetup; ud.config.UseMouse = settings.usemouse; ud.config.UseJoystick = settings.usejoy; clearGrpNamePtr(); g_grpNamePtr = dup_filename(settings.selectedgrp); g_gameType = settings.game; if (g_noSetup == 0 && settings.gamedir != NULL) Bstrcpy(g_modDir,settings.gamedir); else Bsprintf(g_modDir,"/"); { struct grpfile *grp; for (grp = listgrps; grp; grp=grp->next) if (settings.crcval == grp->crcval) break; if (grp) { g_gameNamePtr = grp->name; g_dependencyCRC = grp->dependency; if (grp->scriptname && g_scriptNamePtr == NULL) g_scriptNamePtr = dup_filename(grp->scriptname); if (grp->defname && g_defNamePtr == NULL) g_defNamePtr = dup_filename(grp->defname); } } } if (wavedevs) { struct audioenumdev *d, *e; Bfree(wavedevs->drvs); for (e=wavedevs->devs; e; e=d) { d = e->next; if (e->devs) Bfree(e->devs); Bfree(e); } Bfree(wavedevs); } return done; }
int32_t CONFIG_ReadSetup(void) { int32_t dummy, i = 0; char commmacro[] = "CommbatMacro# "; char tempbuf[1024]; CONTROL_ClearAssignments(); CONFIG_SetDefaults(); ud.config.setupread = 1; pathsearchmode = 1; #ifndef EDUKE32_TOUCH_DEVICES if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 ud.config.scripthandle = SCRIPT_Load(setupfilename); else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0) { i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " "Import configuration data from \"%s\"?",setupfilename,SETUPFILENAME); if (i) ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME); } else if (SafeFileExists("duke3d.cfg") && ud.config.scripthandle < 0) { i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " "Import configuration data from \"duke3d.cfg\"?",setupfilename); if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg"); } #endif pathsearchmode = 0; if (ud.config.scripthandle < 0) return -1; if (ud.config.scripthandle >= 0) { char dummybuf[64]; for (dummy = 0; dummy < MAXRIDECULE; dummy++) { commmacro[13] = dummy+'0'; SCRIPT_GetString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); } Bmemset(tempbuf, 0, sizeof(tempbuf)); // Bmemset(dummybuf, 0, sizeof(dummybuf)); SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","PlayerName",&tempbuf[0]); while (Bstrlen(OSD_StripColors(dummybuf,tempbuf)) > 10) tempbuf[Bstrlen(tempbuf)-1] = '\0'; Bstrncpyz(szPlayerName, tempbuf, sizeof(szPlayerName)); if (g_rtsNamePtr == NULL) SCRIPT_GetString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ConfigVersion",&ud.configversion); SCRIPT_GetNumber(ud.config.scripthandle, "Setup","ForceSetup",&ud.config.ForceSetup); SCRIPT_GetNumber(ud.config.scripthandle, "Setup","NoAutoLoad",&ud.config.NoAutoLoad); // #ifdef _WIN32 if (g_noSetup == 0 && g_modDir[0] == '/') { struct Bstat st; SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]); if (Bstat(g_modDir, &st)) { if ((st.st_mode & S_IFDIR) != S_IFDIR) { initprintf("Invalid mod dir in cfg!\n"); Bsprintf(g_modDir,"/"); } } } // #endif if (g_grpNamePtr == NULL && g_usingAddon == 0) { SCRIPT_GetStringPtr(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr); if (g_grpNamePtr && !Bstrlen(g_grpNamePtr)) g_grpNamePtr = dup_filename(G_DefaultGrpFile()); } if (!NAM) { SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Out",&ud.lockout); SCRIPT_GetString(ud.config.scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); } SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",&ud.config.ScreenHeight); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",&ud.config.ScreenMode); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",&ud.config.ScreenWidth); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", (int32_t *)&windowpos); windowx = -1; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", (int32_t *)&windowx); windowy = -1; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", (int32_t *)&windowy); #ifdef RENDERTYPEWIN SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", (int32_t *)&maxrefreshfreq); #endif SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", &ud.config.ScreenBPP); if (ud.config.ScreenBPP < 8) ud.config.ScreenBPP = 32; #ifdef POLYMER SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "Polymer", &dummy); if (dummy > 0 && ud.config.ScreenBPP >= 16) glrendmode = REND_POLYMER; else glrendmode = REND_POLYMOST; #endif /* SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Color",&ud.color); G_CheckPlayerColor((int32_t *)&ud.color,-1); g_player[0].ps->palookup = g_player[0].pcolor = ud.color; tempbuf[0] = 0; */ SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions); #ifdef _WIN32 SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates); SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", &ud.config.LastUpdateCheck); #endif } //CONFIG_SetupMouse(ud.config.scripthandle); //CONFIG_SetupJoystick(ud.config.scripthandle); ud.config.setupread = 1; return 0; }