-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
autocombo.h
161 lines (141 loc) · 3.1 KB
/
autocombo.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef _AUTOCOMBO_H_
#define _AUTOCOMBO_H_
#include <vector>
#include <map>
#include <string>
#include "base/ints.h"
#include "base/general.h"
enum { ACT_NORMAL, ACT_CPOOL };
enum { AUTOCOMBO_NONE, AUTOCOMBO_Z1, AUTOCOMBO_BASIC, AUTOCOMBO_FENCE, AUTOCOMBO_Z4, AUTOCOMBO_RELATIONAL, AUTOCOMBO_DGNCARVE, AUTOCOMBO_DOR, AUTOCOMBO_TILING, AUTOCOMBO_REPLACE };
enum
{
ACF_VALID = 0x1,
ACF_CROSSSCREENS = 0x2,
ACF_FLIP = 0x4,
ACF_LEGACY = 0x4, // used by Relational and Dungeon Carving, neither of which use flip
ACF_CONNECTEDGE = 0x8, // used by Basic, Flat Mountain, Relational, and DoR
ACF_CONNECTSOLID = 0x10 // used by Basic and Relational
};
enum
{
ACIR_ILLEGAL_TYPE = 0x1,
ACIR_DUPLICATE_COMBO = 0x2,
ACIR_MISSING_COMBO = 0x4
};
struct autocombo_entry
{
int32_t cid = -1;
byte ctype = 0; // currently unused, will be used for combo pools / future expansion
int16_t offset = -1;
int16_t engrave_offset = 0;
void clear()
{
*this = autocombo_entry();
}
bool valid() const
{
return offset > -1 && unsigned(cid) < MAXCOMBOS;
}
autocombo_entry() = default;
autocombo_entry(int32_t data, byte ct, int32_t of, int32_t eo) :
cid(data), ctype(ct), offset(of), engrave_offset(eo)
{}
static int16_t base_engrave_offset(byte type);
};
struct combo_auto
{
std::vector<autocombo_entry> combos;
byte flags = 0;
combo_auto()
{}
combo_auto& operator=(combo_auto const& other);
void addEntry(int32_t cid, byte ct, int32_t of, int32_t eo); //add a new combo entry
void removeEntry();
void clear(bool clear_all = false)
{
if (clear_all)
{
type = AUTOCOMBO_NONE;
cid_display = 0;
flags = 0;
cid_erase = 0;
}
combos.clear();
combos.shrink_to_fit();
}
bool valid() const
{
return flags & ACF_VALID;
}
void updateValid();
std::string getInvalidReason();
bool hasTemplate();
bool canErase();
bool containsCombo(int32_t cid, bool requirevalid = true) const;
bool isIgnoredCombo(int32_t cid) const;
byte getFlags() const
{
return flags;
}
void setFlags(byte newflags)
{
flags = newflags;
}
int32_t getType() const
{
return type;
}
void setType(int32_t newtype)
{
type = newtype;
}
byte getArg() const
{
return arg;
}
void setArg(byte newarg)
{
arg = newarg;
}
std::pair<byte,byte> getOffsets()
{
return offsets;
}
void setOffsets(byte xo, byte yo)
{
if (xo < 255)
offsets.first = xo;
if (yo < 255)
offsets.second = yo;
}
int32_t getDisplay() const;
int32_t getIconDisplay() const
{
return cid_display;
}
void setDisplay(int32_t newdisplay)
{
cid_display = newdisplay;
}
int32_t getEraseCombo() const
{
return cid_erase;
}
void setEraseCombo(int32_t newerase)
{
cid_erase = newerase;
}
static int32_t legacy_offsets(byte type, int16_t offset);
static int32_t convert_offsets(byte type, int16_t offset);
static bool ignore_fill(byte type, int32_t slot);
std::map<int32_t,byte> getMapping();
int32_t cid_display = 0;
int32_t cid_erase = 0;
private:
byte type = AUTOCOMBO_NONE;
byte arg = 0;
byte invalid_reasons = 0;
std::pair<byte, byte> offsets;
};
extern combo_auto combo_autos[MAXCOMBOPOOLS];
#endif