Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Write an item's squelch status to the savefile. Fixes #1633. #31

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+145 −4
Split
View
@@ -52,6 +52,137 @@ static struct theme *lookup_theme(int idx)
/*
+ * Read an object, version 6 (added ignore status).
+ */
+static int rd_item_7(object_type *o_ptr)
+{
+ byte tmp8u;
+ u16b tmp16u;
+
+ u16b affix_idx, theme_idx, prefix_idx, suffix_idx;
+ byte art_idx;
+
+ size_t i, j;
+
+ char buf[128];
+
+ byte ver = 1;
+ byte max_pvals = 0, of_size = 0, of_bytes = 0, max_affixes = 0;
+
+ rd_u16b(&tmp16u);
+ rd_byte(&ver);
+ assert(tmp16u == 0xffff);
+
+ strip_bytes(2);
+
+ /* read the constants */
+ rd_byte(&max_pvals);
+ if (max_pvals > MAX_PVALS) return -1;
+ rd_byte(&of_size);
+ if (of_size > OF_SIZE) return -1;
+ rd_byte(&of_bytes);
+ if (of_bytes > OF_BYTES) return -1;
+ rd_byte(&max_affixes);
+ if (max_affixes > MAX_AFFIXES) return -1;
+
+ /* Location */
+ rd_byte(&o_ptr->iy);
+ rd_byte(&o_ptr->ix);
+
+ /* Type/Subtype */
+ rd_byte(&o_ptr->tval);
+ rd_byte(&o_ptr->sval);
+
+ /* Pval info */
+ for (i = 0; i < max_pvals; i++)
+ rd_s16b(&o_ptr->pval[i]);
+ rd_byte(&o_ptr->num_pvals);
+
+ /* Pseudo-ID bit */
+ rd_byte(&tmp8u);
+
+ rd_byte(&o_ptr->number);
+ rd_s16b(&o_ptr->weight);
+
+ /* Artifact / theme / affix info */
+ rd_byte(&art_idx);
+ rd_u16b(&theme_idx);
+
+ for (i = 0; i < max_affixes; i++) {
+ rd_u16b(&affix_idx);
+ o_ptr->affix[i] = lookup_affix(affix_idx);
+ }
+ rd_u16b(&prefix_idx);
+ rd_u16b(&suffix_idx);
+
+ /* Basic object data */
+ rd_s16b(&o_ptr->timeout);
+ rd_s32b(&o_ptr->extent);
+
+ rd_s16b(&o_ptr->to_finesse);
+ rd_s16b(&o_ptr->to_prowess);
+ rd_s16b(&o_ptr->to_a);
+ rd_s16b(&o_ptr->balance);
+ rd_s16b(&o_ptr->heft);
+ rd_s16b(&o_ptr->ac);
+ rd_byte(&o_ptr->dd);
+ rd_byte(&o_ptr->ds);
+
+ /* Object metadata */
+ rd_u16b(&o_ptr->ident);
+ rd_byte(&o_ptr->marked);
+ rd_byte(&o_ptr->origin);
+ rd_byte(&o_ptr->origin_depth);
+ rd_u16b(&o_ptr->origin_xtra);
+ rd_byte(&o_ptr->ignore);
+
+ /* Flag and known flag data */
+ for (i = 0; i < of_bytes && i < of_size; i++)
+ rd_byte(&o_ptr->flags[i]);
+ if (i < of_bytes) strip_bytes(of_bytes - i);
+
+ of_wipe(o_ptr->known_flags);
+
+ for (i = 0; i < of_bytes && i < of_size; i++)
+ rd_byte(&o_ptr->known_flags[i]);
+ if (i < of_bytes) strip_bytes(of_bytes - i);
+
+ for (j = 0; j < max_pvals; j++) {
+ for (i = 0; i < of_bytes && i < of_size; i++)
+ rd_byte(&o_ptr->pval_flags[j][i]);
+ if (i < of_bytes) strip_bytes(of_bytes - i);
+ }
+
+ /* Monster holding object */
+ rd_s16b(&o_ptr->held_m_idx);
+
+ rd_s16b(&o_ptr->mimicking_m_idx);
+
+ /* Save the inscription */
+ rd_string(buf, sizeof(buf));
+ if (buf[0]) o_ptr->note = quark_add(buf);
+
+
+ /* Lookup item kind */
+ o_ptr->kind = lookup_kind(o_ptr->tval, o_ptr->sval);
+ if (!o_ptr->kind)
+ return 0;
+
+ o_ptr->theme = lookup_theme(theme_idx);
+ o_ptr->prefix = lookup_affix(prefix_idx);
+ o_ptr->suffix = lookup_affix(suffix_idx);
+
+ if (art_idx >= z_info->a_max)
+ return -1;
+ if (art_idx > 0)
+ o_ptr->artifact = &a_info[art_idx];
+
+ /* Success */
+ return (0);
+}
+
+
+/*
* Read an object, version 6 (added balance and heft).
*/
static int rd_item_6(object_type *o_ptr)
@@ -2367,6 +2498,7 @@ static int rd_inventory(rd_item_t rd_item_version)
/*
* Read the player inventory - wrapper functions
*/
+int rd_inventory_7(void) { return rd_inventory(rd_item_7); }
int rd_inventory_6(void) { return rd_inventory(rd_item_6); }
int rd_inventory_5(void) { return rd_inventory(rd_item_5); }
int rd_inventory_4(void) { return rd_inventory(rd_item_4); }
@@ -2442,6 +2574,7 @@ static int rd_stores(rd_item_t rd_item_version)
/*
* Read the stores - wrapper functions
*/
+int rd_stores_7(void) { return rd_stores(rd_item_7); }
int rd_stores_6(void) { return rd_stores(rd_item_6); }
int rd_stores_5(void) { return rd_stores(rd_item_5); }
int rd_stores_4(void) { return rd_stores(rd_item_4); }
@@ -2705,6 +2838,7 @@ static int rd_objects(rd_item_t rd_item_version)
/*
* Read the object list - wrapper functions
*/
+int rd_objects_7(void) { return rd_objects(rd_item_7); }
int rd_objects_6(void) { return rd_objects(rd_item_6); }
int rd_objects_5(void) { return rd_objects(rd_item_5); }
int rd_objects_4(void) { return rd_objects(rd_item_4); }
View
@@ -499,7 +499,7 @@ typedef struct object {
byte number; /* Number of items */
s32b extent; /* Charges/food|fuel value/gold amount/chest status */
byte marked; /* Object is marked */
- bool ignore; /* Object is ignored */
+ byte ignore; /* Object is ignored */
s16b next_o_idx; /* Next object in stack (if any) */
s16b held_m_idx; /* Monster holding us (if any) */
View
@@ -108,6 +108,7 @@ static void wr_item(const object_type *o_ptr)
wr_byte(o_ptr->origin);
wr_byte(o_ptr->origin_depth);
wr_u16b(o_ptr->origin_xtra);
+ wr_byte(o_ptr->ignore);
for (i = 0; i < OF_BYTES && i < OF_SIZE; i++)
wr_byte(o_ptr->flags[i]);
View
@@ -89,10 +89,10 @@ static const struct {
{ "player hp", wr_player_hp, 1 },
{ "player spells", wr_player_spells, 1 },
{ "randarts", wr_randarts, 3 },
- { "inventory", wr_inventory, 6 },
- { "stores", wr_stores, 6 },
+ { "inventory", wr_inventory, 7 },
+ { "stores", wr_stores, 7 },
{ "dungeon", wr_dungeon, 1 },
- { "objects", wr_objects, 6 },
+ { "objects", wr_objects, 7 },
{ "monsters", wr_monsters, 6 },
{ "ghost", wr_ghost, 1 },
{ "history", wr_history, 1 },
@@ -131,19 +131,22 @@ static const struct {
{ "inventory", rd_inventory_4, 4 },
{ "inventory", rd_inventory_5, 5 },
{ "inventory", rd_inventory_6, 6 },
+ { "inventory", rd_inventory_7, 7 },
{ "stores", rd_stores_1, 1 },
{ "stores", rd_stores_2, 2 },
{ "stores", rd_stores_3, 3 },
{ "stores", rd_stores_4, 4 },
{ "stores", rd_stores_5, 5 },
{ "stores", rd_stores_6, 6 },
+ { "stores", rd_stores_7, 7 },
{ "dungeon", rd_dungeon, 1 },
{ "objects", rd_objects_1, 1 },
{ "objects", rd_objects_2, 2 },
{ "objects", rd_objects_3, 3 },
{ "objects", rd_objects_4, 4 },
{ "objects", rd_objects_5, 5 },
{ "objects", rd_objects_6, 6 },
+ { "objects", rd_objects_7, 7 },
{ "monsters", rd_monsters_1, 1 },
{ "monsters", rd_monsters_2, 2 },
{ "monsters", rd_monsters_3, 3 },
View
@@ -69,19 +69,22 @@ int rd_inventory_3(void);
int rd_inventory_4(void);
int rd_inventory_5(void);
int rd_inventory_6(void);
+int rd_inventory_7(void);
int rd_stores_1(void);
int rd_stores_2(void);
int rd_stores_3(void);
int rd_stores_4(void);
int rd_stores_5(void);
int rd_stores_6(void);
+int rd_stores_7(void);
int rd_dungeon(void);
int rd_objects_1(void);
int rd_objects_2(void);
int rd_objects_3(void);
int rd_objects_4(void);
int rd_objects_5(void);
int rd_objects_6(void);
+int rd_objects_7(void);
int rd_monsters_1(void);
int rd_monsters_2(void);
int rd_monsters_3(void);