summaryrefslogtreecommitdiff
path: root/apps/plugins/doom/m_misc.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-04-08 22:53:26 +0000
committerDave Chapman <dave@dchapman.com>2006-04-08 22:53:26 +0000
commit2ee282396f8cf740db8b3d513f2826503ed2cb00 (patch)
tree36b8e0d510e9d0658e5c40117e32288dd0cbe382 /apps/plugins/doom/m_misc.c
parent3817a3ecc4ee657f1a38bb3c39f53a345ded04cc (diff)
downloadrockbox-2ee282396f8cf740db8b3d513f2826503ed2cb00.tar.gz
rockbox-2ee282396f8cf740db8b3d513f2826503ed2cb00.zip
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
Diffstat (limited to 'apps/plugins/doom/m_misc.c')
-rw-r--r--apps/plugins/doom/m_misc.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/plugins/doom/m_misc.c b/apps/plugins/doom/m_misc.c
index 43e2a3888b..d3e6098b5d 100644
--- a/apps/plugins/doom/m_misc.c
+++ b/apps/plugins/doom/m_misc.c
@@ -797,11 +797,16 @@ int numdefaults;
797void M_SaveDefaults (void) 797void M_SaveDefaults (void)
798{ 798{
799 int i,fd; 799 int i,fd;
800 uint32_t magic = DOOM_CONFIG_MAGIC;
801 uint32_t ver = DOOM_CONFIG_VERSION;
800 802
801 fd = open (GAMEBASE"default.dfg", O_WRONLY|O_CREAT|O_TRUNC); 803 fd = open (GAMEBASE"default.dfg", O_WRONLY|O_CREAT|O_TRUNC);
802 if (fd<0) 804 if (fd<0)
803 return; // can't write the file, but don't complain 805 return; // can't write the file, but don't complain
804 806
807 write(fd,&magic,sizeof(magic));
808 write(fd,&ver,sizeof(ver));
809
805 for (i=0 ; i<numdefaults ; i++) 810 for (i=0 ; i<numdefaults ; i++)
806 if(defaults[i].location.pi) 811 if(defaults[i].location.pi)
807 write(fd,defaults[i].location.pi, sizeof(int)); 812 write(fd,defaults[i].location.pi, sizeof(int));
@@ -833,7 +838,9 @@ struct default_s *M_LookupDefault(const char *name)
833 838
834void M_LoadDefaults (void) 839void M_LoadDefaults (void)
835{ 840{
836 int i; 841 int i;
842 uint32_t magic = 0;
843 uint32_t ver;
837 int fd; 844 int fd;
838 // set everything to base values 845 // set everything to base values
839 846
@@ -849,6 +856,18 @@ void M_LoadDefaults (void)
849 if (fd<0) 856 if (fd<0)
850 return; // don't have anything to read 857 return; // don't have anything to read
851 858
859 read(fd,&magic,sizeof(magic));
860 if (magic != DOOM_CONFIG_MAGIC) {
861 close(fd);
862 return;
863 }
864
865 read(fd,&ver,sizeof(ver));
866 if (ver != DOOM_CONFIG_VERSION) {
867 close(fd);
868 return;
869 }
870
852 for (i=0 ; i<numdefaults ; i++) 871 for (i=0 ; i<numdefaults ; i++)
853 if(defaults[i].location.pi) 872 if(defaults[i].location.pi)
854 read(fd,defaults[i].location.pi, sizeof(int)); 873 read(fd,defaults[i].location.pi, sizeof(int));