#pragma once // Public GDScript-facing network arguments arrive as signed integers. The // wire structs use narrower unsigned fields, so every M2Client entry point // must validate before converting instead of allowing a negative value to // wrap into a large packet argument. #include #include namespace mtnet::bounds { inline constexpr bool u8(int64_t value) { return value >= 0 && value <= std::numeric_limits::max(); } inline constexpr bool u16(int64_t value) { return value >= 0 && value <= std::numeric_limits::max(); } inline constexpr bool u32(int64_t value) { return value >= 0 && value <= std::numeric_limits::max(); } inline constexpr bool i32(int64_t value) { return value >= std::numeric_limits::min() && value <= std::numeric_limits::max(); } // Protocol geometry / array limits from ClientVS22 Packet.h and GameType.h. inline constexpr int QUICK_SLOT_COUNT = 36; inline constexpr int SHOP_ITEM_SLOT_COUNT = 40; inline constexpr int PRIVATE_SHOP_ITEM_COUNT = 39; inline constexpr int EXCHANGE_ITEM_SLOT_COUNT = 12; inline constexpr int CUBE_ITEM_SLOT_COUNT = 24; inline constexpr int POINT_COUNT = 255; inline constexpr int DS_REFINE_SLOT_COUNT = 15; // Packet.h:2041 SKILL_MAX_NUM; ClickSkillSlot rejects slot >= SKILL_MAX_NUM // (PythonPlayerSkill.cpp:108) and the aSkill[] index is always below it. inline constexpr int SKILL_MAX_NUM = 255; inline constexpr bool quick_slot(int64_t value) { return value >= 0 && value < QUICK_SLOT_COUNT; } inline constexpr bool shop_slot(int64_t value) { return value >= 0 && value < SHOP_ITEM_SLOT_COUNT; } inline constexpr bool private_shop_slot(int64_t value) { return value >= 0 && value < SHOP_ITEM_SLOT_COUNT; } inline constexpr bool exchange_slot(int64_t value) { return value >= 0 && value < EXCHANGE_ITEM_SLOT_COUNT; } inline constexpr bool cube_slot(int64_t value) { return value >= 0 && value < CUBE_ITEM_SLOT_COUNT; } // Real skill intent (CG_USE_SKILL vnum). Reference use path only ever sends a // positive index below SKILL_MAX_NUM; a caller value outside that is rejected // rather than masked into the uint32 wire field. inline constexpr bool skill_index(int64_t value) { return value > 0 && value < SKILL_MAX_NUM; } } // namespace mtnet::bounds