port 2D step 5a: EterPack/EterPackManager + EterBase file units against the real 40250 packs

- Mirror copies: EterPack (EterPack, EterPackManager, EterPackCursor, CSHybridCrypt policy, Inline.h)
  and EterBase logic units tea/lzo/Timer/Stl/Random, with PORT-tagged width fixes (LONG index
  fields, static_assert(sizeof(TEterPackIndex) == 192), tea_word = Win32 unsigned long).
- TEA pack keys are extracted from the reference EterPack.cpp at configure time into
  build/.../EterPackKeys.generated.h; nothing key-bearing is tracked.
- Platform EterBase: FileBase (stdio, case-insensitive fallback), MappedFile (mmap /
  MapViewOfFile), CRC32, Debug, Utils StringPath/StringLowers.
- Win32Crt: CreateDirectory/DeleteFile/_access/MAKEFOURCC; Win32MinMax.h min/max (force-included
  on MinGW, whose windows.h omits them in C++).
- tests/port_eterpack_test: registers pack/Index like PackInitialize and checks 119
  registrations / 103 packs + root / 54891 entries / 52609 paths / 2282 overrides with
  first-registered-wins, and that exactly the 4 short-layout SECURITY files fail to load.
- 2R count corrected (136 -> 119 registrations, 103 distinct packs + root).

Not runtime-reachable yet (asset_io pack backend is step 5b), so port-map statuses stay TODO.
port_gate: macos/android/ios/windows PASS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-23 00:56:39 +09:00
co-authored by Claude Opus 5
parent f210f47076
commit 1f1004da79
31 changed files with 4640 additions and 142 deletions
+50
View File
@@ -30,6 +30,44 @@ if(NOT MSVC)
endif()
target_compile_options(port_logic PUBLIC ${MT_PORT_WARNING_FLAGS})
target_compile_features(port_logic PUBLIC cxx_std_20)
# Armadillo nanomite markers (StdAfx.h `__asm _emit` jumps over a signature): x86-32 MSVC inline asm that no
# target here accepts, and a no-op without the Armadillo wrapper, so they expand to nothing.
target_compile_definitions(port_logic PUBLIC "NANOBEGIN=" "NANOEND=")
if(MINGW)
target_compile_options(port_logic PUBLIC -include ${CMAKE_CURRENT_SOURCE_DIR}/common/Win32MinMax.h)
endif()
# EterPack/EterPack.cpp includes EterPackKeys.generated.h in place of the two TEA key arrays: the keys are
# read from the reference EterPack.cpp at configure time and written into the build tree, never the repository.
# Without the reference the arrays are zero and every COMPRESS/SECURITY entry fails to decode.
set(MT_40250_SOURCE "$ENV{MT_40250_SOURCE}" CACHE PATH "40250 ClientVS22/source reference root")
if(NOT MT_40250_SOURCE)
set(MT_40250_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../40250/Server Client TMP4/ClientVS22/source")
endif()
set(MT_PORT_GENERATED ${CMAKE_CURRENT_BINARY_DIR}/generated)
set(mt_eterpack_ref "${MT_40250_SOURCE}/EterPack/EterPack.cpp")
set(mt_eterpack_keys "")
if(EXISTS "${mt_eterpack_ref}")
file(READ "${mt_eterpack_ref}" mt_ref_text)
foreach(arr s_adwEterPackKey s_adwEterPackSecurityKey)
string(REGEX MATCH "static DWORD ${arr}\\[\\][ \t\r\n]*=[ \t\r\n]*{[^}]*}" block "${mt_ref_text}")
string(REGEX MATCHALL "[0-9]+" values "${block}")
list(LENGTH values n)
if(NOT n EQUAL 4)
message(FATAL_ERROR "port: ${arr} not found in ${mt_eterpack_ref}")
endif()
list(JOIN values ", " values)
string(APPEND mt_eterpack_keys "static DWORD ${arr}[] = { ${values} };\n")
endforeach()
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${mt_eterpack_ref}")
else()
message(WARNING "port: ${mt_eterpack_ref} not found (set MT_40250_SOURCE); EterPack keys are zero")
string(APPEND mt_eterpack_keys "static DWORD s_adwEterPackKey[] = { 0, 0, 0, 0 };\n"
"static DWORD s_adwEterPackSecurityKey[] = { 0, 0, 0, 0 };\n")
endif()
file(CONFIGURE OUTPUT ${MT_PORT_GENERATED}/EterPackKeys.generated.h
CONTENT "// Generated from the 40250 reference EterPack.cpp by port/CMakeLists.txt; do not commit.\n#pragma once\n${mt_eterpack_keys}")
target_include_directories(port_logic PRIVATE ${MT_PORT_GENERATED})
if(WIN32)
target_link_libraries(port_logic PUBLIC winmm)
endif()
@@ -86,6 +124,10 @@ add_library(port_header_gate OBJECT ${MT_PORT_GATE_SOURCES})
target_include_directories(port_header_gate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MT_PORT_SHIMS})
target_link_libraries(port_header_gate PRIVATE mt3p::minilzo mt3p::cryptopp)
target_compile_features(port_header_gate PRIVATE cxx_std_20)
target_compile_definitions(port_header_gate PRIVATE "NANOBEGIN=" "NANOEND=")
if(MINGW)
target_compile_options(port_header_gate PRIVATE -include ${CMAKE_CURRENT_SOURCE_DIR}/common/Win32MinMax.h)
endif()
target_compile_options(port_header_gate PRIVATE ${MT_PORT_WARNING_FLAGS})
add_dependencies(port_logic port_header_gate)
@@ -95,4 +137,12 @@ if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
add_executable(port_common_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_common_test.cpp)
target_link_libraries(port_common_test PRIVATE port_logic)
add_test(NAME port.common COMMAND $<TARGET_FILE:port_common_test>)
# Against the real 40250 Client/pack next to the reference source; skipped (77) when it is missing,
# failed instead under MT_ASSETS_STRICT=1.
set(MT_40250_CLIENT "${MT_40250_SOURCE}/../../Client" CACHE PATH "40250 Client directory (pack/, Eternexus/)")
add_executable(port_eterpack_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_eterpack_test.cpp)
target_link_libraries(port_eterpack_test PRIVATE port_platform)
add_test(NAME port.eterpack COMMAND $<TARGET_FILE:port_eterpack_test> ${MT_40250_CLIENT})
set_tests_properties(port.eterpack PROPERTIES SKIP_RETURN_CODE 77)
endif()