blob: 08e6002fc9ff69f938bb24b81ec9f6a05254b8d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#pragma once
#include "h-basic.h"
#include <cassert>
#include <vector>
/**
* A single "grid" in a Cave.
*
* Note that several aspects of the code restrict the actual cave
* to a max size of 256 by 256. In partcular, locations are often
* saved as bytes, limiting each coordinate to the 0-255 range.
*
* The "o_idx" and "m_idx" fields are very interesting. There are
* many places in the code where we need quick access to the actual
* monster or object(s) in a given cave grid. The easiest way to
* do this is to simply keep the index of the monster and object
* (if any) with the grid, but this takes 198*66*4 bytes of memory.
* Several other methods come to mind, which require only half this
* amound of memory, but they all seem rather complicated, and would
* probably add enough code that the savings would be lost. So for
* these reasons, we simply store an index into the "o_list" and
* "m_list" arrays, using "zero" when no monster/object is present.
*
* Note that "o_idx" is the index of the top object in a stack of
* objects, using the "next_o_idx" field of objects to create the
* singly linked list of objects. If "o_idx" is zero then there
* are no objects in the grid.
*/
struct cave_type
{
u16b info = 0; /* Hack -- cave flags */
byte feat = 0; /* Hack -- feature type */
std::vector<s16b> o_idxs { }; /* Indexes of objects in this grid */
s16b m_idx = 0; /* Monster in this grid */
s16b special = 0; /* Special cave info */
s16b special2 = 0; /* Special cave info */
s16b inscription = 0; /* Inscription of the grid */
byte mana = 0; /* Magical energy of the grid */
byte mimic = 0; /* Feature to mimic */
byte cost = 0; /* Hack -- cost of flowing */
byte when = 0; /* Hack -- when cost was computed */
s16b effect = 0; /* The lasting effects */
/**
* @brief wipe the object's state
*/
void wipe() {
/* Reset to defaults */
*this = cave_type();
}
};
|