diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 65e017bdc3..7a6748fdc7 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -185,6 +185,9 @@ static const char *KeyConfCommands[] = "clearplayerclasses" }; +static TArray StoredStartupSets; +static bool RunningStoredStartups; + // CODE -------------------------------------------------------------------- IMPLEMENT_CLASS (DWaitingCommand) @@ -537,6 +540,18 @@ void ResetButtonStates () } } +void C_ExecStoredSets() +{ + assert(!RunningStoredStartups); + RunningStoredStartups = true; + for (unsigned i = 0; i < StoredStartupSets.Size(); ++i) + { + C_DoCommand(StoredStartupSets[i]); + } + StoredStartupSets.Clear(); + RunningStoredStartups = false; +} + void C_DoCommand (const char *cmd, int keynum) { FConsoleCommand *com; @@ -612,7 +627,22 @@ void C_DoCommand (const char *cmd, int keynum) if ( (com = FindNameInHashTable (Commands, beg, len)) ) { - if (gamestate != GS_STARTUP || ParsingKeyConf || + if (gamestate == GS_STARTUP && !RunningStoredStartups && + len == 3 && strnicmp(beg, "set", 3) == 0) + { + // Save setting of unknown cvars for later, in case a loaded wad has a + // CVARINFO that defines it. + FCommandLine args(beg); + if (args.argc() > 1 && FindCVar(args[1], NULL) == NULL) + { + StoredStartupSets.Push(beg); + } + else + { + com->Run(args, players[consoleplayer].mo, keynum); + } + } + else if (gamestate != GS_STARTUP || ParsingKeyConf || (len == 3 && strnicmp (beg, "set", 3) == 0) || (len == 7 && strnicmp (beg, "logfile", 7) == 0) || (len == 9 && strnicmp (beg, "unbindall", 9) == 0) || @@ -657,12 +687,15 @@ void C_DoCommand (const char *cmd, int keynum) } else { // We don't know how to handle this command - char cmdname[64]; - size_t minlen = MIN (len, 63); - - memcpy (cmdname, beg, minlen); - cmdname[len] = 0; - Printf ("Unknown command \"%s\"\n", cmdname); + if (gamestate == GS_STARTUP && !RunningStoredStartups) + { + // Save it for later, in case a CVARINFO defines it. + StoredStartupSets.Push(beg); + } + else + { + Printf ("Unknown command \"%.*s\"\n", len, beg); + } } } } diff --git a/src/c_dispatch.h b/src/c_dispatch.h index f4518608df..b494005c72 100644 --- a/src/c_dispatch.h +++ b/src/c_dispatch.h @@ -42,6 +42,7 @@ class APlayerPawn; extern bool CheckCheatmode (bool printmsg = true); void C_ExecCmdLineParams (); +void C_ExecStoredSets(); // Add commands to the console as if they were typed in. Can handle wait // and semicolon-separated commands. This function may modify the source diff --git a/src/d_main.cpp b/src/d_main.cpp index 2ceec3926a..817d3b9ecc 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2273,6 +2273,8 @@ void D_DoomMain (void) execFiles = Args->GatherFiles ("-exec"); D_MultiExec (execFiles, true); + C_ExecCmdLineParams (); // [RH] do all +set commands on the command line + CopyFiles(allwads, pwads); // Since this function will never leave we must delete this array here manually. @@ -2288,7 +2290,8 @@ void D_DoomMain (void) // Now that wads are loaded, define mod-specific cvars. ParseCVarInfo(); - C_ExecCmdLineParams (); // [RH] do all +set commands on the command line + // Try setting previously unknown cvars again, as a CVARINFO may have made them known. + C_ExecStoredSets(); // [RH] Initialize localizable strings. GStrings.LoadStrings (false); diff --git a/src/g_level.cpp b/src/g_level.cpp index bff8b91715..5b89800c38 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1287,6 +1287,7 @@ void G_InitLevelLocals () level.teamdamage = teamdamage; level.flags = 0; level.flags2 = 0; + level.flags3 = 0; info = FindLevelInfo (level.MapName); @@ -1340,6 +1341,7 @@ void G_InitLevelLocals () level.clusterflags = clus ? clus->flags : 0; level.flags |= info->flags; level.flags2 |= info->flags2; + level.flags3 |= info->flags3; level.levelnum = info->levelnum; level.Music = info->Music; level.musicorder = info->musicorder; diff --git a/src/g_level.h b/src/g_level.h index 8e78361d2b..6e07b0c74f 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -216,6 +216,9 @@ enum ELevelFlags LEVEL2_ENDGAME = 0x20000000, // This is an epilogue level that cannot be quit. LEVEL2_NOAUTOSAVEHINT = 0x40000000, // tell the game that an autosave for this level does not need to be kept LEVEL2_FORGETSTATE = 0x80000000, // forget this map's state in a hub + + // More flags! + LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled }; @@ -285,6 +288,8 @@ struct level_info_t int sucktime; DWORD flags; DWORD flags2; + DWORD flags3; + FString Music; FString LevelName; SBYTE WallVertLight, WallHorizLight; @@ -398,6 +403,7 @@ struct FLevelLocals DWORD flags; DWORD flags2; + DWORD flags3; DWORD fadeto; // The color the palette fades to (usually black) DWORD outsidefog; // The fog for sectors with sky ceilings diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index b68408237a..c44f81ab22 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1190,6 +1190,9 @@ enum EMIType MITYPE_SETFLAG2, MITYPE_CLRFLAG2, MITYPE_SCFLAGS2, + MITYPE_SETFLAG3, + MITYPE_CLRFLAG3, + MITYPE_SCFLAGS3, MITYPE_COMPATFLAG, }; @@ -1275,6 +1278,7 @@ MapFlagHandlers[] = { "rememberstate", MITYPE_CLRFLAG2, LEVEL2_FORGETSTATE, 0 }, { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "spawnwithweaponraised", MITYPE_SETFLAG2, LEVEL2_PRERAISEWEAPON, 0 }, + { "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 }, { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 }, { "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 }, @@ -1372,6 +1376,20 @@ void FMapInfoParser::ParseMapDefinition(level_info_t &info) info.flags2 = (info.flags2 & handler->data2) | handler->data1; break; + case MITYPE_SETFLAG3: + info.flags3 |= handler->data1; + info.flags3 |= handler->data2; + break; + + case MITYPE_CLRFLAG3: + info.flags3 &= ~handler->data1; + info.flags3 |= handler->data2; + break; + + case MITYPE_SCFLAGS3: + info.flags3 = (info.flags3 & handler->data2) | handler->data1; + break; + case MITYPE_COMPATFLAG: { int set = 1; diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index a738a5aad7..7a11a28650 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -1215,7 +1215,11 @@ public: if(Scaled) { if(cx != 0 || cy != 0) + { screen->VirtualToRealCoords(dcx, dcy, tmp, tmp, script->resW, script->resH, true); + if (cx == 0) dcx = 0; + if (cy == 0) dcy = 0; + } if(cr != 0 || cb != 0 || clearDontDraw) screen->VirtualToRealCoords(dcr, dcb, tmp, tmp, script->resW, script->resH, true); screen->VirtualToRealCoords(dx, dy, w, h, script->resW, script->resH, true); diff --git a/src/menu/listmenu.cpp b/src/menu/listmenu.cpp index 53b4fee225..402c1d5e96 100644 --- a/src/menu/listmenu.cpp +++ b/src/menu/listmenu.cpp @@ -300,7 +300,12 @@ void FListMenuItem::DrawSelector(int xofs, int yofs, FTextureID tex) if ((DMenu::MenuTime%8) < 6) { screen->DrawText(ConFont, OptionSettings.mFontColorSelection, - mXpos + xofs, mYpos + yofs, "\xd", DTA_Clean, true, TAG_DONE); + (mXpos + xofs - 160) * CleanXfac + screen->GetWidth() / 2, + (mYpos + yofs - 100) * CleanYfac + screen->GetHeight() / 2, + "\xd", + DTA_CellX, 8 * CleanXfac, + DTA_CellY, 8 * CleanYfac, + TAG_DONE); } } else diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 3b0c7be255..cad1f16fa6 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -970,10 +970,12 @@ CCMD (dump3df) fixed_t height=ffloors[i]->top.plane->ZatPoint(CenterSpot(sector)); fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(CenterSpot(sector)); + IGNORE_FORMAT_PRE Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", i, height / 65536., ffloors[i]->top.model->sectornum, bheight / 65536., ffloors[i]->bottom.model->sectornum, ffloors[i]->flags, ffloors[i]->alpha, (ffloors[i]->flags&FF_EXISTS)? "Exists":"", (ffloors[i]->flags&FF_DYNAMIC)? "Dynamic":""); + IGNORE_FORMAT_POST } } } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e005c3c674..2ea64f26ea 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2393,7 +2393,7 @@ void FBehavior::LoadScriptsDirectory () int size = LittleLong(scripts.dw[1]); if (size >= 6) { - int script_num = LittleShort(scripts.w[4]); + int script_num = LittleShort(scripts.sw[4]); ScriptPtr *ptr = const_cast(FindScript(script_num)); if (ptr != NULL) { @@ -7496,22 +7496,9 @@ scriptwait: break; case PCD_PRINTBINARY: -#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6)))) || defined(__clang__) -#define HAS_DIAGNOSTIC_PRAGMA -#endif -#ifdef HAS_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic push -#ifdef __clang__ -#pragma GCC diagnostic ignored "-Wformat-invalid-specifier" -#else -#pragma GCC diagnostic ignored "-Wformat=" -#endif -#pragma GCC diagnostic ignored "-Wformat-extra-args" -#endif + IGNORE_FORMAT_PRE work.AppendFormat ("%B", STACK(1)); -#ifdef HAS_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic pop -#endif + IGNORE_FORMAT_POST --sp; break; diff --git a/src/p_map.cpp b/src/p_map.cpp index 0b86aa41e6..456db2d0f7 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4279,7 +4279,7 @@ CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &CameraZ, sector_t *&CameraSector) { - fixed_t distance = (fixed_t)(chase_dist * FRACUNIT); + fixed_t distance = (fixed_t)(clamp(chase_dist, 0, 30000) * FRACUNIT); angle_t angle = (t1->angle - ANG180) >> ANGLETOFINESHIFT; angle_t pitch = (angle_t)(t1->pitch) >> ANGLETOFINESHIFT; FTraceResults trace; @@ -4289,7 +4289,7 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera vy = FixedMul(finecosine[pitch], finesine[angle]); vz = finesine[pitch]; - sz = t1->z - t1->floorclip + t1->height + (fixed_t)(chase_height * FRACUNIT); + sz = t1->z - t1->floorclip + t1->height + (fixed_t)(clamp(chase_height, -1000, 1000) * FRACUNIT); if (Trace(t1->x, t1->y, sz, t1->Sector, vx, vy, vz, distance, 0, 0, NULL, trace) && diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 6993508390..904c76c1b3 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -965,7 +965,7 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool noabsolute, int *pfak *pfakecontrast = 0; } - if (!foggy) // Don't do relative lighting in foggy sectors + if (!foggy || level.flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors { if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0) { diff --git a/src/posix/cocoa/i_joystick.cpp b/src/posix/cocoa/i_joystick.cpp index a3bc1c0fa3..29f98fcd18 100644 --- a/src/posix/cocoa/i_joystick.cpp +++ b/src/posix/cocoa/i_joystick.cpp @@ -739,6 +739,11 @@ IOKitJoystickManager* s_joystickManager; void I_StartupJoysticks() { + if (NULL != s_joystickManager) + { + return; + } + // HID Manager API is available on 10.5 (Darwin 9.x) or newer if (darwinVersion.major >= 9) @@ -750,6 +755,7 @@ void I_StartupJoysticks() void I_ShutdownJoysticks() { delete s_joystickManager; + s_joystickManager = NULL; } void I_GetJoysticks( TArray< IJoystickConfig* >& sticks ) diff --git a/src/zstring.h b/src/zstring.h index 1736f34212..0104020fa7 100644 --- a/src/zstring.h +++ b/src/zstring.h @@ -47,6 +47,24 @@ #define PRINTFISH(x) #endif +#ifdef __clang__ +#define IGNORE_FORMAT_PRE \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wformat-invalid-specifier\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") +#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))) +#define IGNORE_FORMAT_PRE \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wformat=\"") \ + _Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"") +#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop") +#else +#define IGNORE_FORMAT_PRE +#define IGNORE_FORMAT_POST +#endif + + struct FStringData { unsigned int Len; // Length of string, excluding terminating null