Add a simple header and version number to the default.dfg config file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9570 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3817a3ecc4
commit
2ee282396f
2 changed files with 29 additions and 1 deletions
|
@ -797,11 +797,16 @@ int numdefaults;
|
|||
void M_SaveDefaults (void)
|
||||
{
|
||||
int i,fd;
|
||||
uint32_t magic = DOOM_CONFIG_MAGIC;
|
||||
uint32_t ver = DOOM_CONFIG_VERSION;
|
||||
|
||||
fd = open (GAMEBASE"default.dfg", O_WRONLY|O_CREAT|O_TRUNC);
|
||||
if (fd<0)
|
||||
return; // can't write the file, but don't complain
|
||||
|
||||
write(fd,&magic,sizeof(magic));
|
||||
write(fd,&ver,sizeof(ver));
|
||||
|
||||
for (i=0 ; i<numdefaults ; i++)
|
||||
if(defaults[i].location.pi)
|
||||
write(fd,defaults[i].location.pi, sizeof(int));
|
||||
|
@ -833,7 +838,9 @@ struct default_s *M_LookupDefault(const char *name)
|
|||
|
||||
void M_LoadDefaults (void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
uint32_t magic = 0;
|
||||
uint32_t ver;
|
||||
int fd;
|
||||
// set everything to base values
|
||||
|
||||
|
@ -849,6 +856,18 @@ void M_LoadDefaults (void)
|
|||
if (fd<0)
|
||||
return; // don't have anything to read
|
||||
|
||||
read(fd,&magic,sizeof(magic));
|
||||
if (magic != DOOM_CONFIG_MAGIC) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
read(fd,&ver,sizeof(ver));
|
||||
if (ver != DOOM_CONFIG_VERSION) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0 ; i<numdefaults ; i++)
|
||||
if(defaults[i].location.pi)
|
||||
read(fd,defaults[i].location.pi, sizeof(int));
|
||||
|
|
|
@ -91,4 +91,13 @@ inline void* memcpy(void* dst, const void* src, size_t size);
|
|||
#define NO_PREDEFINED_LUMPS
|
||||
#define TABLES_AS_LUMPS // This frees up alot of space in the plugin buffer
|
||||
//#define FANCY_MENU // This is a call to allow load_main_backdrop to run in doom
|
||||
|
||||
#define MAKE_FOURCC(a,b,c,d) (uint32_t)((((a)<<24)|((b)<<16)|((c)<<8)|(d)))
|
||||
|
||||
/* Config file magic - increment the version number whenever the settings
|
||||
structure changes.
|
||||
*/
|
||||
#define DOOM_CONFIG_MAGIC MAKE_FOURCC('D','O','O','M')
|
||||
#define DOOM_CONFIG_VERSION 1
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue