Mercurial > hg > early-roguelike
comparison urogue/state.c @ 258:2908dc47f9e2
UltraRogue: fix crash when restoring.
The r_flags field in struct room was being written as an int and read
as a short. This caused the restore functions to receive the wrong
data, usually an impossible string length, and abort.
This breaks save compatibility, though the save files had problems
anyway: the r_fires field should have been used, instead of reading and
writing r_flags twice.
author | John "Elwin" Edwards |
---|---|
date | Wed, 08 Feb 2017 19:50:36 -0500 |
parents | c495a4f288c6 |
children | 096d3cfd9afd |
comparison
equal
deleted
inserted
replaced
257:c4b12d2d1dcd | 258:2908dc47f9e2 |
---|---|
348 for(i=0; i<MAXDOORS; i++) | 348 for(i=0; i<MAXDOORS; i++) |
349 ur_write_coord(savef, r->r_exit[i]); | 349 ur_write_coord(savef, r->r_exit[i]); |
350 | 350 |
351 ur_write_int(savef, r->r_flags); | 351 ur_write_int(savef, r->r_flags); |
352 ur_write_int(savef, r->r_nexits); | 352 ur_write_int(savef, r->r_nexits); |
353 ur_write_int(savef, r->r_flags); | 353 ur_write_short(savef, r->r_fires); |
354 } | 354 } |
355 | 355 |
356 struct room * | 356 struct room * |
357 ur_read_room(FILE *savef) | 357 ur_read_room(FILE *savef) |
358 { | 358 { |
367 for(i=0; i<MAXDOORS; i++) | 367 for(i=0; i<MAXDOORS; i++) |
368 r->r_exit[i] = ur_read_coord(savef); | 368 r->r_exit[i] = ur_read_coord(savef); |
369 | 369 |
370 r->r_flags = ur_read_int(savef); | 370 r->r_flags = ur_read_int(savef); |
371 r->r_nexits = ur_read_int(savef); | 371 r->r_nexits = ur_read_int(savef); |
372 r->r_flags = ur_read_short(savef); | 372 r->r_fires = ur_read_short(savef); |
373 | 373 |
374 return(r); | 374 return(r); |
375 } | 375 } |
376 | 376 |
377 void | 377 void |