This commit is contained in:
Christoph Oelckers 2015-04-07 08:54:17 +02:00
commit 1d0706cb61
30 changed files with 439 additions and 434 deletions

View file

@ -43,158 +43,11 @@
#include "configfile.h"
#include "i_system.h"
#include "d_event.h"
#include "w_wad.h"
#include <math.h>
#include <stdlib.h>
/* 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)
while (sc.GetString())
{
Bindings.SetBinds (DefHereticBindings);
}
FKeyBindings *dest = &Bindings;
int key;
if (gameinfo.gametype == GAME_Hexen)
// bind destination is optional and is the same as the console command
if (sc.Compare("bind"))
{
Bindings.SetBinds (DefHexenBindings);
sc.MustGetString();
}
if (gameinfo.gametype == GAME_Strife)
else if (sc.Compare("doublebind"))
{
Bindings.SetBinds (DefStrifeBindings);
dest = &DoubleBindings;
sc.MustGetString();
}
else if (sc.Compare("mapbind"))
{
dest = &AutomapBindings;
sc.MustGetString();
}
key = GetConfigKeyFromName(sc.String);
sc.MustGetString();
dest->SetBind(key, sc.String);
}
}
AutomapBindings.SetBinds(DefAutomapBindings);
}
CCMD(binddefaults)

View file

@ -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);

View file

@ -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;
}
@ -118,8 +116,7 @@ FConfigFile::~FConfigFile ()
delete[] (char *)entry;
entry = nextentry;
}
section->~FConfigSection();
delete[] (char *)section;
delete section;
section = nextsection;
}
}
@ -140,7 +137,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);
@ -311,7 +308,7 @@ const char *FConfigFile::GetCurrentSection () const
{
if (CurrentSection != NULL)
{
return CurrentSection->Name;
return CurrentSection->SectionName.GetChars();
}
return NULL;
}
@ -508,13 +505,29 @@ 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;
}
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
@ -542,19 +555,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 = &section->RootEntry;
section->Next = NULL;
memcpy (section->Name, name, namelen);
section->Name[namelen] = 0;
section->SectionName = name;
*LastSectionPtr = section;
LastSectionPtr = &section->Next;
}
@ -591,7 +600,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 +614,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);
}
}
}
//====================================================================
@ -787,7 +788,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)

View file

@ -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:
@ -79,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;
@ -94,11 +94,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;

View file

@ -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("=");
@ -393,7 +387,6 @@ int FIWadManager::IdentifyVersion (TArray<FString> &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]));

View file

@ -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;
@ -1978,10 +1978,6 @@ static void D_DoomInit()
}
FRandom::StaticClearRandom ();
Printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
}
//==========================================================================
@ -1990,10 +1986,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 +2020,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)
while ((len = LumpFilterIWAD.IndexOf('.', lastpos+1)) > 0)
{
file = group;
file += ".Autoload";
D_AddConfigWads(allwads, file);
}
// Add IWAD-specific wads
if (autoname != NULL)
{
file = autoname;
file += ".Autoload";
file = LumpFilterIWAD.Left(len) + ".Autoload";
D_AddConfigWads(allwads, file);
lastpos = len;
}
}
}
@ -2216,6 +2200,7 @@ void D_DoomMain (void)
TArray<FString> pwads;
FString *args;
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");
@ -2245,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.
@ -2258,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
@ -2279,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;
@ -2294,7 +2289,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;
@ -2324,6 +2319,8 @@ void D_DoomMain (void)
allwads.ShrinkToFit();
SetMapxxFlag();
GameConfig->DoKeySetup(gameinfo.ConfigName);
// Now that wads are loaded, define mod-specific cvars.
ParseCVarInfo();
@ -2496,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;

View file

@ -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
@ -116,15 +115,13 @@ extern FStartupInfo DoomStartupInfo;
//
//==========================================================================
struct FIWadManager
class FIWadManager
{
private:
TArray<FIWADInfo> mIWads;
TArray<FString> mIWadNames;
TArray<int> 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();
@ -132,7 +129,19 @@ private:
int CheckIWAD (const char *doomwaddir, WadStuff *wads);
int IdentifyVersion (TArray<FString> &wadfiles, const char *iwad, const char *zdoom_wad);
public:
void ParseIWadInfos(const char *fn);
const FIWADInfo *FindIWAD(TArray<FString> &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;
}
};

View file

@ -69,4 +69,4 @@ int SinglePlayerClass[MAXPLAYERS];
bool ToggleFullscreen;
int BorderTopRefresh;
FString LumpFilterGroup, LumpFilterIWAD;
FString LumpFilterIWAD;

View file

@ -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

View file

@ -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;
@ -83,16 +84,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
@ -169,28 +164,49 @@ 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.
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");
double last = 0;
if (SetSection ("LastRun"))
{
const char *lastver = GetValueForKey ("Version");
if (lastver != NULL) last = atof(lastver);
}
if (last < 211)
{
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)
{
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.
@ -237,18 +253,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<FGameConfigFile *>(config)->bMigrating = true;
}
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 ()
{
if (SetSection ("GlobalSettings.Unknown"))
@ -361,10 +365,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';
@ -400,41 +400,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 +420,39 @@ 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 },
NULL, NULL
};
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; binders[i].label != NULL; ++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)
@ -628,26 +626,6 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
mysnprintf (section, countof(section), "%s.AutoExec", game);
if (bMigrating)
{
FBaseCVar *autoexec = FindCVar ("autoexec", NULL);
if (autoexec != NULL)
{
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 <game>.AutoExec section does not exist, create it
// with a default autoexec.cfg file present.
CreateStandardAutoExec(section, false);
@ -667,19 +645,11 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
}
}
}
}
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;

View file

@ -38,15 +38,17 @@
#include "configfile.h"
class DArgs;
class FIWadManager;
class FGameConfigFile : public FConfigFile
{
public:
FGameConfigFile ();
FGameConfigFile (FIWadManager *iwad_man);
~FGameConfigFile ();
void DoGlobalSetup ();
void DoGameSetup (const char *gamename);
void DoKeySetup (const char *gamename);
void DoModSetup (const char *gamename);
void ArchiveGlobalData ();
void ArchiveGameData (const char *gamename);
@ -59,13 +61,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];

View file

@ -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);
}

View file

@ -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);

View file

@ -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));

View file

@ -128,6 +128,8 @@ enum
kVK_UpArrow = 0x7E
};
static const NSOpenGLPixelFormatAttribute NSOpenGLPFAAllowOfflineRenderers = NSOpenGLPixelFormatAttribute(96);
#endif // prior to 10.5

View file

@ -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,41 @@ 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();
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))
{
#ifdef __LITTLE_ENDIAN__
static const CFStringEncoding ENCODING = kCFStringEncodingUTF16LE;
#else // __BIG_ENDIAN__
static const CFStringEncoding ENCODING = kCFStringEncodingUTF16BE;
#endif // __LITTLE_ENDIAN__
if (const CFStringRef utf16 = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, data, ENCODING))
{
const CFRange range = { 0, CFStringGetLength(utf16) };
CFIndex bufferLength = 0;
if (CFStringGetBytes(utf16, range, kCFStringEncodingUTF8, '?', false, NULL, 0, &bufferLength) > 0)
{
UInt8* const buffer = reinterpret_cast<UInt8*>(result.LockNewBuffer(bufferLength));
CFStringGetBytes(utf16, range, kCFStringEncodingUTF8, '?', false, buffer, bufferLength, NULL);
result.UnlockBuffer();
}
const CFIndex flavorCount = CFArrayGetCount(flavorTypeArray);
for (CFIndex flavorIndex = 0; flavorIndex < flavorCount; ++flavorIndex)
{
const CFStringRef flavorType = static_cast<const CFStringRef>(
CFArrayGetValueAtIndex(flavorTypeArray, flavorIndex));
if (UTTypeConformsTo(flavorType, CFSTR("public.utf8-plain-text")))
{
CFDataRef flavorData;
if (0 == PasteboardCopyItemFlavorData(s_clipboard, itemID, flavorType, &flavorData))
{
result += reinterpret_cast<const char*>(CFDataGetBytePtr(flavorData));
}
CFRelease(flavorData);
CFRelease(utf16);
}
}
CFRelease(flavorTypeArray);
return result;
#endif
return "";

View file

@ -344,9 +344,17 @@ 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 -= FilterLumps(gameinfo.ConfigName, lumps, lumpsize, max);
max -= FilterLumps(LumpFilterGroup, lumps, lumpsize, max);
max -= FilterLumps(LumpFilterIWAD, lumps, lumpsize, max);
max -= FilterLumpsByGameType(gameinfo.gametype, 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);
}
@ -406,6 +414,41 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize,
return end - start;
}
//==========================================================================
//
// FResourceFile :: FilterLumpsByGameType
//
// Matches any lumps that match "filter/game-<gametype>/*". 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" },
{ GAME_Any, NULL }
};
if (type == 0)
{
return 0;
}
int count = 0;
for (int i = 0; blanket[i].name != NULL; ++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

View file

@ -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);

View file

@ -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.

103
wadsrc/static/defbinds.txt Normal file
View file

@ -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"

View file

@ -1,3 +1,4 @@
/****************************************************************************/
/* */
/* DOOM SOUNDS */

View file

@ -0,0 +1,3 @@
/* Default keybindings for Heretic */
backspace "use ArtiTomeOfPower"

View file

@ -1,3 +1,4 @@
/****************************************************************************/
/* */
/* HERETIC SOUNDS */

View file

@ -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

View file

@ -1,3 +1,4 @@
/****************************************************************************/
/* */
/* HEXEN SOUNDS */

View file

@ -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

View file

@ -1,3 +1,4 @@
/****************************************************************************/
/* */
/* STRIFE SOUNDS */

View file

@ -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.hacx2"
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.hacx1"
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.chex3"
Game = "Chex"
Config = "Chex"
Mapinfo = "mapinfo/chex.txt"
@ -75,7 +79,7 @@ IWad
IWad
{
Name = "Chex(R) Quest"
Autoname = "Chex1"
Autoname = "chex.chex1"
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"