summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:13 +0200
committerBardur Arantsson <bardur@scientician.net>2016-09-17 09:58:13 +0200
commita7ead32f2066fe12dd2154800f480247dc6d7c6c (patch)
tree2dd4a6371a8fd50e1be7bc3138da0e531e67738d
parent9ca81ed64c847db6b5d2a0890e7aea3ac96d92d1 (diff)
Use std::vector for town_type::store
-rw-r--r--src/birth.cc3
-rw-r--r--src/init2.cc11
-rw-r--r--src/loadsave.cc2
-rw-r--r--src/town_type.hpp5
4 files changed, 10 insertions, 11 deletions
diff --git a/src/birth.cc b/src/birth.cc
index 41a7cc9b..dd66e11f 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -3051,9 +3051,6 @@ void init_town(int t_idx)
/* Generation seed for the town */
t_ptr->seed = randint(0x10000000);
-
- /* Total hack and not even used */
- t_ptr->numstores = 8;
}
/*
diff --git a/src/init2.cc b/src/init2.cc
index fca7473a..5a4662a0 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -682,15 +682,16 @@ static errr init_towns(void)
for (std::size_t i = 1; i < max_towns; i++)
{
- if (i <= max_real_towns) town_info[i].flags |= (TOWN_REAL);
-
- /* Allocate the stores */
- town_info[i].store = new store_type[max_st_idx];
+ if (i <= max_real_towns)
+ {
+ town_info[i].flags |= TOWN_REAL;
+ }
/* Fill in each store */
for (std::size_t j = 0; j < max_st_idx; j++)
{
- /* Access the store */
+ /* Create the store */
+ town_info[i].store.emplace_back(store_type());
store_type *st_ptr = &town_info[i].store[j];
/* Know who we are */
diff --git a/src/loadsave.cc b/src/loadsave.cc
index 4c924527..8d63abf9 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -2351,7 +2351,7 @@ static bool_ do_savefile_aux(ls_flag_t flag)
if (i >= TOWN_RANDOM)
{
do_u32b(&town_info[i].seed, flag);
- do_byte(&town_info[i].numstores, flag);
+ do_byte(&tmp8u, flag);
do_byte(&town_info[i].flags, flag);
/* If the town is realy used create a sock */
diff --git a/src/town_type.hpp b/src/town_type.hpp
index 7758f7fd..e119968b 100644
--- a/src/town_type.hpp
+++ b/src/town_type.hpp
@@ -3,6 +3,8 @@
#include "h-basic.h"
#include "store_type_fwd.hpp"
+#include <vector>
+
/**
* Town descriptor.
*/
@@ -12,8 +14,7 @@ struct town_type
u32b seed = 0; /* Seed for RNG */
- store_type *store = nullptr; /* The stores [max_st_idx] */
- byte numstores = 0;
+ std::vector<store_type> store; /* The stores [max_st_idx] */
byte flags = 0; /* Town flags */