cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node ¶mnode) : m_value(0) { // read the core attributes m_minval = number_and_format(xml_get_attribute_int(¶mnode, "min", 0), xml_get_attribute_int_format(¶mnode, "min")); m_maxval = number_and_format(xml_get_attribute_int(¶mnode, "max", 0), xml_get_attribute_int_format(¶mnode, "max")); m_stepval = number_and_format(xml_get_attribute_int(¶mnode, "step", 1), xml_get_attribute_int_format(¶mnode, "step")); // iterate over items for (xml_data_node *itemnode = xml_get_sibling(paramnode.child, "item"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "item")) { // check for NULL text if (itemnode->value == NULL || itemnode->value[0] == 0) throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line); // check for non-existant value if (xml_get_attribute(itemnode, "value") == NULL) throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line); // extract the parameters UINT64 value = xml_get_attribute_int(itemnode, "value", 0); int format = xml_get_attribute_int_format(itemnode, "value"); // allocate and append a new item item &curitem = m_itemlist.append(*global_alloc(item(itemnode->value, value, format))); // ensure the maximum expands to suit m_maxval = MAX(m_maxval, curitem.value()); } // add a variable to the symbol table for our value symbols.add("param", symbol_table::READ_ONLY, &m_value); }
cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node const ¶mnode) : m_value(0) { // read the core attributes m_minval = number_and_format(paramnode.get_attribute_int("min", 0), paramnode.get_attribute_int_format("min")); m_maxval = number_and_format(paramnode.get_attribute_int("max", 0), paramnode.get_attribute_int_format("max")); m_stepval = number_and_format(paramnode.get_attribute_int("step", 1), paramnode.get_attribute_int_format("step")); // iterate over items for (xml_data_node const *itemnode = paramnode.get_child("item"); itemnode != nullptr; itemnode = itemnode->get_next_sibling("item")) { // check for nullptr text if (itemnode->get_value() == nullptr || itemnode->get_value()[0] == 0) throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line); // check for non-existant value if (!itemnode->has_attribute("value")) throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line); // extract the parameters uint64_t const value = itemnode->get_attribute_int("value", 0); xml_data_node::int_format const format = itemnode->get_attribute_int_format("value"); // allocate and append a new item auto curitem = std::make_unique<item>(itemnode->get_value(), value, format); // ensure the maximum expands to suit m_maxval = std::max(m_maxval, curitem->value()); m_itemlist.push_back(std::move(curitem)); } // add a variable to the symbol table for our value symbols.add("param", symbol_table::READ_ONLY, &m_value); }