From: Christian Heller Date: Tue, 29 Oct 2013 02:48:39 +0000 (+0100) Subject: Not very elegant solution to bug of appropriate inventory selection not being saved... X-Git-Tag: tce~938 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/templates?a=commitdiff_plain;h=18fefabcc05bb3903384efbcc92f4303d9ac9567;p=plomrogue Not very elegant solution to bug of appropriate inventory selection not being saved in record file for dropping actions. --- diff --git a/src/main.c b/src/main.c index bb2ef43..4a7b57d 100644 --- a/src/main.c +++ b/src/main.c @@ -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); } } diff --git a/src/main.h b/src/main.h index bf86e05..8105d34 100644 --- a/src/main.h +++ b/src/main.h @@ -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. */ diff --git a/src/map_object_actions.c b/src/map_object_actions.c index 4217145..d486349 100644 --- a/src/map_object_actions.c +++ b/src/map_object_actions.c @@ -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); diff --git a/src/misc.c b/src/misc.c index aa855cd..bddf571 100644 --- a/src/misc.c +++ b/src/misc.c @@ -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); }