comparison srogue/save.c @ 82:f11eeafc6568

srogue: don't store machine-dependent metadata in the savefile. Super-Rogue, like Rogue V4, stored data of machine-dependent length in the savefile, to prevent cheating. This made saved games non-portable. Also deleted was a check that used this data, and prevented restoring savefiles from backup. This change BREAKS SAVEFILE COMPATIBILITY, but old files can be converted by removing the block at offset 0x1e with length sizeof(ino_t) + sizeof(dev_t) + 2 * sizeof(time_t). That seems to be 0x14 on i686 and 0x20 on x86_64.
author John "Elwin" Edwards
date Tue, 06 Aug 2013 19:02:58 -0700
parents 3aa87373c908
children d852b8f088c5
comparison
equal deleted inserted replaced
81:0e212d46b68f 82:f11eeafc6568
184 fnum = fileno(savef); 184 fnum = fileno(savef);
185 fstat(fnum, &sbuf); 185 fstat(fnum, &sbuf);
186 write(fnum, "RDK", 4); 186 write(fnum, "RDK", 4);
187 lseek(fnum, 0L, 0); 187 lseek(fnum, 0L, 0);
188 encwrite(version,strlen(version)+1,savef); 188 encwrite(version,strlen(version)+1,savef);
189 encwrite(&sbuf.st_ino,sizeof(sbuf.st_ino),savef);
190 encwrite(&sbuf.st_dev,sizeof(sbuf.st_dev),savef);
191 encwrite(&sbuf.st_ctime,sizeof(sbuf.st_ctime),savef);
192 encwrite(&sbuf.st_mtime,sizeof(sbuf.st_mtime),savef);
193 encwrite(&slines,sizeof(slines),savef); 189 encwrite(&slines,sizeof(slines),savef);
194 encwrite(&scols,sizeof(scols),savef); 190 encwrite(&scols,sizeof(scols),savef);
195 msg(""); 191 msg("");
196 rs_save_file(savef); 192 rs_save_file(savef);
197 close(fnum); 193 close(fnum);
236 return FALSE; 232 return FALSE;
237 } 233 }
238 234
239 fstat(inf, &sbuf2); 235 fstat(inf, &sbuf2);
240 236
241 encread(&sbuf.st_ino,sizeof(sbuf.st_ino), inf);
242 encread(&sbuf.st_dev,sizeof(sbuf.st_dev), inf);
243 encread(&sbuf.st_ctime,sizeof(sbuf.st_ctime), inf);
244 encread(&sbuf.st_mtime,sizeof(sbuf.st_mtime), inf);
245 encread(&slines,sizeof(slines),inf); 237 encread(&slines,sizeof(slines),inf);
246 encread(&scols,sizeof(scols),inf); 238 encread(&scols,sizeof(scols),inf);
247 239
248 /* 240 /*
249 * we do not close the file so that we will have a hold of the 241 * we do not close the file so that we will have a hold of the
250 * inode for as long as possible 242 * inode for as long as possible
251 */ 243 */
252
253 if (!wizard)
254 {
255 if(sbuf2.st_ino!=sbuf.st_ino || sbuf2.st_dev!=sbuf.st_dev) {
256 printf("Sorry, saved game is not in the same file.\n");
257 return FALSE;
258 }
259 }
260 244
261 #ifdef __INTERIX 245 #ifdef __INTERIX
262 setenv("TERM","interix"); 246 setenv("TERM","interix");
263 #endif 247 #endif
264 248