home · contact · privacy
Actually save player's hitpoints to savefile (instead of, bug, resetting them on...
authorChristian Heller <c.heller@plomlompom.de>
Wed, 10 Jul 2013 22:24:06 +0000 (00:24 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 10 Jul 2013 22:24:06 +0000 (00:24 +0200)
src/roguelike.c

index b44086aded843a3857baaf1872e7b54b67a06eb6..0ec8194fb75d27031e6efdbf6bc90e1d1125e83c 100644 (file)
@@ -72,6 +72,7 @@ void save_game(struct World * world) {
   write_uint32_bigendian(world->turn, file);
   write_uint16_bigendian(world->player->pos.y + 1, file);
   write_uint16_bigendian(world->player->pos.x + 1, file);
+  fputc(world->player->hitpoints, file);
   write_map_objects (world->monster, file, write_map_objects_monsterdata);
   write_map_objects (world->item, file, readwrite_map_objects_dummy);
   fclose(file); }
@@ -188,6 +189,7 @@ int main (int argc, char *argv[]) {
     world.turn = read_uint32_bigendian(file);
     player.pos.y = read_uint16_bigendian(file) - 1;
     player.pos.x = read_uint16_bigendian(file) - 1;
+    player.hitpoints = fgetc(file);
     read_map_objects (&world.monster, file, sizeof(struct Monster), read_map_objects_monsterdata);
     read_map_objects (&world.item,    file, sizeof(struct Item),    readwrite_map_objects_dummy);
     fclose(file); }