home · contact · privacy
Not very elegant solution to bug of appropriate inventory selection not being saved...
authorChristian Heller <c.heller@plomlompom.de>
Tue, 29 Oct 2013 02:48:39 +0000 (03:48 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 29 Oct 2013 02:48:39 +0000 (03:48 +0100)
src/main.c
src/main.h
src/map_object_actions.c
src/misc.c

index bb2ef43c438c931ff7df99d30f1823563ef6853d..4a7b57d1b5190ac6efce8f240587d481e8359888 100644 (file)
@@ -25,7 +25,7 @@
 #include "wincontrol.h" /* get_win_by_id(), get_winconf_by_win() */
 #include "rrand.h" /* for rrand(), rrand_seed() */
 #include "rexit.h" /* for exit_game(), exit_err() */
-#include "command_db.h" /* for init_command_db() */
+#include "command_db.h" /* for init_command_db(), is_command_id_shortdsc() */
 #include "control.h" /* for *_control(), get_available_keycode_to_action() */
 
 
@@ -182,6 +182,10 @@ int main(int argc, char *argv[])
                 {
                     break;
                 }
+                if (is_command_id_shortdsc(&world, action, "drop"))
+                {
+                    world.inventory_select = getc(file);
+                }
                 record_control(action, &world);
             }
         }
@@ -201,6 +205,10 @@ int main(int argc, char *argv[])
                 action = getc(file);
                 if (EOF != action)
                 {
+                    if (is_command_id_shortdsc(&world, action, "drop"))
+                    {
+                        world.inventory_select = getc(file);
+                    }
                     record_control(action, &world);
                 }
             }
index bf86e0507ce3426ed336e4dbb602d292deaf6127..8105d3421933bf0889565003ae147988d6559a55 100644 (file)
@@ -38,7 +38,8 @@ struct World
     struct MapObjDef * map_obj_defs;  /* Map object type definitions chain. */
     struct MapObj * map_objs;         /* Pointer to map objects chain start. */
     uint8_t inventory_select;         /* Player's inventory selection index. */
-};
+    uint8_t old_inventory_select;     /* Temporarily stores for recordfile */
+};                                    /* writing inventory selection index. */
 
 
 
index 4217145843fc2d1bf80b22df7dd0cbe65f5be159..d486349cc2f6f7ba566b5ae5c44559f8cd5f29df 100644 (file)
@@ -169,9 +169,11 @@ extern void player_drop(struct World * world)
     if (NULL == player->owns)
     {
         update_log(world, "\nYou try to drop an object, but you own none.");
+        world->old_inventory_select = 0;
     }
     else
     {
+        world->old_inventory_select = world->inventory_select;
         struct MapObj * owned = player->owns;
         uint8_t i = 0;
         for (; i != world->inventory_select; i++, owned = owned->next);
index aa855cd19c39fbe9416fa5986fe37036da4e5c7b..bddf571288bc6860ef143d679042687d9545dd1a 100644 (file)
@@ -22,6 +22,8 @@
                          * sorted_wintoggle_and_activate()
                          */
 #include "windows.h" /* for suspend_win() */
+#include "command_db.h" /* for is_command_id_shortdsc() */
+
 
 
 extern char * trouble_msg(struct World * w, char * parent, char * child)
@@ -212,6 +214,11 @@ extern void turn_over(struct World * world, char action)
         }
         try_fclose(file_old, world, f_name);
         exit_err(write_uint8(action, file_new), world, err_write);
+        if (is_command_id_shortdsc(world, action, "drop"))
+        {
+            uint8_t inventory_select = world->old_inventory_select;
+            exit_err(write_uint8(inventory_select, file_new), world, err_write);
+        }
         try_fclose_unlink_rename(file_new, recordfile_tmp, recordfile,
                                  world, f_name);
     }