use battle rule names in ItemRestrictions

This commit is contained in:
Martin Michelsen
2023-03-18 15:37:08 -07:00
parent 077bfb2e7d
commit 40ca249b8a
2 changed files with 25 additions and 29 deletions
+8 -8
View File
@@ -446,16 +446,16 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
case 0: case 0:
case 1: case 1:
switch (this->restrictions->weapon_and_armor_mode) { switch (this->restrictions->weapon_and_armor_mode) {
case Restrictions::WeaponAndArmorMode::NORMAL: case Restrictions::WeaponAndArmorMode::ALL_ON:
case Restrictions::WeaponAndArmorMode::NORMAL2: case Restrictions::WeaponAndArmorMode::ONLY_PICKING:
break; break;
case Restrictions::WeaponAndArmorMode::FORBID_RARES: case Restrictions::WeaponAndArmorMode::NO_RARE:
if (!this->item_parameter_table->is_item_rare(item)) { if (!this->item_parameter_table->is_item_rare(item)) {
this->log.info("Restricted: rare items not allowed"); this->log.info("Restricted: rare items not allowed");
break; break;
} }
[[fallthrough]]; [[fallthrough]];
case Restrictions::WeaponAndArmorMode::FORBID_ALL: case Restrictions::WeaponAndArmorMode::ALL_OFF:
this->log.info("Restricted: weapons and armors not allowed"); this->log.info("Restricted: weapons and armors not allowed");
item.clear(); item.clear();
break; break;
@@ -470,14 +470,14 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
} }
break; break;
case 3: case 3:
if (this->restrictions->tool_mode == Restrictions::ToolMode::FORBID_ALL) { if (this->restrictions->tool_mode == Restrictions::ToolMode::ALL_OFF) {
this->log.info("Restricted: tools not allowed"); this->log.info("Restricted: tools not allowed");
item.clear(); item.clear();
} else if (item.data1[1] == 2) { } else if (item.data1[1] == 2) {
switch (this->restrictions->tech_disk_mode) { switch (this->restrictions->tech_disk_mode) {
case Restrictions::TechDiskMode::NORMAL: case Restrictions::TechDiskMode::ON:
break; break;
case Restrictions::TechDiskMode::FORBID_ALL: case Restrictions::TechDiskMode::OFF:
this->log.info("Restricted: tech disks not allowed"); this->log.info("Restricted: tech disks not allowed");
item.clear(); item.clear();
break; break;
@@ -499,7 +499,7 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
} }
break; break;
case 4: case 4:
if (this->restrictions->meseta_drop_mode == Restrictions::MesetaDropMode::FORBID_ALL) { if (this->restrictions->meseta_drop_mode == Restrictions::MesetaDropMode::OFF) {
this->log.info("Restricted: meseta not allowed"); this->log.info("Restricted: meseta not allowed");
item.clear(); item.clear();
} }
+17 -21
View File
@@ -17,35 +17,31 @@ struct ItemDropSub {
class ItemCreator { class ItemCreator {
public: public:
struct Restrictions { struct Restrictions {
// Note: The original code has a uint8_t enable_item_restrictions here; we // Note: In the original code, this is actually the battle rules structure.
// omit it because the caller can just pass a null pointer for this struct. // We omit some fields here because the item creator doesn't need them.
// Note: The original code has many more fields in this structure; we only
// include those which are used by the item creator. This structure is
// probably actually the battle rules structure in the original game, but
// many rules apply only client-side and newserv doesn't have to care about
// their effects, so we omit those fields. The NORMAL and NORMAL2 modes
// behave identically from the item creator's perspective, but may actually
// mean "keep equipment" vs. "reset equipment" on the client side.
enum class TechDiskMode { enum class TechDiskMode {
NORMAL = 0, ON = 0,
FORBID_ALL = 1, OFF = 1,
LIMIT_LEVEL = 2, LIMIT_LEVEL = 2,
}; };
enum class WeaponAndArmorMode { enum class WeaponAndArmorMode {
NORMAL = 0, // Note: These names match the value names in TPlyPKEditor
NORMAL2 = 1, ALL_ON = 0,
FORBID_ALL = 2, ONLY_PICKING = 1,
FORBID_RARES = 3, ALL_OFF = 2,
NO_RARE = 3,
}; };
enum class ToolMode { enum class ToolMode {
NORMAL = 0, // Note: These names match the value names in TPlyPKEditor
NORMAL2 = 1, ALL_ON = 0,
FORBID_ALL = 2, ONLY_PICKING = 1,
ALL_OFF = 2,
}; };
enum class MesetaDropMode { enum class MesetaDropMode {
NORMAL = 0, // Note: These names match the value names in TPlyPKEditor
FORBID_ALL = 1, ON = 0,
UNKNOWN = 2, OFF = 1,
ONLY_PICKING = 2,
}; };
TechDiskMode tech_disk_mode; TechDiskMode tech_disk_mode;
WeaponAndArmorMode weapon_and_armor_mode; WeaponAndArmorMode weapon_and_armor_mode;