mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
- Added a dialog that gives the user the chance to fix things if the config
could not be saved for some reason. - Added the writeini console command to write the config file, optionally specifying a specific file name for it. - Fixed: "Multiplayer" demos that only had one player were not played back properly because the demo playback code only checked the number of players to determine if it should be played as a netdemo. SVN r333 (trunk)
This commit is contained in:
parent
8854f95152
commit
b132575533
12 changed files with 98 additions and 8 deletions
|
@ -1,4 +1,11 @@
|
|||
September 19, 2006
|
||||
- Added a dialog that gives the user the chance to fix things if the config
|
||||
could not be saved for some reason.
|
||||
- Added the writeini console command to write the config file, optionally
|
||||
specifying a specific file name for it.
|
||||
- Fixed: "Multiplayer" demos that only had one player were not played back
|
||||
properly because the demo playback code only checked the number of players
|
||||
to determine if it should be played as a netdemo.
|
||||
- Assembly code is disabled when building with __APPLE__ defined, for now.
|
||||
- If you aren't targeting x86, m_fixed.h only includes basicinlines.h now.
|
||||
- Moved x64inlines.h into basicinlines.h.
|
||||
|
|
|
@ -398,14 +398,14 @@ char *FConfigFile::ReadLine (char *string, int n, void *file) const
|
|||
return fgets (string, n, (FILE *)file);
|
||||
}
|
||||
|
||||
void FConfigFile::WriteConfigFile () const
|
||||
bool FConfigFile::WriteConfigFile () const
|
||||
{
|
||||
FILE *file = fopen (PathName, "w");
|
||||
FConfigSection *section;
|
||||
FConfigEntry *entry;
|
||||
|
||||
if (file == NULL)
|
||||
return;
|
||||
return false;
|
||||
|
||||
WriteCommentHeader (file);
|
||||
|
||||
|
@ -423,6 +423,7 @@ void FConfigFile::WriteConfigFile () const
|
|||
fprintf (file, "\n");
|
||||
}
|
||||
fclose (file);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FConfigFile::WriteCommentHeader (FILE *file) const
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
void ChangePathName (const char *path);
|
||||
|
||||
void LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata);
|
||||
void WriteConfigFile () const;
|
||||
bool WriteConfigFile () const;
|
||||
|
||||
protected:
|
||||
virtual void WriteCommentHeader (FILE *file) const;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#define UINF_ID BIGE_ID('U','I','N','F')
|
||||
#define COMP_ID BIGE_ID('C','O','M','P')
|
||||
#define BODY_ID BIGE_ID('B','O','D','Y')
|
||||
#define NETD_ID BIGE_ID('N','E','T','D')
|
||||
|
||||
#define ANGLE2SHORT(x) ((((x)/360) & 65535)
|
||||
#define SHORT2ANGLE(x) ((x)*360)
|
||||
|
|
|
@ -2231,6 +2231,15 @@ void G_BeginRecording (const char *startmap)
|
|||
}
|
||||
}
|
||||
|
||||
// It is possible to start a "multiplayer" game with only one player,
|
||||
// so checking the number of players when playing back the demo is not
|
||||
// enough.
|
||||
if (multiplayer)
|
||||
{
|
||||
StartChunk (NETD_ID, &demo_p);
|
||||
FinishChunk (&demo_p);
|
||||
}
|
||||
|
||||
// Write cvars chunk
|
||||
StartChunk (VARS_ID, &demo_p);
|
||||
C_WriteCVars (&demo_p, CVAR_SERVERINFO|CVAR_DEMOSAVE);
|
||||
|
@ -2358,6 +2367,10 @@ bool G_ProcessIFFDemo (char *mapname)
|
|||
D_ReadUserInfoStrings (i, &demo_p, false);
|
||||
break;
|
||||
|
||||
case NETD_ID:
|
||||
multiplayer = netgame = netdemo = true;
|
||||
break;
|
||||
|
||||
case BODY_ID:
|
||||
bodyHit = true;
|
||||
zdembodyend = demo_p + len;
|
||||
|
|
|
@ -519,7 +519,7 @@ FString FGameConfigFile::GetConfigPath (bool tryProg)
|
|||
HRESULT hr;
|
||||
|
||||
TCHAR uname[UNLEN+1];
|
||||
DWORD unamelen = sizeof(uname);
|
||||
DWORD unamelen = countof(uname);
|
||||
|
||||
// Because people complained, try for a user-specific .ini in the program directory first.
|
||||
// If that is not writeable, use the one in the home directory instead.
|
||||
|
|
|
@ -339,18 +339,51 @@ FString GetUserFile (const char *file, bool nodir)
|
|||
// M_SaveDefaults
|
||||
//
|
||||
|
||||
void M_SaveDefaults ()
|
||||
bool M_SaveDefaults (const char *filename)
|
||||
{
|
||||
FString oldpath;
|
||||
bool success;
|
||||
|
||||
if (filename != NULL)
|
||||
{
|
||||
oldpath = GameConfig->GetPathName();
|
||||
GameConfig->ChangePathName (filename);
|
||||
}
|
||||
GameConfig->ArchiveGlobalData ();
|
||||
if (GameNames[gameinfo.gametype] != NULL)
|
||||
{
|
||||
GameConfig->ArchiveGameData (GameNames[gameinfo.gametype]);
|
||||
}
|
||||
GameConfig->WriteConfigFile ();
|
||||
success = GameConfig->WriteConfigFile ();
|
||||
if (filename != NULL)
|
||||
{
|
||||
GameConfig->ChangePathName (filename);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void M_SaveDefaultsFinal ()
|
||||
{
|
||||
while (!M_SaveDefaults (NULL) && I_WriteIniFailed ())
|
||||
{
|
||||
/* Loop until the config saves or I_WriteIniFailed() returns false */
|
||||
}
|
||||
delete GameConfig;
|
||||
GameConfig = NULL;
|
||||
}
|
||||
|
||||
CCMD (writeini)
|
||||
{
|
||||
const char *filename = (argv.argc() == 1) ? NULL : argv[1];
|
||||
if (!M_SaveDefaults (filename))
|
||||
{
|
||||
Printf ("Writing config failed: %s\n", strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf ("Config saved.\n");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// M_LoadDefaults
|
||||
|
@ -361,7 +394,7 @@ void M_LoadDefaults ()
|
|||
GameConfig = new FGameConfigFile;
|
||||
GameConfig->DoGlobalSetup ();
|
||||
atterm (FreeKeySections);
|
||||
atterm (M_SaveDefaults);
|
||||
atterm (M_SaveDefaultsFinal);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ void M_ScreenShot (const char *filename);
|
|||
|
||||
void M_LoadDefaults ();
|
||||
|
||||
void M_SaveDefaults ();
|
||||
bool M_SaveDefaults (const char *filename);
|
||||
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection);
|
||||
|
||||
FString GetUserFile (const char *path, bool nodir=false);
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "stats.h"
|
||||
#include "hardware.h"
|
||||
#include "zstring.h"
|
||||
#include "gameconfigfile.h"
|
||||
|
||||
EXTERN_CVAR (String, language)
|
||||
|
||||
|
@ -364,6 +365,13 @@ int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad)
|
|||
return i-1;
|
||||
}
|
||||
|
||||
bool I_WriteIniFailed ()
|
||||
{
|
||||
printf ("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno));
|
||||
return false;
|
||||
// return true to retry
|
||||
}
|
||||
|
||||
static const char *pattern;
|
||||
|
||||
#ifdef OSF1
|
||||
|
|
|
@ -187,6 +187,9 @@ void I_SetTitleString (const char *title);
|
|||
// Pick from multiple IWADs to use
|
||||
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
|
||||
|
||||
// The ini could not be saved at exit
|
||||
bool I_WriteIniFailed ();
|
||||
|
||||
// [RH] Returns millisecond-accurate time
|
||||
unsigned int I_MSTime (void);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "i_system.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "templates.h"
|
||||
#include "gameconfigfile.h"
|
||||
|
||||
#include "stats.h"
|
||||
|
||||
|
@ -724,6 +725,26 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad)
|
|||
return defaultiwad;
|
||||
}
|
||||
|
||||
bool I_WriteIniFailed ()
|
||||
{
|
||||
char *lpMsgBuf;
|
||||
FString errortext;
|
||||
|
||||
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf);
|
||||
LocalFree (lpMsgBuf);
|
||||
return MessageBox (Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY;
|
||||
}
|
||||
|
||||
void *I_FindFirst (const char *filespec, findstate_t *fileinfo)
|
||||
{
|
||||
return FindFirstFileA (filespec, (LPWIN32_FIND_DATAA)fileinfo);
|
||||
|
|
|
@ -195,6 +195,9 @@ void I_SetTitleString (const char *title);
|
|||
// Pick from multiple IWADs to use
|
||||
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
|
||||
|
||||
// The ini could not be saved at exit
|
||||
bool I_WriteIniFailed ();
|
||||
|
||||
// [RH] Returns millisecond-accurate time
|
||||
unsigned int I_MSTime (void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue