summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-06-22 09:36:59 +0200
committerBardur Arantsson <bardur@scientician.net>2016-06-22 09:47:02 +0200
commit9e04bdd234e09e3e2e50c65ec21688a496ae1c4f (patch)
tree2ea42914d1fe13cab925a00d7e53da292fbb36e3 /src
parent6f02ef2e62739efc23d10ae2c7cea69a908b657b (diff)
Split store_info_type::table into a "kind" and "chance" component
Diffstat (limited to 'src')
-rw-r--r--src/init1.cc17
-rw-r--r--src/store.cc6
-rw-r--r--src/store_info_type.hpp6
3 files changed, 17 insertions, 12 deletions
diff --git a/src/init1.cc b/src/init1.cc
index 7b15440a..e4c2bc98 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -6100,13 +6100,14 @@ errr init_st_info_txt(FILE *fp)
if (!*s) return (1);
/* Get the index */
- st_ptr->table[item_idx][1] = atoi(buf + 2);
+ st_ptr->item_chance[item_idx] = atoi(buf + 2);
/* Append chars to the name */
- st_ptr->table[item_idx++][0] = test_item_name(s);
+ st_ptr->item_kind[item_idx] = test_item_name(s);
- st_ptr->table_num = item_idx;
- assert(st_ptr->table_num <= STORE_CHOICES);
+ item_idx++;
+ st_ptr->item_num = item_idx;
+ assert(st_ptr->item_num <= STORE_CHOICES);
/* Next... */
continue;
@@ -6122,11 +6123,13 @@ errr init_st_info_txt(FILE *fp)
&rar1, &tv1, &sv1)) return (1);
/* Get the index */
- st_ptr->table[item_idx][1] = rar1;
+ st_ptr->item_chance[item_idx] = rar1;
/* Hack -- 256 as a sval means all possible items */
- st_ptr->table[item_idx++][0] = (sv1 < 256) ? lookup_kind(tv1, sv1) : tv1 + 10000;
+ st_ptr->item_kind[item_idx] = (sv1 < 256) ? lookup_kind(tv1, sv1) : tv1 + 10000;
- st_ptr->table_num = item_idx;
+ item_idx++;
+ st_ptr->item_num = item_idx;
+ assert(st_ptr->item_num <= STORE_CHOICES);
/* Next... */
continue;
diff --git a/src/store.cc b/src/store.cc
index 972dd096..72ae4eb0 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -1280,9 +1280,9 @@ static void store_create(void)
else
{
/* Hack -- Pick an item to sell */
- item = rand_int(st_info[st_ptr->st_idx].table_num);
- i = st_info[st_ptr->st_idx].table[item][0];
- chance = st_info[st_ptr->st_idx].table[item][1];
+ item = rand_int(st_info[st_ptr->st_idx].item_num);
+ i = st_info[st_ptr->st_idx].item_kind[item];
+ chance = st_info[st_ptr->st_idx].item_chance[item];
/* Don't allow k_info artifacts */
if ((i <= 10000) && (k_info[i].flags & TR_NORM_ART))
diff --git a/src/store_info_type.hpp b/src/store_info_type.hpp
index 030afe91..6a6efd65 100644
--- a/src/store_info_type.hpp
+++ b/src/store_info_type.hpp
@@ -14,8 +14,10 @@ struct store_info_type
{
const char *name; /* Name */
- s16b table[STORE_CHOICES][2]; /* Table -- Legal item kinds */
- byte table_num; /* Number of items */
+ s16b item_kind[STORE_CHOICES]; /* Table -- Legal item kinds */
+ s16b item_chance[STORE_CHOICES];
+ byte item_num; /* Number of items */
+
s16b max_obj; /* Number of items this store can hold */
u16b owners[4]; /* List of owners(refers to ow_info) */