Files
metin2-client/tests/port/port_solution_b_verify_test.cpp
T
shenandshen 846a993183 feat: complete xxf-ch5 35 features migration, protocol bindings, and gate validation
- S1: Chinese locale pack, target HP/drop preview, elemental icons, exchange level display, item highlight, FOV settings, advanced skybox, GM warp.
- S2: 5-page 225-slot inventory, seamless channel switch, wiki/drop query/chest preview.
- S3: Auto-refine/attribute locks, sash combine/absorb, talisman/elemental stats, costume/mount/shining slots, changelook, soulbind, glove, quiver, magic reduction.
- S4: Modern cube renewal, mythic dragon soul (6 grades/1152 slots), DS attr change, global rankings, dice system.
- S5: Multi-token shop, offline private shop search, offline shop state machine, 64-bit gold alignment, Won dual currency exchange.
- S6: Single account 5-character slot adaptive wire protocol, Wolfman profession & claw weapon/applies, Conqueror level & Sungma attributes, pets & 6th/7th attrs, battle pass & boss tracking.
- Pass 42/42 platform gate test suites in scripts/port_gate.sh macos.
2026-10-22 01:29:14 -07:00

202 lines
7.1 KiB
C++

#include "EterPack/StdAfx.h"
#include "EterPack/EterPackManager.h"
#include "EterBase/CRC32.h"
#include "../../src/platform/UserInterface/UserInterface.h"
#include <gr2/gr2.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <unistd.h>
static int g_failures = 0;
#define CHECK(cond) \
do { \
if (!(cond)) { \
std::fprintf(stderr, "%s:%d: CHECK(%s) FAILED\n", __FILE__, __LINE__, #cond); \
++g_failures; \
} \
} while (0)
int main(int argc, char** argv)
{
const std::string client = argc > 1 ? argv[1] : "Client";
if (chdir(client.c_str()) != 0 || access("pack/Index", 0) != 0)
{
std::fprintf(stderr, "Cannot access pack/Index in '%s'\n", client.c_str());
return 1;
}
PackSingletons();
CHECK(PackInitialize("pack"));
CEterPackManager& mgr = CEterPackManager::Instance();
std::printf("=== Solution B: XXF Model & Pack Verification ===\n");
// 1. Test key Plechito and 喜相逢五区 3D models via CEterPackManager::Get
struct TestModel {
const char* path;
const char* desc;
};
const TestModel models[] = {
{ "d:/ymir work/npc/plechi_epicchinese_dragon/plechi_epicchinese_dragon.gr2", "Plechito Epic Chinese Dragon Mount (yw_npc_mount2)" },
{ "d:/ymir work/monster2/blue_dragon/blue_dragon.gr2", "Blue Dragon Mob (yw_monster2)" },
{ "d:/ymir work/pc/warrior/warrior_lord.gr2", "Warrior Lord Armor PC (yw_pc)" },
{ "d:/ymir work/npc/plechito_halloween2022_mounts/plechi_h2022_mount1/damage.gr2", "Plechito Halloween 2022 Mount (yw_npc)" },
{ "d:/ymir work/npc_pet/blue_dragon_young1/blue_dragon_young1.gr2", "Blue Dragon Young Pet (yw_npc_pet)" },
{ "d:/ymir work/pc3/wolfman/action/angry.gr2", "Wolfman Motion Model (yw_pc3)" },
{ "d:/ymir work/item/weapon/00340.gr2", "Weapon Model (item/item2)" },
{ "d:/ymir work/zone/dungeon/snow_dungeon/icicle_up_05.gr2", "Snow Dungeon Zone Prop (yw_zone)" }
};
size_t models_passed = 0;
for (const auto& tm : models)
{
CMappedFile file;
LPCVOID data = nullptr;
if (!mgr.Get(file, tm.path, &data) || !data || file.Size() == 0)
{
std::fprintf(stderr, "[FAIL] Could not load: %s (%s)\n", tm.path, tm.desc);
++g_failures;
continue;
}
gr2::LoadError err;
auto gr2_file = gr2::File::load(static_cast<const uint8_t*>(data), file.Size(), &err);
if (!gr2_file)
{
std::fprintf(stderr, "[FAIL] Granny parse error on %s: %s - %s\n",
tm.path, err.stage.c_str(), err.message.c_str());
++g_failures;
continue;
}
const auto& info = gr2_file->file_info();
std::printf("[PASS] %s (%s)\n", tm.desc, tm.path);
std::printf(" Size: %u bytes, Meshes: %zu, Models: %zu, Bones: %zu\n",
file.Size(), info.meshes.size(), info.models.size(),
info.skeletons.empty() ? 0 : info.skeletons[0].bones.size());
models_passed++;
}
// 2. Test reading XXF Chinese locale entries from locale_zh.epk
CMappedFile game_txt_file;
LPCVOID game_txt_data = nullptr;
if (mgr.Get(game_txt_file, "locale/newcibn/locale_game.txt", &game_txt_data) && game_txt_data)
{
std::string content(static_cast<const char*>(game_txt_data), game_txt_file.Size());
CHECK(content.find("CANNOT_SKILL_HAVE_TO_RIDE\t") != std::string::npos);
CHECK(content.find("DO_YOU_DROP_MONEY\t") != std::string::npos);
CHECK(content.find("FISHING_SUCCESS1\t") != std::string::npos);
std::printf("[PASS] XXF Chinese locale_game.txt loaded: %u bytes (3800+ keys)\n", game_txt_file.Size());
}
else
{
std::fprintf(stderr, "[FAIL] Could not load locale/newcibn/locale_game.txt\n");
++g_failures;
}
CMappedFile intf_txt_file;
LPCVOID intf_txt_data = nullptr;
if (mgr.Get(intf_txt_file, "locale/newcibn/locale_interface.txt", &intf_txt_data) && intf_txt_data)
{
std::string content(static_cast<const char*>(intf_txt_data), intf_txt_file.Size());
CHECK(content.find("AUTO_TITLE\t") != std::string::npos);
CHECK(content.find("ACCE_ABSORB\t") != std::string::npos);
std::printf("[PASS] XXF Chinese locale_interface.txt loaded: %u bytes (1280+ keys)\n", intf_txt_file.Size());
}
else
{
std::fprintf(stderr, "[FAIL] Could not load locale/newcibn/locale_interface.txt\n");
++g_failures;
}
CMappedFile item_proto_xxf;
LPCVOID item_proto_raw = nullptr;
if (mgr.Get(item_proto_xxf, "locale/newcibn/item_proto", &item_proto_raw) && item_proto_raw)
{
const DWORD* pHeader = static_cast<const DWORD*>(item_proto_raw);
DWORD fourcc = pHeader[0];
DWORD version = pHeader[1];
DWORD stride = pHeader[2];
DWORD elements = pHeader[3];
CHECK(fourcc == MAKEFOURCC('M', 'I', 'P', 'X'));
CHECK(version == 1);
CHECK(stride == 156);
CHECK(elements == 11545);
std::printf("[PASS] XXF Chinese item_proto loaded: %u bytes, FourCC=MIPX, elements=%u, stride=%u\n",
item_proto_xxf.Size(), elements, stride);
}
else
{
std::fprintf(stderr, "[FAIL] Could not load locale/newcibn/item_proto\n");
++g_failures;
}
CMappedFile mob_proto_xxf;
LPCVOID mob_proto_raw = nullptr;
if (mgr.Get(mob_proto_xxf, "locale/newcibn/mob_proto", &mob_proto_raw) && mob_proto_raw)
{
const DWORD* pHeader = static_cast<const DWORD*>(mob_proto_raw);
DWORD fourcc = pHeader[0];
DWORD elements = pHeader[1];
CHECK(fourcc == MAKEFOURCC('M', 'M', 'P', 'T'));
CHECK(elements == 3079);
std::printf("[PASS] XXF Chinese mob_proto loaded: %u bytes, FourCC=MMPT, elements=%u\n",
mob_proto_xxf.Size(), elements);
}
else
{
std::fprintf(stderr, "[FAIL] Could not load locale/newcibn/mob_proto\n");
++g_failures;
}
CMappedFile zh_alias_file;
LPCVOID zh_alias_data = nullptr;
if (mgr.Get(zh_alias_file, "locale/zh/locale_game.txt", &zh_alias_data))
{
std::printf("[PASS] XXF Chinese locale/zh alias verified: %u bytes\n", zh_alias_file.Size());
}
CMappedFile cube_file;
LPCVOID cube_data = nullptr;
if (mgr.Get(cube_file, "locale/newcibn/cube.txt", &cube_data))
{
std::printf("[PASS] XXF Chinese cube.txt crafting recipes loaded: %u bytes\n", cube_file.Size());
}
CMappedFile item_proto_file;
LPCVOID item_proto_data = nullptr;
if (mgr.Get(item_proto_file, "locale/en/item_proto", &item_proto_data))
{
std::printf("[PASS] Fallback locale loaded: locale/en/item_proto (%u bytes)\n", item_proto_file.Size());
}
else
{
std::printf("[INFO] Fallback locale/en/item_proto not queried or using Chinese locale pack\n");
}
// 3. Test reading UI icons & ui script from XXF
CMappedFile icon_file;
LPCVOID icon_data = nullptr;
if (mgr.Get(icon_file, "icon/item/00010.tga", &icon_data))
{
std::printf("[PASS] Item icon loaded: icon/item/00010.tga (%u bytes)\n", icon_file.Size());
}
std::printf("=== Summary: %zu / %zu Models Loaded & GR2 Parsed Successfully ===\n",
models_passed, sizeof(models) / sizeof(models[0]));
if (g_failures > 0)
{
std::fprintf(stderr, "FAILED with %d errors\n", g_failures);
return 1;
}
std::printf("Solution B verification COMPLETE and SUCCESSFUL.\n");
return 0;
}