int loadsetup(const char *fn) { BFILE *fp; #define VL 32 char val[VL]; int i; if ((fp = Bfopen(fn, "rt")) == NULL) return -1; if (readconfig(fp, "fullscreen", val, VL) > 0) { if (Batoi(val) != 0) fullscreen = 1; else fullscreen = 0; } if (readconfig(fp, "resolution", val, VL) > 0) { i = Batoi(val) & 0x0f; if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } } if (readconfig(fp, "2dresolution", val, VL) > 0) { i = Batoi(val) & 0x0f; if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; } } if (readconfig(fp, "xdim2d", val, VL) > 0) { xdim2d = Batoi(val); } if (readconfig(fp, "ydim2d", val, VL) > 0) { ydim2d = Batoi(val); } if (readconfig(fp, "xdim3d", val, VL) > 0) { xdimgame = Batoi(val); } if (readconfig(fp, "ydim3d", val, VL) > 0) { ydimgame = Batoi(val); } if (readconfig(fp, "samplerate", val, VL) > 0) { option[7] = (Batoi(val) & 0x0f) << 4; } if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) { bppgame = Batoi(val); } if (readconfig(fp, "renderer", val, VL) > 0) { i = Batoi(val); setrendermode(i); } if (readconfig(fp, "brightness", val, VL) > 0) { brightness = min(max(Batoi(val),0),15); } #ifdef RENDERTYPEWIN if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) { maxrefreshfreq = Batoi(val); } #endif option[0] = 1; // vesa all the way... option[1] = 1; // sound all the way... option[4] = 0; // no multiplayer option[5] = 0; if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keybackward", val, VL) > 0) keys[1] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyturnleft", val, VL) > 0) keys[2] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyturnright", val, VL) > 0) keys[3] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyrun", val, VL) > 0) keys[4] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystrafe", val, VL) > 0) keys[5] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyfire", val, VL) > 0) keys[6] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyuse", val, VL) > 0) keys[7] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystandhigh", val, VL) > 0) keys[8] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystandlow", val, VL) > 0) keys[9] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keylookup", val, VL) > 0) keys[10] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keylookdown", val, VL) > 0) keys[11] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystrafeleft", val, VL) > 0) keys[12] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keystraferight", val, VL) > 0) keys[13] = Bstrtol(val, NULL, 16); if (readconfig(fp, "key2dmode", val, VL) > 0) keys[14] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyviewcycle", val, VL) > 0) keys[15] = Bstrtol(val, NULL, 16); if (readconfig(fp, "key2dzoomin", val, VL) > 0) keys[16] = Bstrtol(val, NULL, 16); if (readconfig(fp, "key2dzoomout", val, VL) > 0) keys[17] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keychat", val, VL) > 0) keys[18] = Bstrtol(val, NULL, 16); if (readconfig(fp, "keyconsole", val, VL) > 0) { keys[19] = Bstrtol(val, NULL, 16); OSD_CaptureKey(keys[19]); } if (readconfig(fp, "mousesensitivity", val, VL) > 0) msens = Bstrtod(val, NULL); Bfclose(fp); return 0; }
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_GetString(ud.config.scripthandle, "Misc", "CrosshairColor",&tempbuf[0]); if (tempbuf[0]) { char *ptr = strtok(tempbuf,","); palette_t temppal; char *palptr = (char *)&temppal; i = 0; while (ptr != NULL && i < 3) { palptr[i++] = Batoi(ptr); ptr = strtok(NULL,","); } if (i == 3) { Bmemcpy(&CrosshairColors,&temppal,sizeof(palette_t)); DefaultCrosshairColors.f = 1; } } 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; }