// // Write the header for a savegame // void P_WriteSaveGameHeader(char *description) { char name[VERSIONSIZE]; int i; for (i = 0; description[i] != '\0'; i++) saveg_write8(description[i]); for (; i < SAVESTRINGSIZE; i++) saveg_write8(0); memset(name, 0, sizeof(name)); strcpy(name, PACKAGE_SAVEGAMEVERSIONSTRING); for (i = 0; i < VERSIONSIZE; i++) saveg_write8(name[i]); saveg_write8(gameskill); saveg_write8(gameepisode); if (M_StringCompare(mapnum, "E1M4B")) saveg_write8(10); else if (M_StringCompare(mapnum, "E1M8B")) saveg_write8(11); else saveg_write8(gamemap); saveg_write8(gamemission); saveg_write8((leveltime >> 16) & 0xFF); saveg_write8((leveltime >> 8) & 0xFF); saveg_write8(leveltime & 0xFF); }
void HU_Init(void) { int i; int j; int lump; char buffer[9]; // load the heads-up font j = HU_FONTSTART; for (i = 0; i < HU_FONTSIZE; i++) { M_snprintf(buffer, 9, "STCFN%.3d", j++); hu_font[i] = W_CacheLumpName(buffer, PU_STATIC); } tempscreen = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); if ((lump = W_CheckNumForName("MEDIA0")) >= 0) healthpatch = W_CacheLumpNum(lump, PU_CACHE); if ((lump = W_CheckNumForName("PSTRA0")) >= 0) berserkpatch = W_CacheLumpNum(lump, PU_CACHE); else berserkpatch = healthpatch; if ((lump = W_CheckNumForName("ARM1A0")) >= 0) greenarmorpatch = W_CacheLumpNum(lump, PU_CACHE); if ((lump = W_CheckNumForName("ARM2A0")) >= 0) bluearmorpatch = W_CacheLumpNum(lump, PU_CACHE); ammopic[am_clip].patch = HU_LoadHUDAmmoPatch(am_clip); ammopic[am_shell].patch = HU_LoadHUDAmmoPatch(am_shell); if (gamemode != shareware) ammopic[am_cell].patch = HU_LoadHUDAmmoPatch(am_cell); ammopic[am_misl].patch = HU_LoadHUDAmmoPatch(am_misl); keypic[it_bluecard].patch = HU_LoadHUDKeyPatch(it_bluecard); keypic[it_yellowcard].patch = HU_LoadHUDKeyPatch(hacx ? it_yellowskull : it_yellowcard); keypic[it_redcard].patch = HU_LoadHUDKeyPatch(it_redcard); if (gamemode != shareware) { keypic[it_blueskull].patch = HU_LoadHUDKeyPatch(it_blueskull); keypic[it_yellowskull].patch = HU_LoadHUDKeyPatch(it_yellowskull); keypic[it_redskull].patch = HU_LoadHUDKeyPatch(it_redskull); } if ((lump = W_CheckNumForName("STDISK")) >= 0) stdisk = W_CacheLumpNum(lump, PU_CACHE); s_STSTR_BEHOLD2 = M_StringCompare(s_STSTR_BEHOLD, STSTR_BEHOLD2); if (!M_StringCompare(playername, playername_default)) s_GOTMEDINEED = s_GOTMEDINEED2; HU_AltInit(); HU_SetTranslucency(); }
int M_CheckParmsWithArgs(char *check1, char *check2, int num_args, int start) { int i; for (i = start; i < myargc - num_args; i++) if (M_StringCompare(check1, myargv[i]) || M_StringCompare(check2, myargv[i])) return i; return 0; }
// Parses float values in the configuration file static float ParseFloatParameter(char *strparm, int valuealiastype) { for (int i = 0; *valuealiases[i].text; i++) if (M_StringCompare(strparm, valuealiases[i].text) && valuealiastype == valuealiases[i].type) return (float)valuealiases[i].value; return (float)atof(strparm); }
// Parses integer values in the configuration file static int ParseIntParameter(char *strparm, int valuealiastype) { int parm = 0; for (int i = 0; *valuealiases[i].text; i++) if (M_StringCompare(strparm, valuealiases[i].text) && valuealiastype == valuealiases[i].type) return valuealiases[i].value; sscanf(strparm, "%10d", &parm); return parm; }
// // F_StartCast // static void F_StartCast(void) { firstevent = true; wipegamestate = GS_NONE; // force a screen wipe castnum = 0; caststate = &states[mobjinfo[castorder[castnum].type].seestate]; casttics = caststate->tics; castrot = 0; castdeath = false; castdeathflip = false; finalestage = F_STAGE_CAST; castframes = 0; castonmelee = 0; castattacking = false; if (!M_StringCompare(playername, playername_default)) s_CC_HERO = playername; S_ChangeMusic(mus_evil, true, false, false); }
dboolean SC_Compare(char *text) { return M_StringCompare(text, sc_String); }
void HU_Init(void) { int j = HU_FONTSTART; int lump; char buffer[9]; // load the heads-up font for (int i = 0; i < HU_FONTSIZE; i++) { M_snprintf(buffer, sizeof(buffer), "STCFN%.3d", j++); hu_font[i] = W_CacheLumpName(buffer); caretcolor = FindDominantColor(hu_font[i]); } if (W_CheckMultipleLumps("STTMINUS") > 1 || W_CheckMultipleLumps("STTNUM0") == 1) minuspatch = W_CacheLumpName("STTMINUS"); tempscreen = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); if ((lump = W_CheckNumForName("MEDIA0")) >= 0) healthpatch = W_CacheLumpNum(lump); if ((lump = W_CheckNumForName("PSTRA0")) >= 0) berserkpatch = W_CacheLumpNum(lump); else berserkpatch = healthpatch; if ((lump = W_CheckNumForName("ARM1A0")) >= 0) greenarmorpatch = W_CacheLumpNum(lump); if ((lump = W_CheckNumForName("ARM2A0")) >= 0) bluearmorpatch = W_CacheLumpNum(lump); ammopic[am_clip].patch = HU_LoadHUDAmmoPatch(am_clip); ammopic[am_shell].patch = HU_LoadHUDAmmoPatch(am_shell); if (gamemode != shareware) ammopic[am_cell].patch = HU_LoadHUDAmmoPatch(am_cell); ammopic[am_misl].patch = HU_LoadHUDAmmoPatch(am_misl); keypic[it_bluecard].patch = HU_LoadHUDKeyPatch(it_bluecard); keypic[it_yellowcard].patch = HU_LoadHUDKeyPatch(hacx ? it_yellowskull : it_yellowcard); keypic[it_redcard].patch = HU_LoadHUDKeyPatch(it_redcard); if (gamemode != shareware) { keypic[it_blueskull].patch = HU_LoadHUDKeyPatch(it_blueskull); keypic[it_yellowskull].patch = HU_LoadHUDKeyPatch(it_yellowskull); keypic[it_redskull].patch = HU_LoadHUDKeyPatch(it_redskull); } if ((lump = W_CheckNumForName(M_CheckParm("-cdrom") ? "STCDROM" : "STDISK")) >= 0) { stdisk = W_CacheLumpNum(lump); stdiskwidth = SHORT(stdisk->width); } s_STSTR_BEHOLD2 = M_StringCompare(s_STSTR_BEHOLD, STSTR_BEHOLD2); if (!M_StringCompare(playername, playername_default)) s_GOTMEDINEED = s_GOTMEDINEED2; HU_AltInit(); HU_SetTranslucency(); }
// // M_LoadCVARs // void M_LoadCVARs(char *filename) { int bindcount = 0; int cvarcount = 0; int statcount = 0; // read the file in, overriding any set defaults FILE *file = fopen(filename, "r"); if (!file) { M_CheckCVARs(); M_SaveCVARs(); C_Output("Created <b>%s</b>.", filename); cvarsloaded = true; return; } for (int i = 0; i < MAXALIASES; i++) { aliases[i].name[0] = '\0'; aliases[i].string[0] = '\0'; } // Clear all default controls before reading them from config file if (!togglingvanilla && M_StringEndsWith(filename, PACKAGE_CONFIG)) { for (int i = 0; *actions[i].action; i++) { if (actions[i].keyboard1) *(int *)actions[i].keyboard1 = 0; if (actions[i].keyboard2) *(int *)actions[i].keyboard2 = 0; if (actions[i].mouse1) *(int *)actions[i].mouse1 = -1; if (actions[i].gamepad1) *(int *)actions[i].gamepad1 = 0; if (actions[i].gamepad2) *(int *)actions[i].gamepad2 = 0; } for (int i = 0; i < NUMKEYS; i++) keyactionlist[i][0] = '\0'; } while (!feof(file)) { char cvar[64] = ""; char value[256] = ""; if (fscanf(file, "%63s %255[^\n]\n", cvar, value) != 2) continue; if (cvar[0] == ';') continue; if (M_StringCompare(cvar, "bind")) { bind_cmd_func2("bind", value); bindcount++; continue; } else if (M_StringCompare(cvar, "alias")) { if (!togglingvanilla) alias_cmd_func2("alias", value); continue; } // Strip off trailing non-printable characters (\r characters from DOS text files) while (*value && !isprint((unsigned char)value[strlen(value) - 1])) value[strlen(value) - 1] = '\0'; if (togglingvanilla) { char *value_free = uncommify(value); C_ValidateInput(M_StringJoin(cvar, " ", value_free, NULL)); free(value_free); continue; } // Find the setting in the list for (int i = 0; i < arrlen(cvars); i++) { char *s; if (!M_StringCompare(cvar, cvars[i].name)) continue; // not this one if (M_StringStartsWith(cvar, "stat_")) statcount++; else cvarcount++; // parameter found switch (cvars[i].type) { case DEFAULT_STRING: s = M_StringDuplicate(value + 1); s[strlen(s) - 1] = '\0'; *(char **)cvars[i].location = s; break; case DEFAULT_INT: { char *value_free = uncommify(value); M_StringCopy(value, value_free, sizeof(value)); *(int *)cvars[i].location = ParseIntParameter(value, cvars[i].valuealiastype); free(value_free); break; } case DEFAULT_INT_UNSIGNED: { char *value_free = uncommify(value); M_StringCopy(value, value_free, sizeof(value)); sscanf(value, "%10u", (unsigned int *)cvars[i].location); free(value_free); break; } case DEFAULT_INT_PERCENT: { char *value_free = uncommify(value); M_StringCopy(value, value_free, sizeof(value)); s = M_StringDuplicate(value); if (*s && s[strlen(s) - 1] == '%') s[strlen(s) - 1] = '\0'; *(int *)cvars[i].location = ParseIntParameter(s, cvars[i].valuealiastype); free(value_free); break; } case DEFAULT_FLOAT: { char *value_free = uncommify(value); M_StringCopy(value, value_free, sizeof(value)); *(float *)cvars[i].location = ParseFloatParameter(value, cvars[i].valuealiastype); free(value_free); break; } case DEFAULT_FLOAT_PERCENT: { char *value_free = uncommify(value); M_StringCopy(value, value_free, sizeof(value)); s = M_StringDuplicate(value); if (*s && s[strlen(s) - 1] == '%') s[strlen(s) - 1] = '\0'; *(float *)cvars[i].location = ParseFloatParameter(s, cvars[i].valuealiastype); free(value_free); break; } case DEFAULT_OTHER: *(char **)cvars[i].location = M_StringDuplicate(value); break; } // finish break; } } fclose(file); if (!togglingvanilla) { char *cvarcount_str = commify(cvarcount); char *statcount_str = commify(statcount); char *bindcount_str = commify(bindcount); C_Output("Loaded %s CVARs and %s player stats from <b>%s</b>.", cvarcount_str, statcount_str, filename); C_Output("Bound %s actions to the keyboard, mouse and gamepad.", bindcount_str); M_CheckCVARs(); cvarsloaded = true; free(cvarcount_str); free(statcount_str); free(bindcount_str); } }
static void M_CheckCVARs(void) { if (alwaysrun != false && alwaysrun != true) alwaysrun = alwaysrun_default; if (am_allmapcdwallcolor < am_allmapcdwallcolor_min || am_allmapcdwallcolor > am_allmapcdwallcolor_max) am_allmapcdwallcolor = am_allmapcdwallcolor_default; if (am_allmapfdwallcolor < am_allmapfdwallcolor_min || am_allmapfdwallcolor > am_allmapfdwallcolor_max) am_allmapfdwallcolor = am_allmapfdwallcolor_default; if (am_allmapwallcolor < am_allmapwallcolor_min || am_allmapwallcolor > am_allmapwallcolor_max) am_allmapwallcolor = am_allmapwallcolor_default; if (am_backcolor < am_backcolor_min || am_backcolor > am_backcolor_max) am_backcolor = am_backcolor_default; if (am_cdwallcolor < am_cdwallcolor_min || am_cdwallcolor > am_cdwallcolor_max) am_cdwallcolor = am_cdwallcolor_default; if (am_crosshaircolor < am_crosshaircolor_min || am_crosshaircolor > am_crosshaircolor_max) am_crosshaircolor = am_crosshaircolor_default; if (am_external != false && am_external != true) am_external = am_external_default; if (am_fdwallcolor < am_fdwallcolor_min || am_fdwallcolor > am_fdwallcolor_max) am_fdwallcolor = am_fdwallcolor_default; if (am_grid != false && am_grid != true) am_grid = am_grid_default; if (am_gridcolor < am_gridcolor_min || am_gridcolor > am_gridcolor_max) am_gridcolor = am_gridcolor_default; if (am_markcolor < am_markcolor_min || am_markcolor > am_markcolor_max) am_markcolor = am_markcolor_default; if (am_path != false && am_path != true) am_path = am_path_default; if (am_pathcolor < am_pathcolor_min || am_pathcolor > am_pathcolor_max) am_pathcolor = am_pathcolor_default; if (am_playercolor < am_playercolor_min || am_playercolor > am_playercolor_max) am_playercolor = am_playercolor_default; if (am_rotatemode != false && am_rotatemode != true) am_rotatemode = am_rotatemode_default; if (am_teleportercolor < am_teleportercolor_min || am_teleportercolor > am_teleportercolor_max) am_teleportercolor = am_teleportercolor_default; if (am_thingcolor < am_thingcolor_min || am_thingcolor > am_thingcolor_max) am_thingcolor = am_thingcolor_default; if (am_tswallcolor < am_tswallcolor_min || am_tswallcolor > am_tswallcolor_max) am_tswallcolor = am_tswallcolor_default; if (am_wallcolor < am_wallcolor_min || am_wallcolor > am_wallcolor_max) am_wallcolor = am_wallcolor_default; if (autoaim != false && autoaim != true) autoaim = autoaim_default; if (autoload != false && autoload != true) autoload = autoload_default; if (autotilt != false && autotilt != true) autotilt = autotilt_default; if (autouse != false && autouse != true) autouse = autouse_default; if (centerweapon != false && centerweapon != true) centerweapon = centerweapon_default; if (con_backcolor < con_backcolor_min || con_backcolor > con_backcolor_max) con_backcolor = con_backcolor_default; if (con_obituaries != false && con_obituaries != true) con_obituaries = con_obituaries_default; if (con_timestamps != false && con_timestamps != true) con_timestamps = con_timestamps_default; if (crosshair != crosshair_none && crosshair != crosshair_cross && crosshair != crosshair_dot) crosshair = crosshair_default; if (crosshaircolor < crosshaircolor_min || crosshaircolor > crosshaircolor_max) crosshaircolor = crosshaircolor_default; episode = BETWEEN(episode_min, episode, episode_max); expansion = BETWEEN(expansion_min, expansion, expansion_max); if (facebackcolor < facebackcolor_min || facebackcolor > facebackcolor_max) facebackcolor = facebackcolor_default; if (gp_analog != false && gp_analog != true) gp_analog = gp_analog_default; gp_deadzone_left = BETWEENF(gp_deadzone_left_min, gp_deadzone_left, gp_deadzone_left_max); I_SetGamepadLeftDeadZone(); gp_deadzone_right = BETWEENF(gp_deadzone_right_min, gp_deadzone_right, gp_deadzone_right_max); I_SetGamepadRightDeadZone(); if (gp_invertyaxis != false && gp_invertyaxis != true) gp_invertyaxis = gp_invertyaxis_default; gp_sensitivity = BETWEEN(gp_sensitivity_min, gp_sensitivity, gp_sensitivity_max); I_SetGamepadSensitivity(); if (gp_swapthumbsticks != false && gp_swapthumbsticks != true) gp_swapthumbsticks = gp_swapthumbsticks_default; if (gp_thumbsticks < gp_thumbsticks_min || gp_thumbsticks > gp_thumbsticks_max) gp_thumbsticks = gp_thumbsticks_default; gp_vibrate_barrels = BETWEEN(gp_vibrate_barrels_min, gp_vibrate_barrels, gp_vibrate_barrels_max); gp_vibrate_damage = BETWEEN(gp_vibrate_damage_min, gp_vibrate_damage, gp_vibrate_damage_max); gp_vibrate_weapons = BETWEEN(gp_vibrate_weapons_min, gp_vibrate_damage, gp_vibrate_weapons_max); if (infighting != false && infighting != true) infighting = infighting_default; if (infiniteheight != false && infiniteheight != true) infiniteheight = infiniteheight_default; if (!*iwadfolder || M_StringCompare(iwadfolder, iwadfolder_default) || !M_FolderExists(iwadfolder)) D_InitIWADFolder(); if (m_acceleration != false && m_acceleration != true) m_acceleration = m_acceleration_default; if (m_doubleclick_use != false && m_doubleclick_use != true) m_doubleclick_use = m_doubleclick_use_default; if (m_invertyaxis != false && m_invertyaxis != true) m_invertyaxis = m_invertyaxis_default; if (m_novertical != false && m_novertical != true) m_novertical = m_novertical_default; m_sensitivity = BETWEEN(m_sensitivity_min, m_sensitivity, m_sensitivity_max); if (messages != false && messages != true) messages = messages_default; if (mouselook != false && mouselook != true) mouselook = mouselook_default; movebob = BETWEEN(movebob_min, movebob, movebob_max); if (!*playername) playername = M_StringDuplicate(playername_default); if (r_althud != false && r_althud != true) r_althud = r_althud_default; r_berserkintensity = BETWEEN(r_berserkintensity_min, r_berserkintensity, r_berserkintensity_max); if (r_blood != r_blood_none && r_blood != r_blood_red && r_blood != r_blood_all) r_blood = r_blood_default; r_bloodsplats_max = BETWEEN(r_bloodsplats_max_min, r_bloodsplats_max, r_bloodsplats_max_max); if (r_bloodsplats_translucency != false && r_bloodsplats_translucency != true) r_bloodsplats_translucency = r_bloodsplats_translucency_default; if (r_brightmaps != false && r_brightmaps != true) r_brightmaps = r_brightmaps_default; r_color = BETWEEN(r_color_min, r_color, r_color_max); if (r_corpses_color != false && r_corpses_color != true) r_corpses_color = r_corpses_color_default; if (r_corpses_mirrored != false && r_corpses_mirrored != true) r_corpses_mirrored = r_corpses_mirrored_default; if (r_corpses_moreblood != false && r_corpses_moreblood != true) r_corpses_moreblood = r_corpses_moreblood_default; if (r_corpses_nudge != false && r_corpses_nudge != true) r_corpses_nudge = r_corpses_nudge_default; if (r_corpses_slide != false && r_corpses_slide != true) r_corpses_slide = r_corpses_slide_default; if (r_corpses_smearblood != false && r_corpses_smearblood != true) r_corpses_smearblood = r_corpses_smearblood_default; if (r_detail != r_detail_low && r_detail != r_detail_high) r_detail = r_detail_default; if (r_diskicon != false && r_diskicon != true) r_diskicon = r_diskicon_default; if (r_dither != false && r_dither != true) r_dither = r_dither_default; if (r_fixmaperrors != false && r_fixmaperrors != true) r_fixmaperrors = r_fixmaperrors_default; if (r_fixspriteoffsets != false && r_fixspriteoffsets != true) r_fixspriteoffsets = r_fixspriteoffsets_default; if (r_floatbob != false && r_floatbob != true) r_floatbob = r_floatbob_default; r_fov = BETWEEN(r_fov_min, r_fov, r_fov_max); r_gamma = BETWEENF(r_gamma_min, r_gamma, r_gamma_max); I_SetGamma(r_gamma); if (r_homindicator != false && r_homindicator != true) r_homindicator = r_homindicator_default; if (r_hud != false && r_hud != true) r_hud = r_hud_default; if (r_hud_translucency != false && r_hud_translucency != true) r_hud_translucency = r_hud_translucency_default; if (r_liquid_bob != false && r_liquid_bob != true) r_liquid_bob = r_liquid_bob_default; if (r_liquid_clipsprites != false && r_liquid_clipsprites != true) r_liquid_clipsprites = r_liquid_clipsprites_default; if (r_liquid_current != false && r_liquid_current != true) r_liquid_current = r_liquid_current_default; if (r_liquid_lowerview != false && r_liquid_lowerview != true) r_liquid_lowerview = r_liquid_lowerview_default; if (r_liquid_swirl != false && r_liquid_swirl != true) r_liquid_swirl = r_liquid_swirl_default; if (r_mirroredweapons != false && r_mirroredweapons != true) r_mirroredweapons = r_mirroredweapons_default; if (r_playersprites != false && r_playersprites != true) r_playersprites = r_playersprites_default; if (r_rockettrails != false && r_rockettrails != true) r_rockettrails = r_rockettrails_default; r_screensize = BETWEEN(r_screensize_min, r_screensize, r_screensize_max); if (r_shadows != false && r_shadows != true) r_shadows = r_shadows_default; if (r_shadows_translucency != false && r_shadows_translucency != true) r_shadows_translucency = r_shadows_translucency_default; if (r_shake_barrels != false && r_shake_barrels != true) r_shake_barrels = r_shake_barrels_default; r_shake_damage = BETWEEN(r_shake_damage_min, r_shake_damage, r_shake_damage_max); if (r_skycolor != r_skycolor_none && (r_skycolor < r_skycolor_min || r_skycolor > r_skycolor_max)) r_skycolor = r_skycolor_default; if (r_textures != false && r_textures != true) r_textures = r_textures_default; if (r_translucency != false && r_translucency != true) r_translucency = r_translucency_default; s_channels = BETWEEN(s_channels_min, s_channels, s_channels_max); s_musicvolume = BETWEEN(s_musicvolume_min, s_musicvolume, s_musicvolume_max); musicVolume = (s_musicvolume * 31 + 50) / 100; if (s_randommusic != false && s_randommusic != true) s_randommusic = s_randommusic_default; if (s_randompitch != false && s_randompitch != true) s_randompitch = s_randompitch_default; s_sfxvolume = BETWEEN(s_sfxvolume_min, s_sfxvolume, s_sfxvolume_max); sfxVolume = (s_sfxvolume * 31 + 50) / 100; if (s_stereo != false && s_stereo != true) s_stereo = s_stereo_default; savegame = BETWEEN(savegame_min, savegame, savegame_max); skilllevel = BETWEEN(skilllevel_min, skilllevel, skilllevel_max); stillbob = BETWEEN(stillbob_min, stillbob, stillbob_max); if (tossdrop != false && tossdrop != true) tossdrop = tossdrop_default; turbo = BETWEEN(turbo_min, turbo, turbo_max); if (units != units_imperial && units != units_metric) units = units_default; version = version_default; vid_capfps = BETWEEN(vid_capfps_min, vid_capfps, vid_capfps_max); vid_display = MAX(vid_display_min, vid_display); if (vid_fullscreen != false && vid_fullscreen != true) vid_fullscreen = vid_fullscreen_default; vid_motionblur = BETWEEN(vid_motionblur_min, vid_motionblur, vid_motionblur_max); if (vid_pillarboxes != false && vid_pillarboxes != true) vid_pillarboxes = vid_pillarboxes_default; if (!M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d) #if defined(__MACOSX__) && !M_StringCompare(vid_scaleapi, vid_scaleapi_metal) #endif && !M_StringCompare(vid_scaleapi, vid_scaleapi_opengl) #if !defined(_WIN32) && !M_StringCompare(vid_scaleapi, vid_scaleapi_opengles) && !M_StringCompare(vid_scaleapi, vid_scaleapi_opengles2) #endif && !M_StringCompare(vid_scaleapi, vid_scaleapi_software)) vid_scaleapi = vid_scaleapi_default; if (!M_StringCompare(vid_scalefilter, vid_scalefilter_linear) && !M_StringCompare(vid_scalefilter, vid_scalefilter_nearest) && !M_StringCompare(vid_scalefilter, vid_scalefilter_nearest_linear)) vid_scalefilter = vid_scalefilter_default; if (vid_vsync != false && vid_vsync != true) vid_vsync = vid_vsync_default; if (vid_widescreen != false && vid_widescreen != true) vid_widescreen = vid_widescreen_default; if (vid_widescreen) { returntowidescreen = true; vid_widescreen = false; r_screensize = r_screensize_max; } else r_hud = true; weaponbob = BETWEEN(weaponbob_min, weaponbob, weaponbob_max); if (weaponbounce != false && weaponbounce != true) weaponbounce = weaponbounce_default; if (weaponrecoil != false && weaponrecoil != true) weaponrecoil = weaponrecoil_default; if (wipe != false && wipe != true) wipe = wipe_default; }
// // M_SaveCVARs // void M_SaveCVARs(void) { int numaliases = 0; int p; FILE *file; if (!cvarsloaded || vanilla || togglingvanilla) return; p = M_CheckParmWithArgs("-config", 1, 1); if (!(file = fopen((p ? myargv[p + 1] : packageconfig), "w"))) return; // can't write the file, but don't complain if (returntowidescreen) vid_widescreen = true; for (int i = 0; i < arrlen(cvars); i++) { if (!*cvars[i].name) { fputs("\n", file); continue; } if (cvars[i].name[0] == ';') { fputs(cvars[i].name, file); continue; } // Print the name fprintf(file, "%s ", cvars[i].name); // Print the value switch (cvars[i].type) { case DEFAULT_INT: { dboolean flag = false; int v = *(int *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = commify(v); fputs(v_str, file); free(v_str); } break; } case DEFAULT_INT_UNSIGNED: { char *cvars_location_free = commify(*(unsigned int *)cvars[i].location); fputs(cvars_location_free, file); free(cvars_location_free); } break; case DEFAULT_INT_PERCENT: { dboolean flag = false; int v = *(int *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = commify(v); fprintf(file, "%s%%", v_str); free(v_str); } break; } case DEFAULT_FLOAT: { dboolean flag = false; float v = *(float *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { static char buf[128]; int len; M_snprintf(buf, sizeof(buf), "%.2f", v); len = (int)strlen(buf); if (len >= 2 && buf[len - 1] == '0' && buf[len - 2] == '0') buf[len - 1] = '\0'; fputs(buf, file); } break; } case DEFAULT_FLOAT_PERCENT: { dboolean flag = false; float v = *(float *)cvars[i].location; for (int j = 0; *valuealiases[j].text; j++) if (v == valuealiases[j].value && cvars[i].valuealiastype == valuealiases[j].type) { fputs(valuealiases[j].text, file); flag = true; break; } if (!flag) { char *v_str = striptrailingzero(v, 1); fprintf(file, "%s%%", v_str); free(v_str); } break; } case DEFAULT_STRING: if (M_StringCompare(*(char **)cvars[i].location, EMPTYVALUE)) fputs(*(char **)cvars[i].location, file); else fprintf(file, "%s%s%s", (M_StringCompare(cvars[i].name, "version") ? "" : "\""), *(char **)cvars[i].location, (M_StringCompare(cvars[i].name, "version") ? "" : "\"")); break; case DEFAULT_OTHER: fputs(*(char **)cvars[i].location, file); break; } fputs("\n", file); } fputs("\n; bound controls\n", file); for (int i = 0; *actions[i].action; i++) { if (actions[i].keyboard1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].keyboard1, keyboardcontrol); if (actions[i].keyboard2) SaveBindByValue(file, actions[i].action, *(int *)actions[i].keyboard2, keyboardcontrol); if (actions[i].mouse1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].mouse1, mousecontrol); if (actions[i].gamepad1) SaveBindByValue(file, actions[i].action, *(int *)actions[i].gamepad1, gamepadcontrol); if (actions[i].gamepad2) SaveBindByValue(file, actions[i].action, *(int *)actions[i].gamepad2, gamepadcontrol); } for (int i = 0; controls[i].type; i++) if (controls[i].type == keyboardcontrol && keyactionlist[controls[i].value][0]) SaveBind(file, controls[i].control, keyactionlist[controls[i].value]); else if (controls[i].type == mousecontrol && mouseactionlist[controls[i].value][0]) SaveBind(file, controls[i].control, mouseactionlist[controls[i].value]); for (int i = 0; i < MAXALIASES; i++) if (*aliases[i].name) numaliases++; if (numaliases) { fputs("\n; aliases\n", file); for (int i = 0; i < MAXALIASES; i++) if (*aliases[i].name) fprintf(file, "alias %s \"%s\"\n", aliases[i].name, aliases[i].string); } fclose(file); if (returntowidescreen) vid_widescreen = false; }
static void AddSpriteLump(lumpinfo_t *lump) { sprite_frame_t *sprite; int angle_num; int i = 0; static int MISFA0; static int MISFB0; dboolean ispackagewad = M_StringCompare(leafname(lump->wadfile->path), PACKAGE_WAD); if (!ValidSpriteLumpName(lump->name)) return; if (lump->wadfile->type == PWAD) { if (M_StringCompare(lump->name, "SHT2A0") && !BTSX) SHT2A0 = true; if (!ispackagewad) { MISFA0 += M_StringCompare(lump->name, "MISFA0"); MISFB0 += M_StringCompare(lump->name, "MISFB0"); while (*weaponsprites[i].spr1) { if (M_StringStartsWith(lump->name, weaponsprites[i].spr1) || (*weaponsprites[i].spr2 && M_StringStartsWith(lump->name, weaponsprites[i].spr2))) weaponinfo[i].altered = true; i++; } } if (M_StringCompare(lump->name, "BAR1A0") || M_StringCompare(lump->name, "BAR1B0")) { states[S_BAR3].nextstate = S_BAR2; mobjinfo[MT_BARREL].frames = 2; } } if (ispackagewad && M_StringStartsWith(lump->name, "MISF") && ((MISFA0 >= 2 || MISFB0 >= 2) || hacx || FREEDOOM)) return; // first angle sprite = FindSpriteFrame(lump->name, lump->name[4]); angle_num = lump->name[5] - '0'; if (!angle_num) { for (i = 0; i < 8; i++) sprite->angle_lumps[i] = lump; } else sprite->angle_lumps[angle_num - 1] = lump; // second angle // no second angle? if (lump->name[6] == '\0') return; sprite = FindSpriteFrame(lump->name, lump->name[6]); angle_num = lump->name[7] - '0'; if (!angle_num) { for (i = 0; i < 8; i++) sprite->angle_lumps[i] = lump; } else sprite->angle_lumps[angle_num - 1] = lump; }
// // W_AddFile // All files are optional, but at least one file must be // found (PWAD, if all required lumps are present). // Files with a .wad extension are wadlink files // with multiple lumps. // Other files are single lumps with the base filename // for the lump name. wad_file_t *W_AddFile(char *filename, dboolean automatic) { wadinfo_t header; lumpindex_t i; int startlump; filelump_t *fileinfo; filelump_t *filerover; lumpinfo_t *filelumps; int numfilelumps; // open the file and add to directory wad_file_t *wad_file = W_OpenFile(filename); if (!wad_file) return NULL; M_StringCopy(wad_file->path, filename, sizeof(wad_file->path)); wad_file->freedoom = IsFreedoom(filename); if (!M_StringCompare(filename + strlen(filename) - 3, "wad")) { // single lump file // fraggle: Swap the filepos and size here. The WAD directory // parsing code expects a little-endian directory, so will swap // them back. Effectively we're constructing a "fake WAD directory" // here, as it would appear on disk. fileinfo = Z_Malloc(sizeof(filelump_t), PU_STATIC, NULL); fileinfo->filepos = LONG(0); fileinfo->size = LONG(wad_file->length); // Name the lump after the base of the filename (without the // extension). ExtractFileBase(filename, fileinfo->name); numfilelumps = 1; } else { int length; // WAD file W_Read(wad_file, 0, &header, sizeof(header)); // Homebrew levels? if (strncmp(header.identification, "IWAD", 4) && strncmp(header.identification, "PWAD", 4)) I_Error("Wad file %s doesn't have IWAD or PWAD id\n", filename); wad_file->type = (!strncmp(header.identification, "IWAD", 4) ? IWAD : PWAD); header.numlumps = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); length = header.numlumps * sizeof(filelump_t); fileinfo = Z_Malloc(length, PU_STATIC, NULL); W_Read(wad_file, header.infotableofs, fileinfo, length); numfilelumps = header.numlumps; } // Increase size of numlumps array to accommodate the new file. filelumps = calloc(numfilelumps, sizeof(lumpinfo_t)); if (!filelumps) I_Error("Failed to allocate array for lumps from new file."); startlump = numlumps; numlumps += numfilelumps; lumpinfo = Z_Realloc(lumpinfo, numlumps * sizeof(lumpinfo_t *)); if (!lumpinfo) I_Error("Failed to increase lumpinfo[] array size."); filerover = fileinfo; for (i = startlump; i < numlumps; ++i) { lumpinfo_t *lump_p = &filelumps[i - startlump]; lump_p->wad_file = wad_file; lump_p->position = LONG(filerover->filepos); lump_p->size = LONG(filerover->size); lump_p->cache = NULL; strncpy(lump_p->name, filerover->name, 8); lumpinfo[i] = lump_p; ++filerover; } Z_Free(fileinfo); if (lumphash) { Z_Free(lumphash); lumphash = NULL; } C_Output("%s %s lump%s from %.4s file %s.", (automatic ? "Automatically added" : "Added"), commify(numlumps - startlump), (numlumps - startlump == 1 ? "" : "s"), header.identification, uppercase(filename)); return wad_file; }