From c6196b25d119a10e79deedef26a73e0d5a021b0e Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 12 Jun 2015 06:27:05 +0200 Subject: 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. --- src/cave_type.hpp | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/cave_type.hpp') 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 +#include + /** * 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 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 */ }; -- cgit v1.2.3