From 702fef7b4739b984fb26c5557769d90af3ff7cc8 Mon Sep 17 00:00:00 2001 From: shenlei Date: Wed, 23 Sep 2026 22:05:24 +0900 Subject: [PATCH] 2V2-e.5a: restore 40250 min-max helpers for camera update --- audit/port-map/EterBase/Utils.cpp.json | 95 +++++++++++++++++++++++ extension/src/platform/EterBase/Utils.cpp | 36 ++++----- extension/src/port/CMakeLists.txt | 3 + extension/tests/port_utils_test.cpp | 25 ++++++ 4 files changed, 141 insertions(+), 18 deletions(-) create mode 100644 audit/port-map/EterBase/Utils.cpp.json create mode 100644 extension/tests/port_utils_test.cpp diff --git a/audit/port-map/EterBase/Utils.cpp.json b/audit/port-map/EterBase/Utils.cpp.json new file mode 100644 index 00000000..ed5a8d0e --- /dev/null +++ b/audit/port-map/EterBase/Utils.cpp.json @@ -0,0 +1,95 @@ +{ + "reference": "EterBase/Utils.cpp", + "reference_sha256": "031ffe819a55e0cea829e0da23e490ebf6b17dca8e2e0c9151350081b12f59b3", + "priority": "P4", + "contracts": [], + "functions": { + "CreateTempFileName": { + "status": "TODO" + }, + "GetFilePathNameExtension": { + "status": "TODO" + }, + "GetFileExtension": { + "status": "TODO" + }, + "GetFileNameParts": { + "status": "TODO" + }, + "GetOldIndexingName": { + "status": "TODO" + }, + "GetIndexingName": { + "status": "TODO" + }, + "GetOnlyFileName": { + "status": "TODO" + }, + "GetExceptionPathName": { + "status": "TODO" + }, + "GetOnlyPathName": { + "status": "TODO" + }, + "GetLocalFileName": { + "status": "TODO" + }, + "GetWorkingFolder": { + "status": "TODO" + }, + "StringLowers": { + "status": "TODO" + }, + "StringPath": { + "status": "TODO" + }, + "PrintAsciiData": { + "status": "TODO" + }, + "fMIN": { + "status": "ADAPTED", + "impl": ["extension/src/platform/EterBase/Utils.cpp:fMIN"], + "note": "Exact 40250 pure float comparison; platform unit retains its OS-specific functions.", + "test": "extension/tests/port_utils_test.cpp" + }, + "fMAX": { + "status": "ADAPTED", + "impl": ["extension/src/platform/EterBase/Utils.cpp:fMAX"], + "note": "Exact 40250 pure float comparison; fixes zero-distance camera when map becomes ready.", + "test": "extension/tests/port_utils_test.cpp" + }, + "fMINMAX": { + "status": "ADAPTED", + "impl": ["extension/src/platform/EterBase/Utils.cpp:fMINMAX"], + "note": "Exact 40250 pure float clamp in platform translation unit.", + "test": "extension/tests/port_utils_test.cpp" + }, + "IsFile": { + "status": "TODO" + }, + "IsGlobalFileName": { + "status": "TODO" + }, + "MyCreateDirectory": { + "status": "TODO" + }, + "RemoveAllDirectory": { + "status": "TODO" + }, + "StringExceptCharacter": { + "status": "TODO" + }, + "SplitLine": { + "status": "TODO" + }, + "GetExcutedFileName": { + "status": "TODO" + }, + "_getf": { + "status": "TODO" + }, + "CommandLineToArgv": { + "status": "TODO" + } + } +} diff --git a/extension/src/platform/EterBase/Utils.cpp b/extension/src/platform/EterBase/Utils.cpp index da50a105..a0148542 100644 --- a/extension/src/platform/EterBase/Utils.cpp +++ b/extension/src/platform/EterBase/Utils.cpp @@ -142,40 +142,40 @@ auto IsGlobalFileName(const char *) -> bool return mt_platform_stub_return(); } -auto MIN(int, int) -> int +auto MIN(int a, int b) -> int { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + return a < b ? a : b; } -auto MAX(int, int) -> int +auto MAX(int a, int b) -> int { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + return a > b ? a : b; } -auto MINMAX(int, int, int) -> int +auto MINMAX(int min, int value, int max) -> int { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + if (max < min) + return MAX(min, value); + int tv; + tv = (min > value ? min : value); + return (max < tv) ? max : tv; } -auto fMIN(float, float) -> float +auto fMIN(float a, float b) -> float { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + return a < b ? a : b; } -auto fMAX(float, float) -> float +auto fMAX(float a, float b) -> float { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + return a > b ? a : b; } -auto fMINMAX(float, float, float) -> float +auto fMINMAX(float min, float value, float max) -> float { - MT_PLATFORM_STUB(); - return mt_platform_stub_return(); + float tv; + tv = (min > value ? min : value); + return (max < tv) ? max : tv; } auto MyCreateDirectory(const char *) -> void diff --git a/extension/src/port/CMakeLists.txt b/extension/src/port/CMakeLists.txt index 534fee4a..5cdf49d7 100644 --- a/extension/src/port/CMakeLists.txt +++ b/extension/src/port/CMakeLists.txt @@ -155,6 +155,9 @@ add_dependencies(port_logic port_header_gate) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../platform ${CMAKE_CURRENT_BINARY_DIR}/../platform) if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME) + add_executable(port_utils_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_utils_test.cpp) + target_link_libraries(port_utils_test PRIVATE port_platform) + add_test(NAME port.utils COMMAND $) 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 $) diff --git a/extension/tests/port_utils_test.cpp b/extension/tests/port_utils_test.cpp new file mode 100644 index 00000000..0fbc2ebd --- /dev/null +++ b/extension/tests/port_utils_test.cpp @@ -0,0 +1,25 @@ +#include "EterBase/StdAfx.h" +#include "EterBase/Utils.h" + +#include + +int main() +{ + int failures = 0; + auto check = [&failures](bool ok, const char *name) { + if (!ok) { + std::fprintf(stderr, "FAIL %s\n", name); + ++failures; + } + }; + check(MIN(-3, 8) == -3 && MIN(8, -3) == -3, "MIN order/sign"); + check(MAX(-3, 8) == 8 && MAX(8, -3) == 8, "MAX order/sign"); + check(MINMAX(2, -5, 9) == 2, "MINMAX lower"); + check(MINMAX(2, 20, 9) == 9, "MINMAX upper"); + check(MINMAX(9, 4, 2) == 9, "MINMAX reversed bounds"); + check(fMIN(-3.5f, 8.5f) == -3.5f, "fMIN sign"); + check(fMAX(200.0f, 0.0f) == 200.0f, "fMAX camera floor"); + check(fMINMAX(2.0f, -5.0f, 9.0f) == 2.0f, "fMINMAX lower"); + check(fMINMAX(2.0f, 20.0f, 9.0f) == 9.0f, "fMINMAX upper"); + return failures ? 1 : 0; +}