Skip to content

Commit

Permalink
[Fix] Ring transformation on creation (#238)
Browse files Browse the repository at this point in the history
Rings was transforming into wrong itemIDs on creation.
  • Loading branch information
marcosvf132 authored Mar 11, 2022
1 parent 5cb9ff7 commit 0eacb35
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
19 changes: 6 additions & 13 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,13 @@ Item* Item::CreateItem(const uint16_t type, uint16_t count /*= 0*/)
newItem = new Mailbox(type);
} else if (it.isBed()) {
newItem = new BedItem(type);
} else if (it.id >= ITEM_SWORD_RING && it.id <= ITEM_CLUB_RING) {
newItem = new Item(type - 3, count);
} else if (it.id == ITEM_DWARVEN_RING || it.id == ITEM_RING_HEALING) {
newItem = new Item(type - 2, count);
} else if (it.id >= ITEM_STEALTH_RING && it.id <= ITEM_TIME_RING) {
newItem = new Item(type - 37, count);
} else if (it.id == ITEM_PAIR_SOFT_BOOTS_ACTIVATED) {
newItem = new Item(ITEM_PAIR_SOFT_BOOTS, count);
} else if (it.id == ITEM_DEATH_RING_ACTIVATED) {
newItem = new Item(ITEM_DEATH_RING, count);
} else if (it.id == ITEM_PRISMATIC_RING_ACTIVATED) {
newItem = new Item(ITEM_PRISMATIC_RING, count);
} else {
newItem = new Item(type, count);
auto itemMap = ItemTransformationMap.find(static_cast<item_t>(it.id));
if (itemMap != ItemTransformationMap.end()) {
newItem = new Item(itemMap->second, count);
} else {
newItem = new Item(type, count);
}
}

newItem->incrementReferenceCounter();
Expand Down
28 changes: 27 additions & 1 deletion src/utils/utils_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,25 +704,51 @@ enum item_t : uint16_t {

ITEM_OLD_DIAMOND_ARROW = 25757,
ITEM_DIAMOND_ARROW = 35901,

ITEM_FILLED_BATH_TUBE = 26077,

ITEM_SWORD_RING = 3091,
ITEM_SWORD_RING_ACTIVATED = 3094,

ITEM_CLUB_RING = 3093,
ITEM_CLUB_RING_ACTIVATED = 3096,

ITEM_DWARVEN_RING = 3097,
ITEM_DWARVEN_RING_ACTIVATED = 3099,

ITEM_RING_HEALING = 3098,
ITEM_RING_HEALING_ACTIVATED = 3100,

ITEM_STEALTH_RING = 3049,
ITEM_STEALTH_RING_ACTIVATED = 3086,

ITEM_TIME_RING = 3053,
ITEM_TIME_RING_ACTIVATED = 3090,

ITEM_PAIR_SOFT_BOOTS = 6529,
ITEM_PAIR_SOFT_BOOTS_ACTIVATED = 3549,

ITEM_DEATH_RING = 6299,
ITEM_DEATH_RING_ACTIVATED = 6300,

ITEM_PRISMATIC_RING = 16114,
ITEM_PRISMATIC_RING_ACTIVATED = 16264
};

// A map which contains items that, when on creating, should be transformed to the default type.
const std::unordered_map<item_t, item_t> ItemTransformationMap = {
{ITEM_SWORD_RING_ACTIVATED, ITEM_SWORD_RING},
{ITEM_CLUB_RING_ACTIVATED, ITEM_CLUB_RING},
{ITEM_DWARVEN_RING_ACTIVATED, ITEM_DWARVEN_RING},
{ITEM_RING_HEALING_ACTIVATED, ITEM_RING_HEALING},
{ITEM_STEALTH_RING_ACTIVATED, ITEM_STEALTH_RING},
{ITEM_TIME_RING_ACTIVATED, ITEM_TIME_RING},
{ITEM_PAIR_SOFT_BOOTS_ACTIVATED, ITEM_PAIR_SOFT_BOOTS},
{ITEM_DEATH_RING_ACTIVATED, ITEM_DEATH_RING},
{ITEM_PRISMATIC_RING_ACTIVATED, ITEM_PRISMATIC_RING},
{ITEM_OLD_DIAMOND_ARROW, ITEM_DIAMOND_ARROW},
};

enum PlayerFlags : uint64_t {
PlayerFlag_CannotUseCombat = 1 << 0,
PlayerFlag_CannotAttackPlayer = 1 << 1,
Expand Down

0 comments on commit 0eacb35

Please sign in to comment.