Files
metin2-server/tests/features/test_material_stack_policy.py
shenlei bb0963210e feat: support Linux/ARM cross-platform build and AVA2 feature updates
- Port server core and libraries to Linux and 32-bit ARM (armhf):
  * Replace FreeBSD kqueue with Linux epoll in libthecore fdwatch
  * Fix unaligned float and 64-bit int memory stores in utils.h str_to_number to avoid ARM VFP alignment fault (SIGBUS)
  * Fix getopt loop variable type in main.cpp (char -> int) to eliminate infinite loop caused by default unsigned char on ARM
  * Add -fsigned-char and multi-architecture flags to Makefiles (x86_64 -m32, i386, and ARM armhf)
  * Update libsql for modern MariaDB client library (removed reconnect field) and C++20 concept/syntax compatibility
  * Replace Win32 xdirent with standard POSIX dirent on Unix/Linux
  * Include xmd5 in libthecore on non-FreeBSD platforms
- AVA2 unlock features and tools:
  * Material stacking up to 2000 count, refine material resolution and test suites
  * AVA2 ticket shop and point drop configuration updates
2026-11-11 00:59:49 -08:00

49 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Compile the active item-level material policy and verify its grant/storage rules."""
import pathlib
import subprocess
import tempfile
root = pathlib.Path(__file__).resolve().parents[2]
source = r'''
#include <cstdint>
typedef uint8_t BYTE;
typedef uint16_t WORD;
#include "src/server/common/length.h"
#include "src/server/common/item_length.h"
#include "src/server/game/src/port_material_stack_policy.h"
#include <cassert>
int main() {
using namespace PortMaterialStackPolicy;
for (auto t : {ITEM_USE, ITEM_AUTOUSE, ITEM_MATERIAL, ITEM_METIN,
ITEM_RESOURCE, ITEM_BLEND, ITEM_EXTRACT})
assert(Limit(t, true, false) == 2000);
assert(Limit(ITEM_USE, false, false) == 200);
assert(Limit(ITEM_USE, true, true) == 200);
assert(Limit(ITEM_QUEST, true, false) == 200);
assert(Limit(ITEM_TREASURE_BOX, true, false) == 200);
assert(Limit(ITEM_WEAPON, false, false) == 200);
assert(GrantLimit(ITEM_WEAPON, false, false) == 1);
assert(GrantLimit(ITEM_USE, true, true) == 1);
setenv("PORT_MATERIAL_STACK_QA_LOGIN", "alice,bob", 1);
assert(QAAllowed("alice") && QAAllowed("bob") && !QAAllowed("ali") && !QAAllowed("eve"));
unsetenv("PORT_MATERIAL_STACK_QA_LOGIN");
assert(QAAllowed("eve"));
setenv("PORT_MATERIAL_STACK_LEGACY_MODE", "1", 1);
assert(LegacyGrowthMode());
assert(Limit(ITEM_USE, true, false) == 2000); // Reading old wide rows remains safe.
unsetenv("PORT_MATERIAL_STACK_LEGACY_MODE");
assert(!LegacyGrowthMode());
RefineIngredients().insert(999001);
assert(Limit(ITEM_QUEST, true, false, 999001) == 2000);
assert(Limit(ITEM_QUEST, true, false, 999002) == 200);
}
'''.replace('#include <cassert>', '#include <cassert>\n#include <initializer_list>')
with tempfile.TemporaryDirectory() as td:
path = pathlib.Path(td) / 'policy.cpp'
path.write_text(source)
exe = pathlib.Path(td) / 'policy'
subprocess.run(['c++', '-std=c++11', '-I', str(root), str(path), '-o', str(exe)], check=True)
subprocess.run([str(exe)], check=True)
print('PASS: material stack policy')