BDIR *Bopendir(const char *name) { BDIR_real *dirr; #ifdef _MSC_VER char *t, *tt; t = (char *)Bmalloc(Bstrlen(name) + 1 + 4); if (!t) return NULL; #endif dirr = (BDIR_real *)Bmalloc(sizeof(BDIR_real) + Bstrlen(name)); if (!dirr) { #ifdef _MSC_VER Bfree(t); #endif return NULL; } #ifdef _MSC_VER Bstrcpy(t, name); tt = t + Bstrlen(name) - 1; while (*tt == ' ' && tt > t) tt--; if (*tt != '/' && *tt != '\\') *(++tt) = '/'; *(++tt) = '*'; *(++tt) = '.'; *(++tt) = '*'; *(++tt) = 0; dirr->dir = _findfirst(t, &dirr->fid); Bfree(t); if (dirr->dir == -1) { Bfree(dirr); return NULL; } #else dirr->dir = opendir(name); if (dirr->dir == NULL) { Bfree(dirr); return NULL; } #endif dirr->status = 0; Bstrcpy(dirr->name, name); return (BDIR *)dirr; }
void texcache_openfiles(void) { Bstrcpy(ptempbuf,TEXCACHEFILE); Bstrcat(ptempbuf,".cache"); texcache.index = Bfopen(ptempbuf, "at+"); texcache.filehandle = Bopen(TEXCACHEFILE, BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR, BS_IREAD|BS_IWRITE); if (!texcache.index || texcache.filehandle < 0) { initprintf("Unable to open cache file \"%s\" or \"%s\": %s\n", TEXCACHEFILE, ptempbuf, strerror(errno)); texcache_closefiles(); glusetexcache = 0; return; } Bfseek(texcache.index, 0, BSEEK_END); if (!Bftell(texcache.index)) { Brewind(texcache.index); Bfprintf(texcache.index,"// automatically generated by EDuke32, DO NOT MODIFY!\n"); } else Brewind(texcache.index); initprintf("Opened \"%s\" as cache file\n", TEXCACHEFILE); }
static void texcache_deletefiles(void) { Bstrcpy(ptempbuf, TEXCACHEFILE); unlink(ptempbuf); Bstrcat(ptempbuf, ".cache"); unlink(ptempbuf); }
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; Bstrncpy(settings.selectedgrp, g_grpNamePtr, BMAX_PATH); if (ud.config.NoAutoLoad) settings.autoload = FALSE; else settings.autoload = TRUE; #ifdef POLYMER if (glrendmode == RDR_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 { int32_t i; 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; g_grpNamePtr = 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; for (i = 0; i<numgrpfiles; i++) if (settings.crcval == grpfiles[i].crcval) break; if (i != numgrpfiles) g_gameNamePtr = (char *)grpfiles[i].name; } return retval; }
int32_t texcache_loadoffsets(void) { int32_t foffset, fsize, i; char *fname; scriptfile *script; Bstrcpy(ptempbuf,TEXCACHEFILE); Bstrcat(ptempbuf,".cache"); script = scriptfile_fromfile(ptempbuf); if (!script) return -1; while (!scriptfile_eof(script)) { if (scriptfile_getstring(script, &fname)) break; // hashed filename if (scriptfile_getnumber(script, &foffset)) break; // offset in cache if (scriptfile_getnumber(script, &fsize)) break; // size i = hash_find(&texcache.hashes,fname); if (i > -1) { // update an existing entry texcacheindex *t = texcache.iptrs[i]; t->offset = foffset; t->len = fsize; /*initprintf("%s %d got a match for %s offset %d\n",__FILE__, __LINE__, fname,foffset);*/ } else { Bstrncpyz(texcache.currentindex->name, fname, BMAX_PATH); texcache.currentindex->offset = foffset; texcache.currentindex->len = fsize; texcache.currentindex->next = (texcacheindex *)Xcalloc(1, sizeof(texcacheindex)); hash_add(&texcache.hashes, fname, texcache.numentries, 1); if (++texcache.numentries > texcache.iptrcnt) { texcache.iptrcnt += 512; texcache.iptrs = (texcacheindex **) Xrealloc(texcache.iptrs, sizeof(intptr_t) * texcache.iptrcnt); } texcache.iptrs[texcache.numentries-1] = texcache.currentindex; texcache.currentindex = texcache.currentindex->next; } } scriptfile_close(script); return 0; }
void readsavenames(void) { long dummy; short i; char fn[13]; BFILE *fil; Bstrcpy(fn,"game_.sav"); for (i=0;i<10;i++) { fn[4] = i+'0'; if ((fil = Bfopen(fn,"rb")) == NULL ) continue; if (dfread(&dummy,4,1,fil) != 1) { Bfclose(fil); continue; } if(dummy != BYTEVERSION) return; if (dfread(&dummy,4,1,fil) != 1) { Bfclose(fil); continue; } if (dfread(&ud.savegame[i][0],19,1,fil) != 1) { ud.savegame[i][0] = 0; } Bfclose(fil); } }
static const char * texcache_calcid(char *cachefn, const char *fn, const int32_t len, const int32_t dameth, const char effect) { // Assert that BMAX_PATH is a multiple of 4 so that struct texcacheid_t // gets no padding inserted by the compiler. EDUKE32_STATIC_ASSERT((BMAX_PATH & 3) == 0); struct texcacheid_t { int32_t len, method; char effect, name[BMAX_PATH+3]; // +3: pad to a multiple of 4 } id = { len, dameth, effect, "" }; Bstrcpy(id.name, fn); while (Bstrlen(id.name) < BMAX_PATH - Bstrlen(fn)) Bstrcat(id.name, fn); Bsprintf(cachefn, "%08x%08x%08x", XXH32((uint8_t *)fn, Bstrlen(fn), TEXCACHEMAGIC[3]), XXH32((uint8_t *)id.name, Bstrlen(id.name), TEXCACHEMAGIC[3]), XXH32((uint8_t *)&id, sizeof(struct texcacheid_t), TEXCACHEMAGIC[3])); return cachefn; }
// checks from path and in ZIPs, returns 1 if NOT found int32_t check_file_exist(const char *fn) { int32_t opsm = pathsearchmode; char *tfn; pathsearchmode = 1; if (findfrompath(fn,&tfn) < 0) { char buf[BMAX_PATH]; Bstrcpy(buf,fn); kzfindfilestart(buf); if (!kzfindfile(buf)) { initprintf("Error: file \"%s\" does not exist\n",fn); pathsearchmode = opsm; return 1; } } else Bfree(tfn); pathsearchmode = opsm; return 0; }
void CONFIG_SetDefaults( void ) { // JBF 20031211 int32 i,f; byte k1,k2; #if MEGAWANG ScreenMode = -1; #else ScreenMode = 1; #endif ScreenWidth = 640; ScreenHeight = 480; ScreenBPP = 8; FXDevice = 0; MusicDevice = 0; FXVolume = 192; MusicVolume = 128; NumVoices = 32; NumChannels = 2; NumBits = 16; MixRate = 44100; gs.FlipStereo = 0; Bstrcpy(RTSName, DEFAULTRTSFILE); Bstrcpy(CommPlayerName, "Kato"); Bstrcpy(WangBangMacro[0], "Burn baby burn..."); Bstrcpy(WangBangMacro[1], "You make another stupid move."); Bstrcpy(WangBangMacro[2], "Blocking with your head again?"); Bstrcpy(WangBangMacro[3], "You not fight well with hands!"); Bstrcpy(WangBangMacro[4], "You so stupid!"); Bstrcpy(WangBangMacro[5], "Quit jerking off. Come fight me!"); Bstrcpy(WangBangMacro[6], "What the matter you scaredy cat?"); Bstrcpy(WangBangMacro[7], "Did I break your concentration?"); Bstrcpy(WangBangMacro[8], "Hope you were paying attention."); Bstrcpy(WangBangMacro[9], "ITTAIIIUUU!!!"); memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0]))/3; i++) { f = CONFIG_FunctionNameToNum( keydefaults[3*i+0] ); if (f == -1) continue; k1 = KB_StringToScanCode( keydefaults[3*i+1] ); k2 = KB_StringToScanCode( keydefaults[3*i+2] ); KeyboardKeys[f][0] = k1; KeyboardKeys[f][1] = k2; } memset(MouseFunctions, -1, sizeof(MouseFunctions)); for (i=0; i < (int32)(sizeof(mousedefaults)/sizeof(char*)); i++) { MouseFunctions[i][0] = CONFIG_FunctionNameToNum( mousedefaults[i] ); if (i<4) continue; MouseFunctions[i][1] = CONFIG_FunctionNameToNum( mouseclickeddefaults[i] ); } memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); for (i=0; i<MAXMOUSEAXES; i++) { MouseAnalogueScale[i] = 65536; MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2] ); MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2+1] ); MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum( mouseanalogdefaults[i] ); } CONTROL_SetMouseSensitivity(32768<<2); memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); for (i=0; i < (int32)(sizeof(joystickdefaults)/sizeof(char*)); i++) { JoystickFunctions[i][0] = CONFIG_FunctionNameToNum( joystickdefaults[i] ); JoystickFunctions[i][1] = CONFIG_FunctionNameToNum( joystickclickeddefaults[i] ); } memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); for (i=0; i < (int32)(sizeof(joystickanalogdefaults)/sizeof(char*)); i++) { JoystickAnalogueScale[i] = 65536; JoystickAnalogueDead[i] = 1000; JoystickAnalogueSaturate[i] = 9500; JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2] ); JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2+1] ); JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum( joystickanalogdefaults[i] ); } }
void CONFIG_SetDefaults( void ) { // JBF 20031211 int32 i,f; byte k1,k2; ScreenMode = 1; ScreenWidth = 640; ScreenHeight = 480; ScreenBPP = 8; FXDevice = 0; MusicDevice = 0; NumVoices = 32; NumChannels = 2; NumBits = 16; MixRate = 44100; memcpy(&gs, &gs_defaults, sizeof(gs)); Bstrcpy(RTSName, DEFAULTRTSFILE); Bstrcpy(CommPlayerName, DEFAULTPLAYERNAME); Bstrcpy(WangBangMacro[0], MACRO1); Bstrcpy(WangBangMacro[1], MACRO2); Bstrcpy(WangBangMacro[2], MACRO3); Bstrcpy(WangBangMacro[3], MACRO4); Bstrcpy(WangBangMacro[4], MACRO5); Bstrcpy(WangBangMacro[5], MACRO6); Bstrcpy(WangBangMacro[6], MACRO7); Bstrcpy(WangBangMacro[7], MACRO8); Bstrcpy(WangBangMacro[8], MACRO9); Bstrcpy(WangBangMacro[9], MACRO10); SetDefaultKeyDefinitions(0); SetMouseDefaults(0); memset(MouseDigitalAxes, -1, sizeof(MouseDigitalAxes)); for (i=0; i<MAXMOUSEAXES; i++) { MouseAnalogScale[i] = 65536; MouseDigitalAxes[i][0] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2] ); MouseDigitalAxes[i][1] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2+1] ); MouseAnalogAxes[i] = CONFIG_AnalogNameToNum( mouseanalogdefaults[i] ); } CONTROL_SetMouseSensitivity(gs.MouseSpeed); memset(JoystickButtons, -1, sizeof(JoystickButtons)); memset(JoystickButtonsClicked, -1, sizeof(JoystickButtonsClicked)); for (i=0; i < (int32)(sizeof(joystickdefaults)/sizeof(char*)); i++) { JoystickButtons[i] = CONFIG_FunctionNameToNum( joystickdefaults[i] ); JoystickButtonsClicked[i] = CONFIG_FunctionNameToNum( joystickclickeddefaults[i] ); } memset(JoystickDigitalAxes, -1, sizeof(JoystickDigitalAxes)); for (i=0; i < (int32)(sizeof(joystickanalogdefaults)/sizeof(char*)); i++) { JoystickAnalogScale[i] = 65536; JoystickAnalogDead[i] = 1024; JoystickAnalogSaturate[i] = 32767-1024; JoystickDigitalAxes[i][0] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2] ); JoystickDigitalAxes[i][1] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2+1] ); JoystickAnalogAxes[i] = CONFIG_AnalogNameToNum( joystickanalogdefaults[i] ); } }
void G_SetupCheats(void) { // KEEPINSYNC: NAM_WW2GI_CHEATS if (WW2GI) { #if 0 // WWII GI's original cheat prefix temporarily disabled because W conflicts with WSAD movement CheatKeys[0] = CheatKeys[1] = sc_W; #else CheatKeys[0] = sc_G; CheatKeys[1] = sc_I; #endif Bstrcpy(CheatStrings[0], "2god"); Bstrcpy(CheatStrings[1], "2blood"); Bstrcpy(CheatStrings[2], "2level###"); Bstrcpy(CheatStrings[3], "2coords"); Bstrcpy(CheatStrings[4], "2view"); Bstrcpy(CheatStrings[5], "<RESERVED>"); Bstrcpy(CheatStrings[7], "<RESERVED>"); Bstrcpy(CheatStrings[8], "<RESERVED>"); Bstrcpy(CheatStrings[9], "2rate"); Bstrcpy(CheatStrings[10], "2skill"); Bstrcpy(CheatStrings[11], "<RESERVED>"); Bstrcpy(CheatStrings[12], "<RESERVED>"); Bstrcpy(CheatStrings[13], "<RESERVED>"); Bstrcpy(CheatStrings[16], "2matt"); Bstrcpy(CheatStrings[17], "2showmap"); Bstrcpy(CheatStrings[18], "2ryan"); Bstrcpy(CheatStrings[19], "<RESERVED>"); Bstrcpy(CheatStrings[20], "2clip"); Bstrcpy(CheatStrings[21], "2weapons"); Bstrcpy(CheatStrings[22], "2inventory"); Bstrcpy(CheatStrings[23], "<RESERVED>"); Bstrcpy(CheatStrings[24], "2debug"); Bstrcpy(CheatStrings[26], "2cgs"); Bstrcpy(GametypeNames[0], "GI Match (Spawn)"); Bstrcpy(GametypeNames[2], "GI Match (No Spawn)"); } else if (NAM) { CheatKeys[0] = sc_N; CheatKeys[1] = sc_V; Bstrcpy(CheatStrings[0], "acaleb"); Bstrcpy(CheatStrings[1], "ablood"); Bstrcpy(CheatStrings[2], "alevel###"); Bstrcpy(CheatStrings[3], "acoords"); Bstrcpy(CheatStrings[4], "aview"); Bstrcpy(CheatStrings[5], "<RESERVED>"); Bstrcpy(CheatStrings[7], "<RESERVED>"); Bstrcpy(CheatStrings[8], "<RESERVED>"); Bstrcpy(CheatStrings[9], "arate"); Bstrcpy(CheatStrings[10], "askill"); Bstrcpy(CheatStrings[11], "<RESERVED>"); Bstrcpy(CheatStrings[12], "ahyper"); Bstrcpy(CheatStrings[13], "<RESERVED>"); Bstrcpy(CheatStrings[16], "amatt"); Bstrcpy(CheatStrings[17], "ashowmap"); Bstrcpy(CheatStrings[18], "agod"); Bstrcpy(CheatStrings[19], "<RESERVED>"); Bstrcpy(CheatStrings[20], "aclip"); Bstrcpy(CheatStrings[21], "aweapons"); Bstrcpy(CheatStrings[22], "ainventory"); Bstrcpy(CheatStrings[23], "<RESERVED>"); Bstrcpy(CheatStrings[24], "adebug"); Bstrcpy(CheatStrings[26], "acgs"); Bstrcpy(GametypeNames[0], "GruntMatch (Spawn)"); Bstrcpy(GametypeNames[2], "GruntMatch (No Spawn)"); } }
int32_t Bcanonicalisefilename(char *filename, int32_t removefn) { char cwd[BMAX_PATH]; char *fnp = filename; #ifdef _WIN32 int drv = 0; if (filename[0] && filename[1] == ':') { // filename is prefixed with a drive drv = toupper(filename[0]) - 'A' + 1; fnp += 2; } if (!_getdcwd(drv, cwd, sizeof(cwd))) return -1; for (char *p = cwd; *p; p++) if (*p == '\\') *p = '/'; #else if (!getcwd(cwd, sizeof(cwd))) return -1; #endif char *p = Bstrrchr(cwd, '/'); if (!p || p[1]) Bstrcat(cwd, "/"); char fn[BMAX_PATH]; Bstrcpy(fn, fnp); #ifdef _WIN32 for (p = fn; *p; p++) if (*p == '\\') *p = '/'; #endif if (fn[0] != '/') { // we are dealing with a path relative to the current directory Bstrcpy(filename, cwd); Bstrcat(filename, fn); } else { #ifdef _WIN32 filename[0] = cwd[0]; filename[1] = ':'; filename[2] = 0; Bstrcat(filename, fn); #else Bstrcpy(filename, fn); #endif } fnp = filename; #ifdef _WIN32 fnp += 2; // skip the drive #endif UNREFERENCED_PARAMETER(removefn); // change the call below to use removefn instead of 1? return Bcorrectfilename(fnp, 1); }
void CONFIG_SetDefaults(void) { int32 i,f; byte k1,k2; extern int32 useDarts; extern BOOL ClassicLighting; ScreenMode = -1; ScreenWidth = 800; ScreenHeight = 600; ScreenBPP = 32; vsync = 0; xfov = 1.0f; FXDevice = 0; MusicDevice = 0; FXVolume = 192; MusicVolume = 160; NumVoices = 32; NumChannels = 2; NumBits = 16; MixRate = 44100; gs.FlipStereo = 0; gs.MusicVolume = MusicVolume; gs.AutoRun = 1; useDarts = FALSE; Bstrcpy(RTSName, DEFAULTRTSFILE); Bstrcpy(CommPlayerName, "Kato"); Bstrcpy(WangBangMacro[0], "Burn baby burn..."); Bstrcpy(WangBangMacro[1], "You make another stupid move."); Bstrcpy(WangBangMacro[2], "Blocking with your head again?"); Bstrcpy(WangBangMacro[3], "You not fight well with hands!"); Bstrcpy(WangBangMacro[4], "You so stupid!"); Bstrcpy(WangBangMacro[5], "Quit jerking off. Come fight me!"); Bstrcpy(WangBangMacro[6], "What the matter you scaredy cat?"); Bstrcpy(WangBangMacro[7], "Did I break your concentration?"); Bstrcpy(WangBangMacro[8], "Hope you were paying attention."); Bstrcpy(WangBangMacro[9], "ITTAIIIUUU!!!"); memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); memset(MouseFunctions, -1, sizeof(MouseFunctions)); memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); dnResetBindings(); dnSetMouseSensitivity(16384); gs.MouseInvert = 0; gs.MouseAimingOn = TRUE; ClassicLighting = TRUE; }
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; }
void CONFIG_SetDefaults( void ) { int32 i,f; byte k1,k2; FXDevice = 0; MusicDevice = 0; NumVoices = 16; NumChannels = 2; NumBits = 16; MixRate = 44100; SoundToggle = 1; MusicToggle = 1; VoiceToggle = 1; AmbienceToggle = 1; FXVolume = 220; MusicVolume = 200; ReverseStereo = 0; myaimmode = ps[0].aim_mode = 1; ud.mouseaiming = 0; ud.weaponswitch = 3; // new+empty AutoAim = 0; UseJoystick = 0; UseMouse = 1; ud.mouseflip = 0; ud.runkey_mode = 0; ud.statusbarscale = 100; ud.screen_size = 8; ud.screen_tilting = 1; ud.shadows = 1; ud.detail = 1; ud.lockout = 0; ud.pwlockout[0] = '\0'; ud.crosshair = 1; ud.m_marker = 1; ud.m_ffire = 1; ud.levelstats = 0; ud.vsync = 1; ud.fps_max = 120; ShowOpponentWeapons = 0; Bstrcpy(ud.rtsname, "DUKE.RTS"); Bstrcpy(myname, "Duke"); Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); Bstrcpy(ud.ridecule[2], "It hurts to be you."); Bstrcpy(ud.ridecule[3], "Lucky Son of a Bitch."); Bstrcpy(ud.ridecule[4], "Hmmm....Payback time."); Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker."); Bstrcpy(ud.ridecule[6], "Damn, you're ugly."); Bstrcpy(ud.ridecule[7], "Ha ha ha...Wasted!"); Bstrcpy(ud.ridecule[8], "You suck!"); Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); #if 0 memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3) { f = CONFIG_FunctionNameToNum( keydefaults[i+0] ); if (f == -1) continue; KeyboardKeys[f][0] = KB_StringToScanCode( keydefaults[i+1] ); KeyboardKeys[f][1] = KB_StringToScanCode( keydefaults[i+2] ); if (f == gamefunc_Show_Console) OSD_CaptureKey(KeyboardKeys[f][0]); else CONTROL_MapKey( f, KeyboardKeys[f][0], KeyboardKeys[f][1] ); } memset(MouseFunctions, -1, sizeof(MouseFunctions)); for (i=0; i<MAXMOUSEBUTTONS; i++) { MouseFunctions[i][0] = CONFIG_FunctionNameToNum( mousedefaults[i] ); CONTROL_MapButton( MouseFunctions[i][0], i, 0, controldevice_mouse ); if (i>=4) continue; MouseFunctions[i][1] = CONFIG_FunctionNameToNum( mouseclickeddefaults[i] ); CONTROL_MapButton( MouseFunctions[i][1], i, 1, controldevice_mouse ); } memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); for (i=0; i<MAXMOUSEAXES; i++) { MouseAnalogueScale[i] = -65536; CONTROL_SetAnalogAxisScale( i, MouseAnalogueScale[i], controldevice_mouse ); MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2] ); MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum( mousedigitaldefaults[i*2+1] ); CONTROL_MapDigitalAxis( i, MouseDigitalFunctions[i][0], 0, controldevice_mouse ); CONTROL_MapDigitalAxis( i, MouseDigitalFunctions[i][1], 1, controldevice_mouse ); MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum( mouseanalogdefaults[i] ); CONTROL_MapAnalogAxis( i, MouseAnalogueAxes[i], controldevice_mouse); } CONTROL_SetMouseSensitivity(32768); memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); for (i=0; i<MAXJOYBUTTONS; i++) { JoystickFunctions[i][0] = CONFIG_FunctionNameToNum( joystickdefaults[i] ); JoystickFunctions[i][1] = CONFIG_FunctionNameToNum( joystickclickeddefaults[i] ); CONTROL_MapButton( JoystickFunctions[i][0], i, 0, controldevice_joystick ); CONTROL_MapButton( JoystickFunctions[i][1], i, 1, controldevice_joystick ); } memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); for (i=0; i<MAXJOYAXES; i++) { JoystickAnalogueScale[i] = 65536; JoystickAnalogueDead[i] = 1000; JoystickAnalogueSaturate[i] = 9500; CONTROL_SetAnalogAxisScale( i, JoystickAnalogueScale[i], controldevice_joystick ); JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2] ); JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum( joystickdigitaldefaults[i*2+1] ); CONTROL_MapDigitalAxis( i, JoystickDigitalFunctions[i][0], 0, controldevice_joystick ); CONTROL_MapDigitalAxis( i, JoystickDigitalFunctions[i][1], 1, controldevice_joystick ); JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum( joystickanalogdefaults[i] ); CONTROL_MapAnalogAxis(i, JoystickAnalogueAxes[i], controldevice_joystick); } #endif dnResetBindings(); }
void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect, texcacheheader *head) { static GLint glGetTexLevelParameterivOK = GL_TRUE; char cachefn[BMAX_PATH]; char *pic = NULL, *packbuf = NULL; void *midbuf = NULL; uint32_t alloclen=0, level; uint32_t padx=0, pady=0; GLint gi; int32_t offset = 0; if (!texcache_enabled()) return; gi = GL_FALSE; bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi); if (gi != GL_TRUE) { if (glGetTexLevelParameterivOK == GL_TRUE) { OSD_Printf("Error: glGetTexLevelParameteriv returned GL_FALSE!\n"); glGetTexLevelParameterivOK = GL_FALSE; } return; } Blseek(texcache.filehandle, 0, BSEEK_END); offset = Blseek(texcache.filehandle, 0, BSEEK_CUR); // OSD_Printf("Caching %s, offset 0x%x\n", cachefn, offset); Bmemcpy(head->magic, TEXCACHEMAGIC, 4); // sizes are set by caller if (glusetexcache == 2) head->flags |= CACHEAD_COMPRESSED; // native -> external (little-endian) head->xdim = B_LITTLE32(head->xdim); head->ydim = B_LITTLE32(head->ydim); head->flags = B_LITTLE32(head->flags); head->quality = B_LITTLE32(head->quality); if (Bwrite(texcache.filehandle, head, sizeof(texcacheheader)) != sizeof(texcacheheader)) goto failure; CLEAR_GL_ERRORS(); for (level = 0; level==0 || (padx > 1 || pady > 1); level++) { uint32_t miplen; texcachepicture pict; bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, &gi); WRITEX_FAIL_ON_ERROR(); if (gi != GL_TRUE) goto failure; // an uncompressed mipmap bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &gi); WRITEX_FAIL_ON_ERROR(); #ifdef __APPLE__ if (pr_ati_textureformat_one && gi == 1) gi = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; #endif // native -> external (little endian) pict.format = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_WIDTH, &gi); WRITEX_FAIL_ON_ERROR(); padx = gi; pict.xdim = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_HEIGHT, &gi); WRITEX_FAIL_ON_ERROR(); pady = gi; pict.ydim = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_BORDER, &gi); WRITEX_FAIL_ON_ERROR(); pict.border = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_DEPTH, &gi); WRITEX_FAIL_ON_ERROR(); pict.depth = B_LITTLE32(gi); bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &gi); WRITEX_FAIL_ON_ERROR(); miplen = gi; pict.size = B_LITTLE32(gi); if (alloclen < miplen) { pic = (char *)Xrealloc(pic, miplen); alloclen = miplen; packbuf = (char *)Xrealloc(packbuf, alloclen); midbuf = (void *)Xrealloc(midbuf, miplen); } bglGetCompressedTexImageARB(GL_TEXTURE_2D, level, pic); WRITEX_FAIL_ON_ERROR(); if (Bwrite(texcache.filehandle, &pict, sizeof(texcachepicture)) != sizeof(texcachepicture)) goto failure; if (dxtfilter(texcache.filehandle, &pict, pic, midbuf, packbuf, miplen)) goto failure; } { texcacheindex *t; int32_t i = hash_find(&texcache.hashes, texcache_calcid(cachefn, fn, len, dameth, effect)); if (i > -1) { // update an existing entry t = texcache.iptrs[i]; t->offset = offset; t->len = Blseek(texcache.filehandle, 0, BSEEK_CUR) - t->offset; /*initprintf("%s %d got a match for %s offset %d\n",__FILE__, __LINE__, cachefn,offset);*/ } else { t = texcache.currentindex; Bstrcpy(t->name, cachefn); t->offset = offset; t->len = Blseek(texcache.filehandle, 0, BSEEK_CUR) - t->offset; t->next = (texcacheindex *)Xcalloc(1, sizeof(texcacheindex)); hash_add(&texcache.hashes, cachefn, texcache.numentries, 0); if (++texcache.numentries > texcache.iptrcnt) { texcache.iptrcnt += 512; texcache.iptrs = (texcacheindex **) Xrealloc(texcache.iptrs, sizeof(intptr_t) * texcache.iptrcnt); } texcache.iptrs[texcache.numentries-1] = t; texcache.currentindex = t->next; } if (texcache.index) { fseek(texcache.index, 0, BSEEK_END); Bfprintf(texcache.index, "%s %d %d\n", t->name, t->offset, t->len); } else OSD_Printf("wtf?\n"); } goto success; failure: initprintf("ERROR: cache failure!\n"); texcache.currentindex->offset = 0; Bmemset(texcache.currentindex->name,0,sizeof(texcache.currentindex->name)); success: TEXCACHE_FREEBUFS(); }
void CONFIG_SetDefaults(void) { // JBF 20031211 int32_t i; ud.config.scripthandle = -1; #ifdef __ANDROID__ droidinput.forward_sens = 5.f; droidinput.strafe_sens = 5.f; droidinput.pitch_sens = 5.f; droidinput.yaw_sens = 5.f; droidinput.hideStick = 0; droidinput.gameControlsAlpha = 0.5; droidinput.toggleCrouch = 1; droidinput.quickSelectWeapon = 1; ud.config.ScreenWidth = droidinfo.screen_width; ud.config.ScreenHeight = droidinfo.screen_height; #elif defined _3DS ud.config.ScreenWidth = 400; ud.config.ScreenHeight = 240; #else ud.config.ScreenWidth = 1024; ud.config.ScreenHeight = 768; #endif ud.config.ScreenMode = 0; #ifdef USE_OPENGL ud.config.ScreenBPP = 32; #else ud.config.ScreenBPP = 8; #endif ud.config.useprecache = 1; ud.config.ForceSetup = 1; ud.config.NoAutoLoad = 1; ud.config.AmbienceToggle = 1; ud.config.AutoAim = 1; ud.config.MasterVolume = 255; ud.config.FXVolume = 225; #if defined(_WIN32) ud.config.MixRate = 44100; #elif defined __ANDROID__ ud.config.MixRate = droidinfo.audio_sample_rate; #else ud.config.MixRate = 32730; #endif ud.config.MouseBias = 0; ud.config.MouseDeadZone = 0; ud.config.MusicToggle = 1; ud.config.MusicVolume = 100; g_myAimMode = g_player[0].ps->aim_mode = 1; ud.config.NumBits = 16; ud.config.NumChannels = 1; ud.config.NumVoices = 16; ud.config.ReverseStereo = 0; ud.auto_run = 1; ud.config.ShowOpponentWeapons = 0; ud.config.SmoothInput = 1; ud.config.SoundToggle = 1; ud.althud = 1; ud.automsg = 0; ud.autovote = 0; ud.brightness = 8; ud.camerasprite = -1; #if defined GEKKO || defined __OPENDINGUX__ ud.camera_time = 11; #elif defined(__ANDROID__) ud.camera_time = 7; #else ud.camera_time = 4; #endif ud.color = 0; ud.crosshair = 1; ud.crosshairscale = 50; ud.obituaries = 1; ud.democams = 1; ud.detail = 1; ud.drawweapon = 1; ud.idplayers = 1; ud.levelstats = 0; ud.lockout = 0; ud.m_ffire = 1; ud.m_marker = 1; ud.mouseaiming = 0; ud.mouseflip = 1; ud.msgdisptime = 120; ud.pwlockout[0] = '\0'; ud.runkey_mode = 0; ud.screen_size = 4; ud.screen_tilting = 1; ud.shadows = 1; ud.statusbarmode = 1; ud.statusbarscale = 100; ud.team = 0; ud.viewbob = 1; ud.weaponsway = 1; ud.weaponswitch = 3; // new+empty ud.angleinterpolation = 0; #ifdef GEKKO ud.config.UseJoystick = 1; #else ud.config.UseJoystick = 1; #endif ud.config.UseMouse = 1; ud.config.VoiceToggle = 5; // bitfield, 1 = local, 2 = dummy, 4 = other players in DM ud.display_bonus_screen = 1; ud.show_level_text = 1; ud.configversion = 0; ud.weaponscale = 100; ud.textscale = 100; ud.config.CheckForUpdates = 1; if (g_rtsNamePtr == NULL) Bstrcpy(ud.rtsname, G_DefaultRtsFile()); Bstrcpy(szPlayerName, "Duke"); Bstrcpy(ud.ridecule[0], "An inspiration for birth control."); Bstrcpy(ud.ridecule[1], "You're gonna die for that!"); Bstrcpy(ud.ridecule[2], "It hurts to be you."); Bstrcpy(ud.ridecule[3], "Lucky son of a bitch."); Bstrcpy(ud.ridecule[4], "Hmmm... payback time."); Bstrcpy(ud.ridecule[5], "You bottom dwelling scum sucker."); Bstrcpy(ud.ridecule[6], "Damn, you're ugly."); Bstrcpy(ud.ridecule[7], "Ha ha ha... wasted!"); Bstrcpy(ud.ridecule[8], "You suck!"); Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); // JBF 20031211 CONFIG_SetDefaultKeys((const char (*)[MAXGAMEFUNCLEN])keydefaults); memset(ud.config.MouseFunctions, -1, sizeof(ud.config.MouseFunctions)); for (i=0; i<MAXMOUSEBUTTONS; i++) { ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]); CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse); if (i>=4) continue; ud.config.MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]); CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse); } memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions)); for (i=0; i<MAXMOUSEAXES; i++) { ud.config.MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE; CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse); ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2]); ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i*2+1]); CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][0], 0, controldevice_mouse); CONTROL_MapDigitalAxis(i, ud.config.MouseDigitalFunctions[i][1], 1, controldevice_mouse); ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]); CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse); } CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY; memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions)); for (i=0; i<MAXJOYBUTTONSANDHATS; i++) { ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]); ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]); CONTROL_MapButton(ud.config.JoystickFunctions[i][0], i, 0, controldevice_joystick); CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick); } memset(ud.config.JoystickDigitalFunctions, -1, sizeof(ud.config.JoystickDigitalFunctions)); for (i=0; i<MAXJOYAXES; i++) { ud.config.JoystickAnalogueScale[i] = DEFAULTJOYSTICKANALOGUESCALE; ud.config.JoystickAnalogueDead[i] = DEFAULTJOYSTICKANALOGUEDEAD; ud.config.JoystickAnalogueSaturate[i] = DEFAULTJOYSTICKANALOGUESATURATE; CONTROL_SetAnalogAxisScale(i, ud.config.JoystickAnalogueScale[i], controldevice_joystick); ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2]); ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(joystickdigitaldefaults[i*2+1]); CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][0], 0, controldevice_joystick); CONTROL_MapDigitalAxis(i, ud.config.JoystickDigitalFunctions[i][1], 1, controldevice_joystick); ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(joystickanalogdefaults[i]); CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick); } }
void G_DoCheats(void) { int32_t ch, i, j, k=0, weapon; static int32_t vol1inited=0; char consolecheat = 0; // JBF 20030914 if (osdcmd_cheatsinfo_stat.cheatnum != -1) { if (ud.player_skill == 4) { P_DoQuote(QUOTE_CHEATS_DISABLED, g_player[myconnectindex].ps); osdcmd_cheatsinfo_stat.cheatnum = -1; return; } // JBF 20030914 k = osdcmd_cheatsinfo_stat.cheatnum; osdcmd_cheatsinfo_stat.cheatnum = -1; consolecheat = 1; } if (VOLUMEONE && !vol1inited) { // change "scotty###" to "scotty##" uint32_t const warpend = Bstrlen(CheatStrings[2]); if (strcmp(&CheatStrings[2][warpend-3], "###") == 0) CheatStrings[2][warpend-1] = '\0'; Bstrcpy(CheatStrings[6], "<RESERVED>"); vol1inited = 1; } if (consolecheat && numplayers < 2 && ud.recstat == 0) goto FOUNDCHEAT; if (g_player[myconnectindex].ps->gm & (MODE_TYPE|MODE_MENU)) return; if (g_player[myconnectindex].ps->cheat_phase == 1) { while (KB_KeyWaiting()) { ch = Btolower(KB_GetCh()); if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) { g_player[myconnectindex].ps->cheat_phase = 0; // P_DoQuote(QUOTE_46,g_player[myconnectindex].ps); return; } cheatbuf[cheatbuflen++] = (int8_t) ch; // This assertion is not obvious, but it should hold because of the // cheat string matching logic below. Bassert(cheatbuflen < (signed)sizeof(cheatbuf)); cheatbuf[cheatbuflen] = 0; // KB_ClearKeysDown(); for (k=0; k < NUMCHEATCODES; k++) { for (j = 0; j<cheatbuflen; j++) { if (cheatbuf[j] == CheatStrings[k][j] || (CheatStrings[k][j] == '#' && ch >= '0' && ch <= '9')) { if (CheatStrings[k][j+1] == 0) goto FOUNDCHEAT; if (j == cheatbuflen-1) return; } else break; } } g_player[myconnectindex].ps->cheat_phase = 0; return; FOUNDCHEAT: i = VM_OnEventWithReturn(EVENT_ACTIVATECHEAT, g_player[myconnectindex].ps->i, myconnectindex, k); if (k != CHEAT_COMEGETSOME) // Users are not allowed to interfere with TX's debugging cheat. k = i; { switch (k) { case CHEAT_WEAPONS: j = 0; if (VOLUMEONE) j = 6; for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++) { P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); g_player[myconnectindex].ps->gotweapon |= (1<<weapon); } P_DoQuote(QUOTE_CHEAT_ALL_WEAPONS, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_INVENTORY: G_CheatGetInv(); P_DoQuote(QUOTE_CHEAT_ALL_INV, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_KEYS: g_player[myconnectindex].ps->got_access = 7; KB_FlushKeyboardQueue(); P_DoQuote(QUOTE_CHEAT_ALL_KEYS, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_DEBUG: g_Debug = 1-g_Debug; G_DumpDebugInfo(); Bsprintf(tempbuf, "Gamevars dumped to log"); G_AddUserQuote(tempbuf); Bsprintf(tempbuf, "Map dumped to debug.map"); G_AddUserQuote(tempbuf); end_cheat(); break; case CHEAT_CLIP: ud.noclip = !ud.noclip; P_DoQuote(QUOTE_CHEAT_NOCLIP-!ud.noclip, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_RESERVED2: g_player[myconnectindex].ps->player_par = 0; g_player[myconnectindex].ps->gm = MODE_EOL; end_cheat(); return; case CHEAT_ALLEN: P_DoQuote(QUOTE_CHEAT_ALLEN, g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_ClearKeyDown(sc_N); return; case CHEAT_CORNHOLIO: case CHEAT_KROZ: case CHEAT_COMEGETSOME: { const int32_t pi = g_player[myconnectindex].ps->i; ud.god = 1-ud.god; if (ud.god) { pus = 1; pub = 1; sprite[pi].cstat = 257; actor[pi].t_data[0] = 0; actor[pi].t_data[1] = 0; actor[pi].t_data[2] = 0; actor[pi].t_data[3] = 0; actor[pi].t_data[4] = 0; actor[pi].t_data[5] = 0; sprite[pi].hitag = 0; sprite[pi].lotag = 0; sprite[pi].pal = g_player[myconnectindex].ps->palookup; if (k != CHEAT_COMEGETSOME) { P_DoQuote(QUOTE_CHEAT_GODMODE_ON, g_player[myconnectindex].ps); } else { Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Come Get Some!"); S_PlaySound(DUKE_GETWEAPON2); P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); G_CheatGetInv(); for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++) g_player[myconnectindex].ps->gotweapon |= (1<<weapon); for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++) P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); g_player[myconnectindex].ps->got_access = 7; } } else { sprite[pi].extra = g_player[myconnectindex].ps->max_player_health; actor[pi].extra = -1; g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health; P_DoQuote(QUOTE_CHEAT_GODMODE_OFF, g_player[myconnectindex].ps); } sprite[pi].extra = g_player[myconnectindex].ps->max_player_health; actor[pi].extra = 0; if (k != CHEAT_COMEGETSOME) g_player[myconnectindex].ps->dead_flag = 0; end_cheat(); return; } case CHEAT_STUFF: j = 0; if (VOLUMEONE) j = 6; for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++) g_player[myconnectindex].ps->gotweapon |= (1<<weapon); for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS-j; weapon++) P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps); // P_DoQuote(QUOTE_21,g_player[myconnectindex].ps); g_player[myconnectindex].ps->inven_icon = ICON_FIRSTAID; end_cheat(); return; case CHEAT_SCOTTY: case CHEAT_SKILL: if (k == CHEAT_SCOTTY) { i = Bstrlen(CheatStrings[k])-3+VOLUMEONE; if (!consolecheat) { // JBF 20030914 int16_t volnume, levnume; if (VOLUMEALL) { volnume = cheatbuf[i] - '0'; levnume = (cheatbuf[i+1] - '0')*10+(cheatbuf[i+2]-'0'); } else { volnume = cheatbuf[i] - '0'; levnume = cheatbuf[i+1] - '0'; } volnume--; levnume--; if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 || levnume >= MAXLEVELS || MapInfo[volnume *MAXLEVELS+levnume].filename == NULL) { end_cheat(); return; } ud.m_volume_number = ud.volume_number = volnume; ud.m_level_number = ud.level_number = levnume; } else { // JBF 20030914 ud.m_volume_number = ud.volume_number = osdcmd_cheatsinfo_stat.volume; ud.m_level_number = ud.level_number = osdcmd_cheatsinfo_stat.level; } } else { if (!consolecheat) { i = Bstrlen(CheatStrings[k])-1; ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1'; } else { ud.m_player_skill = ud.player_skill = osdcmd_cheatsinfo_stat.volume; } } /*if (numplayers > 1 && g_netServer) Net_NewGame(ud.m_volume_number,ud.m_level_number); else*/ g_player[myconnectindex].ps->gm |= MODE_RESTART; end_cheat(); return; case CHEAT_COORDS: #ifdef USE_OPENGL if (++ud.coords >= 3) ud.coords = 0; #else if (++ud.coords >= 2) ud.coords = 0; #endif end_cheat(); return; case CHEAT_VIEW: if (g_player[myconnectindex].ps->over_shoulder_on) g_player[myconnectindex].ps->over_shoulder_on = 0; else { g_player[myconnectindex].ps->over_shoulder_on = 1; CAMERADIST = 0; CAMERACLOCK = totalclock; } // P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_TIME: // P_DoQuote(QUOTE_21,g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_UNLOCK: if (VOLUMEONE) return; for (i=numsectors-1; i>=0; i--) //Unlock { j = sector[i].lotag; if (j == -1 || j == 32767) continue; if ((j & 0x7fff) > 2) { if (j&(0xffff-16384)) sector[i].lotag &= (0xffff-16384); G_OperateSectors(i, g_player[myconnectindex].ps->i); } } G_OperateForceFields(g_player[myconnectindex].ps->i, -1); P_DoQuote(QUOTE_CHEAT_UNLOCK, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_CASHMAN: ud.cashman = 1-ud.cashman; KB_ClearKeyDown(sc_N); g_player[myconnectindex].ps->cheat_phase = 0; return; case CHEAT_ITEMS: G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_SHOWMAP: // SHOW ALL OF THE MAP TOGGLE; ud.showallmap = !ud.showallmap; for (i=0; i<(MAXSECTORS>>3); i++) show2dsector[i] = ud.showallmap*255; P_DoQuote(ud.showallmap ? QUOTE_SHOW_MAP_ON : QUOTE_SHOW_MAP_OFF, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_TODD: if (NAM) { Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], g_NAMMattCheatQuote); P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); } else { P_DoQuote(QUOTE_CHEAT_TODD, g_player[myconnectindex].ps); } end_cheat(); return; case CHEAT_RATE: if (ud.tickrate++ > 2) ud.tickrate = 0; end_cheat(); return; case CHEAT_BETA: P_DoQuote(QUOTE_CHEAT_BETA, g_player[myconnectindex].ps); KB_ClearKeyDown(sc_H); end_cheat(); return; case CHEAT_HYPER: g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = 399; g_player[myconnectindex].ps->inv_amount[GET_HEATS] = 1200; P_DoQuote(QUOTE_CHEAT_STEROIDS, g_player[myconnectindex].ps); end_cheat(); return; case CHEAT_MONSTERS: { const char *s [] ={ "On", "Off", "On (2)" }; if (++g_noEnemies == 3) g_noEnemies = 0; Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]); P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); end_cheat(); return; } case CHEAT_RESERVED: case CHEAT_RESERVED3: ud.eog = 1; g_player[myconnectindex].ps->player_par = 0; g_player[myconnectindex].ps->gm |= MODE_EOL; KB_FlushKeyboardQueue(); return; default: end_cheat(); return; } } } } else { if (KB_KeyPressed((uint8_t) CheatKeys[0]))
int32_t loadsetup(const char *fn) { BFILE *fp; #define VL 1024 char val[VL]; int32_t i; if ((fp = Bfopen(fn, "rt")) == NULL) return -1; if (readconfig(fp, "forcesetup", val, VL) > 0) { if (atoi_safe(val) != 0) forcesetup = 1; else forcesetup = 0; } if (readconfig(fp, "fullscreen", val, VL) > 0) { if (atoi_safe(val) != 0) fullscreen = 1; else fullscreen = 0; } if (readconfig(fp, "resolution", val, VL) > 0) { i = atoi_safe(val) & 0x0f; if ((unsigned)i<13) { xdimgame = xdim2d = vesares[i][0]; ydimgame = ydim2d = vesares[i][1]; } } if (readconfig(fp, "2dresolution", val, VL) > 0) { i = atoi_safe(val) & 0x0f; if ((unsigned)i<13) { xdim2d = vesares[i][0]; ydim2d = vesares[i][1]; } } if (readconfig(fp, "xdim2d", val, VL) > 0) xdim2d = atoi_safe(val); if (readconfig(fp, "ydim2d", val, VL) > 0) ydim2d = atoi_safe(val); if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = atoi_safe(val); if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = atoi_safe(val); // if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (atoi_safe(val) & 0x0f) << 4; // if (readconfig(fp, "music", val, VL) > 0) { if (atoi_safe(val) != 0) option[2] = 1; else option[2] = 0; } // if (readconfig(fp, "mouse", val, VL) > 0) { if (atoi_safe(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) bppgame = atoi_safe(val); if (readconfig(fp, "vsync", val, VL) > 0) vsync = !!atoi_safe(val); if (readconfig(fp, "editorgridextent", val, VL) > 0) { int32_t tmp = atoi_safe(val); editorgridextent = clamp(tmp, 65536, BXY_MAX); } if (readconfig(fp, "grid", val, VL) > 0) { grid = atoi_safe(val); default_grid = grid; autogrid = (grid==9); grid = clamp(grid, 0, 8); } #ifdef POLYMER if (readconfig(fp, "rendmode", val, VL) > 0) { i = atoi_safe(val); glrendmode = i; } #endif if (readconfig(fp, "vid_gamma", val, VL) > 0) vid_gamma = clampd(Bstrtod(val, NULL), 0.0, 10.0); if (readconfig(fp, "vid_brightness", val, VL) > 0) vid_brightness = clampd(Bstrtod(val, NULL), 0.0, 10.0); if (readconfig(fp, "vid_contrast", val, VL) > 0) vid_contrast = clampd(Bstrtod(val, NULL), 0.0, 10.0); #ifdef RENDERTYPEWIN if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = atoi_safe(val); #endif #ifdef USE_OPENGL if (readconfig(fp, "usemodels", val, VL) > 0) usemodels = !!atoi_safe(val); if (readconfig(fp, "usehightile", val, VL) > 0) usehightile = !!atoi_safe(val); if (readconfig(fp, "lazytileselector", val, VL) > 0) g_lazy_tileselector = !!atoi_safe(val); glusetexcache = -1; if (readconfig(fp, "glusetexcache", val, VL) > 0) { glusetexcache = clamp(atoi_safe(val), 0, 2); } if (readconfig(fp, "glusememcache", val, VL) > 0) { glusememcache = !!atoi_safe(val); } if (readconfig(fp, "gltexfiltermode", val, VL) > 0) { gltexfiltermode = atoi_safe(val); } if (readconfig(fp, "glanisotropy", val, VL) > 0) { glanisotropy = atoi_safe(val); } if (readconfig(fp, "r_downsize", val, VL) > 0) { r_downsize = atoi_safe(val); r_downsize = clamp(r_downsize, 0, 5); r_downsizevar = r_downsize; } if (readconfig(fp, "r_texcompr", val, VL) > 0) glusetexcompr = !!atoi_safe(val); if (readconfig(fp, "r_shadescale", val, VL) > 0) shadescale = clampd(Bstrtod(val, NULL), 0.0, 10.0); if (readconfig(fp, "r_usenewshading", val, VL) > 0) r_usenewshading = clamp(atoi_safe(val), 0, 2); #endif if (readconfig(fp, "r_usenewaspect", val, VL) > 0) r_usenewaspect = !!atoi_safe(val); #ifndef RENDERTYPEWIN if (readconfig(fp, "r_screenxy", val, VL) > 0) { r_screenxy = clamp(atoi_safe(val), 0, 9999); if (r_screenxy/100==0 || r_screenxy%100==0) r_screenxy = 403; } #endif if (readconfig(fp, "gameexecutable", val, VL) > 0) Bstrcpy(game_executable, val); // option[0] = 1; // vesa all the way... // option[1] = 1; // sound all the way... // option[4] = 0; // no multiplayer // option[5] = 0; #if 1 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); #endif #ifdef RENDERTYPEWIN if (readconfig(fp, "windowpositioning", val, VL) > 0) windowpos = atoi_safe(val); windowx = -1; if (readconfig(fp, "windowposx", val, VL) > 0) windowx = atoi_safe(val); windowy = -1; if (readconfig(fp, "windowposy", val, VL) > 0) windowy = atoi_safe(val); #endif 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); if (readconfig(fp, "mousenavigation", val, VL) > 0) unrealedlook = !!atoi_safe(val); if (readconfig(fp, "mousenavigationaccel", val, VL) > 0) pk_uedaccel = atoi_safe(val); if (readconfig(fp, "quickmapcycling", val, VL) > 0) quickmapcycling = !!atoi_safe(val); if (readconfig(fp, "sideview_reversehorizrot", val, VL) > 0) sideview_reversehrot = !!atoi_safe(val); if (readconfig(fp, "revertCTRL", val, VL) > 0) revertCTRL = !!atoi_safe(val); if (readconfig(fp, "scrollamount", val, VL) > 0) scrollamount = atoi_safe(val); if (readconfig(fp, "turnaccel", val, VL) > 0) pk_turnaccel = atoi_safe(val); if (readconfig(fp, "turndecel", val, VL) > 0) pk_turndecel = atoi_safe(val); if (readconfig(fp, "autosavesec", val, VL) > 0) autosave = max(0, atoi_safe(val)); if (readconfig(fp, "autocorruptchecksec", val, VL) > 0) autocorruptcheck = max(0, atoi_safe(val)); if (readconfig(fp, "corruptcheck_noalreadyrefd", val, VL) > 0) corruptcheck_noalreadyrefd = !!atoi_safe(val); if (readconfig(fp, "fixmaponsave_sprites", val, VL) > 0) fixmaponsave_sprites = !!atoi_safe(val); if (readconfig(fp, "keeptexturestretch", val, VL) > 0) keeptexturestretch = !!atoi_safe(val); if (readconfig(fp, "showheightindicators", val, VL) > 0) showheightindicators = clamp(atoi_safe(val), 0, 2); if (readconfig(fp, "showambiencesounds", val, VL) > 0) showambiencesounds = clamp(atoi_safe(val), 0, 2); if (readconfig(fp, "autogray", val, VL) > 0) autogray = !!atoi_safe(val); // if (readconfig(fp, "showinnergray", val, VL) > 0) // showinnergray = !!atoi_safe(val); if (readconfig(fp, "graphicsmode", val, VL) > 0) graphicsmode = clamp(atoi_safe(val), 0, 2); if (readconfig(fp, "samplerate", val, VL) > 0) MixRate = clamp(atoi_safe(val), 8000, 48000); if (readconfig(fp, "ambiencetoggle", val, VL) > 0) AmbienceToggle = !!atoi_safe(val); if (readconfig(fp, "parlock", val, VL) > 0) ParentalLock = !!atoi_safe(val); if (readconfig(fp, "osdtryscript", val, VL) > 0) m32_osd_tryscript = !!atoi_safe(val); for (i=0; i<256; i++) remap[i]=i; remapinit=1; if (readconfig(fp, "remap", val, VL) > 0) { char *p=val; int32_t v1,v2; while (*p) { if (!sscanf(p,"%x",&v1))break; if ((p=strchr(p,'-'))==0)break; p++; if (!sscanf(p,"%x",&v2))break; remap[v1]=v2; initprintf("Remap %X key to %X\n",v1,v2); if ((p=strchr(p,','))==0)break; p++; } } // load m32script history for (i=0; i<SCRIPTHISTSIZ; i++) { Bsprintf(val, "hist%d", i); if (readconfig(fp, val, val, VL) <= 0) break; scripthist[i] = Bstrdup(val); } scripthistend = i; // copy script history into OSD history for (i=0; i<min(scripthistend, OSD_HISTORYDEPTH); i++) { Bstrncpyz(osdhistorybuf[i], scripthist[scripthistend-1-i], OSD_EDITLENGTH+1); osdhistorysize++; osdhistorytotal++; } scripthistend %= SCRIPTHISTSIZ; Bfclose(fp); return 0; }
int Bcorrectfilename(char *filename, int removefn) { #ifdef _WIN32 int r, trailslash=0; #endif char path[256]="", fn[64]="", scratch[256], *ptr, *ptr2, ch; char cwd[256], *cwdp = cwd; char *tokarr[64]; int ntok=0, i, j; int grpmode = 0; if (!Bstrncasecmp(filename,"GRP:",4)) { grpmode = 1; for (ptr=filename; *ptr; ptr++) if (*ptr == '\\') *ptr = '/'; } #ifdef _WIN32 if (!grpmode) { // Windows uses backslashes so translate all unix-like forwardslashes for (ptr=filename; *ptr; ptr++) if (*ptr == '/') *ptr = '\\'; if (*(ptr-1) == '\\') trailslash = 1; r = GetFullPathName(filename, 256, path, &ptr); if (r > 256) return -1; if (r == 0) return -1; if (!trailslash && removefn && ptr) *ptr=0; if (trailslash) { if (path[ strlen(path) - 1 ] != '\\') strcat(path, "\\"); } for (ptr=path; *ptr; ptr++) if (*ptr == '\\') *ptr = '/'; strcpy(filename,path); } else { #endif #ifndef _WIN32 if (!grpmode) { Bgetcwd(cwd, 256); Bstrcat(cwd, "/"); } else { #endif cwd[0] = '/'; cwd[1] = 0; #ifndef _WIN32 } #endif ptr2 = filename; if (grpmode) { ptr2 += 3; if (ptr2[1] != '/') *ptr2 = '/'; else ptr2++; } if (removefn) { ptr = Bstrrchr(ptr2, '/'); if (ptr) ptr[1] = 0; else if (!grpmode) ptr2[0] = 0; } // now we have all the bits and pieces, clean it all up scratch[0] = 0; if (ptr2[0] != '/') { // relative path, which means prepend the current dir to the path Bstrcat(scratch, cwdp); } Bstrcat(scratch, ptr2); ptr2 = scratch; while ((ptr = Bstrtoken(ptr2==scratch?scratch:NULL,"/",&ptr2,1)) != NULL) { if (!Bstrcmp(ptr,".")) continue; else if (!Bstrcmp(ptr,"..")) { if (ntok>0) ntok--; } else { tokarr[ntok++] = ptr; } } ptr2 = filename; if (grpmode) { Bstrcpy(filename,"GRP:"); ptr2 += 4; } else filename[0] = 0; *(ptr2++) = '/'; for (i=0; i<ntok; i++) { ptr = tokarr[i]; if (i>0) *(ptr2++) = '/'; while (*ptr) *(ptr2++) = *(ptr++); } if (removefn) if (*(ptr2-1) != '/') *(ptr2++) = '/'; *(ptr2) = 0; #ifdef _WIN32 } #endif return 0; }