diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-06-12 06:27:05 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-08-01 17:26:10 +0200 |
commit | c6196b25d119a10e79deedef26a73e0d5a021b0e (patch) | |
tree | 199f5bff5cf363787eb610caa495fd3682a463ed /src/cave_type.hpp | |
parent | 000f6272f8ab1d43ec6300fb5972f7813ada1c88 (diff) |
Refactor cave_type and monster_type to use non-intrusive lists
We use vectors of object indexes instead of embedding the list within
object_type itself.
Diffstat (limited to 'src/cave_type.hpp')
-rw-r--r-- | src/cave_type.hpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/cave_type.hpp b/src/cave_type.hpp index 912e1091..958ace1d 100644 --- a/src/cave_type.hpp +++ b/src/cave_type.hpp @@ -2,6 +2,9 @@ #include "h-basic.h" +#include <cassert> +#include <vector> + /** * A single "grid" in a Cave. * @@ -27,26 +30,36 @@ */ struct cave_type { - u16b info; /* Hack -- cave flags */ + u16b info = 0; /* Hack -- cave flags */ + + byte feat = 0; /* Hack -- feature type */ + + std::vector<s16b> o_idxs { }; /* Indexes of objects in this grid */ - byte feat; /* Hack -- feature type */ + s16b m_idx = 0; /* Monster in this grid */ - s16b o_idx; /* Object in this grid */ + s16b t_idx = 0; /* trap index (in t_list) or zero */ - s16b m_idx; /* Monster in this grid */ + s16b special = 0; /* Special cave info */ + s16b special2 = 0; /* Special cave info */ - s16b t_idx; /* trap index (in t_list) or zero */ + s16b inscription = 0; /* Inscription of the grid */ - s16b special, special2; /* Special cave info */ + byte mana = 0; /* Magical energy of the grid */ - s16b inscription; /* Inscription of the grid */ + byte mimic = 0; /* Feature to mimic */ - byte mana; /* Magical energy of the grid */ + byte cost = 0; /* Hack -- cost of flowing */ + byte when = 0; /* Hack -- when cost was computed */ - byte mimic; /* Feature to mimic */ + s16b effect = 0; /* The lasting effects */ - byte cost; /* Hack -- cost of flowing */ - byte when; /* Hack -- when cost was computed */ + /** + * @brief wipe the object's state + */ + void wipe() { + /* Reset to defaults */ + *this = cave_type(); + } - s16b effect; /* The lasting effects */ }; |