summaryrefslogtreecommitdiff
path: root/src/birth.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
committerBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
commit2c8b8579faf729b9cf21b8b2d827f0e482570bd3 (patch)
tree7c258a9008d00ff1ec54de578d092e370b90cd95 /src/birth.cc
parentfdb532aec5234db77a9111d219f8a870d660c4fc (diff)
Move random_artifacts to Game struct
Diffstat (limited to 'src/birth.cc')
-rw-r--r--src/birth.cc40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/birth.cc b/src/birth.cc
index 36f319d6..2f56ec28 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -56,6 +56,7 @@
#include "xtra2.hpp"
#include "z-rand.hpp"
+#include <algorithm>
#include <fmt/format.h>
#include <numeric>
#include <string>
@@ -465,33 +466,28 @@ static void get_extra()
*/
static errr init_randart()
{
- int i;
-
- long cost;
-
- random_artifact* ra_ptr;
-
char buf[80];
-
- for (i = 0; i < MAX_RANDARTS; i++)
+ for (int i = 0; i < MAX_RANDARTS; i++)
{
- ra_ptr = &random_artifacts[i];
-
- strcpy(ra_ptr->name_short,
- get_line("rart_s.txt", ANGBAND_DIR_FILE, buf, i));
- strcpy(ra_ptr->name_full,
- get_line("rart_f.txt", ANGBAND_DIR_FILE, buf, i));
-
- ra_ptr->attr = randint(15);
- ra_ptr->activation = rand_int(MAX_T_ACT);
- ra_ptr->generated = FALSE;
-
- cost = randnor(0, 250);
+ // Generate a 'cost'
+ auto cost = randnor(0, 250);
+ if (cost < 0)
+ {
+ cost = 0;
+ }
- if (cost < 0) cost = 0;
+ // Generate the random artifact
+ random_artifact ra;
+ ra.name_short = get_line("rart_s.txt", ANGBAND_DIR_FILE, buf, i);
+ ra.name_full = get_line("rart_f.txt", ANGBAND_DIR_FILE, buf, i);
+ ra.attr = randint(15);
+ ra.activation = rand_int(MAX_T_ACT);
+ ra.generated = FALSE;
+ ra.cost = cost;
- ra_ptr->cost = cost;
+ // Push
+ game->random_artifacts.push_back(ra);
}
return 0;