diff options
author | Bardur Arantsson <bardur@scientician.net> | 2016-10-05 18:45:08 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2016-10-05 18:45:08 +0200 |
commit | 1173c144b06d5d2d3c9e6351af5e6f06cb843d4b (patch) | |
tree | d26a6fb2fb9be5633d2277b5679ce1260d725bf3 /src/generate.cc | |
parent | 4d51094236b79b5d525c771d6cd3d990b9e64df8 (diff) |
Move v_info into GameEditData
Diffstat (limited to 'src/generate.cc')
-rw-r--r-- | src/generate.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/generate.cc b/src/generate.cc index 752b0f53..3f6d64c0 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -3744,8 +3744,10 @@ static void build_vault(int yval, int xval, int ymax, int xmax, std::string cons */ static void build_type7(int by0, int bx0) { - vault_type *v_ptr = NULL; - int dummy = 0, xval, yval; + auto const &v_info = game->edit_data.v_info; + + auto v_ptr(v_info.end()); + int dummy = 0; /* Pick a lesser vault */ while (dummy < SAFE_MAX_ATTEMPTS) @@ -3753,13 +3755,15 @@ static void build_type7(int by0, int bx0) dummy++; /* Access a random vault record */ - v_ptr = &v_info[rand_int(max_v_idx)]; + v_ptr = uniform_element(v_info); /* Accept the first lesser vault */ if (v_ptr->typ == 7) break; } /* Try to allocate space for room. If fails, exit */ + int xval; + int yval; if (!room_alloc(v_ptr->wid, v_ptr->hgt, FALSE, by0, bx0, &xval, &yval)) { if (options->cheat_room) @@ -3806,8 +3810,10 @@ static void build_type7(int by0, int bx0) */ static void build_type8(int by0, int bx0) { - vault_type *v_ptr = NULL; - int dummy = 0, xval, yval; + auto const &v_info = game->edit_data.v_info; + + auto v_ptr(v_info.end()); + int dummy = 0; /* Pick a lesser vault */ while (dummy < SAFE_MAX_ATTEMPTS) @@ -3815,13 +3821,15 @@ static void build_type8(int by0, int bx0) dummy++; /* Access a random vault record */ - v_ptr = &v_info[rand_int(max_v_idx)]; + v_ptr = uniform_element(v_info); /* Accept the first greater vault */ if (v_ptr->typ == 8) break; } /* Try to allocate space for room. If fails, exit */ + int xval; + int yval; if (!room_alloc(v_ptr->wid, v_ptr->hgt, FALSE, by0, bx0, &xval, &yval)) { if (options->cheat_room) |