mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-23 21:17:45 +00:00
Consolidate constants used for ever-changing inventory actions
They seem to be in order (Sapphire and other sources suggest this as well.) So they are now derived from a BASE_INVENTORY_ACTION constant to make it easier to update in the future.
This commit is contained in:
parent
1e015db2f7
commit
64fc99d7a9
2 changed files with 9 additions and 29 deletions
|
@ -25,10 +25,7 @@ mod currency;
|
|||
pub use currency::CurrencyKind;
|
||||
pub use currency::CurrencyStorage;
|
||||
|
||||
use crate::{
|
||||
INVENTORY_ACTION_COMBINE_STACK, INVENTORY_ACTION_DISCARD, INVENTORY_ACTION_EXCHANGE,
|
||||
INVENTORY_ACTION_MOVE, INVENTORY_ACTION_SPLIT_STACK, INVENTORY_ACTION_UPDATE_CURRENCY,
|
||||
};
|
||||
use crate::BASE_INVENTORY_ACTION;
|
||||
|
||||
const MAX_NORMAL_STORAGE: usize = 35;
|
||||
const MAX_LARGE_STORAGE: usize = 50;
|
||||
|
@ -39,18 +36,18 @@ const MAX_LARGE_STORAGE: usize = 50;
|
|||
#[repr(u8)]
|
||||
pub enum ItemOperationKind {
|
||||
/// The operation opcode/type when updating the currency storage.
|
||||
UpdateCurrency = INVENTORY_ACTION_UPDATE_CURRENCY,
|
||||
UpdateCurrency = BASE_INVENTORY_ACTION,
|
||||
/// The operation opcode/type when discarding an item from the inventory.
|
||||
Discard = INVENTORY_ACTION_DISCARD,
|
||||
Discard = BASE_INVENTORY_ACTION + 1,
|
||||
#[default]
|
||||
/// The operation opcode/type when moving an item to an emtpy slot in the inventory.
|
||||
Move = INVENTORY_ACTION_MOVE,
|
||||
Move = BASE_INVENTORY_ACTION + 2,
|
||||
/// The operation opcode/type when moving an item to a slot occupied by another in the inventory.
|
||||
Exchange = INVENTORY_ACTION_EXCHANGE,
|
||||
Exchange = BASE_INVENTORY_ACTION + 3,
|
||||
/// The operation opcode/type when splitting stacks of identical items.
|
||||
SplitStack = INVENTORY_ACTION_SPLIT_STACK,
|
||||
SplitStack = BASE_INVENTORY_ACTION + 4,
|
||||
/// The operation opcode/type when combining stacks of identical items.
|
||||
CombineStack = INVENTORY_ACTION_COMBINE_STACK,
|
||||
CombineStack = BASE_INVENTORY_ACTION + 6,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for ItemOperationKind {
|
||||
|
|
21
src/lib.rs
21
src/lib.rs
|
@ -91,25 +91,8 @@ pub const ITEM_CONDITION_MAX: u16 = 30000;
|
|||
/// The invalid/nothing/none actor ID.
|
||||
pub const INVALID_ACTOR_ID: u32 = 0xE000_0000;
|
||||
|
||||
// These operation codes/types change regularly, so update them when needed!
|
||||
|
||||
/// The operation opcode/type when updating the currency storage.
|
||||
pub const INVENTORY_ACTION_UPDATE_CURRENCY: u8 = 144;
|
||||
|
||||
/// The operation opcode/type when discarding an item from the inventory.
|
||||
pub const INVENTORY_ACTION_DISCARD: u8 = 145;
|
||||
|
||||
/// The operation opcode/type when moving an item to an emtpy slot in the inventory.
|
||||
pub const INVENTORY_ACTION_MOVE: u8 = 146;
|
||||
|
||||
/// The operation opcode/type when moving an item to a slot occupied by another in the inventory.
|
||||
pub const INVENTORY_ACTION_EXCHANGE: u8 = 147;
|
||||
|
||||
/// The operation opcode/type when splitting stacks of identical items.
|
||||
pub const INVENTORY_ACTION_SPLIT_STACK: u8 = 148;
|
||||
|
||||
/// The operation opcode/type when combining stacks of identical items.
|
||||
pub const INVENTORY_ACTION_COMBINE_STACK: u8 = 150;
|
||||
// This operation code change regularly, so update it when needed!
|
||||
pub const BASE_INVENTORY_ACTION: u8 = 144;
|
||||
|
||||
/// The server's acknowledgement of a shop item being purchased.
|
||||
pub const INVENTORY_ACTION_ACK_SHOP: u8 = 6;
|
||||
|
|
Loading…
Add table
Reference in a new issue