// Public M2Client argument bounds shared by the Classic and m2dev backends. #include "../src/net/net_bounds.h" #include static int g_fail = 0; #define CHECK(c, msg) \ do { \ if (!(c)) { \ std::fprintf(stderr, "FAIL: %s\n", msg); \ ++g_fail; \ } \ } while (0) int main() { using namespace mtnet::bounds; CHECK(u8(0) && u8(255), "u8 accepts wire range"); CHECK(!u8(-1) && !u8(256), "u8 rejects outside range"); CHECK(u16(65535) && !u16(-1) && !u16(65536), "u16 range"); CHECK(u32(0) && u32(0xffffffffLL) && !u32(-1), "u32 range"); CHECK(i32(-2147483648LL) && i32(2147483647LL), "i32 accepts signed range"); CHECK(!i32(-2147483649LL) && !i32(2147483648LL), "i32 rejects outside range"); CHECK(quick_slot(0) && quick_slot(35), "quick slot endpoints"); CHECK(!quick_slot(-1) && !quick_slot(36), "quick slot outside range"); CHECK(private_shop_slot(0) && private_shop_slot(39), "private shop endpoints"); CHECK(!private_shop_slot(40), "private shop outside range"); CHECK(exchange_slot(0) && exchange_slot(11) && !exchange_slot(12), "exchange range"); CHECK(cube_slot(0) && cube_slot(23) && !cube_slot(24), "cube range"); // ยง3.8 mod 3: use_skill skill index. 1..254 accepted, 0 / >=255 / negative rejected. CHECK(SKILL_MAX_NUM == 255, "SKILL_MAX_NUM matches Packet.h"); CHECK(skill_index(1) && skill_index(254), "skill index endpoints"); CHECK(!skill_index(0) && !skill_index(255) && !skill_index(-1), "skill index outside range"); CHECK(!skill_index(0x7fffffffLL + 1), "skill index rejects large value"); if (g_fail) { std::fprintf(stderr, "%d checks FAILED\n", g_fail); return 1; } std::puts("net_bounds_test: OK"); return 0; }