Move special node category into the node properties struct

This commit is contained in:
2017-04-14 00:40:05 -04:00
parent 791c2a27d4
commit e98f9381fe
5 changed files with 12 additions and 10 deletions

View File

@@ -656,7 +656,7 @@ static int offsets[] = {
int(eSpecType::OUT_MAKE_WANDER),
};
eSpecCat getNodeCategory(eSpecType node) {
static eSpecCat getNodeCategory(eSpecType node) {
int code = (int) node;
if(code >= 0 && code <= 47)
return eSpecCat::GENERAL;
@@ -688,6 +688,7 @@ static std::map<eSpecType, node_properties_t> loadProps() {
if(category == eSpecCat::INVALID) continue;
node_properties_t props;
props.self = check;
props.cat = category;
int j = int(category), k = i - offsets[j];
props.m1_btn = button_dict[j][0][k];
props.m2_btn = button_dict[j][1][k];
@@ -716,8 +717,10 @@ static std::map<eSpecType, node_properties_t> loadProps() {
}
const node_properties_t& operator* (eSpecType t) {
static node_properties_t invalid;
static std::map<eSpecType, node_properties_t> allNodeProps = loadProps();
return allNodeProps.at(t);
auto iter = allNodeProps.find(t);
return iter == allNodeProps.end() ? invalid : iter->second;
}
std::string node_properties_t::opcode() const {

View File

@@ -120,6 +120,7 @@ enum class eSpecCat {
struct node_properties_t {
eSpecType self;
eSpecCat cat;
std::string opcode() const;
std::string name() const, descr() const;
std::string sdf1_lbl() const, sdf2_lbl() const, sdf1_hlp() const, sdf2_hlp() const;
@@ -130,11 +131,10 @@ struct node_properties_t {
std::string jmp_lbl() const, jmp_hlp() const;
char sd1_btn, sd2_btn, m1_btn, m2_btn, m3_btn, p_btn, pt_btn;
char x1a_btn, x1b_btn, x1c_btn, x2a_btn, x2b_btn, x2c_btn;
node_properties_t() {}
node_properties_t() : self(eSpecType::INVALID), cat(eSpecCat::INVALID) {}
node_properties_t(std::initializer_list<std::function<void(node_properties_t)>>);
};
const node_properties_t& operator* (eSpecType t);
eSpecCat getNodeCategory(eSpecType node);
#endif