From 82f7b439c889500ad2e8bececb8cebe595886381 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Apr 2015 10:59:07 +0300 Subject: [PATCH 01/20] Improved text pasting on OS X Support for UTF-8 and UTF-16 encodings should cover all cases of text pasting from clipboard --- src/posix/i_system.cpp | 44 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/posix/i_system.cpp b/src/posix/i_system.cpp index b3de61419..f87cf76ae 100644 --- a/src/posix/i_system.cpp +++ b/src/posix/i_system.cpp @@ -603,6 +603,15 @@ int I_FindAttr (findstate_t *fileinfo) #ifdef __APPLE__ static PasteboardRef s_clipboard; + +static CFDataRef GetPasteboardData(const PasteboardItemID itemID, const CFStringRef flavorType) +{ + CFDataRef data = NULL; + + const OSStatus result = PasteboardCopyItemFlavorData(s_clipboard, itemID, flavorType, &data); + + return noErr == result ? data : NULL; +} #endif // __APPLE__ // Clipboard support requires GTK+ @@ -688,35 +697,36 @@ FString I_GetFromClipboard (bool use_primary_selection) return FString(); } - CFArrayRef flavorTypeArray; - - if (0 != PasteboardCopyItemFlavors(s_clipboard, itemID, &flavorTypeArray)) + if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF8PlainText)) { - return FString(); + result = reinterpret_cast(CFDataGetBytePtr(data)); } - - const CFIndex flavorCount = CFArrayGetCount(flavorTypeArray); - - for (CFIndex flavorIndex = 0; flavorIndex < flavorCount; ++flavorIndex) + else if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF16PlainText)) { - const CFStringRef flavorType = static_cast( - CFArrayGetValueAtIndex(flavorTypeArray, flavorIndex)); +#ifdef __LITTLE_ENDIAN__ + static const CFStringEncoding ENCODING = kCFStringEncodingUTF16LE; +#else // __BIG_ENDIAN__ + static const CFStringEncoding ENCODING = kCFStringEncodingUTF16BE; +#endif // __LITTLE_ENDIAN__ - if (UTTypeConformsTo(flavorType, CFSTR("public.utf8-plain-text"))) + if (const CFStringRef utf16 = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, data, ENCODING)) { - CFDataRef flavorData; + const CFRange range = { 0, CFStringGetLength(utf16) }; + CFIndex bufferLength = 0; - if (0 == PasteboardCopyItemFlavorData(s_clipboard, itemID, flavorType, &flavorData)) + if (CFStringGetBytes(utf16, range, kCFStringEncodingUTF8, '?', false, NULL, 0, &bufferLength) > 0) { - result += reinterpret_cast(CFDataGetBytePtr(flavorData)); + UInt8* const buffer = reinterpret_cast(result.LockNewBuffer(bufferLength)); + + CFStringGetBytes(utf16, range, kCFStringEncodingUTF8, '?', false, buffer, bufferLength, NULL); + + result.UnlockBuffer(); } - CFRelease(flavorData); + CFRelease(utf16); } } - CFRelease(flavorTypeArray); - return result; #endif return ""; From ebd8f2410347477e774515a53ca402c64e765daa Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Apr 2015 11:39:49 +0300 Subject: [PATCH 02/20] Fixed compilation with OS X SDK 10.4 --- src/posix/cocoa/i_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 081466e87..545540b2f 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -128,6 +128,8 @@ enum kVK_UpArrow = 0x7E }; +static const NSOpenGLPixelFormatAttribute NSOpenGLPFAAllowOfflineRenderers = NSOpenGLPixelFormatAttribute(96); + #endif // prior to 10.5 From 7b8931292318c145ce34ec53d4ee8f6a3291274e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 5 Apr 2015 11:52:57 +0300 Subject: [PATCH 03/20] Fixed potential issue with read beyond buffer boundaries --- src/posix/i_system.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/posix/i_system.cpp b/src/posix/i_system.cpp index f87cf76ae..0a1b2f69a 100644 --- a/src/posix/i_system.cpp +++ b/src/posix/i_system.cpp @@ -699,7 +699,12 @@ FString I_GetFromClipboard (bool use_primary_selection) if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF8PlainText)) { - result = reinterpret_cast(CFDataGetBytePtr(data)); + const CFIndex bufferLength = CFDataGetLength(data); + char* const buffer = result.LockNewBuffer(bufferLength); + + memcpy(buffer, CFDataGetBytePtr(data), bufferLength); + + result.UnlockBuffer(); } else if (CFDataRef data = GetPasteboardData(itemID, kUTTypeUTF16PlainText)) { From a91997d12c41805421dd446fdd6a045b898857d9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Apr 2015 22:07:24 +0200 Subject: [PATCH 04/20] - fixed: Don't try to load autoload sections for empty section names. --- src/d_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index ab2459788..930b0f629 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2031,7 +2031,7 @@ static void AddAutoloadFiles(const char *group, const char *autoname) D_AddConfigWads (allwads, file); // Add group-specific wads - if (group != NULL) + if (group != NULL && group[0] != 0) { file = group; file += ".Autoload"; @@ -2039,7 +2039,7 @@ static void AddAutoloadFiles(const char *group, const char *autoname) } // Add IWAD-specific wads - if (autoname != NULL) + if (autoname != NULL && autoname[0] != 0) { file = autoname; file += ".Autoload"; From 62d036a63e12cdafb74ff617a5bd58444892284e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 5 Apr 2015 20:24:49 -0500 Subject: [PATCH 05/20] Added gametype-based filter - For when IWADs are too specific, filter by the base gametype too. - Minor small edits to the sndinfo.txt files so that zipdir will notice the changes, since it doesn't check path names when checking for file differences. --- src/resourcefiles/resourcefile.cpp | 35 ++++++++++++++++++ src/resourcefiles/resourcefile.h | 1 + .../{doom => game-doomchex}/sndinfo.txt | 1 + .../{heretic => game-heretic}/sndinfo.txt | 1 + .../filter/{hexen => game-hexen}/sndinfo.txt | 1 + .../{strife => game-strife}/acs/strfhelp.o | Bin .../{strife => game-strife}/loadacs.txt | 0 .../{strife => game-strife}/sndinfo.txt | 1 + 8 files changed, 40 insertions(+) rename wadsrc/static/filter/{doom => game-doomchex}/sndinfo.txt (99%) rename wadsrc/static/filter/{heretic => game-heretic}/sndinfo.txt (99%) rename wadsrc/static/filter/{hexen => game-hexen}/sndinfo.txt (99%) rename wadsrc/static/filter/{strife => game-strife}/acs/strfhelp.o (100%) rename wadsrc/static/filter/{strife => game-strife}/loadacs.txt (100%) rename wadsrc/static/filter/{strife => game-strife}/sndinfo.txt (99%) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index caeb1090f..d5ad659af 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -344,6 +344,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) // in the ini file use. We reduce the maximum lump concidered after // each one so that we don't risk refiltering already filtered lumps. DWORD max = NumLumps; + max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max); max -= FilterLumps(gameinfo.ConfigName, lumps, lumpsize, max); max -= FilterLumps(LumpFilterGroup, lumps, lumpsize, max); max -= FilterLumps(LumpFilterIWAD, lumps, lumpsize, max); @@ -406,6 +407,40 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, return end - start; } +//========================================================================== +// +// FResourceFile :: FilterLumpsByGameType +// +// Matches any lumps that match "filter/game-/*". Includes +// inclusive gametypes like Raven. +// +//========================================================================== + +int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, DWORD max) +{ + static const struct { int match; const char *name; } blanket[] = + { + { GAME_Raven, "game-Raven" }, + { GAME_DoomStrifeChex, "game-DoomStrifeChex" }, + { GAME_DoomChex, "game-DoomChex" }, + }; + if (type == 0) + { + return 0; + } + int count = 0; + for (int i = 0; i < countof(blanket); ++i) + { + if (type & blanket[i].match) + { + count += FilterLumps(blanket[i].name, lumps, lumpsize, max); + } + } + FString filter = "game-"; + filter += GameNames[type]; + return count + FilterLumps(filter, lumps, lumpsize, max); +} + //========================================================================== // // FResourceFile :: JunkLeftoverFilters diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index c62981ca7..e84967a24 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -72,6 +72,7 @@ private: DWORD FirstLump; int FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max); + int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, DWORD max); bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD max, DWORD &start, DWORD &end); void JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max); diff --git a/wadsrc/static/filter/doom/sndinfo.txt b/wadsrc/static/filter/game-doomchex/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/doom/sndinfo.txt rename to wadsrc/static/filter/game-doomchex/sndinfo.txt index 6028b11f0..c103f493c 100644 --- a/wadsrc/static/filter/doom/sndinfo.txt +++ b/wadsrc/static/filter/game-doomchex/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* DOOM SOUNDS */ diff --git a/wadsrc/static/filter/heretic/sndinfo.txt b/wadsrc/static/filter/game-heretic/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/heretic/sndinfo.txt rename to wadsrc/static/filter/game-heretic/sndinfo.txt index cb3fe1e73..b9f1fd7c3 100644 --- a/wadsrc/static/filter/heretic/sndinfo.txt +++ b/wadsrc/static/filter/game-heretic/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* HERETIC SOUNDS */ diff --git a/wadsrc/static/filter/hexen/sndinfo.txt b/wadsrc/static/filter/game-hexen/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/hexen/sndinfo.txt rename to wadsrc/static/filter/game-hexen/sndinfo.txt index 85d7a75dd..a1169dcb9 100644 --- a/wadsrc/static/filter/hexen/sndinfo.txt +++ b/wadsrc/static/filter/game-hexen/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* HEXEN SOUNDS */ diff --git a/wadsrc/static/filter/strife/acs/strfhelp.o b/wadsrc/static/filter/game-strife/acs/strfhelp.o similarity index 100% rename from wadsrc/static/filter/strife/acs/strfhelp.o rename to wadsrc/static/filter/game-strife/acs/strfhelp.o diff --git a/wadsrc/static/filter/strife/loadacs.txt b/wadsrc/static/filter/game-strife/loadacs.txt similarity index 100% rename from wadsrc/static/filter/strife/loadacs.txt rename to wadsrc/static/filter/game-strife/loadacs.txt diff --git a/wadsrc/static/filter/strife/sndinfo.txt b/wadsrc/static/filter/game-strife/sndinfo.txt similarity index 99% rename from wadsrc/static/filter/strife/sndinfo.txt rename to wadsrc/static/filter/game-strife/sndinfo.txt index 877bba50a..22f9b8356 100644 --- a/wadsrc/static/filter/strife/sndinfo.txt +++ b/wadsrc/static/filter/game-strife/sndinfo.txt @@ -1,3 +1,4 @@ + /****************************************************************************/ /* */ /* STRIFE SOUNDS */ From c36222d2ef6c61e5d1693130d6311ff90df41ac6 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 5 Apr 2015 21:40:53 -0500 Subject: [PATCH 06/20] Externalized default key bindings --- src/c_bind.cpp | 208 +++--------------- src/c_bind.h | 7 - src/d_main.cpp | 2 + src/gameconfigfile.cpp | 70 +++--- src/gameconfigfile.h | 1 + wadsrc/static/defbinds.txt | 103 +++++++++ .../static/filter/game-heretic/defbinds.txt | 3 + wadsrc/static/filter/game-hexen/defbinds.txt | 12 + wadsrc/static/filter/game-strife/defbinds.txt | 11 + 9 files changed, 191 insertions(+), 226 deletions(-) create mode 100644 wadsrc/static/defbinds.txt create mode 100644 wadsrc/static/filter/game-heretic/defbinds.txt create mode 100644 wadsrc/static/filter/game-hexen/defbinds.txt create mode 100644 wadsrc/static/filter/game-strife/defbinds.txt diff --git a/src/c_bind.cpp b/src/c_bind.cpp index 1a62469bc..0231820dc 100644 --- a/src/c_bind.cpp +++ b/src/c_bind.cpp @@ -43,158 +43,11 @@ #include "configfile.h" #include "i_system.h" #include "d_event.h" +#include "w_wad.h" #include #include -/* Default keybindings for Doom (and all other games) - */ -static const FBinding DefBindings[] = -{ - { "`", "toggleconsole" }, - { "1", "slot 1" }, - { "2", "slot 2" }, - { "3", "slot 3" }, - { "4", "slot 4" }, - { "5", "slot 5" }, - { "6", "slot 6" }, - { "7", "slot 7" }, - { "8", "slot 8" }, - { "9", "slot 9" }, - { "0", "slot 0" }, - { "[", "invprev" }, - { "]", "invnext" }, - { "mwheelleft", "invprev" }, - { "mwheelright", "invnext" }, - { "enter", "invuse" }, - { "-", "sizedown" }, - { "=", "sizeup" }, - { "ctrl", "+attack" }, - { "alt", "+strafe" }, - { "shift", "+speed" }, - { "space", "+use" }, - { "rightarrow", "+right" }, - { "leftarrow", "+left" }, - { "uparrow", "+forward" }, - { "downarrow", "+back" }, - { ",", "+moveleft" }, - { ".", "+moveright" }, - { "mouse1", "+attack" }, - { "mouse2", "+strafe" }, - { "mouse3", "+forward" }, - { "mouse4", "+speed" }, - { "capslock", "toggle cl_run" }, - { "f1", "menu_help" }, - { "f2", "menu_save" }, - { "f3", "menu_load" }, - { "f4", "menu_options" }, - { "f5", "menu_display" }, - { "f6", "quicksave" }, - { "f7", "menu_endgame" }, - { "f8", "togglemessages" }, - { "f9", "quickload" }, - { "f11", "bumpgamma" }, - { "f10", "menu_quit" }, - { "tab", "togglemap" }, - { "pause", "pause" }, - { "sysrq", "screenshot" }, - { "t", "messagemode" }, - { "\\", "+showscores" }, - { "f12", "spynext" }, - { "mwheeldown", "weapnext" }, - { "mwheelup", "weapprev" }, - - // Generic joystick buttons - { "joy1", "+attack" }, - { "joy2", "+strafe" }, - { "joy3", "+speed" }, - { "joy4", "+use" }, - - // Xbox 360 / PS2 controllers - { "pad_a", "+use" }, - { "pad_y", "+jump" }, - { "rtrigger", "+attack" }, - { "ltrigger", "+altattack" }, - { "lshoulder", "weapprev" }, - { "rshoulder", "weapnext" }, - { "dpadleft", "invprev" }, - { "dpadright", "invnext" }, - { "dpaddown", "invuse" }, - { "dpadup", "togglemap" }, - { "pad_start", "pause" }, - { "pad_back", "menu_main" }, - { "lthumb", "crouch" }, - { NULL, NULL } -}; - -static const FBinding DefRavenBindings[] = -{ - { "pgup", "+moveup" }, - { "ins", "+movedown" }, - { "home", "land" }, - { "pgdn", "+lookup" }, - { "del", "+lookdown" }, - { "end", "centerview" }, - { NULL, NULL } -}; - -static const FBinding DefHereticBindings[] = -{ - { "backspace", "use ArtiTomeOfPower" }, - { NULL, NULL } -}; - -static const FBinding DefHexenBindings[] = -{ - { "/", "+jump" }, - { "backspace", "invuseall" }, - { "\\", "use ArtiHealth" }, - { "0", "useflechette" }, - { "9", "use ArtiBlastRadius" }, - { "8", "use ArtiTeleport" }, - { "7", "use ArtiTeleportOther" }, - { "6", "use ArtiPork" }, - { "5", "use ArtiInvulnerability2" }, - { "scroll", "+showscores" }, - { NULL, NULL } -}; - -static const FBinding DefStrifeBindings[] = -{ - { "a", "+jump" }, - { "w", "showpop 1" }, - { "backspace", "invdrop" }, - { "z", "showpop 3" }, - { "k", "showpop 2" }, - { "q", "invquery" }, - { NULL, NULL } - // not done - // h - use health -}; - -static const FBinding DefAutomapBindings[] = -{ - { "f", "am_togglefollow" }, - { "g", "am_togglegrid" }, - { "p", "am_toggletexture" }, - { "m", "am_setmark" }, - { "c", "am_clearmarks" }, - { "0", "am_gobig" }, - { "rightarrow", "+am_panright" }, - { "leftarrow", "+am_panleft" }, - { "uparrow", "+am_panup" }, - { "downarrow", "+am_pandown" }, - { "-", "+am_zoomout" }, - { "=", "+am_zoomin" }, - { "kp-", "+am_zoomout" }, - { "kp+", "+am_zoomin" }, - { "mwheelup", "am_zoom 1.2" }, - { "mwheeldown", "am_zoom -1.2" }, - { NULL, NULL } -}; - - - const char *KeyNames[NUM_KEYS] = { // This array is dependant on the particular keyboard input @@ -452,21 +305,6 @@ void FKeyBindings::DoBind (const char *key, const char *bind) // //============================================================================= -void FKeyBindings::SetBinds(const FBinding *binds) -{ - while (binds->Key) - { - DoBind (binds->Key, binds->Bind); - binds++; - } -} - -//============================================================================= -// -// -// -//============================================================================= - void FKeyBindings::UnbindAll () { for (int i = 0; i < NUM_KEYS; ++i) @@ -785,29 +623,37 @@ CCMD (rebind) void C_BindDefaults () { - Bindings.SetBinds (DefBindings); + int lump, lastlump = 0; - if (gameinfo.gametype & (GAME_Raven|GAME_Strife)) + while ((lump = Wads.FindLump("DEFBINDS", &lastlump)) != -1) { - Bindings.SetBinds (DefRavenBindings); - } + FScanner sc(lump); - if (gameinfo.gametype == GAME_Heretic) - { - Bindings.SetBinds (DefHereticBindings); - } + while (sc.GetString()) + { + FKeyBindings *dest = &Bindings; + int key; - if (gameinfo.gametype == GAME_Hexen) - { - Bindings.SetBinds (DefHexenBindings); + // bind destination is optional and is the same as the console command + if (sc.Compare("bind")) + { + sc.MustGetString(); + } + else if (sc.Compare("doublebind")) + { + dest = &DoubleBindings; + sc.MustGetString(); + } + else if (sc.Compare("mapbind")) + { + dest = &AutomapBindings; + sc.MustGetString(); + } + key = GetConfigKeyFromName(sc.String); + sc.MustGetString(); + dest->SetBind(key, sc.String); + } } - - if (gameinfo.gametype == GAME_Strife) - { - Bindings.SetBinds (DefStrifeBindings); - } - - AutomapBindings.SetBinds(DefAutomapBindings); } CCMD(binddefaults) diff --git a/src/c_bind.h b/src/c_bind.h index 4c9edb2bb..394d313c9 100644 --- a/src/c_bind.h +++ b/src/c_bind.h @@ -42,19 +42,12 @@ class FCommandLine; void C_NameKeys (char *str, int first, int second); -struct FBinding -{ - const char *Key; - const char *Bind; -}; - class FKeyBindings { FString Binds[NUM_KEYS]; public: void PerformBind(FCommandLine &argv, const char *msg); - void SetBinds(const FBinding *binds); bool DoKey(event_t *ev); void ArchiveBindings(FConfigFile *F, const char *matchcmd = NULL); int GetKeysForCommand (const char *cmd, int *first, int *second); diff --git a/src/d_main.cpp b/src/d_main.cpp index 930b0f629..5dc5c7a78 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2324,6 +2324,8 @@ void D_DoomMain (void) allwads.ShrinkToFit(); SetMapxxFlag(); + GameConfig->DoKeySetup(gameinfo.ConfigName); + // Now that wads are loaded, define mod-specific cvars. ParseCVarInfo(); diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index deb870774..6cfd6456b 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -244,9 +244,6 @@ void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, vo void FGameConfigFile::MigrateOldConfig () { - // Set default key bindings. These will be overridden - // by the bindings in the config file if it exists. - C_SetDefaultBindings (); } void FGameConfigFile::DoGlobalSetup () @@ -400,41 +397,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename) ReadCVars (0); } - if (!bMigrating) - { - C_SetDefaultBindings (); - } - - strncpy (subsection, "Bindings", sublen); - if (SetSection (section)) - { - Bindings.UnbindAll(); - while (NextInSection (key, value)) - { - Bindings.DoBind (key, value); - } - } - - strncpy (subsection, "DoubleBindings", sublen); - if (SetSection (section)) - { - DoubleBindings.UnbindAll(); - while (NextInSection (key, value)) - { - DoubleBindings.DoBind (key, value); - } - } - - strncpy (subsection, "AutomapBindings", sublen); - if (SetSection (section)) - { - AutomapBindings.UnbindAll(); - while (NextInSection (key, value)) - { - AutomapBindings.DoBind (key, value); - } - } - strncpy (subsection, "ConsoleAliases", sublen); if (SetSection (section)) { @@ -455,6 +417,38 @@ void FGameConfigFile::DoGameSetup (const char *gamename) OkayToWrite = true; } +// Moved from DoGameSetup so that it can happen after wads are loaded +void FGameConfigFile::DoKeySetup(const char *gamename) +{ + static const struct { const char *label; FKeyBindings *bindings; } binders[] = + { + { "Bindings", &Bindings }, + { "DoubleBindings", &DoubleBindings }, + { "AutomapBindings", &AutomapBindings }, + }; + const char *key, *value; + + sublen = countof(section) - 1 - mysnprintf(section, countof(section), "%s.", gamename); + subsection = section + countof(section) - sublen - 1; + section[countof(section) - 1] = '\0'; + + C_SetDefaultBindings (); + + for (int i = 0; i < countof(binders); ++i) + { + strncpy(subsection, binders[i].label, sublen); + if (SetSection(section)) + { + FKeyBindings *bindings = binders[i].bindings; + bindings->UnbindAll(); + while (NextInSection(key, value)) + { + bindings->DoBind(key, value); + } + } + } +} + // Like DoGameSetup(), but for mod-specific cvars. // Called after CVARINFO has been parsed. void FGameConfigFile::DoModSetup(const char *gamename) diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 74376b583..55867eaf8 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -47,6 +47,7 @@ public: void DoGlobalSetup (); void DoGameSetup (const char *gamename); + void DoKeySetup (const char *gamename); void DoModSetup (const char *gamename); void ArchiveGlobalData (); void ArchiveGameData (const char *gamename); diff --git a/wadsrc/static/defbinds.txt b/wadsrc/static/defbinds.txt new file mode 100644 index 000000000..420d22432 --- /dev/null +++ b/wadsrc/static/defbinds.txt @@ -0,0 +1,103 @@ +/* Default keybindings for all games */ + +` toggleconsole +1 "slot 1" +2 "slot 2" +3 "slot 3" +4 "slot 4" +5 "slot 5" +6 "slot 6" +7 "slot 7" +8 "slot 8" +9 "slot 9" +0 "slot 0" +[ invprev +] invnext +mwheelleft invprev +mwheelright invnext +enter invuse +- sizedown += sizeup +ctrl +attack +alt +strafe +shift +speed +space +use +rightarrow +right +leftarrow +left +uparrow +forward +downarrow +back +, +moveleft +. +moveright +mouse1 +attack +mouse2 +strafe +mouse3 +forward +mouse4 +speed +capslock "toggle cl_run" +f1 menu_help +f2 menu_save +f3 menu_load +f4 menu_options +f5 menu_display +f6 quicksave +f7 menu_endgame +f8 togglemessages +f9 quickload +f11 bumpgamma +f10 menu_quit +tab togglemap +pause pause +sysrq screenshot +t messagemode +\ +showscores +f12 spynext +mwheeldown weapnext +mwheelup weapprev + +// Originally just for Heretic, Hexen, and Strife. +// I can't see why they shouldn't be for Doom or Chex either. +pgup +moveup +ins +movedown +home land +pgdn +lookup +del +lookdown +end centerview + +// Generic joystick buttons +joy1 +attack +joy2 +strafe +joy3 +speed +joy4 +use + +// Xbox 360 / PS2 controllers +pad_a +use +pad_y +jump +rtrigger +attack +ltrigger +altattack +lshoulder weapprev +rshoulder weapnext +dpadleft invprev +dpadright invnext +dpaddown invuse +dpadup togglemap +pad_start pause +pad_back menu_main +lthumb crouch + + +/* Default automap bindings */ +mapbind f am_togglefollow +mapbind g am_togglegrid +mapbind p am_toggletexture +mapbind m am_setmark +mapbind c am_clearmarks +mapbind 0 am_gobig +mapbind rightarrow +am_panright +mapbind leftarrow +am_panleft +mapbind uparrow +am_panup +mapbind downarrow +am_pandown +mapbind - +am_zoomout +mapbind = +am_zoomin +mapbind kp- +am_zoomout +mapbind kp+ +am_zoomin +mapbind mwheelup "am_zoom 1.2" +mapbind mwheeldown "am_zoom -1.2" diff --git a/wadsrc/static/filter/game-heretic/defbinds.txt b/wadsrc/static/filter/game-heretic/defbinds.txt new file mode 100644 index 000000000..ed820a378 --- /dev/null +++ b/wadsrc/static/filter/game-heretic/defbinds.txt @@ -0,0 +1,3 @@ +/* Default keybindings for Heretic */ + +backspace "use ArtiTomeOfPower" \ No newline at end of file diff --git a/wadsrc/static/filter/game-hexen/defbinds.txt b/wadsrc/static/filter/game-hexen/defbinds.txt new file mode 100644 index 000000000..58167f57e --- /dev/null +++ b/wadsrc/static/filter/game-hexen/defbinds.txt @@ -0,0 +1,12 @@ +/* Default keybindings for Hexen */ + +/ +jump +backspace invuseall +\ "use ArtiHealth" +0 useflechette +9 "use ArtiBlastRadius" +8 "use ArtiTeleport" +7 "use ArtiTeleportOther" +6 "use ArtiPork" +5 "use ArtiInvulnerability2" +scroll +showscores \ No newline at end of file diff --git a/wadsrc/static/filter/game-strife/defbinds.txt b/wadsrc/static/filter/game-strife/defbinds.txt new file mode 100644 index 000000000..9370896a0 --- /dev/null +++ b/wadsrc/static/filter/game-strife/defbinds.txt @@ -0,0 +1,11 @@ +/* Default keybindings for Strife */ + +a +jump +w "showpop 1" +backspace invdrop +z "showpop 3" +k "showpop 2" +q invquery + +; not done +; h - use health From b300cfaf62e60aef1b48548c406f46bbb4edaecd Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 5 Apr 2015 21:56:00 -0500 Subject: [PATCH 07/20] Remove old pre-INI config migration code - As if any of this matters now. It's not the 90s anymore. --- src/configfile.cpp | 16 ++-------- src/configfile.h | 5 ++- src/gameconfigfile.cpp | 69 +++++++----------------------------------- src/gameconfigfile.h | 4 --- 4 files changed, 16 insertions(+), 78 deletions(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 177c019fb..8792175f4 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -66,15 +66,13 @@ FConfigFile::FConfigFile () // //==================================================================== -FConfigFile::FConfigFile (const char *pathname, - void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), - void *userdata) +FConfigFile::FConfigFile (const char *pathname) { Sections = CurrentSection = NULL; LastSectionPtr = &Sections; CurrentEntry = NULL; ChangePathName (pathname); - LoadConfigFile (nosechandler, userdata); + LoadConfigFile (); OkayToWrite = true; FileExisted = true; } @@ -591,7 +589,7 @@ FConfigFile::FConfigEntry *FConfigFile::NewConfigEntry ( // //==================================================================== -void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata) +void FConfigFile::LoadConfigFile () { FILE *file = fopen (PathName, "r"); bool succ; @@ -605,14 +603,6 @@ void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FCo succ = ReadConfig (file); fclose (file); FileExisted = succ; - - if (!succ) - { // First valid line did not define a section - if (nosechandler != NULL) - { - nosechandler (PathName, this, userdata); - } - } } //==================================================================== diff --git a/src/configfile.h b/src/configfile.h index 25c366f01..34ab9d56b 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -41,8 +41,7 @@ class FConfigFile { public: FConfigFile (); - FConfigFile (const char *pathname, - void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata)=0, void *userdata=NULL); + FConfigFile (const char *pathname); FConfigFile (const FConfigFile &other); virtual ~FConfigFile (); @@ -70,7 +69,7 @@ public: const char *GetPathName () const { return PathName.GetChars(); } void ChangePathName (const char *path); - void LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata); + void LoadConfigFile (); bool WriteConfigFile () const; protected: diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 6cfd6456b..7e0ddc6a1 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -83,16 +83,10 @@ FGameConfigFile::FGameConfigFile () FString pathname; OkayToWrite = false; // Do not allow saving of the config before DoGameSetup() - bMigrating = false; bModSetup = false; pathname = GetConfigPath (true); ChangePathName (pathname); - LoadConfigFile (MigrateStub, NULL); - - if (!HaveSections ()) - { // Config file not found; try the old one - MigrateOldConfig (); - } + LoadConfigFile (); // If zdoom.ini was read from the program directory, switch // to the user directory now. If it was read from the user @@ -237,15 +231,6 @@ void FGameConfigFile::WriteCommentHeader (FILE *file) const fprintf (file, "# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime()); } -void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, void *userdata) -{ - static_cast(config)->bMigrating = true; -} - -void FGameConfigFile::MigrateOldConfig () -{ -} - void FGameConfigFile::DoGlobalSetup () { if (SetSection ("GlobalSettings.Unknown")) @@ -358,10 +343,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename) const char *key; const char *value; - if (bMigrating) - { - MigrateOldConfig (); - } sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; @@ -622,41 +603,20 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game) mysnprintf (section, countof(section), "%s.AutoExec", game); - if (bMigrating) + // If .AutoExec section does not exist, create it + // with a default autoexec.cfg file present. + CreateStandardAutoExec(section, false); + // Run any files listed in the .AutoExec section + if (!SectionIsEmpty()) { - FBaseCVar *autoexec = FindCVar ("autoexec", NULL); - - if (autoexec != NULL) + while (NextInSection (key, value)) { - UCVarValue val; - char *path; - - val = autoexec->GetGenericRep (CVAR_String); - path = copystring (val.String); - delete autoexec; - SetSection (section, true); - SetValueForKey ("Path", path); - list->AppendArg (path); - delete[] path; - } - } - else - { - // If .AutoExec section does not exist, create it - // with a default autoexec.cfg file present. - CreateStandardAutoExec(section, false); - // Run any files listed in the .AutoExec section - if (!SectionIsEmpty()) - { - while (NextInSection (key, value)) + if (stricmp (key, "Path") == 0 && *value != '\0') { - if (stricmp (key, "Path") == 0 && *value != '\0') + FString expanded_path = ExpandEnvVars(value); + if (FileExists(expanded_path)) { - FString expanded_path = ExpandEnvVars(value); - if (FileExists(expanded_path)) - { - list->AppendArg (ExpandEnvVars(value)); - } + list->AppendArg (ExpandEnvVars(value)); } } } @@ -667,13 +627,6 @@ void FGameConfigFile::SetRavenDefaults (bool isHexen) { UCVarValue val; - if (bMigrating) - { - con_centernotify.ResetToDefault (); - msg0color.ResetToDefault (); - color.ResetToDefault (); - } - val.Bool = false; wi_percents.SetGenericRepDefault (val, CVAR_Bool); val.Bool = true; diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 55867eaf8..57956f7cd 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -60,13 +60,9 @@ protected: void CreateStandardAutoExec (const char *section, bool start); private: - static void MigrateStub (const char *pathname, FConfigFile *config, void *userdata); - - void MigrateOldConfig (); void SetRavenDefaults (bool isHexen); void ReadCVars (DWORD flags); - bool bMigrating; bool bModSetup; char section[64]; From cac634567bb368d3b19e797175443574ece1dbb4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 10:51:28 +0200 Subject: [PATCH 08/20] - use a proper FString to hold the name of config sections instead of a buffer tacked onto the actual structure. This is necessary if we want to be able to rename a section. --- src/configfile.cpp | 16 ++++++---------- src/configfile.h | 3 ++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 8792175f4..9a1f7bd4d 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -138,7 +138,7 @@ FConfigFile &FConfigFile::operator = (const FConfigFile &other) while (fromsection != NULL) { fromentry = fromsection->RootEntry; - tosection = NewConfigSection (fromsection->Name); + tosection = NewConfigSection (fromsection->SectionName); while (fromentry != NULL) { NewConfigEntry (tosection, fromentry->Key, fromentry->Value); @@ -309,7 +309,7 @@ const char *FConfigFile::GetCurrentSection () const { if (CurrentSection != NULL) { - return CurrentSection->Name; + return CurrentSection->SectionName.GetChars(); } return NULL; } @@ -506,7 +506,7 @@ FConfigFile::FConfigSection *FConfigFile::FindSection (const char *name) const { FConfigSection *section = Sections; - while (section != NULL && stricmp (section->Name, name) != 0) + while (section != NULL && section->SectionName.CompareNoCase(name) != 0) { section = section->Next; } @@ -540,19 +540,15 @@ FConfigFile::FConfigEntry *FConfigFile::FindEntry ( FConfigFile::FConfigSection *FConfigFile::NewConfigSection (const char *name) { FConfigSection *section; - char *memblock; section = FindSection (name); if (section == NULL) { - size_t namelen = strlen (name); - memblock = new char[sizeof(*section)+namelen]; - section = ::new(memblock) FConfigSection; + section = new FConfigSection; section->RootEntry = NULL; section->LastEntryPtr = §ion->RootEntry; section->Next = NULL; - memcpy (section->Name, name, namelen); - section->Name[namelen] = 0; + section->SectionName = name; *LastSectionPtr = section; LastSectionPtr = §ion->Next; } @@ -777,7 +773,7 @@ bool FConfigFile::WriteConfigFile () const { fputs (section->Note.GetChars(), file); } - fprintf (file, "[%s]\n", section->Name); + fprintf (file, "[%s]\n", section->SectionName.GetChars()); while (entry != NULL) { if (strpbrk(entry->Value, "\r\n") == NULL) diff --git a/src/configfile.h b/src/configfile.h index 34ab9d56b..31943ccb6 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -93,11 +93,12 @@ private: }; struct FConfigSection { + FString SectionName; FConfigEntry *RootEntry; FConfigEntry **LastEntryPtr; FConfigSection *Next; FString Note; - char Name[1]; // + length of name + //char Name[1]; // + length of name }; FConfigSection *Sections; From 3114a26bc8aa7984b92db3da9ac311cd8e7b0567 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 11:21:28 +0200 Subject: [PATCH 09/20] - allow renaming of config sections and added migration code to rename the old autoload sections to the more flexible naming system that's planned. --- src/configfile.cpp | 16 ++++++++++++++++ src/configfile.h | 1 + src/gameconfigfile.cpp | 20 ++++++++++++++++++++ src/version.h | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 9a1f7bd4d..e64005fc4 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -513,6 +513,22 @@ FConfigFile::FConfigSection *FConfigFile::FindSection (const char *name) const return section; } +//==================================================================== +// +// FConfigFile :: RenameSection +// +//==================================================================== + +void FConfigFile::RenameSection (const char *oldname, const char *newname) const +{ + FConfigSection *section = FindSection(oldname); + + if (section != NULL) + { + section->SectionName = newname; + } +} + //==================================================================== // // FConfigFile :: FindEntry diff --git a/src/configfile.h b/src/configfile.h index 31943ccb6..e125351dc 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -78,6 +78,7 @@ protected: virtual char *ReadLine (char *string, int n, void *file) const; bool ReadConfig (void *file); static const char *GenerateEndTag(const char *value); + void RenameSection(const char *oldname, const char *newname) const; bool OkayToWrite; bool FileExisted; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 7e0ddc6a1..9121e79d6 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -334,6 +334,26 @@ void FGameConfigFile::DoGlobalSetup () SetValueForKey ("5", "use ArtiInvulnerability2"); } } + if (last < 211) + { + //RenameSection("Hacx2.Autoload", "hacx.2_0.Autoload"); + //RenameSection("Hacx12.Autoload", "hacx.1_2.Autoload"); + //RenameSection("Hexen1.Autoload", "hexen.hexen.Autoload"); + RenameSection("Chex3.Autoload", "chex.3.Autoload"); + RenameSection("Chex1.Autoload", "chex.1.Autoload"); + RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload"); + RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload"); + RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); + RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); + RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); + RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); + RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); + RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); + RenameSection("TNT.Autoload", "doom.doom2.tnt.Autoload"); + RenameSection("Plutonia.Autoload", "doom.doom2.plutonia.Autoload"); + RenameSection("Doom2BFG.Autoload", "doom.doom2.bfg.Autoload"); + RenameSection("Doom2.Autoload", "doom.doom2.commercial.Autoload"); + } } } } diff --git a/src/version.h b/src/version.h index cbbb8bd21..f45f58b2f 100644 --- a/src/version.h +++ b/src/version.h @@ -56,7 +56,7 @@ const char *GetVersionString(); // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to // be able to migrate in FGameConfigFile::DoGlobalSetup(). -#define LASTRUNVERSION "210" +#define LASTRUNVERSION "211" // Protocol version used in demos. // Bump it if you change existing DEM_ commands or add new ones. From 3241b1d3db2d9ce75f303bbf15af3eb3cb79b12b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 11:31:08 +0200 Subject: [PATCH 10/20] - add new config section names to iwadinfo.txt --- wadsrc/static/iwadinfo.txt | 53 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/wadsrc/static/iwadinfo.txt b/wadsrc/static/iwadinfo.txt index 0fcdd9b87..ceceafd2b 100644 --- a/wadsrc/static/iwadinfo.txt +++ b/wadsrc/static/iwadinfo.txt @@ -3,6 +3,7 @@ IWad { Name = "The Adventures of Square" + Autoname = "square.square" Game = "Doom" Config = "Square" MustContain = "SQU-IWAD", "E1A1" @@ -12,6 +13,7 @@ IWad IWad { Name = "The Adventures of Square (Square-ware)" + Autoname = "square.squareware" Game = "Doom" Config = "Square" MustContain = "SQU-SWE1", "E1A1" @@ -21,6 +23,7 @@ IWad IWad { Name = "Harmony" + Autoname = "harmony" Game = "Doom" Config = "Harmony" Mapinfo = "mapinfo/hacxharm.txt" @@ -33,7 +36,7 @@ IWad Name = "Hacx 2.0" Game = "Doom" Config = "Hacx" - Autoname = "Hacx2" + Autoname = "hacx.2_0" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-E" BannerColors = "ff ff ff", "00 88 22" @@ -44,7 +47,7 @@ IWad Name = "Hacx: Twitch'n Kill" Game = "Doom" Config = "Hacx" - Autoname = "Hacx12" + Autoname = "hacx.1_2" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-R" BannerColors = "00 00 a8", "a8 a8 a8" @@ -53,6 +56,7 @@ IWad IWad { Name = "Action Doom 2: Urban Brawl" + Autoname = "urbanbrawl" Game = "Doom" Config = "UrbanBrawl" Mapinfo = "mapinfo/urbanbrawl.txt" @@ -63,7 +67,7 @@ IWad IWad { Name = "Chex(R) Quest 3" - Autoname = "Chex3" + Autoname = "chex.3" Game = "Chex" Config = "Chex" Mapinfo = "mapinfo/chex.txt" @@ -75,7 +79,7 @@ IWad IWad { Name = "Chex(R) Quest" - Autoname = "Chex1" + Autoname = "chex.1" Game = "Chex" Config = "Chex" Mapinfo = "mapinfo/chex.txt" @@ -86,6 +90,7 @@ IWad IWad { Name = "Strife: Quest for the Sigil" + Autoname = "strife" Game = "Strife" Config = "Strife" Mapinfo = "mapinfo/strife.txt" @@ -99,7 +104,7 @@ IWad Name = "Strife: Teaser (New Version)" Game = "Strife" Config = "Strife" - Autoname = "Strifeteaser2" + Autoname = "strifeteaser2" Mapinfo = "mapinfo/strife.txt" Compatibility = "Shareware", "Teaser2" MustContain = "MAP33", "ENDSTRF", "INVCURS" @@ -111,7 +116,7 @@ IWad Name = "Strife: Teaser (Old Version)" Game = "Strife" Config = "Strife" - Autoname = "Strifeteaser1" + Autoname = "strifeteaser1" Mapinfo = "mapinfo/strife.txt" Compatibility = "Shareware" MustContain = "MAP33", "ENDSTRF" @@ -123,7 +128,7 @@ IWad Name = "Hexen: Beyond Heretic" Game = "Hexen" Config = "Hexen" - Autoname = "Hexen1" + Autoname = "hexen.hexen" Mapinfo = "mapinfo/hexen.txt" Compatibility = "Poly1" MustContain = "TITLE", "MAP01", "MAP40", "WINNOWR" @@ -133,7 +138,7 @@ IWad IWad { Name = "Hexen: Deathkings of the Dark Citadel" - Autoname = "HexenDK" + Autoname = "hexen.deathkings" Game = "Hexen" Config = "Hexen" Mapinfo = "mapinfo/hexen.txt" @@ -157,7 +162,7 @@ IWad IWad { Name = "Blasphemer" - Autoname = "Blasphemer" + Autoname = "blasphemer" Game = "Heretic" Config = "Heretic" Mapinfo = "mapinfo/heretic.txt" @@ -168,7 +173,7 @@ IWad IWad { Name = "Heretic: Shadow of the Serpent Riders" - Autoname = "HereticSR" + Autoname = "heretic.shadow" Game = "Heretic" Config = "Heretic" Mapinfo = "mapinfo/heretic.txt" @@ -182,7 +187,7 @@ IWad Name = "Heretic" Game = "Heretic" Config = "Heretic" - Autoname = "Heretic1" + Autoname = "heretic.heretic" Mapinfo = "mapinfo/heretic.txt" MustContain = "E1M1", "E2M1", "TITLE", "MUS_E1M1" BannerColors = "fc fc 00", "a8 00 00" @@ -202,8 +207,7 @@ IWad IWad { Name = "FreeDM" - Autoname = "FreeDM" - Group = "Freedoom" + Autoname = "doom.freedoom.freedm" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom2.txt" @@ -214,8 +218,7 @@ IWad IWad { Name = "Freedoom: Phase 2" - Autoname = "Freedoom2" - Group = "Freedoom" + Autoname = "doom.freedoom.phase2" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom2.txt" @@ -226,8 +229,7 @@ IWad IWad { Name = "Freedoom: Phase 1" - Autoname = "Freedoom1" - Group = "Freedoom" + Autoname = "doom.freedoom.phase1" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom1.txt" @@ -238,8 +240,7 @@ IWad IWad { Name = "Freedoom: Demo Version" - Autoname = "Freedoom1" - Group = "Freedoom" + Autoname = "doom.freedoom.demo" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom1.txt" @@ -250,7 +251,7 @@ IWad IWad { Name = "DOOM: BFG Edition" - Autoname = "DoomBFG" + Autoname = "doom.doom1.bfg" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/ultdoom.txt" @@ -265,7 +266,7 @@ IWad IWad { Name = "The Ultimate DOOM" - Autoname = "DoomU" + Autoname = "doom.doom1.ultimate" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/ultdoom.txt" @@ -279,7 +280,7 @@ IWad IWad { Name = "DOOM Registered" - Autoname = "Doom1" + Autoname = "doom.doom1.registered" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom1.txt" @@ -304,7 +305,7 @@ IWad IWad { Name = "Final Doom: TNT - Evilution" - Autoname = "TNT" + Autoname = "doom.doom2.tnt" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/tnt.txt" @@ -316,7 +317,7 @@ IWad IWad { Name = "Final Doom: Plutonia Experiment" - Autoname = "Plutonia" + Autoname = "doom.doom2.plutonia" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/plutonia.txt" @@ -328,7 +329,7 @@ IWad IWad { Name = "DOOM 2: BFG Edition" - Autoname = "Doom2BFG" + Autoname = "doom.doom2.bfg" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom2bfg.txt" @@ -342,7 +343,7 @@ IWad IWad { Name = "DOOM 2: Hell on Earth" - Autoname = "Doom2" + Autoname = "doom.doom2.commercial" Game = "Doom" Config = "Doom" Mapinfo = "mapinfo/doom2.txt" From 258822ef3bab753113eec96c6196f0fd2dc69a7b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 11:57:12 +0200 Subject: [PATCH 11/20] - redid autoload handler and resource file filtering to use the newly defined method with multi-part names. As a result the old 'Group' property could be removed and all other means to get a section name were disabled. As an example, if the code gets 'doom.doom2.commercial' it will use the following sections in this order: global.autoload doom.autoload doom.doom2.autoload doom.doom2.commercial.autoload. --- src/d_iwad.cpp | 6 ------ src/d_main.cpp | 28 ++++++++-------------------- src/d_main.h | 1 - src/doomstat.cpp | 2 +- src/doomstat.h | 2 +- src/gameconfigfile.cpp | 5 ++--- src/resourcefiles/resourcefile.cpp | 13 ++++++++++--- 7 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 4a46a93cd..e09baa26d 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -138,12 +138,6 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize) sc.MustGetString(); iwad->Autoname = sc.String; } - else if (sc.Compare("Group")) - { - sc.MustGetStringName("="); - sc.MustGetString(); - iwad->Group = sc.String; - } else if (sc.Compare("Config")) { sc.MustGetStringName("="); diff --git a/src/d_main.cpp b/src/d_main.cpp index 5dc5c7a78..78d12e651 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1990,10 +1990,9 @@ static void D_DoomInit() // //========================================================================== -static void AddAutoloadFiles(const char *group, const char *autoname) +static void AddAutoloadFiles(const char *autoname) { - LumpFilterGroup = group; - LumpFilterIWAD = autoname; + LumpFilterIWAD.Format("%s.", autoname); // The '.' is appened to simplify parsing the string if (!(gameinfo.flags & GI_SHAREWARE) && !Args->CheckParm("-noautoload")) { @@ -2025,25 +2024,14 @@ static void AddAutoloadFiles(const char *group, const char *autoname) // Add common (global) wads D_AddConfigWads (allwads, "Global.Autoload"); - // Add game-specific wads - file = gameinfo.ConfigName; - file += ".Autoload"; - D_AddConfigWads (allwads, file); + long len; + int lastpos = -1; - // Add group-specific wads - if (group != NULL && group[0] != 0) - { - file = group; - file += ".Autoload"; - D_AddConfigWads(allwads, file); - } - - // Add IWAD-specific wads - if (autoname != NULL && autoname[0] != 0) + while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) { - file = autoname; - file += ".Autoload"; + file = LumpFilterIWAD.Left(len) + ".Autoload"; D_AddConfigWads(allwads, file); + lastpos = len; } } } @@ -2294,7 +2282,7 @@ void D_DoomMain (void) FBaseCVar::DisableCallbacks(); GameConfig->DoGameSetup (gameinfo.ConfigName); - AddAutoloadFiles(iwad_info->Group, iwad_info->Autoname); + AddAutoloadFiles(iwad_info->Autoname); // Run automatically executed files execFiles = new DArgs; diff --git a/src/d_main.h b/src/d_main.h index dd2ffc409..e4641c41d 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -75,7 +75,6 @@ struct FIWADInfo { FString Name; // Title banner text for this IWAD FString Autoname; // Name of autoload ini section for this IWAD - FString Group; // Groupname for this IWAD FString Configname; // Name of config section for this IWAD FString Required; // Requires another IWAD DWORD FgColor; // Foreground color for title banner diff --git a/src/doomstat.cpp b/src/doomstat.cpp index 697ef3afe..2ec72db9d 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -69,4 +69,4 @@ int SinglePlayerClass[MAXPLAYERS]; bool ToggleFullscreen; int BorderTopRefresh; -FString LumpFilterGroup, LumpFilterIWAD; +FString LumpFilterIWAD; diff --git a/src/doomstat.h b/src/doomstat.h index d7f3796ac..835ef73fb 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -251,6 +251,6 @@ EXTERN_CVAR (Int, compatflags2); extern int i_compatflags, i_compatflags2, ii_compatflags, ii_compatflags2, ib_compatflags; // Filters from AddAutoloadFiles(). Used to filter files from archives. -extern FString LumpFilterGroup, LumpFilterIWAD; +extern FString LumpFilterIWAD; #endif diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 9121e79d6..e17a3e127 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -163,6 +163,7 @@ FGameConfigFile::FGameConfigFile () // Create auto-load sections, so users know what's available. // Note that this totem pole is the reverse of the order that // they will appear in the file. +#if 0 CreateSectionAtStart("Harmony.Autoload"); CreateSectionAtStart("UrbanBrawl.Autoload"); CreateSectionAtStart("Chex3.Autoload"); @@ -185,6 +186,7 @@ FGameConfigFile::FGameConfigFile () CreateSectionAtStart("DoomU.Autoload"); CreateSectionAtStart("Doom1.Autoload"); CreateSectionAtStart("Doom.Autoload"); +#endif CreateSectionAtStart("Global.Autoload"); // The same goes for auto-exec files. @@ -336,9 +338,6 @@ void FGameConfigFile::DoGlobalSetup () } if (last < 211) { - //RenameSection("Hacx2.Autoload", "hacx.2_0.Autoload"); - //RenameSection("Hacx12.Autoload", "hacx.1_2.Autoload"); - //RenameSection("Hexen1.Autoload", "hexen.hexen.Autoload"); RenameSection("Chex3.Autoload", "chex.3.Autoload"); RenameSection("Chex1.Autoload", "chex.1.Autoload"); RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload"); diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index d5ad659af..e5c12b0ef 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -345,9 +345,16 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) // each one so that we don't risk refiltering already filtered lumps. DWORD max = NumLumps; max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max); - max -= FilterLumps(gameinfo.ConfigName, lumps, lumpsize, max); - max -= FilterLumps(LumpFilterGroup, lumps, lumpsize, max); - max -= FilterLumps(LumpFilterIWAD, lumps, lumpsize, max); + + long len; + int lastpos = -1; + FString file; + + while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0) + { + max -= FilterLumps(LumpFilterIWAD.Left(len), lumps, lumpsize, max); + lastpos = len; + } JunkLeftoverFilters(lumps, lumpsize, max); } From dfda74ffe3496997caef6732fd302bb52eb683ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 13:52:08 +0200 Subject: [PATCH 12/20] - automatically create autoload section based on IWADINFO. This has an important implication: Previously the config was loaded before IWADINFO so in order to allow the config to access the data this had to be switched around. This means that zdoom.pk3 will not be looked for in the global IWAD search paths anymore, but since it shouldn't be there to begin with it should be an acceptable compromise. --- src/d_iwad.cpp | 1 - src/d_main.cpp | 24 +++++++++++------ src/d_main.h | 16 +++++++++--- src/gameconfigfile.cpp | 58 ++++++++++++++++++++++++------------------ src/gameconfigfile.h | 3 ++- src/m_misc.cpp | 4 +-- src/m_misc.h | 3 ++- 7 files changed, 68 insertions(+), 41 deletions(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index e09baa26d..7574347bc 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -387,7 +387,6 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, bool iwadparmfound = false; FString custwad; - ParseIWadInfos(zdoom_wad); wads.Resize(mIWadNames.Size()); foundwads.Resize(mIWads.Size()); memset(&foundwads[0], 0, foundwads.Size() * sizeof(foundwads[0])); diff --git a/src/d_main.cpp b/src/d_main.cpp index 78d12e651..5f4f09d4d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1978,10 +1978,6 @@ static void D_DoomInit() } FRandom::StaticClearRandom (); - - Printf ("M_LoadDefaults: Load system defaults.\n"); - M_LoadDefaults (); // load before initing other systems - } //========================================================================== @@ -2203,7 +2199,8 @@ void D_DoomMain (void) DArgs *execFiles; TArray pwads; FString *args; - int argcount; + int argcount; + FIWadManager *iwad_man; // +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here. FString logfile = Args->TakeValue("+logfile"); @@ -2233,8 +2230,6 @@ void D_DoomMain (void) } D_DoomInit(); - PClass::StaticInit (); - atterm(FinalGC); // [RH] Make sure zdoom.pk3 is always loaded, // as it contains magic stuff we need. @@ -2246,6 +2241,14 @@ void D_DoomMain (void) } FString basewad = wad; + iwad_man = new FIWadManager; + iwad_man->ParseIWadInfos(basewad); + + Printf ("M_LoadDefaults: Load system defaults.\n"); + M_LoadDefaults (iwad_man); // load before initing other systems + + PClass::StaticInit (); + atterm(FinalGC); // reinit from here @@ -2267,7 +2270,11 @@ void D_DoomMain (void) // restart is initiated without a defined IWAD assume for now that it's not going to change. if (iwad.IsEmpty()) iwad = lastIWAD; - FIWadManager *iwad_man = new FIWadManager; + if (iwad_man == NULL) + { + iwad_man = new FIWadManager; + iwad_man->ParseIWadInfos(basewad); + } const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad, basewad); gameinfo.gametype = iwad_info->gametype; gameinfo.flags = iwad_info->flags; @@ -2486,6 +2493,7 @@ void D_DoomMain (void) FBaseCVar::EnableNoSet (); delete iwad_man; // now we won't need this anymore + iwad_man = NULL; // [RH] Run any saved commands from the command line or autoexec.cfg now. gamestate = GS_FULLCONSOLE; diff --git a/src/d_main.h b/src/d_main.h index e4641c41d..afca8bc3b 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -115,15 +115,13 @@ extern FStartupInfo DoomStartupInfo; // //========================================================================== -struct FIWadManager +class FIWadManager { -private: TArray mIWads; TArray mIWadNames; TArray mLumpsFound; void ParseIWadInfo(const char *fn, const char *data, int datasize); - void ParseIWadInfos(const char *fn); void ClearChecks(); void CheckLumpName(const char *name); int GetIWadInfo(); @@ -131,7 +129,19 @@ private: int CheckIWAD (const char *doomwaddir, WadStuff *wads); int IdentifyVersion (TArray &wadfiles, const char *iwad, const char *zdoom_wad); public: + void ParseIWadInfos(const char *fn); const FIWADInfo *FindIWAD(TArray &wadfiles, const char *iwad, const char *basewad); + const FString *GetAutoname(unsigned int num) const + { + if (num < mIWads.Size()) return &mIWads[num].Autoname; + else return NULL; + } + int GetIWadFlags(unsigned int num) const + { + if (num < mIWads.Size()) return mIWads[num].flags; + else return false; + } + }; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index e17a3e127..112bcbe1b 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -61,6 +61,7 @@ extern HWND Window; #include "doomstat.h" #include "i_system.h" #include "gi.h" +#include "d_main.h" EXTERN_CVAR (Bool, con_centernotify) EXTERN_CVAR (Int, msg0color) @@ -75,7 +76,7 @@ EXTERN_CVAR (Color, am_cdwallcolor) EXTERN_CVAR (Float, spc_amp) EXTERN_CVAR (Bool, wi_percents) -FGameConfigFile::FGameConfigFile () +FGameConfigFile::FGameConfigFile (FIWadManager *iwad_man) { #ifdef __APPLE__ FString user_docs, user_app_support, local_app_support; @@ -163,30 +164,36 @@ FGameConfigFile::FGameConfigFile () // Create auto-load sections, so users know what's available. // Note that this totem pole is the reverse of the order that // they will appear in the file. -#if 0 - CreateSectionAtStart("Harmony.Autoload"); - CreateSectionAtStart("UrbanBrawl.Autoload"); - CreateSectionAtStart("Chex3.Autoload"); - CreateSectionAtStart("Chex1.Autoload"); - CreateSectionAtStart("Chex.Autoload"); - CreateSectionAtStart("Strife.Autoload"); - CreateSectionAtStart("HexenDK.Autoload"); - CreateSectionAtStart("Hexen.Autoload"); - CreateSectionAtStart("HereticSR.Autoload"); - CreateSectionAtStart("Heretic.Autoload"); - CreateSectionAtStart("FreeDM.Autoload"); - CreateSectionAtStart("Freedoom2.Autoload"); - CreateSectionAtStart("Freedoom1.Autoload"); - CreateSectionAtStart("Freedoom.Autoload"); - CreateSectionAtStart("Plutonia.Autoload"); - CreateSectionAtStart("TNT.Autoload"); - CreateSectionAtStart("Doom2BFG.Autoload"); - CreateSectionAtStart("Doom2.Autoload"); - CreateSectionAtStart("DoomBFG.Autoload"); - CreateSectionAtStart("DoomU.Autoload"); - CreateSectionAtStart("Doom1.Autoload"); - CreateSectionAtStart("Doom.Autoload"); -#endif + + double last = 0; + if (SetSection ("LastRun")) + { + const char *lastver = GetValueForKey ("Version"); + if (lastver != NULL) last = atof(lastver); + } + + // don't create the autoload section if we are about to migrate an old config because it'd mess up the upcoming migration step. + // This will be taken care of once the game runs again with the migrated config file. + if (last >= 211) + { + const FString *pAuto; + for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++) + { + if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering) + { + FString workname = *pAuto; + + while (workname.IsNotEmpty()) + { + FString section = workname + ".Autoload"; + CreateSectionAtStart(section.GetChars()); + long dotpos = workname.LastIndexOf('.'); + if (dotpos < 0) break; + workname.Truncate(dotpos); + } + } + } + } CreateSectionAtStart("Global.Autoload"); // The same goes for auto-exec files. @@ -345,6 +352,7 @@ void FGameConfigFile::DoGlobalSetup () RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); + RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload"); RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 57956f7cd..5862bb79e 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -38,11 +38,12 @@ #include "configfile.h" class DArgs; +class FIWadManager; class FGameConfigFile : public FConfigFile { public: - FGameConfigFile (); + FGameConfigFile (FIWadManager *iwad_man); ~FGameConfigFile (); void DoGlobalSetup (); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 7f4fa482d..1369bdb52 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -410,9 +410,9 @@ CCMD (writeini) // M_LoadDefaults // -void M_LoadDefaults () +void M_LoadDefaults (FIWadManager *iwad_man) { - GameConfig = new FGameConfigFile; + GameConfig = new FGameConfigFile(iwad_man); GameConfig->DoGlobalSetup (); atterm (M_SaveDefaultsFinal); } diff --git a/src/m_misc.h b/src/m_misc.h index 9599306de..ea146c690 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -28,6 +28,7 @@ class FConfigFile; class FGameConfigFile; +class FIWadManager; extern FGameConfigFile *GameConfig; @@ -40,7 +41,7 @@ void M_FindResponseFile (void); // Pass a NULL to get the original behavior. void M_ScreenShot (const char *filename); -void M_LoadDefaults (); +void M_LoadDefaults (FIWadManager *iwad_man); bool M_SaveDefaults (const char *filename); void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen); From a013703e1ce8a41dafb148c02b2ee3d3b20673b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 16:44:03 +0200 Subject: [PATCH 13/20] - add a NULL pointer check for the config to BaseFileSearch. --- src/d_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 5f4f09d4d..1244cc88f 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1657,7 +1657,7 @@ static const char *BaseFileSearch (const char *file, const char *ext, bool lookf return wad; } - if (GameConfig->SetSection ("FileSearch.Directories")) + if (GameConfig != NULL && GameConfig->SetSection ("FileSearch.Directories")) { const char *key; const char *value; From 7d2ab461d9820c5f42d1d9ddaad564bcab1789c6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 20:59:43 +0200 Subject: [PATCH 14/20] - don't use 'countof' to iterate through a static array that's defined inside a function. Some GCC versions apparently do not like that. --- src/gameconfigfile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 112bcbe1b..a168579a0 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -433,6 +433,7 @@ void FGameConfigFile::DoKeySetup(const char *gamename) { "Bindings", &Bindings }, { "DoubleBindings", &DoubleBindings }, { "AutomapBindings", &AutomapBindings }, + NULL, NULL }; const char *key, *value; @@ -442,7 +443,7 @@ void FGameConfigFile::DoKeySetup(const char *gamename) C_SetDefaultBindings (); - for (int i = 0; i < countof(binders); ++i) + for (int i = 0; binders[i].label != NULL; ++i) { strncpy(subsection, binders[i].label, sublen); if (SetSection(section)) From 4971e7def1462461579ae30750c679365536e564 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 21:40:14 +0200 Subject: [PATCH 15/20] - another GCC countof fix... --- src/resourcefiles/resourcefile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index e5c12b0ef..11d60795e 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -430,13 +430,14 @@ int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, { GAME_Raven, "game-Raven" }, { GAME_DoomStrifeChex, "game-DoomStrifeChex" }, { GAME_DoomChex, "game-DoomChex" }, + { GAME_Any, NULL } }; if (type == 0) { return 0; } int count = 0; - for (int i = 0; i < countof(blanket); ++i) + for (int i = 0; blanket[i].name != NULL; ++i) { if (type & blanket[i].match) { From 2cc6e74b31b503232bc95b427e9454e05c7dcb4c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 21:43:55 +0200 Subject: [PATCH 16/20] - renamed Hacx's autoload sections to remove minor version numbers. --- wadsrc/static/iwadinfo.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/iwadinfo.txt b/wadsrc/static/iwadinfo.txt index ceceafd2b..a92bc554d 100644 --- a/wadsrc/static/iwadinfo.txt +++ b/wadsrc/static/iwadinfo.txt @@ -36,7 +36,7 @@ IWad Name = "Hacx 2.0" Game = "Doom" Config = "Hacx" - Autoname = "hacx.2_0" + Autoname = "hacx.2" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-E" BannerColors = "ff ff ff", "00 88 22" @@ -47,7 +47,7 @@ IWad Name = "Hacx: Twitch'n Kill" Game = "Doom" Config = "Hacx" - Autoname = "hacx.1_2" + Autoname = "hacx.1" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-R" BannerColors = "00 00 a8", "a8 a8 a8" From c584e9ec9525799af10cd81fbb35e03f565f290b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 23:23:50 +0200 Subject: [PATCH 17/20] - fixed destructor call of FConfigSection in FConfigFile. --- src/configfile.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index e64005fc4..b8db74eb3 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -116,8 +116,7 @@ FConfigFile::~FConfigFile () delete[] (char *)entry; entry = nextentry; } - section->~FConfigSection(); - delete[] (char *)section; + delete section; section = nextsection; } } From cf7c04b6053800e86f187f72367269c9fec34625 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 7 Apr 2015 08:41:45 +0200 Subject: [PATCH 18/20] - more autoload name changing: hacx.1/2 -> hacx.hacx1/2 and chex.1/3 -> chex.chex1/3 --- wadsrc/static/iwadinfo.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/iwadinfo.txt b/wadsrc/static/iwadinfo.txt index a92bc554d..a274a1f2f 100644 --- a/wadsrc/static/iwadinfo.txt +++ b/wadsrc/static/iwadinfo.txt @@ -36,7 +36,7 @@ IWad Name = "Hacx 2.0" Game = "Doom" Config = "Hacx" - Autoname = "hacx.2" + Autoname = "hacx.hacx2" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-E" BannerColors = "ff ff ff", "00 88 22" @@ -47,7 +47,7 @@ IWad Name = "Hacx: Twitch'n Kill" Game = "Doom" Config = "Hacx" - Autoname = "hacx.1" + Autoname = "hacx.hacx1" Mapinfo = "mapinfo/hacxharm.txt" MustContain = "MAP01", "HACX-R" BannerColors = "00 00 a8", "a8 a8 a8" @@ -67,7 +67,7 @@ IWad IWad { Name = "Chex(R) Quest 3" - Autoname = "chex.3" + Autoname = "chex.chex3" Game = "Chex" Config = "Chex" Mapinfo = "mapinfo/chex.txt" @@ -79,7 +79,7 @@ IWad IWad { Name = "Chex(R) Quest" - Autoname = "chex.1" + Autoname = "chex.chex1" Game = "Chex" Config = "Chex" Mapinfo = "mapinfo/chex.txt" From e75bdf86dbc419434f9cf833245a75a06a4ec831 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 7 Apr 2015 08:46:42 +0200 Subject: [PATCH 19/20] - move section renaming code into FGameConfigFile's constructor so renaming of the old and creation of the new autoload sections can be done in one step, not two. --- src/gameconfigfile.cpp | 63 +++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index a168579a0..3f83da408 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -172,25 +172,38 @@ FGameConfigFile::FGameConfigFile (FIWadManager *iwad_man) if (lastver != NULL) last = atof(lastver); } - // don't create the autoload section if we are about to migrate an old config because it'd mess up the upcoming migration step. - // This will be taken care of once the game runs again with the migrated config file. - if (last >= 211) + if (last < 211) { - const FString *pAuto; - for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++) + RenameSection("Chex3.Autoload", "chex.chex3.Autoload"); + RenameSection("Chex1.Autoload", "chex.chex1.Autoload"); + RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload"); + RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload"); + RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); + RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); + RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); + RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload"); + RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); + RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); + RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); + RenameSection("TNT.Autoload", "doom.doom2.tnt.Autoload"); + RenameSection("Plutonia.Autoload", "doom.doom2.plutonia.Autoload"); + RenameSection("Doom2BFG.Autoload", "doom.doom2.bfg.Autoload"); + RenameSection("Doom2.Autoload", "doom.doom2.commercial.Autoload"); + } + const FString *pAuto; + for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++) + { + if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering) { - if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering) - { - FString workname = *pAuto; + FString workname = *pAuto; - while (workname.IsNotEmpty()) - { - FString section = workname + ".Autoload"; - CreateSectionAtStart(section.GetChars()); - long dotpos = workname.LastIndexOf('.'); - if (dotpos < 0) break; - workname.Truncate(dotpos); - } + while (workname.IsNotEmpty()) + { + FString section = workname + ".Autoload"; + CreateSectionAtStart(section.GetChars()); + long dotpos = workname.LastIndexOf('.'); + if (dotpos < 0) break; + workname.Truncate(dotpos); } } } @@ -343,24 +356,6 @@ void FGameConfigFile::DoGlobalSetup () SetValueForKey ("5", "use ArtiInvulnerability2"); } } - if (last < 211) - { - RenameSection("Chex3.Autoload", "chex.3.Autoload"); - RenameSection("Chex1.Autoload", "chex.1.Autoload"); - RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload"); - RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload"); - RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); - RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); - RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); - RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload"); - RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); - RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); - RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); - RenameSection("TNT.Autoload", "doom.doom2.tnt.Autoload"); - RenameSection("Plutonia.Autoload", "doom.doom2.plutonia.Autoload"); - RenameSection("Doom2BFG.Autoload", "doom.doom2.bfg.Autoload"); - RenameSection("Doom2.Autoload", "doom.doom2.commercial.Autoload"); - } } } } From 6f5dbdefb05587dbe07e9b044f5af9b5ec93d221 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 7 Apr 2015 08:51:21 +0200 Subject: [PATCH 20/20] - fixed: args of non-actor mapthings were ignored. --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 76afec801..e3317e1a2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4617,7 +4617,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) } // copy args to mapthing so that we have them in one place for the rest of this function - if (mentry->Special >= 0) + if (mentry->Type != NULL && mentry->Special >= 0) { mthing->special = mentry->Special; memcpy(mthing->args, mentry->Args, sizeof(mthing->args));