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 1:
switch (this->restrictions->weapon_and_armor_mode) {
case Restrictions::WeaponAndArmorMode::NORMAL:
case Restrictions::WeaponAndArmorMode::NORMAL2:
case Restrictions::WeaponAndArmorMode::ALL_ON:
case Restrictions::WeaponAndArmorMode::ONLY_PICKING:
break;
case Restrictions::WeaponAndArmorMode::FORBID_RARES:
case Restrictions::WeaponAndArmorMode::NO_RARE:
if (!this->item_parameter_table->is_item_rare(item)) {
this->log.info("Restricted: rare items not allowed");
break;
}
[[fallthrough]];
case Restrictions::WeaponAndArmorMode::FORBID_ALL:
case Restrictions::WeaponAndArmorMode::ALL_OFF:
this->log.info("Restricted: weapons and armors not allowed");
item.clear();
break;
@@ -470,14 +470,14 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
}
break;
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");
item.clear();
} else if (item.data1[1] == 2) {
switch (this->restrictions->tech_disk_mode) {
case Restrictions::TechDiskMode::NORMAL:
case Restrictions::TechDiskMode::ON:
break;
case Restrictions::TechDiskMode::FORBID_ALL:
case Restrictions::TechDiskMode::OFF:
this->log.info("Restricted: tech disks not allowed");
item.clear();
break;
@@ -499,7 +499,7 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
}
break;
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");
item.clear();
}
+17 -21
View File
@@ -17,35 +17,31 @@ struct ItemDropSub {
class ItemCreator {
public:
struct Restrictions {
// Note: The original code has a uint8_t enable_item_restrictions here; we
// omit it because the caller can just pass a null pointer for this struct.
// 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.
// Note: In the original code, this is actually the battle rules structure.
// We omit some fields here because the item creator doesn't need them.
enum class TechDiskMode {
NORMAL = 0,
FORBID_ALL = 1,
ON = 0,
OFF = 1,
LIMIT_LEVEL = 2,
};
enum class WeaponAndArmorMode {
NORMAL = 0,
NORMAL2 = 1,
FORBID_ALL = 2,
FORBID_RARES = 3,
// Note: These names match the value names in TPlyPKEditor
ALL_ON = 0,
ONLY_PICKING = 1,
ALL_OFF = 2,
NO_RARE = 3,
};
enum class ToolMode {
NORMAL = 0,
NORMAL2 = 1,
FORBID_ALL = 2,
// Note: These names match the value names in TPlyPKEditor
ALL_ON = 0,
ONLY_PICKING = 1,
ALL_OFF = 2,
};
enum class MesetaDropMode {
NORMAL = 0,
FORBID_ALL = 1,
UNKNOWN = 2,
// Note: These names match the value names in TPlyPKEditor
ON = 0,
OFF = 1,
ONLY_PICKING = 2,
};
TechDiskMode tech_disk_mode;
WeaponAndArmorMode weapon_and_armor_mode;