Align AVA2 Windows behavior and improve mobile touch interactions
This commit is contained in:
+15
-3
@@ -42,7 +42,7 @@ find_package(SDL3 CONFIG REQUIRED)
|
||||
add_library(ava2_transport src/network/login_client.cpp)
|
||||
target_include_directories(ava2_transport PUBLIC src src/network)
|
||||
target_link_libraries(ava2_transport PUBLIC ava2_protocol Threads::Threads)
|
||||
add_library(ava2_render src/eter_render/HardwareScene.cpp src/eter_render/Gr2ModelRenderer.cpp src/eter_render/TerrainHeightmap.cpp src/eter_render/MapObjectManager.cpp src/eter_render/WaterManager.cpp src/eter_render/OrbitCamera.cpp src/eter_render/MinimapManager.cpp src/eter_render/ActorInstance.cpp src/eter_render/ActorInstanceMotionEvent.cpp src/eter_render/RaceData.cpp src/eter_render/FloatingTextManager.cpp src/eter_render/TargetManager.cpp src/eter_render/TextTailManager.cpp src/eter_sound/SoundManager.cpp src/eter_resource/dxt.cpp src/eter_effect/EffectData.cpp src/eter_effect/EffectInstance.cpp src/eter_effect/FlyTrace.cpp src/eter_effect/FlyingManager.cpp src/eter_effect/EffectManager.cpp src/eter_net/NetworkActorManager.cpp src/eter_render/EnvironmentData.cpp src/eter_render/SkyBox.cpp src/eter_render/SpeedTreeRT.cpp src/eter_render/SpeedTreeForest.cpp src/eter_image/MarkManager.cpp src/eter_render/CRenderTarget.cpp shared/common/CRC32.cpp src/eter_image/GrpImageInstance.cpp src/eter_image/GrpDevice.cpp src/eter_resource/texture_decode.cpp)
|
||||
add_library(ava2_render src/eter_base/Timer.cpp src/eter_base/Random.cpp src/eter_render/HardwareScene.cpp src/eter_render/Gr2ModelRenderer.cpp src/eter_render/TerrainHeightmap.cpp src/eter_render/MapObjectManager.cpp src/eter_render/WaterManager.cpp src/eter_render/OrbitCamera.cpp src/eter_render/MinimapManager.cpp src/eter_render/ActorInstance.cpp src/eter_render/ActorInstanceMotionEvent.cpp src/eter_render/RaceData.cpp src/eter_render/FloatingTextManager.cpp src/eter_render/TargetManager.cpp src/eter_render/TextTailManager.cpp src/eter_sound/SoundManager.cpp src/eter_resource/dxt.cpp src/eter_effect/EffectData.cpp src/eter_effect/EffectInstance.cpp src/eter_effect/FlyTrace.cpp src/eter_effect/FlyingManager.cpp src/eter_effect/EffectManager.cpp src/eter_net/NetworkActorManager.cpp src/eter_render/EnvironmentData.cpp src/eter_render/SkyBox.cpp src/eter_render/SpeedTreeRT.cpp src/eter_render/SpeedTreeForest.cpp src/eter_image/MarkManager.cpp src/eter_render/CRenderTarget.cpp shared/common/CRC32.cpp src/eter_image/GrpImageInstance.cpp src/eter_image/GrpDevice.cpp src/eter_resource/texture_decode.cpp)
|
||||
target_include_directories(ava2_render PUBLIC src src/network src/game ${CMAKE_CURRENT_SOURCE_DIR} third_party/extern_include)
|
||||
target_link_libraries(ava2_render PUBLIC libgr2 libgr2_render speedtree SDL3::SDL3)
|
||||
option(AVA2_EMBED_PYTHON "Build embedded Python 2.7 runtime" ON)
|
||||
@@ -85,8 +85,6 @@ if(AVA2_EMBED_PYTHON)
|
||||
src/scripting/python_event_manager.cpp
|
||||
src/scripting/python_chat.cpp
|
||||
src/eter_lib/parser.cpp
|
||||
src/eter_base/Random.cpp
|
||||
src/eter_base/Timer.cpp
|
||||
src/game/game_type.cpp
|
||||
src/eter_ui/PythonWindow.cpp
|
||||
src/eter_ui/PythonWindowManager.cpp
|
||||
@@ -127,6 +125,17 @@ if(BUILD_TESTING AND NOT ANDROID)
|
||||
add_test(NAME ava2.player_panel COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py"
|
||||
"AVA2 skill slot, received level and derived status parity passed" "$<TARGET_FILE:player_panel_test>" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root")
|
||||
add_executable(python_test tests/python_test.cpp)
|
||||
add_executable(windows_behavior_test tests/windows_behavior_test.cpp)
|
||||
target_link_libraries(windows_behavior_test PRIVATE ava2_python ava2_protocol)
|
||||
add_dependencies(windows_behavior_test mtpython_stdlib)
|
||||
add_test(NAME ava2.windows_behavior COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py"
|
||||
"AVA2 Windows network, player and terrain behavior parity passed" "$<TARGET_FILE:windows_behavior_test>" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root")
|
||||
add_executable(player_motion_test tests/player_motion_test.cpp)
|
||||
target_link_libraries(player_motion_test PRIVATE ava2_python ava2_protocol)
|
||||
add_dependencies(player_motion_test mtpython_stdlib)
|
||||
add_test(NAME ava2.player_motion COMMAND player_motion_test "${MT_PYTHON_STDLIB_ZIP}")
|
||||
set_tests_properties(ava2.player_motion PROPERTIES SKIP_RETURN_CODE 77
|
||||
ENVIRONMENT "AVA2_TEST_RUNDIR=${AVA2_TEST_RUNDIR}")
|
||||
target_link_libraries(python_test PRIVATE ava2_python ava2_lzo ava2_protocol)
|
||||
add_dependencies(python_test mtpython_stdlib)
|
||||
add_executable(item_data_test tests/item_data_test.cpp)
|
||||
@@ -248,6 +257,9 @@ if(BUILD_TESTING AND NOT ANDROID)
|
||||
add_executable(ava2_render_3d_test tests/ava2_render_3d_test.cpp)
|
||||
target_link_libraries(ava2_render_3d_test PRIVATE ava2_render)
|
||||
add_test(NAME ava2.render_3d COMMAND ava2_render_3d_test "ymir work/pc/warrior/warrior_assasin1.gr2")
|
||||
add_executable(flying_target_test tests/flying_target_test.cpp)
|
||||
target_link_libraries(flying_target_test PRIVATE ava2_render)
|
||||
add_test(NAME ava2.flying_target COMMAND flying_target_test)
|
||||
add_executable(attack_combo_test tests/attack_combo_test.cpp)
|
||||
target_link_libraries(attack_combo_test PRIVATE ava2_render)
|
||||
add_test(NAME ava2.attack_combo COMMAND attack_combo_test "ymir work/pc/warrior/warrior_assasin1.gr2")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"module": "ServerStateChecker",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/ServerStateCheckerModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 5,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -13,7 +13,7 @@
|
||||
{
|
||||
"module": "app",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonApplicationModule.cpp",
|
||||
"port_file": "src/python_app.cpp",
|
||||
"port_file": "src/scripting/python_app.cpp",
|
||||
"windows_methods": 116,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -22,7 +22,7 @@
|
||||
{
|
||||
"module": "background",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonBackgroundModule.cpp",
|
||||
"port_file": "src/python_background.cpp",
|
||||
"port_file": "src/scripting/python_background.cpp",
|
||||
"windows_methods": 52,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -34,7 +34,7 @@
|
||||
{
|
||||
"module": "battlepass",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonBattlePass.cpp",
|
||||
"port_file": "src/python_battlepass.cpp",
|
||||
"port_file": "src/scripting/python_battlepass.cpp",
|
||||
"windows_methods": 8,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
"module": "chat",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonChatModule.cpp",
|
||||
"port_file": "src/python_chat.cpp",
|
||||
"port_file": "src/scripting/python_chat.cpp",
|
||||
"windows_methods": 33,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -52,7 +52,7 @@
|
||||
{
|
||||
"module": "chr",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonCharacterModule.cpp",
|
||||
"port_file": "src/python_chr.cpp",
|
||||
"port_file": "src/scripting/python_chr.cpp",
|
||||
"windows_methods": 80,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -61,7 +61,7 @@
|
||||
{
|
||||
"module": "chrmgr",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonCharacterManagerModule.cpp",
|
||||
"port_file": "src/python_chr.cpp",
|
||||
"port_file": "src/scripting/python_chr.cpp",
|
||||
"windows_methods": 37,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -70,7 +70,7 @@
|
||||
{
|
||||
"module": "cube_renewal",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonCubeRenewal.cpp",
|
||||
"port_file": "src/python_cube_renewal.cpp",
|
||||
"port_file": "src/scripting/python_cube_renewal.cpp",
|
||||
"windows_methods": 5,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -79,7 +79,7 @@
|
||||
{
|
||||
"module": "dbg",
|
||||
"windows_file": "upstream/ava2-client/ScriptLib/PythonDebugModule.cpp",
|
||||
"port_file": "src/python_dbg.cpp",
|
||||
"port_file": "src/scripting/python_dbg.cpp",
|
||||
"windows_methods": 5,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -88,7 +88,7 @@
|
||||
{
|
||||
"module": "drop_item",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonDropItem.cpp",
|
||||
"port_file": "src/python_drop_item.cpp",
|
||||
"port_file": "src/scripting/python_drop_item.cpp",
|
||||
"windows_methods": 8,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -97,7 +97,7 @@
|
||||
{
|
||||
"module": "dungeon_info",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonDungeonInfo.cpp",
|
||||
"port_file": "src/python_dungeon_info.cpp",
|
||||
"port_file": "src/scripting/python_dungeon_info.cpp",
|
||||
"windows_methods": 12,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -106,7 +106,7 @@
|
||||
{
|
||||
"module": "effect",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonEffectModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 7,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -115,7 +115,7 @@
|
||||
{
|
||||
"module": "event",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonEventManagerMoudle.cpp",
|
||||
"port_file": "src/python_event_manager.cpp",
|
||||
"port_file": "src/scripting/python_event_manager.cpp",
|
||||
"windows_methods": 29,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -124,7 +124,7 @@
|
||||
{
|
||||
"module": "eventMgr",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonGameEventManagerModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 1,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -133,7 +133,7 @@
|
||||
{
|
||||
"module": "exchange",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonExchangeModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 23,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -151,7 +151,7 @@
|
||||
{
|
||||
"module": "fly",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonFlyModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 2,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -160,7 +160,7 @@
|
||||
{
|
||||
"module": "grp",
|
||||
"windows_file": "upstream/ava2-client/EterPythonLib/PythonGraphicModule.cpp",
|
||||
"port_file": "src/python_grp.cpp",
|
||||
"port_file": "src/scripting/python_grp.cpp",
|
||||
"windows_methods": 54,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -169,7 +169,7 @@
|
||||
{
|
||||
"module": "grpImage",
|
||||
"windows_file": "upstream/ava2-client/EterPythonLib/PythonGraphicImageModule.cpp",
|
||||
"port_file": "src/python_grp.cpp",
|
||||
"port_file": "src/scripting/python_grp.cpp",
|
||||
"windows_methods": 15,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -178,7 +178,7 @@
|
||||
{
|
||||
"module": "grpText",
|
||||
"windows_file": "upstream/ava2-client/EterPythonLib/PythonGraphicTextModule.cpp",
|
||||
"port_file": "src/python_grp.cpp",
|
||||
"port_file": "src/scripting/python_grp.cpp",
|
||||
"windows_methods": 21,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -187,7 +187,7 @@
|
||||
{
|
||||
"module": "grpThing",
|
||||
"windows_file": "upstream/ava2-client/EterPythonLib/PythonGraphicThingModule.cpp",
|
||||
"port_file": "src/python_grp.cpp",
|
||||
"port_file": "src/scripting/python_grp.cpp",
|
||||
"windows_methods": 8,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -196,7 +196,7 @@
|
||||
{
|
||||
"module": "guild",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonGuild.cpp",
|
||||
"port_file": "src/python_guild.cpp",
|
||||
"port_file": "src/scripting/python_guild.cpp",
|
||||
"windows_methods": 34,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -205,7 +205,7 @@
|
||||
{
|
||||
"module": "ime",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonIMEModule.cpp",
|
||||
"port_file": "src/python_ime.cpp",
|
||||
"port_file": "src/scripting/python_ime.cpp",
|
||||
"windows_methods": 33,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -214,7 +214,7 @@
|
||||
{
|
||||
"module": "item",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonItemModule.cpp",
|
||||
"port_file": "src/python_gameplay_modules.cpp",
|
||||
"port_file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"windows_methods": 48,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -228,7 +228,7 @@
|
||||
{
|
||||
"module": "managerBankLogs",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonManagerBank.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 1,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -237,7 +237,7 @@
|
||||
{
|
||||
"module": "messenger",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonMessenger.cpp",
|
||||
"port_file": "src/python_messenger.cpp",
|
||||
"port_file": "src/scripting/python_messenger.cpp",
|
||||
"windows_methods": 5,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -246,7 +246,7 @@
|
||||
{
|
||||
"module": "miniMap",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonMiniMapModule.cpp",
|
||||
"port_file": "src/python_minimap.cpp",
|
||||
"port_file": "src/scripting/python_minimap.cpp",
|
||||
"windows_methods": 27,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -255,7 +255,7 @@
|
||||
{
|
||||
"module": "net",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonNetworkStreamModule.cpp",
|
||||
"port_file": "src/python_net.cpp",
|
||||
"port_file": "src/scripting/python_net.cpp",
|
||||
"windows_methods": 154,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -279,7 +279,7 @@
|
||||
{
|
||||
"module": "nonplayer",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonNonPlayerModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 24,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -290,7 +290,7 @@
|
||||
{
|
||||
"module": "pack",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonPackModule.cpp",
|
||||
"port_file": "src/python_runtime.cpp",
|
||||
"port_file": "src/scripting/python_runtime.cpp",
|
||||
"windows_methods": 2,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -299,7 +299,7 @@
|
||||
{
|
||||
"module": "petskill",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSkillPet.cpp",
|
||||
"port_file": "src/python_pet_skill.cpp",
|
||||
"port_file": "src/scripting/python_pet_skill.cpp",
|
||||
"windows_methods": 4,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -308,11 +308,13 @@
|
||||
{
|
||||
"module": "player",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonPlayerModule.cpp",
|
||||
"port_file": "src/python_gameplay_modules.cpp",
|
||||
"port_file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"windows_methods": 149,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
"CanSealItem",
|
||||
"GetAutoHuntOption",
|
||||
"GetAutoHuntState",
|
||||
"GetCombatZonePoints",
|
||||
"GetElements",
|
||||
"GetItemBind",
|
||||
@@ -323,15 +325,21 @@
|
||||
"GetItemSealDate",
|
||||
"GetItemUnSealLeftTime",
|
||||
"GetItemUnbindTime",
|
||||
"IsAutoHunt",
|
||||
"IsCombatZoneMap",
|
||||
"IsTournamentMap"
|
||||
"IsTournamentMap",
|
||||
"RequestAddGlobalQuickSlot",
|
||||
"RequestMoveGlobalQuickSlotToGlobalQuickSlot",
|
||||
"RequestUseGlobalQuickSlot",
|
||||
"SetAutoHunt",
|
||||
"SetAutoHuntOption"
|
||||
],
|
||||
"placeholder": []
|
||||
},
|
||||
{
|
||||
"module": "playerLoad",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonPlayerSettingsModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 1,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -340,7 +348,7 @@
|
||||
{
|
||||
"module": "privateShopSearch",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonPrivateShopSearch.cpp",
|
||||
"port_file": "src/python_shop_search.cpp",
|
||||
"port_file": "src/scripting/python_shop_search.cpp",
|
||||
"windows_methods": 12,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -349,7 +357,7 @@
|
||||
{
|
||||
"module": "profiler",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonProfilerModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 2,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -358,7 +366,7 @@
|
||||
{
|
||||
"module": "quest",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonQuest.cpp",
|
||||
"port_file": "src/python_quest.cpp",
|
||||
"port_file": "src/scripting/python_quest.cpp",
|
||||
"windows_methods": 6,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -367,7 +375,7 @@
|
||||
{
|
||||
"module": "renderTarget",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/CPythonRenderTargetModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 24,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -376,7 +384,7 @@
|
||||
{
|
||||
"module": "safebox",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSafeBox.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 15,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -389,7 +397,7 @@
|
||||
{
|
||||
"module": "sash",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSash.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 7,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -398,7 +406,7 @@
|
||||
{
|
||||
"module": "shop",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonShop.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 42,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -410,7 +418,7 @@
|
||||
{
|
||||
"module": "skill",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSkill.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 41,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -419,7 +427,7 @@
|
||||
{
|
||||
"module": "snd",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSoundManagerModule.cpp",
|
||||
"port_file": "src/python_gameplay_modules.cpp",
|
||||
"port_file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"windows_methods": 14,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -428,7 +436,7 @@
|
||||
{
|
||||
"module": "switchbot",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSwitchbot.cpp",
|
||||
"port_file": "src/python_switchbot.cpp",
|
||||
"port_file": "src/scripting/python_switchbot.cpp",
|
||||
"windows_methods": 9,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -437,7 +445,7 @@
|
||||
{
|
||||
"module": "systemSetting",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonSystemModule.cpp",
|
||||
"port_file": "src/python_system.cpp",
|
||||
"port_file": "src/scripting/python_system.cpp",
|
||||
"windows_methods": 73,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -446,7 +454,7 @@
|
||||
{
|
||||
"module": "textTail",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonTextTailModule.cpp",
|
||||
"port_file": "src/python_native_modules.cpp",
|
||||
"port_file": "src/scripting/python_native_modules.cpp",
|
||||
"windows_methods": 18,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
@@ -460,7 +468,7 @@
|
||||
{
|
||||
"module": "wiki",
|
||||
"windows_file": "upstream/ava2-client/UserInterface/PythonWiki.cpp",
|
||||
"port_file": "src/python_wiki.cpp",
|
||||
"port_file": "src/scripting/python_wiki.cpp",
|
||||
"windows_methods": 22,
|
||||
"missing": [],
|
||||
"extra": [],
|
||||
@@ -469,11 +477,14 @@
|
||||
{
|
||||
"module": "wndMgr",
|
||||
"windows_file": "upstream/ava2-client/EterPythonLib/PythonWindowManagerModule.cpp",
|
||||
"port_file": "src/python_wndmgr.cpp",
|
||||
"port_file": "src/scripting/python_wndmgr.cpp",
|
||||
"windows_methods": 188,
|
||||
"missing": [],
|
||||
"extra": [
|
||||
"SetClipRect"
|
||||
"RegisterDisc",
|
||||
"SetClipRect",
|
||||
"SetDiscArc",
|
||||
"SetDiscColors"
|
||||
],
|
||||
"placeholder": []
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# 移动端架构(2026-10-12)
|
||||
|
||||
2026-10-13 交互更新:摇杆闲置隐藏、真实落点与显示中心分离;技能独立多指、拖动瞄准与冷却重试,物品图标抬高、快捷按钮完整热区,以及 NPC/物品接近交互。实现文件、测试和限制见 [移动交互调整](MOBILE-INTERACTION-2026-10-13.md)。
|
||||
|
||||
本文是引入移动端(Android 优先,iOS 其后)后的目标结构和实施顺序。游戏逻辑、网络、渲染、资源各层保持现状;变化集中在平台打包、主程序的平台适配与触屏输入、以及 Python 界面的手机 HUD 叠加层。标为"新增"或"拆分"的部分尚未实现。
|
||||
|
||||
## 现状
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# 移动端交互调整:浮动摇杆、技能与物品手势
|
||||
|
||||
参考项目:https://github.com/jhaizhou-ops/d2r-mobile 。对照其 `dm/ios/Sources/dm_touch_controls.c` 的交互思路;没有复制其代码或美术,实际移动、技能、物品及 NPC 报文继续调用 AVA2 现有接口。保留 Python 2。
|
||||
|
||||
## 修改文件与行为
|
||||
|
||||
- `src/app/input/touch_router.h/.cpp`:真实落点与绘制底盘中心分离。边缘夹回仅影响显示,落指不立即移动;系统取消后的接管保留真实输入原点。新增独立 Skill 手指归属,技能按钮能与摇杆、攻击、镜头同时操作;同一技能槽拒绝重复手指。100ms 区分按住、200ms 尝试重复施放,拖动超过死区后提供方向;短点击在抬起时施放一次,抬起不重复,取消/阶段切换不补发。提供 GetSkillAim 给显示层。
|
||||
- `upstream/python-root/ui_mobile_joystick.py`:去掉闲置固定位置图案,只在激活时显示;隐藏子图案而不是父窗口,保证继续收到更新。
|
||||
- `src/scripting/python_touch.h/.cpp`:只从窗口管理器当前实际命中的、可见的快捷格查询技能槽,前景面板优先;拖着图标时保留原始槽位操作,不抢作施法。新增 touch.GetSkillAim。
|
||||
- `upstream/python-root/ui_mobile_widgets.py`:保留 32px 原版图标,快捷按钮整个 46/50px 热区可操作;绑定与点击物品仍走原始快捷格。技能槽提供动态查询,按下时捕获技能槽,不受随后翻页影响。
|
||||
- `upstream/python-root/ui_mobile_combat.py`:拖动技能时显示指尖方向标记,松开/取消后隐藏;小功能按钮扩大至 44px。视觉沿用 AVA2 自己的图标及圆框。
|
||||
- `src/scripting/python_gameplay_modules.h/.cpp`:新增移动端施法适配。方向按当前镜头转换;攻击技能可在方向 ±35° 内选择最近有效敌人,没有有效目标的轻点选择范围内最近敌人,距离相同按 VID 排序。辅助/友方/尸体技能不被敌人瞄准覆盖。重复施放排除开关、被动、公会和辅助技能,冷却/动作锁/保留技能期间不重复请求;最终仍进入 ClickSkillSlot 的完整检查和原报文流程。技能/手动攻击/方向键/摇杆取消本适配器的 NPC/拾取接近任务。
|
||||
- 同文件新增场景触控适配:掉落物名字额外 16px 容差,投影物品和角色 28px 半径;物品精确名字命中优先于外围扩展。选中角色沿用目标报文,NPC/入口超过 500 单位则接近,进入范围发送原 OnClick(1 秒节流);物品进入 150 单位后发送原拾取报文。技能/情绪/不能行动期间暂停接近;删除、主角切换及同 VID 实例替换取消任务。普通地面点击继续使用原有点地输入。
|
||||
- `src/scripting/python_item.h`:地面物品创建/更新附带本地 generation,接近任务不会拾取删除后复用 VID 的另一件物品;不改变协议。
|
||||
- `src/eter_render/TextTailManager.h/.cpp`:提供可选名字热区扩展,精确命中优先,然后选择最近扩展框;默认 0 保持桌面行为。
|
||||
- `src/app/app_loop.cpp`、`src/scripting/python_app.cpp`:接入技能及场景触控适配,处理接近任务;失焦、暂停和阶段退出释放任务。
|
||||
- `upstream/python-root/mousemodule.py`(文件系统也可用 mouseModule.py 大小写路径访问):移动模式的拖拽图标/数量抬高到手指上方,顶端限制在安全区内;鼠标坐标不变,仍按真实指尖位置落格。保留原文件编码;仅修改相关 ASCII 行。
|
||||
- `tests/touch_router_test.cpp`:边缘零输入、取消接管、技能单击/拖动/连续/释放/取消/重复指头及四类同时操作。
|
||||
- `tests/touch_game_test.cpp`:真实 HUD 的闲置摇杆隐藏、快捷按钮外围命中、拖动标记、NPC 接近与报文字节、物品删除后 VID 复用取消。
|
||||
- `tests/windows_behavior_test.cpp`:实际目标/技能报文字节、镜头方向、冷却阻止重复、冷却结束继续施放、辅助技能不重复、点击附近自动目标。
|
||||
- `tests/inventory_touch_test.cpp`:保留真实背包双击使用、长按详情/拆分/快捷栏/整理、拖动落格,并加入图标实际抬高坐标验证。
|
||||
|
||||
## 验证与边界
|
||||
|
||||
日志位于 `build/verification/mobile-interaction-2026-10-13/`。桌面软件渲染、Python 2 实际 HUD、触控路由和报文合成测试不能替代 iOS/Android 真机多指体验。
|
||||
|
||||
最终验证:完整构建通过,移动专项 4/4(12.74 秒),完整 CTest 62/62(63.67 秒),严格 ASan/UBSan 4/4(19.86 秒),无跳过和执行路径诊断。Python C 代码未全部同等插桩。46 模块方法无缺失/占位,395 映射协议常量无不匹配/未匹配;git diff --check 通过。SDK 与 Windows 参考无修改。
|
||||
|
||||
单击背包仍沿用 AVA2 的选取并拿起图标语义,双击使用/装备、长按详情与操作面板已存在并继续验证;没有改成新的服务器物品操作规则。NPC/入口是否可交互仍由服务器决定。角色热区使用当前投影模型高度近似,没有恢复精确模型点击体;障碍绕行仍依赖现有移动/碰撞,不新增完整寻路。资源矿石的骑乘矿镐特殊交互及完整 Windows 预留点击战斗流程不在本适配器中。
|
||||
|
||||
按钮大小、安全区和镜头手势在现有移动 HUD 基础上增强,没有替换全部背包/商城布局。方向提示为指尖标记,未增加技能范围模型、弹道预览或取消施放区域。辅助技能不自动循环,无新增自动药水或服务器玩法。本轮未修改 SDK、Windows 参考或服务器,也未提交/推送。
|
||||
@@ -1762,3 +1762,172 @@ P1, visible gameplay:
|
||||
- SafeBoxWrongPassword does not call `OnSafeBoxError`;
|
||||
- background Create/DeleteTargetEffect (shop and location markers);
|
||||
- server commands StoneDetect and Start/StopStaminaConsume.
|
||||
|
||||
|
||||
### 2026-10-13 Module behavior parity: first repair batch
|
||||
|
||||
This is a targeted behavior repair after updating to client HEAD 31c5b3dd, not a claim of full Windows equivalence. See [the per-module audit](WINDOWS-MODULE-AUDIT-2026-10-13.md) for all 46 modules, source paths, reviewed scope and remaining work. The audit scripts now inspect src/scripting and fail instead of reporting an empty source set. Method coverage is complete, but 71 constant-return candidates and unreviewed behavior remain.
|
||||
|
||||
Fixed SMS and enabled 67-attribute/calendar/CatchKing senders; warehouse row capacities and original open/error/money/batched refresh callbacks; stamina start/stop/frame accumulation and mobile callbacks; PvP/safe-area queries and shared attack eligibility; casting cooldown using point 21 instead of movement point 19; TextureChange and original per-texture scale/offset coordinates. Added windows_behavior_test with literal wire fixtures, state/callback and terrain checks. Corrected obsolete forest tests to the source's forced full LOD and full-bound frustum culling.
|
||||
|
||||
Desktop build and all 60 CTests pass. ASan/UBSan windows_behavior passes. Packet audit compares 395 constants with zero mismatch. No live-server or Android-device test, no Windows process output oracle. Five Python baseline hash differences predate this batch in the pulled HEAD; original reference C++ and the shared SDK were not changed. Pending: guild mark connection/cache; target/StoneDetect effects; motion queues and advanced skills; terrain splat/shadows/fog/environment; Windows NO_WIND/static-lighting vs current tree rendering (leaf rocking needs separate handling); adapt necessary collision/GPU changes from the preserved pre-pull stash to the new layout. Older backlog descriptions about damage-number queues, missing network horse actors, LookAt and MarkBox_Load are superseded by the linked audit.
|
||||
|
||||
|
||||
### 2026-10-13 Windows behavior parity: target effects, StoneDetect, tree lighting
|
||||
|
||||
Restored the missing background calls in target-create/update/delete receive handlers. Background now owns target effect instances, follows actual actor positions, converts global coordinates using MapOutdoor BasePosition, defers zero-height locations, and cleans its instances/bindings on deletion and map changes. Preserves first-insert actor bindings and the original shared reservation resource rule. Removes stale special-effect ID associations so deleted/recreated targets can follow instead of leaking. StoneDetect now selects the four original assets and converts its compass angle; invalid input does not spawn. SpeedTree tree/frond/leaf commands now disable dynamic lighting as WRAPPER_USE_STATIC_LIGHTING requires, preserving vertex diffuse colors.
|
||||
|
||||
See [second-batch details](WINDOWS-TARGET-EFFECTS-2026-10-13.md) and verification logs in build/verification/windows-target-effects-2026-10-13. Expanded windows_behavior tests cover received packet fragments, nonzero map bases, draw positions, following and ownership lifecycle; forest tests cover static lighting. Full Windows/Android visual parity remains unverified. Still pending: guild mark transfer/cache, advanced motion and skills, terrain shading/fog/splat/environment, tree wind-method separation and prior collision/GPU integration adaptation. Target effects still depend on the replacement effect renderer and current terrain-only height query.
|
||||
|
||||
Validation: desktop full build and CTest 60/60 passed (52.67 s); final expanded behavior/forest tests 2/2 passed (1.75 s), ASan/UBSan 2/2 passed (3.17 s). git diff --check passed; no new upstream reference changes and the shared SDK is clean.
|
||||
|
||||
|
||||
### 2026-10-13 Windows terrain parity: map settings, culling and water grid
|
||||
|
||||
Restored HeightScale through initial and streamed terrain loads and water vertices; TerrainVisible now independently gates terrain drawing. Reset per-map settings and texture/UV caches at map load. The compatibility fallback block entry now uses the same streaming loader instead of a stale-origin raw path. Valid camera culling no longer falls back to an uncullable whole-map draw. Water starts at its block origin, uses the map height scale without the invented -200 bias, draws every valid cell (including odd rows/columns) and skips -1 layers.
|
||||
|
||||
[Third-batch source comparisons and regression cases](WINDOWS-TERRAIN-SETTINGS-2026-10-13.md) document retained developer-map defaults and malformed-input boundaries. background_test covers 4×1 streaming, heights, pointers, per-map vs runtime visibility, reset, culling, sparse water and bad scale. ViewRadius patch allocation, true LOD, shadow/fog/splat, water depth alpha/material/animation and ambient sound remain outstanding; this is not visual equivalence. Other backlog: guild mark transfer/cache, advanced actors/skills, tree wind separation and collision/GPU adaptation. No reference/server/SDK changes or live-server/device proof.
|
||||
|
||||
Validation: full desktop build and 60/60 CTests passed (52.49 s). ASan/UBSan background + windows_behavior 2/2 passed (1.51 s); SDK/client C++ instrumented, Python C dependency not equally instrumented. git diff --check passed.
|
||||
|
||||
|
||||
### 2026-10-13 Windows SpeedTree parity: WIND_NONE vs leaf rocking
|
||||
|
||||
Client forest/model now default to no branch/frond/leaf-center deformation using identity wind matrices, matching WRAPPER_USE_NO_WIND. Empty matrices cannot mean no wind because the SDK synthesizes it. Leaf pivot rocking and camera-facing placement remain active. Explicit SetCpuWindEnabled(true) / the final BuildDrawCommands cpuWind argument preserves optional CPU wind. The background forest now uses accepted game-frame dt instead of fixed 0.033; invalid/overflowing forest time steps retain prior state.
|
||||
|
||||
[Fourth-batch source comparison and limits](WINDOWS-SPEEDTREE-WIND-MODE-2026-10-13.md) distinguish completed mode separation from still-approximate leaf amplitudes, normalized strength and original per-tree creation/environment propagation. Added actual draw/pivot checks under yaw/scale and adversarial custom matrices, mode toggling, stable fronds/trunks and background frame-clock comparisons. No SDK/reference/server modifications. Random generation, exact leaf/DLL values, collision/GPU adapter migration, guild marks, advanced actors/skills and remaining terrain shading continue in the backlog.
|
||||
|
||||
Validation: full desktop build and CTest 60/60 passed (49.73 s); ASan/UBSan forest/background/windows_behavior 3/3 passed (2.38 s). Method audit: 46 modules, no missing methods; packet audit: 395 constants, zero differences. No Windows or Android dynamic parity proof.
|
||||
|
||||
|
||||
### 2026-10-13 Windows player motion parity: emotion request, fishing and digging
|
||||
|
||||
Restored player.ActEmotion's alive-target /kiss request and original NEED_TARGET callback, and IsActingEmotion's narrow KISS/FRENCH_KISS motion-index query (not all emotes). RecvFishing now drives the existing once/loop motion queue and fish emoticon, gates STOP/REACT on actual fishing WAIT/REACT, and preserves main-only failure callbacks. Removed the packet-flag stand-in: cancellation and fish messages query current motion data. RecvDigMotion faces an existing target and queues exactly the received count, while missing targets do not suppress digging.
|
||||
|
||||
[Source comparisons and precise limits](WINDOWS-PLAYER-MOTION-2026-10-13.md) retain pending dual-emotion approach/TCP locking and fishing water target/blend timing. New asset-backed player_motion uses temporary MSA/race data with original read-only model/wait GR2 to verify transitions, eight kiss queries and fragmented/repeated DIG; it explicitly skips if resources are absent, but ran and passed here. Full build and CTest 61/61 passed (31.98 s); ASan/UBSan windows_behavior + player_motion 2/2 passed (1.53 s). Static method and packet audits remain zero-mismatch; git diff --check passed. No SDK/reference/server changes or Windows/Android visual equivalence proof. Guild marks, advanced skills/dual motions, terrain shading and exact tree generation/leaf values remain outstanding.
|
||||
|
||||
|
||||
### 2026-10-13 Windows dual-emotion parity: scheduling, approach and roles
|
||||
|
||||
Replaced server-command local pair pushes with a VID-based dual scheduler: 500ms clock deadline, requested 100-unit endpoint, far approach then mutual facing and job-specific once motions. Preserved MAKELONG high/low assignment (slap sender HIT, receiver HURT). Pending main as either participant blocks manual movement/attack; native move target/direction entry points cannot bypass the lock. Kiss/slap local movement stays locked by current motion. TCP movement packets are deferred instead of discarded and resume after permission; deletion/clear releases state. Server clock callback and existing deterministic test clock cover uint32 rollover.
|
||||
|
||||
[Sixth-batch details and remaining differences](WINDOWS-DUAL-EMOTION-2026-10-13.md) explicitly retain root motion/blend/collision and unified TCP scheduling gaps, plus conservative rejection of self/overlapping pairs and safe coincident coordinates. Extended player_motion exercises delay, approach, job/role mapping, input recovery, queued movement, both main roles and removal. No reference/SDK/server modifications or visual equivalence proof.
|
||||
|
||||
Validation: full desktop build and CTest 61/61 passed (50.91 s); ASan/UBSan windows_behavior/player_motion 2/2 passed (1.47 s). Active method audit 46 modules and mapped packet audit 395 constants remain zero-mismatch. git diff --check passed; no new reference changes or shared SDK edits.
|
||||
|
||||
|
||||
### 2026-10-13 Windows motion parity: weighted variants and playback speed
|
||||
|
||||
Restored BYTE percentage selection for all motion modes, including the original first-entry fallback for underfilled weights. Selected GR2 and MSA metadata now stay together; queued motions select only at activation and LOD uses the selected file. Added explicit C++ speed overloads retained in queued nodes while preserving existing native attack-speed behavior. Network body and mount creation/updates now propagate movspd/100 to WALK/RUN; running speed changes restart the loop. Zero speed stays zero and >1100 clamps to zero, including main input movement.
|
||||
|
||||
See [seventh-batch comparison and limits](WINDOWS-MOTION-VARIANTS-SPEED-2026-10-13.md). Asset-backed player_motion tests enumerate all 100 selection values, malformed totals, metadata/clip identity, immediate/queued speeds and live network speed changes. Mount propagation is source-reviewed without a dedicated mount fixture. Platform RNG sequence, skeletal blending, blend-overlap timing, root motion, special NPC/polymorph speed rules and full TCP scheduling remain pending. No SDK/reference/server changes.
|
||||
|
||||
Validation: full desktop build succeeded; CTest 61/61 passed (49.58 s); ASan/UBSan player_motion/windows_behavior/attack_combo 3/3 passed (3.62 s). No Windows/Android dynamic or visual equivalence proof.
|
||||
|
||||
|
||||
### 2026-10-13 Windows attack speed: zero, overflow and binding time
|
||||
|
||||
Network creation/RefreshState/updates and mount creation/updates now clamp raw attack speed >1100 to zero and normalize by 100, preserving zero instead of replacing it with normal speed. Actor speed storage accepts finite nonnegative values; bound attacks retain their current ratio until a new attack binds, matching the original setter and elapsed-time calculation. Regressions cover raw boundaries including UINT32_MAX, mount storage, zero-speed attack freeze, next-attack recovery and unchanged current-attack speed.
|
||||
|
||||
See [eighth-batch comparison](WINDOWS-ATTACK-SPEED-2026-10-13.md). The AVA2 reference disables ENABLE_FAST_MOB_MOVE_SPEED; its guarded NPC caps are not missing active features. Outstanding: overflow detection queue, polymorph type/mode and 1.1-second scaling, bone blending, root motion and full TCP scheduling. No reference/SDK/server changes or runtime visual parity claim.
|
||||
|
||||
The full suite exposed intermittent inventory_touch shutdown failure after its completion marker. macOS crash frames identify preview-manager static destruction releasing an image after the resource cache died. Added CRenderTargetManager::Destroy and call it during PythonRuntime teardown before image pools/resources, following Windows PythonApplication::Destroy. Added weak ownership/index lifecycle regression; retained initial failure logs.
|
||||
|
||||
Final full build succeeded; CTest 61/61 passed (42.78 s). Instrumented four-test regression passed (10.88 s), inventory_touch repeated three times passed (21.60 s), and the preview-image use-after-free disappeared. Recoverable UBSan diagnostics remain in unmodified Singleton offset calculation, unaligned reads and font color conversion; process success does not establish sanitizer-clean code. Detailed logs retain these findings for follow-up. Method/packet audits: 46 modules with no missing methods, 395 mapped constants with no mismatch. git diff --check passed; SDK/reference unchanged.
|
||||
|
||||
|
||||
### 2026-10-13 Strict UBSan and polymorph motion parity
|
||||
|
||||
Removed invented-address singleton offset arithmetic; actual base-subobject registration plus compiler casts preserves multiple inheritance. Font RGB now retains valid Win32 truncation and uses explicit ARGB packing, with documented finite/clamped input boundaries. Packed sockets use memcpy in inventory/warehouse/switchbot paths; packed attribute values are materialized before pair reference forwarding. Regression tests cover nonzero singleton base offsets and exact font colors.
|
||||
|
||||
Restored TYPE_POLY or PC race>=8 classification, GENERAL mode, base-variant interception without RNG and duration/1.1 speed scaling; ordinary loops retain random selection and unscaled explicit speed. Network poly shape zero and PC-poly sash rejection follow Windows. Synthetic ordinary-PC motion fixtures now use playable race indices 1/2. See [ninth-batch scope and remaining work](WINDOWS-UBSAN-POLYMORPH-2026-10-13.md).
|
||||
|
||||
Strict ASan/UBSan four-test regression with halt_on_error=1 passed (11.89 s), including inventory teardown; detailed output contains no sanitizer diagnostics on those paths. Python C dependency is not equally instrumented. Remaining modules and unreviewed paths are not declared complete; no SDK/reference/server edits or Windows/Android/live-server dynamic parity proof.
|
||||
|
||||
Full desktop build and CTest 61/61 passed (50.12 s). Subsequent test-only strengthening checks literal odd-aligned socket bytes and a negative attribute value: native targeted test passed (1.23 s), strict sanitizer targeted test passed (2.05 s). Active method inventory 46 modules/zero missing, packet audit 395 constants/zero mismatches; git diff --check passed.
|
||||
|
||||
|
||||
### 2026-10-13 Windows skill permission and toggle requests
|
||||
|
||||
Restored pre-send actor/observer/poly/dress/pickaxe permissions, passive rejection, MSA LoopCancelEnable cancellation, active AVA2 riding slot 107 threshold and source mount-level cases. Added horse-skill mismatch and attack-skill safe-zone callbacks; blocked paths emit no packets or cooldown events. Ordinary active toggles send the skill-slot argument; active standing toggles retain the separate original zero-argument branch before generic permissions. Animal/dress weapon constraints and repeated-armor checks now use requested PART_MAIN instead of poly render shape zero.
|
||||
|
||||
See [tenth-batch source comparisons and limitations](WINDOWS-SKILL-PERMISSION-2026-10-13.md). Literal AVA2 CG233 fixtures cover acceptance/refusal and both toggle paths; asset-backed actor tests cover cancel flags and stun priority. Static mount-case audit compares all 100 active cases with zero differences. Strict ASan/UBSan four-test regression with halt_on_error=1 passed (10.23 s). No SDK/reference/server modifications; remaining skill conditions, targets/movement, guild marks, terrain and tree work are not declared complete.
|
||||
|
||||
Final full desktop build succeeded and CTest 61/61 passed (49.71 s). Strict sanitizer detailed output has no diagnostics on executed paths. Method audit 46 modules/zero missing, packet audit 395 mapped constants/zero mismatch; git diff --check passed. Python C dependency not equally instrumented; no live-server or device proof.
|
||||
|
||||
|
||||
### 2026-10-13 Windows skill costs, learned level and equipment conditions
|
||||
|
||||
Restored bottle scans, fishing-mode restriction, active/default learned-level gate, weapon masks and bow-arrow condition. HP/SP use source point indices 5/7 and Win32 formula truncation; equal resources pass, client does not deduct ahead of server. Preserve source zero-cost refusal/chat, -1 SP sentinel, partial-SP flag, summon exemption and DASH/CHARGE cooldown/resource exceptions. Skill failure/cooldown/arrow callbacks now go to the network game-phase window, verified with distinct player and phase windows.
|
||||
|
||||
See [eleventh-batch evidence and limitations](WINDOWS-SKILL-COST-2026-10-13.md). Real SkillDesc/SkillTable inputs cover normal/exception boundaries and literal CG233 requests. Targets, multi-target/moving skills, right-button mode, bone blending/root motion, guild marks, terrain and tree work remain pending; no reference/SDK/server changes or live-server/device parity claim.
|
||||
|
||||
Final full build and CTest 61/61 passed (47.53 s); strict ASan/UBSan four-test regression passed (11.84 s) without diagnostics on executed paths. Method inventory 46 modules/zero missing; packet audit 395 mapped constants/zero mismatch; git diff --check passed. Earlier intermediate runs retained in the verification directory; final logs include the window-routing correction.
|
||||
|
||||
|
||||
### 2026-10-13 Windows skill target resolution
|
||||
|
||||
Separated UI selection from local skill target: no-target skills send zero; alive/corpse lookup, picked fallback, alliance/self and enemy safe/attack checks now follow the reviewed source branches. Added front auto-search's distance-varying cone and capped-distance/VID ordering, actual fly target binding and horizontal facing. Failed animation binding cannot send packets/cooldown. Restored __UseSkill's second IsUsingSkill lock even when the lower actor predicate allows LoopCancelEnable; asset-backed regression proves that distinction.
|
||||
|
||||
See [twelfth-batch scope and limitations](WINDOWS-SKILL-TARGET-2026-10-13.md). Static/fixture tests cover literal target/use packets, native picked state, target deletion/death and roles. Source range reservation/approach, 1000/2000ms selection throttling/UI targeting effects, fan/circle/random fly targets, moving skills and blending remain pending. No SDK/reference/server changes or Windows/Android/live-server visual proof.
|
||||
|
||||
Final full build and CTest 61/61 passed (48.43 s); strict four-test ASan/UBSan passed (11.96 s) with no diagnostics on executed paths. Subsequent test-only deletion, capped-sort ties and 2000/2001 distance boundaries passed native (1.29 s) and strict sanitizer (2.26 s). Method inventory 46 modules/zero missing; packet audit 395 mapped constants/zero mismatch; git diff --check passed.
|
||||
|
||||
|
||||
### 2026-10-13 Windows skill range and reserved approach
|
||||
|
||||
Added targetRange + point34*100, source >= range reservation and strict arrival with the 10-unit margin, moving-target following and permission/resource rechecks. Restore source huge race2493 correction, enemy ATTR_BLOCK check, zero-range exemption and charge's first target-zero send/cooldown followed by DASH completion. Frame pipeline processes the reservation; locks pause owned movement, manual input/deletion/main changes cancel. Weak actor identity prevents VID reuse inheriting a cast. Auto hunt does not overwrite the reserved approach. Formal skill callback (-1) no longer invokes the app's preview cooldown/effects.
|
||||
|
||||
See [thirteenth-batch source comparisons and limits](WINDOWS-SKILL-RANGE-2026-10-13.md). Tests cover 190/189 boundaries, follow/reselect/one-shot, stun/revive, input/lifecycle cancellation, friendly approach, range bonus, blockers and charge bytes. Root motion, exact movement/stop packet timing, full right-button/standing-toggle reservation interactions, target hold/UI lifecycle and multi-target remain pending. No SDK/reference/server changes or Windows/Android/live-server visual proof.
|
||||
|
||||
Final full build and CTest 61/61 passed (46.68 s); strict four-test ASan/UBSan passed (8.48 s) without diagnostics on executed paths. Method inventory 46 modules/zero missing; packet audit 395 mapped constants/zero mismatch; git diff --check passed. Python C dependency not equally instrumented. Preview callback guard is compiled/static-checked without app visual proof.
|
||||
|
||||
### 2026-10-13 第十四批:技能追加飞行目标
|
||||
|
||||
已接通 FAN/CIRCLE 候选选择、距离/VID 排序、MSM 防御球位置与严格 3D 范围、原版随机算法的 8000 锥形补足、CG53→动作绑定→CG233 顺序和现有 Actor 队列。新增报文回归与真实 GR2/MSA 队列消费/主目标恢复测试。异常数量上限保护为明确偏差;精确模型中心、骨骼矩阵/附件生命周期、持续追踪和移动技能仍未完成。详见 [第十四批记录](WINDOWS-SKILL-FLIGHT-2026-10-13.md)。
|
||||
|
||||
本批验证:桌面完整构建成功,61/61 CTest(33.73 秒);四项严格 ASan/UBSan(10.85 秒)通过,无执行路径诊断。方法与协议静态审计通过。未提交/推送本轮修改。
|
||||
|
||||
### 2026-10-13 第十五批:飞行物目标与生命周期
|
||||
|
||||
接通 FLY/服务器索引飞行物的对象追踪、对象消失转最后位置与安全实例身份、严格线段命中、实际飞行距离退出,删除五秒误报命中。恢复 MSF 初始旋转及速度/加速度积分、重力、homing 延迟/半角规则、主目标一次性穿透及受击动作。新增独立飞行回归和真实 GR2/MSA 回调链测试;背景/其他怪物碰撞、视觉附件、shake 和精确包围中心仍未完成。详见 [第十五批记录](WINDOWS-FLYING-LIFECYCLE-2026-10-13.md)。
|
||||
|
||||
同批继续恢复 SpreadingFlag 的三次原版随机调用和初始旋转顺序;固定种子验证独立计算轨迹、速度/加速度一致旋转及关闭时随机序列不变。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(57.66 秒);五项严格 ASan/UBSan(14.25 秒)通过,无执行路径诊断。静态方法与协议审计通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 第十六批:飞行物场景碰撞
|
||||
|
||||
已接通 BODY/DEFENDING 分类、演员双轨迹检测、发射者身份排除、额外角色穿透去重、回调/碰撞优先级、严格地形高度和当前物体三维 OBB 代理;游戏入口借用当前场景,地图高度使用多区块查询。新增合成 MSM/移动演员回归及真实 GR2 物体代理测试。原版 culling 首候选顺序、静态完整碰撞图元、树木碰撞、骨骼/部件历史仍未完全对齐。详见 [第十六批记录](WINDOWS-FLYING-COLLISION-2026-10-13.md)。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(54.71 秒);五项严格 ASan/UBSan(12.49 秒)通过,无执行路径诊断。方法与协议审计通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 第十七批:飞行附件与受击震动
|
||||
|
||||
已接通多 AttachData、独立效果与尾迹、angular rotation、LINE/MULTI/SINE/EXP 偏移、全局矩阵与完整清理,以及 OnShootDamage 的 100ms 图形震动。主体/骨骼/飞行中心使用图形偏移,逻辑坐标和碰撞球不受影响。修正 CG51 图形 Y 符号并验证实际默认处理器报文字节。真实 GR2/MSA 与 MSE/尾迹绘制回归已加入;CRT 精确随机序列、第一帧/粒子时序、近战全部受击流程和 GPU 逐帧画面仍未对齐。详见 [第十七批记录](WINDOWS-FLYING-VISUAL-2026-10-13.md)。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(53.47 秒);五项严格 ASan/UBSan(13.20 秒)通过,无执行路径诊断。方法与协议审计通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 第十八批:飞行尾迹几何与衰减
|
||||
|
||||
恢复六顶点四三角形尖角尾迹、相机位置参与的方向基底、逐段深度排序、原色恒定 alpha、宽度衰减、原版 UV、alpha test、小尺寸参数及严格过期边界。扩展固定源公式绘制几何和前批多附件回归。逐段 frustum、继承 GPU 深度状态、首帧绝对时间和相机/浮点动态输出仍未完全对齐。详见 [第十八批记录](WINDOWS-FLYTRACE-2026-10-13.md)。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(51.52 秒);五项严格 ASan/UBSan(12.55 秒)通过,无执行路径诊断。方法与协议审计通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 第十九批:尾迹逐段视锥裁剪
|
||||
|
||||
接通 view×projection 六平面、每段中点/最长轴半长球、外侧相切剔除及部分可见保留;标准透视粗球保留原版 FOV 度值直接传 tan 的历史行为。新增边界/相机/透视及历史单位回归,基础几何测试使用明确宽投影。原版全局 frustum 更新时序、非标准投影粗球、浮点逐位和 GPU 深度继承仍待对照。详见 [第十九批记录](WINDOWS-TAIL-FRUSTUM-2026-10-13.md)。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(50.78 秒);五项严格 ASan/UBSan(12.06 秒)通过,无执行路径诊断。Python C 代码未全部同等插桩。46 模块方法和 395 个映射协议常量审计通过,git diff --check 通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 第二十批:视锥更新缓存、非标准投影与 GPU 深度继承
|
||||
|
||||
UpdateGame 更新阶段建立缓存,渲染阶段尾迹读取该快照。相机/投影设置不自动刷新缓存,正交及自定义矩阵继续使用最近透视元数据计算原版粗球。接通 Python 正交投影;尾迹继承深度开关/写入并使用 LESS,硬件管线键及软件光栅器同步支持;加法混合不再强制关闭软件深度写入。新增快照/投影/软件回归和真实 GPU 像素回读。Windows 浮点逐位、全局相机切换、SDL 几何备用后端无深度缓冲等边界详见 [第二十批记录](WINDOWS-TAIL-STATE-2026-10-13.md)。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(62.48 秒);六项严格 ASan/UBSan(17.43 秒)通过,包含实际执行的 GPU 回读,无执行路径诊断。Python C 代码未全部同等插桩。方法/协议审计与 git diff --check 通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
### 2026-10-13 移动交互:浮动摇杆、技能手势及场景点击
|
||||
|
||||
参考 d2r-mobile 的交互思路,移除闲置固定摇杆,真实落点与绘制中心分离,补齐技能独立多指归属、拖动方向提示、按住遵守冷却重试、最近敌人选择、完整快捷按钮热区及物品拖拽抬高。增加 NPC/入口和掉落物热区、接近交互、失焦取消与实例/物品 generation 防复用。保留原版双击/长按物品面板及报文,新增真实 HUD、库存和目标/技能/NPC 字节测试。详见 [移动交互调整](MOBILE-INTERACTION-2026-10-13.md)。真机多指、精确模型点击体、完整寻路和技能范围预览仍待验证/实现。
|
||||
|
||||
本批最终验证:完整构建成功,62/62 CTest(63.67 秒),移动专项 4/4,严格 ASan/UBSan 4/4(19.86 秒),无执行路径诊断。Python C 代码未全部同等插桩。方法/协议审计及 git diff --check 通过。SDK/参考/服务器未修改,尚未提交或推送。
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# SpeedTreeRT 静态反编译记录
|
||||
|
||||
## 本次结果
|
||||
|
||||
分析对象为 `../AVA2/1. Client DEV/SpeedTreeRT.dll`,PE32 / x86 Windows DLL,
|
||||
映像基址 `0x10000000`。PE 时间戳为 2004-01-09;时间戳仅为文件元数据。
|
||||
SHA-256:`ddba9b9b427d541ebc0bf1221fffc5d56a85d7b8ee0dfe6370a83a133da6967b`。
|
||||
|
||||
使用 Ghidra 12.1.4、OpenJDK 21 和在本机编译的 arm64 decompiler:
|
||||
|
||||
- 识别并成功导出 1,219 个函数,失败 0 个;包含运行库、模板和异常处理辅助函数,不能视为 1,219 个树木算法。
|
||||
- 139 个命名导出项:137 个函数、2 个静态数据项;137 个函数均有反编译文件。
|
||||
- 合并伪代码 41,100 行,静态调用图 2,162 条边。
|
||||
- 355 个函数包含 Ghidra 警告。导出成功仅表示工具产生了结果,不证明类型、数组大小、控制流或算法已完全恢复。
|
||||
- 未运行原 DLL,未进行原版输出对照,未修改原 DLL、SDK 实现或客户端运行行为。
|
||||
|
||||
生成结果集中在 `build/verification/speedtree-decompile/`:
|
||||
|
||||
| 文件 | 内容 |
|
||||
|---|---|
|
||||
| `decompiled.c` | 全部函数的合并反编译伪代码 |
|
||||
| `functions/*.c` | 按原始虚拟地址拆分的函数伪代码 |
|
||||
| `functions.tsv` | 地址、名称、推断签名、状态及文件路径 |
|
||||
| `exports.tsv` | 原 DLL 导出项与反编译文件的对应关系 |
|
||||
| `calls.tsv` | Ghidra 识别的静态调用边;间接调用可能不完整 |
|
||||
| `disassembly.txt` | LLVM objdump 输出的反汇编 |
|
||||
| `pe-headers.txt`、`strings.txt` | PE 头、导入/导出表与字符串 |
|
||||
| `summary.txt`、`validation.json`、`analysis.log` | 导出统计、完整性检查和分析日志 |
|
||||
| `input-sha256.txt` | DLL、导入库和接口头文件的输入哈希 |
|
||||
| `ghidra-project/` | 可继续交互分析的 Ghidra 项目 |
|
||||
|
||||
## 核心入口
|
||||
|
||||
下列地址是虚拟地址;对应文件为 `functions/<地址>.c`。
|
||||
|
||||
| 地址 | 函数 | 分析用途 |
|
||||
|---|---|---|
|
||||
| `1001ae70` | `CSpeedTreeRT::LoadTree(char const*)` | 文件读取,调用内存版加载器 |
|
||||
| `1001b110` | `CSpeedTreeRT::LoadTree(unsigned char const*, unsigned int)` | 主加载流程和扩展段分派 |
|
||||
| `10022950` | 未命名内部函数 | 主文件段解析;检查起始 token 和标识字符串 |
|
||||
| `10007ae0` | 未命名内部函数 | 从当前游标读取 4 字节并推进游标;在此上下文中用作 token 读取 |
|
||||
| `10007ad0` | 未命名内部函数 | 从当前游标读取 float 并推进 4 字节 |
|
||||
| `1001a2b0` | `CSpeedTreeRT::Compute` | 树木计算、几何准备、变换、包围与投影等流程 |
|
||||
| `100232c0` | 未命名内部函数 | Compute 调用的种子处理逻辑;0、1 和其他值有不同分支 |
|
||||
| `1001fb10` | `CSpeedTreeRT::GetGeometry` | 按位掩码分派树枝、frond、叶片和 billboard 几何 |
|
||||
| `1001fc90` | `CSpeedTreeRT::GetBranchGeometry` | 树枝几何输出 |
|
||||
| `1001fea0` | `CSpeedTreeRT::GetFrondGeometry` | Frond 几何输出 |
|
||||
| `100200b0` | `CSpeedTreeRT::GetLeafGeometry` | 叶片几何输出 |
|
||||
| `10020390`、`10020560` | `Get360BillboardGeometry`、`GetSimpleBillboardGeometry` | 远景面片输出 |
|
||||
| `10020cd0` | `CSpeedTreeRT::GetTextures` | 纹理信息输出 |
|
||||
| `1001b4a0` | `CSpeedTreeRT::SaveTree` | 序列化流程,可与解析器交叉核对 |
|
||||
| `1001c230` | `CSpeedTreeRT::ComputeWindEffects` | 风力求值入口 |
|
||||
| `1001d1c0` | `CSpeedTreeRT::ComputeLodLevel` | LOD 计算入口,内部调用 `10022fc0` |
|
||||
|
||||
## 已从静态结果观察到的结构
|
||||
|
||||
内存版 LoadTree 先调用 `10022950` 解析主文件段,再分派扩展段。
|
||||
主段解析器检查 token `1000`,并读取和比较标识字符串;主段以 `1001` 结束。
|
||||
当前观察到的扩展段入口如下;语义来自已识别函数名称或所在调用上下文,
|
||||
未命名部分仍需进一步研究和运行对照。
|
||||
|
||||
| token | 处理入口 |
|
||||
|---|---|
|
||||
| `8000` | `10018380`,未命名内部处理器 |
|
||||
| `9000` | `ParseLodInfo` (`1001e840`) |
|
||||
| `10000` | `ParseTextureCoordInfo` (`1001ebb0`) |
|
||||
| `11000` | `ParseWindInfo` (`1001ea20`) |
|
||||
| `12000` | `ParseCollisionObjects` (`1001f2d0`) |
|
||||
| `13000` | `100085b0`,未命名内部处理器 |
|
||||
| `15000` | `100243c0`,未命名内部处理器 |
|
||||
| `16000` | `10024760`,未命名内部处理器 |
|
||||
| `16013` | `10024e30`,未命名内部处理器 |
|
||||
| `16014` | 读取 float,写入 CSpeedTreeRT 对象偏移 `0x28` |
|
||||
| `18000` | `ParseShadowProjectionInfo` (`10020ad0`) |
|
||||
| `19000` | `ParseUserData` (`100211f0`) |
|
||||
| `20000` | `ParseSupplementalTexCoordInfo` (`10021840`) |
|
||||
|
||||
GetGeometry 的分派位为:`1` 树枝、`2` frond、`4` 叶片、`8` billboard;
|
||||
billboard 分支还检查 `0x10` 和对象状态,选择 simple 或 360 输出。
|
||||
|
||||
现有 `sdk/speedtree/src/spt_parser.cpp` 只处理部分标记,并有纹理字符串扫描回退。
|
||||
本次结果提供了补齐解析和生成流程的入口,但尚未把反编译算法移植到该 SDK。
|
||||
|
||||
## 后续跨平台实现的验证边界
|
||||
|
||||
伪代码仍使用 Win32 ABI、32 位地址、异常处理和旧 C++ 运行库结构,
|
||||
包含 `undefined*`、自动生成变量名及可能错误的局部数组尺寸,不能直接作为可编译源码。
|
||||
应逐段恢复结构和算法,使用明确宽度的数据读取与边界检查,
|
||||
再通过原 DLL 对同一 SPT、种子、LOD 和时间输入产生的输出做差分验证。
|
||||
|
||||
优先顺序:恢复文件格式和字段 → 静态几何对照 → LOD → 叶片/billboard → 风力。
|
||||
精确的树木生成、对象字段命名、内部函数命名和动态等价验证仍未完成。
|
||||
@@ -0,0 +1,34 @@
|
||||
# AVA2 Windows 第八批修复:攻击速度边界和生效时机
|
||||
|
||||
> 后续:[第九批](WINDOWS-UBSAN-POLYMORPH-2026-10-13.md) 修复了下方记录的已复现 UBSan 告警,并接通变形基础动作倍率。其余未覆盖路径仍需审查。
|
||||
|
||||
修复网络攻击速度 0 被替换成 100、超过 1100 未归零,以及坐骑没有接收攻击速度的问题。仅使用 AVA2 Windows 源码作为行为依据。
|
||||
|
||||
## 依据和实现
|
||||
|
||||
- `UserInterface/InstanceBaseMovement.cpp::SetAttackSpeed` 将原始值大于 1100 的速度设为 0,然后除以 100 传给演员及坐骑。NetworkActorManager 的创建、RefreshState、属性更新和坐骑路径现在采用该规则。
|
||||
- `GameLib/ActorInstance.cpp::SetAttackSpeed` 保存倍率,包括 0;没有重启动画。当前实现保留有效的非负有限值,拒绝负值和非有限值,避免非法本地调用污染状态。
|
||||
- `GameLib/ActorInstanceBattle.cpp::GetAttackingElapsedTime` 使用当前动作节点已经绑定的速度;新攻击通过 `InterceptOnceMotion` 获取新的攻速。回归验证当前动作不因攻速更新立即改变,下次攻击采用新值。零速攻击不推进动作时间,不会自动变成正常速度。
|
||||
- 坐骑初始化和属性更新也保存同一归一化倍率;更新坐骑不需要重新创建实例。
|
||||
|
||||
## 有效开关核查
|
||||
|
||||
第七批记录中的“NPC 非移动动作限速”需要以编译开关为前提:`Locale_inc.h` 注释了 `ENABLE_FAST_MOB_MOVE_SPEED`,整个参考目录没有其他定义。因此 `ActorInstanceMotion.cpp` 中循环 1.5 倍、插入 1.0 倍的 NPC 限速分支在 AVA2 未启用。本批没有添加这些限制;不再将其列为当前配置缺失功能。
|
||||
|
||||
## 验证和边界
|
||||
|
||||
player_motion 验证创建及更新的原始速度 0、1、100、175、1100、1101、UINT32_MAX,并验证独立坐骑实例创建/更新的存储倍率。坐骑使用临时 race,没有证明其真实攻击动画视觉效果。attack_combo 使用原版模型和动作验证当前/下次攻击计时、零速冻结及恢复。
|
||||
|
||||
## 退出生命周期修复
|
||||
|
||||
首次完整测试的 inventory_touch 在完成所有断言后退出崩溃;单独重跑一次通过、再次重跑失败。macOS 崩溃栈定位到进程结束时 CRenderTargetManager 的静态析构,随后 CGraphicImageInstance::Destroy / CRef<CGraphicImage>::Clear / CReferenceObject::Release 访问已释放的图像资源。未修复前的另一轮完整测试虽通过,也不能排除这个生命周期缺陷。
|
||||
|
||||
原版 `UserInterface/PythonApplication.cpp::Destroy` 显式调用预览窗口管理器 Destroy。跨平台版本新增同等清理入口,在 PythonRuntime 的窗口和 minimap 清理后、图像池及资源缓存销毁前释放预览窗口,避免静态单例继续持有背景图。player_motion 通过 weak_ptr 和索引回收检查确认退出时释放;inventory_touch 继续使用真实预览 UI 检查退出流程。
|
||||
|
||||
验证日志保存在 `build/verification/windows-attack-speed-2026-10-13/`,保留首次失败与修复前复跑记录。没有 Windows 原版进程、Android 设备或真实服务器动态验证。
|
||||
|
||||
修复后的 ASan/UBSan 四项回归(player_motion、attack_combo、windows_behavior、inventory_touch)进程均通过,10.88 秒,原先预览图像 heap-use-after-free 不再出现。但 UBSan 为可恢复模式:详细日志仍包含已有 Singleton 虚构地址偏移计算、未对齐读取和 UI 字体颜色越界转换告警,不能将“测试通过”解释成 sanitizer 全无告警。这些未修改路径仍需后续修复;Python C 依赖未全面插桩。
|
||||
|
||||
最终完整桌面构建成功,CTest 61/61 通过(42.78 秒);插桩的 inventory_touch 连续三次通过(21.60 秒)。46 个 Python 模块方法清点无缺失,395 个映射协议常量无差异;git diff --check 通过,平级 SDK 和原版参考源码无修改。
|
||||
|
||||
仍待恢复:原版攻速异常检测队列(大于 3 倍时记录检测,并不因此限速)、变形演员的类型/模式及 1.1 秒动作归一化、局部骨骼混合、root motion、精确队列时序与完整 TCP 调度。显式 C++ 速度接口仍拒绝非正值,网络零攻速通过普通攻击路径接入。没有修改参考源码、SDK 或服务器。
|
||||
@@ -0,0 +1,40 @@
|
||||
# AVA2 Windows 第六批修复:双人情绪调度与移动锁
|
||||
|
||||
本批接通 kiss / french_kiss / slap 的双人协调,替换原先双方原地各排一个动作的实现。依据仅为 AVA2 Windows 源码;不修改参考源码、SDK 或服务器。
|
||||
|
||||
## 对照与实现
|
||||
|
||||
`SpeedTree`、地形与单人动作前序结果见 [逐模块记录](WINDOWS-MODULE-AUDIT-2026-10-13.md)。双人流程依据 `UserInterface/InstanceBaseMotion.cpp::ActDualEmotion`、`InstanceBase.cpp::__ProcessFunctionEmotion / __IsEnableTCPProcess`、`GameLib/ActorInstanceMotion.cpp::isLock` 和 `PythonPlayerInput.cpp::__CanMove / __CanAttack`。
|
||||
|
||||
- 收到服务端双人命令后,通过 NetworkActorManager 建立 VID 配对调度。双方已有移动目的地/行走状态清理,必要时回 WAIT,500 毫秒后处理。
|
||||
- 目的地在请求时计算:目标当前位置沿“目标→发起者”方向偏移 100。若离目的地超过 100,则先走到那里;较近时直接执行原版位置设置。
|
||||
- 使用当前图形演员坐标和已有移动速度靠近,过程中更新网络坐标、主角位置及地形高度。目标保持不动,发送者逐帧移动;普通输入不能覆盖这段靠近过程。
|
||||
- 到达后双方立即相向,清理行走,按对方职业选择一次动作。Windows 的 MAKELONG(first,second) 在处理时 src 使用 HIWORD、dst 使用 LOWORD;因此 slap 发起者为 HIT+目标职业,接收者为 HURT+发起者职业,而不是照原参数顺序播放。
|
||||
- 正常客户端使用 GetServerMSec 回调作为调度时钟;原有测试时钟可注入,比较按 Win32 32 位回绕处理。纯渲染环境没有 Python 时使用本地单调时钟备用。
|
||||
- 主角为任一方时,靠近期间阻止键盘/摇杆、鼠标移动和普通攻击,暂停自动狩猎产生新动作;原有移动目标取消。动作开始即结束“处理情绪”的 pending 状态;接吻/slap 动画自身仍按原版运动锁阻止本地移动。
|
||||
- 原版 TCP 锁是处理限制:锁定期间和接吻期间的移动报文暂存,允许后逐帧恢复处理,不直接丢弃。slap 的 IsActingEmotion 为 false(原版如此),其网络状态可按原规则恢复。
|
||||
- 删除任一方取消配对并释放存活方,Clear 清理配对与暂存报文。自配对、缺失演员和已有重叠配对拒绝,避免一方被两个调度同时控制。坐标重合时采用发起者朝向的后方作为方向,避免复制原版除零导致的坏坐标。
|
||||
|
||||
## 本地回归
|
||||
|
||||
扩展 `ava2.player_motion` 的真实 ActorInstance/GR2 时序回归:
|
||||
|
||||
- 499ms 不开始,500ms 开始靠近;100 速度从 x=0 分步到 x=400,目标停在 x=500。
|
||||
- 两个不同职业的 kiss 和 slap 动作编号,以及 90/270 度相互朝向。
|
||||
- 主角为发起者或接收者时都锁定;直接移动、点地目的地和摇杆不能绕过 pending 锁,动作结束后输入恢复。
|
||||
- 锁期间收到的 Stop/MOVE 状态会恢复消费;接吻播放期间不会提前抢占。
|
||||
- uint32 时钟回绕、双方重合、自配对/重叠请求、删除目标或删除发起者的解除锁。
|
||||
|
||||
使用临时 MSA、只读原版战士 body/wait GR2;动画资源用于状态机验证,不是实际接吻/拍打图像对照。
|
||||
|
||||
## 仍待对齐的边界
|
||||
|
||||
本批是专门的双人调度器,不是完整原版 TCP 状态队列:其他动作报文的统一时间排序、网络延迟补偿、与多个重复情绪请求的队列关系仍待恢复。已有配对的重复/重叠请求当前拒绝,原版可能继续排队;这是明确的保护策略差异。
|
||||
|
||||
靠近使用现有线性 Actor speed 和高度采样,原版 root motion、渐变旋转/动作混合、碰撞与 skip-collision 恢复时序仍不完全等价。动画开始后的输入锁只补充双人动作范围,没有假称全部 isLock / 可取消技能规则已经恢复。自动狩猎暂停但保留自身控制器状态,未把它冒充原版 CPythonPlayer 的全部保留动作/自动攻击状态。
|
||||
|
||||
钓鱼水面目标、移动技能/多目标、完整动画混合/随机动作、公会标记传输、地形阴影/雾/splat、水材质动画、树形生成/叶片数值仍是其他待办。没有 Windows 动态输出或 Android 画面对照。
|
||||
|
||||
完整日志在 `build/verification/windows-dual-emotion-2026-10-13/`。
|
||||
|
||||
验证结果:完整桌面构建通过,CTest 61/61 通过(50.91 秒),新增/扩展动作回归实际执行而未跳过;ASan/UBSan windows_behavior 与 player_motion 2/2 通过(1.47 秒)。客户端/SDK C++ 插桩,Python C 依赖未同等插桩。46 模块方法名审计零缺失,395 个映射协议常量零差异;git diff --check 通过。未做真实服务器或 Windows/Android 动态对照。
|
||||
@@ -0,0 +1,35 @@
|
||||
# AVA2 Windows 第十六批修复:飞行物场景碰撞
|
||||
|
||||
对照本地 `FlyingInstance.cpp::FCheckAnotherMonsterDuringFlying / FCheckBackgroundDuringFlying / Update`、`ActorInstanceCollisionDetection.cpp::TestCollisionWithDynamicSphere`、`GameUtil.cpp::DetectCollisionDynamicSphereVSDynamicSphere`、`GameType.h` 和 `CollisionData.cpp::COBBCollisionInstance::OnCollisionDynamicSphere`。只修改跨平台客户端。
|
||||
|
||||
## 本批接通
|
||||
|
||||
- 解析 MSF HitOnBackground 和 HitOnAnotherMonster;关闭标志时不执行对应碰撞。
|
||||
- RaceData 分别保留 BODY(1) 与 DEFENDING(3) 球,BODY 不污染技能距离/普通攻击使用的 DEFENDING 半径。Actor 提供变换后的 BODY 球及当前帧移动前的球心,支持演员和飞行物的两段轨迹检测;半径保留原版不随 actor scale 缩放的行为。
|
||||
- 额外角色检测使用 radius=10 的飞行球与 BODY 球轨迹的最近距离,边界包含等号。与主目标严格 bomb_range 距离分支不同。
|
||||
- 只排除发射者实例,不按敌我、是否可攻击或是否死亡过滤。主目标穿透后仍可能进入普通角色碰撞分支,保留原版不同集合的语义。
|
||||
- 碰撞集合按弱实例身份记录,穿透时每个实例只触发一次额外目标回调。相同 VID 的新实例可以重新碰撞。保留原版先选首个碰撞对象、再检查集合的顺序:已经击中过的首个对象可能遮住其他候选。
|
||||
- 检查顺序为射程耗尽→主目标→额外角色→地形→物体。命中且继续穿透时立即返回本帧,不继续处理其他碰撞。
|
||||
- 地形只检查移动终点是否严格低于地面,不把高度相等判为撞地。Python/app 入口逐帧借用当前场景,原生地图使用 CPythonBackground 的多区块高度查询;地图销毁后不保留旧指针。
|
||||
- 地图物体接入现有三维 OBB 代理,使用 radius=1、旧/新端点距离判断;保留原版 OBB 端点检查,不擅自改成整条线段扫掠。高度、yaw 和接触边界生效,避免沿用角色走路的二维圆柱检查。
|
||||
- FLY 动作事件捕获发射者身份、技能 ID 与额外角色/背景回调。沿用原版 PythonPlayerEventHandler:额外目标回调默认不发送攻击报文,也不触发额外角色 OnShootDamage。
|
||||
|
||||
## 验证
|
||||
|
||||
flying_target 新增真实 MSM BODY 数据、BODY/DEFENDING 分类、发射者排除、死亡友方角色仍碰撞、双轨迹交叉、BODY 半径等号边界、对象穿透去重与同 VID 新实例、已命中首候选遮蔽规则、主目标/额外角色/地形/射程优先级、地形等高与低于地面、关闭标志及多区块高度回调覆盖。
|
||||
|
||||
player_motion 使用真实 GR2 生成 MapObjectManager OBB,验证旧/新端点碰撞、飞越物体顶部、两端在外的原版 OBB 漏扫分支,以及实际背景回调。测试资源仅复制到临时目录,没有新增或改写项目资源。
|
||||
|
||||
验证日志位于 `build/verification/windows-flying-collision-2026-10-13/`。
|
||||
|
||||
最终桌面完整构建成功,CTest 62/62 通过(54.71 秒);五项严格 ASan/UBSan 通过(12.49 秒,halt_on_error=1),详细执行日志无 sanitizer 诊断。Python C 依赖未同等全面插桩。46 模块方法清点无缺失/占位,395 个映射协议常量无差异,git diff --check 通过。SDK、Windows 参考和服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
## 仍未完全对齐
|
||||
|
||||
原版 CCullingManager 的空间候选集合和遍历顺序尚未恢复。额外角色目前遍历网络演员、按 VID 稳定排序,可能与原版树的首候选不同;未注册的预览演员不参与。碰撞几何相符不等于原版空间筛选与性能相符。
|
||||
|
||||
静态物体使用现有 mesh OBB,不是原版 .mdatr/.atr 的所有 Sphere/Plane/Cylinder/AABB/OBB 碰撞图元。原版 AABB 等图元还有历史代码差异;SpeedTree 独立碰撞球也未接入本路径。本批证明代理路径已工作,不宣称建筑和树木碰撞形状完全相同。
|
||||
|
||||
骨骼 BODY 球复用现有 Granny 姿态转换,缺失根骨骼回退、不同部件的 attaching model index 和 shape/装备碰撞实例生命周期仍有差异。移动前球心记录覆盖 Actor.Update 内部运动,网络坐标瞬移与模型/骨骼历史缓存的精确时序尚需继续恢复。平行/极短轨迹的浮点逐位等价未验证。
|
||||
|
||||
100ms 受击震动、angular velocity 和多视觉附件、精确包围球中心、移动技能/root motion、选择节流、完整 TCP 时序,以及公会标记、地形/水材质、SpeedTree 数值和旧 GPU/碰撞接入仍待推进。没有 Windows、Android 或真实服务器动态验证。
|
||||
@@ -0,0 +1,38 @@
|
||||
# AVA2 Windows 第十五批修复:飞行物目标与生命周期
|
||||
|
||||
依据本地 `GameLib/FlyTarget.cpp`、`FlyingInstance.cpp`、`FlyingData.cpp`、`FlyingObjectManager.cpp`、`ActorInstanceMotionEvent.cpp`、`ActorInstanceBattle.cpp::OnShootDamage`、`ActorInstanceMotion.cpp::isLock` 与 `PythonPlayerEventHandler.cpp`。只修改跨平台客户端。
|
||||
|
||||
## 本批修复
|
||||
|
||||
- FLY 动作事件及服务器 CreateFly 的 normal/auto-fire 路径捕获对象目标,每帧读取其当前位置。对无追踪需求的位置目标保留固定位置。烟花继续使用随机位置。
|
||||
- 对象删除后转为最后采样的位置,停止 homing 和对象命中回调。弱生命周期标识加实例身份检查,避免删除、同 VID 替换或旧对象仍被其他代码持有时继承飞行物。与原版 NotifyTargetClear 的生命周期行为对应,使用安全身份而不是裸指针注册链。
|
||||
- 命中改为本帧飞行线段到目标点的平方距离,严格小于 bomb_range²;不再使用默认最小 25 半径,高速穿过目标也可命中。
|
||||
- 每帧累计实际移动距离并扣减 range,剩余 range<0 时退出,优先于目标命中。超射程不播放爆炸、不触发命中;删除五秒即当作命中的旧分支。
|
||||
- MSF initial velocity 保留低速/零速;积分顺序为加速度和 gravity 先更新速度,再移动。gravity 使用原版直接加速度和 Z-up→engine height 转换,不再乘 -9.8 或施加到地面 Z。
|
||||
- 初始 roll/cone 旋转及目标方向旋转同时作用于速度和加速度,修复原版前向加速资源被当作侧向加速的问题。
|
||||
- homing 仅针对对象目标,保留 homing_start_time 严格边界、原版 SafeRotationNormalizedArc、0.001 方向近似阈值和每次更新的 quaternion 半角限制;不按 dt 插值。超过 180 时直接转向,并同时旋转加速度。
|
||||
- 解析 pierce_count,主目标命中只回调一次;剩余穿透次数时播放爆炸并继续飞行,否则终止。
|
||||
- FLY 对象命中接入 OnShootDamage:眩晕角色死亡,否则在原版动作锁、击飞/起身限制之外播放 DAMAGE 并排队 WAIT,保留可取消技能例外。不自行扣除 HP。
|
||||
- 技能身份由发射时的 motion node 捕获,避免主角切换技能或目标后改变飞行物回调参数。原版主目标命中回调不发送攻击报文,本批也不增加该报文。
|
||||
- SpreadingFlag 已恢复三次原版随机调用和发射旋转:两次散布角求平均,再绕负 Y 旋转,随后应用初始 roll/cone 与目标方向。速度和加速度共用旋转。组合顺序依据 [Microsoft D3DXQuaternionMultiply 定义](https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxquaternionmultiply)核对。
|
||||
- Indexed 烟花改用已有 eter::frandom;Random.cpp 下移到渲染公共库,所有调用共享原来的同一发生器。
|
||||
|
||||
## 测试
|
||||
|
||||
新增 flying_target 测试:实际 MSF 新字段、移动目标采样、严格半径、跨帧高速线段命中、超射程优先级与不误报命中、range=0 边界、低速超过五秒仍存活、原版重力轴/单位/积分顺序、初始旋转后的加速度、延迟 homing 与半角/速度保持、无限制 homing、固定位置不 homing、一次性穿透目标回调、对象删除转位置及同 VID 替换安全性。
|
||||
|
||||
player_motion 扩展真实 GR2/MSA:DAMAGE→WAIT、锁定与可取消技能、眩晕受击死亡;FLY 事件发射后移动目标,验证实际 FlyingManager 更新命中、受击动作及携带原技能身份的一次性回调。原 render_3d 真实 geompung.msf 命中回归保留。
|
||||
|
||||
Spreading 使用固定种子及独立计算的原版轨迹坐标,验证速度与加速度共用旋转、恰好消耗三次随机数,以及关闭时不消耗随机数。
|
||||
|
||||
验证日志位于 `build/verification/windows-flying-lifecycle-2026-10-13/`。
|
||||
|
||||
最终桌面完整构建成功,CTest 62/62 通过(57.66 秒)。五项严格 ASan/UBSan 通过(14.25 秒,halt_on_error=1),详细日志无 sanitizer 诊断。Python C 依赖未同等全面插桩。46 模块方法清点无缺失/占位,395 个映射协议常量无差异,git diff --check 通过。SDK、Windows 参考和服务器未修改,尚未提交或推送。
|
||||
|
||||
## 剩余差异
|
||||
|
||||
angular velocity 视觉转动、多附件/网格及烟花视觉尚未完整恢复。背景和其他怪物的飞行碰撞、穿透其他怪物/碰撞集合、owner 排除和对应回调尚未接入。本批穿透测试只覆盖原主目标一次性处理。零长度目标方向采用安全零速度分支,不复现原版异常输入路径。
|
||||
|
||||
OnShootDamage 的 100ms shake 尚未接入;现有 InterceptMotion 的混合、精确包围球中心和骨骼附件碰撞矩阵仍有差异。GetFlyTargetCenter 仍取现有近似中心,不能据本批证明命中视觉完全一致。对象身份安全检查比原版更保守;native 位置 hitCb 为现有调用兼容接口,区别于原版只对对象调用 IFlyEventHandler。
|
||||
|
||||
技能移动/root motion、选择节流/UI 生命周期、完整 TCP 时序,以及公会标记、地形/水材质、SpeedTree 数值及旧 GPU/碰撞接入继续保留在差异清单。无 Windows、Android 或真实服务器动态验证,不宣称整个客户端完全对齐。
|
||||
@@ -0,0 +1,32 @@
|
||||
# AVA2 Windows 第十七批修复:飞行附件与受击震动
|
||||
|
||||
依据本地 `FlyingData.cpp::LoadScriptFile`、`FlyingInstance.cpp::UpdateAttachInstance / BuildAttachInstance / AdjustDirectionForHoming`、`ActorInstanceBattle.cpp::OnShootDamage / __Shake / ShakeProcess`、`ActorInstance.cpp::INSTANCEBASE_Transform` 和 `PythonPlayerEventHandler.cpp::OnSetFlyTarget`。只修改跨平台客户端。
|
||||
|
||||
## 本批修复
|
||||
|
||||
- MSF 保留全部 AttachData,而不是只保留最后一个。每个 EFFECT 附件独立创建效果与尾迹,解析 Roll/Distance/Period/Amplitude 和 AngularVelocity;现有 attach 字段保留首附件兼容访问。
|
||||
- 保留初始 roll/cone、spreading、目标方向和 homing 后的飞行四元数。AngularVelocity 按每帧增量累积附件旋转,不改变飞行速度或加速度。
|
||||
- LINE 沿飞行姿态,按原版忽略附件旋转;MULTI_LINE 使用 Roll/Distance 的侧向偏移;SINE 使用 amplitude×sin(age×2π/period);EXP 使用 amplitude×exp(-age/period)×age/period。后三类偏移受组合后的附件/飞行旋转影响。
|
||||
- 效果收到完整全局矩阵,尾迹按各自附件的实际位置更新;飞行物终止或销毁时清理所有拥有的效果及尾迹,不删除无关效果。保留原版 homing 两个分支的四元数组合顺序差异。
|
||||
- OnShootDamage 未眩晕时开始 100ms 图形震动,即使当前技能锁定也震动;眩晕时走死亡分支,不新增震动。每次 Actor.Update/Transform 采样一次,三个原版轴各使用 sign=rand()%2 与 amount=rand()%10,再转换到 engine X/height/Z。
|
||||
- 图形偏移进入主体绘制、骨骼世界矩阵和现有飞行目标中心,逻辑坐标保持不变。BODY/DEFENDING 球使用不含震动的矩阵,避免把图形震动变成物理移动。下一帧先清除旧图形偏移,再计算当前偏移;零 dt 也处理震动过期。
|
||||
- 保留原版严格 `shakeEnd < now`:正好 100ms 时仍采样,101ms 清理。Timer.cpp 下移到公共渲染库,Python 和非 Python 路径共享同一原有计时状态。
|
||||
- 修正主飞行目标 CG51 的 Y 符号,按原版 OnGetFlyTargetPosition 图形坐标发送负 game Y,与前批 CG53 一致,再加地图基址。
|
||||
|
||||
## 回归
|
||||
|
||||
player_motion 使用真实 GR2/MSA 验证 100/101ms 边界、固定六次震动随机调用、坐标轴转换、逻辑坐标不变、重复绘制不再采样、锁定技能仍震动和眩晕死亡不新增震动。实际主角 FLY 动作绑定触发默认处理器,断言 CG51 的完整 13 字节及负 Y。
|
||||
|
||||
flying_target 使用实际四个 AttachData 和 MSE:解析顺序、四条独立尾迹的绘制顶点、LINE/MULTI/SINE/EXP 偏移及 angular rotation、实际粒子绘制中心、全部拥有的效果释放、无关效果保留、终止尾迹清空。另验证震动不改变 BODY 几何,而图形飞行中心具有偏移。原 render_3d 真实飞行资源回归保留。
|
||||
|
||||
日志位于 `build/verification/windows-flying-visual-2026-10-13/`。
|
||||
|
||||
最终桌面完整构建成功,CTest 62/62 通过(53.47 秒)。五项严格 ASan/UBSan 通过(13.20 秒,halt_on_error=1),详细执行日志无 sanitizer 诊断;Python C 依赖未同等全面插桩。46 模块方法清点无缺失/占位,395 个映射协议常量无差异,git diff --check 通过。SDK、Windows 参考和服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
## 剩余差异
|
||||
|
||||
Windows CRT rand 的精确全局序列与各模块调用顺序尚未恢复;本批验证采样数量和范围,不声称随机震动逐位相同。DWORD 极端回绕沿用原版比较规则,没有新加回绕修正。普通近战/特殊攻击的完整 HitGood/HitGreat/HitStone 及其震动触发未在本批重写。
|
||||
|
||||
零/非有限 Period 使用零振幅的安全偏移,不复现原版除零。FLY_ATTACH_OBJECT 在原版自身就是未实现项,当前跳过;未知 FlyType 和缺失字段的非法资源行为未逐位恢复。附件第一帧时间戳、粒子发射顺序、尾迹衰减/形状和浮点组合的 Windows 动态输出尚未验证,本批为绘制命令/顶点验证,没有 GPU 截图或视觉逐帧对照。
|
||||
|
||||
模型包围球中心仍使用近似值,骨骼附件时序、完整 shape/装备碰撞生命周期、原版 culling 遍历、.mdatr 完整图元及 SpeedTree 独立碰撞仍有差异。移动技能/root motion、选择节流、完整 TCP 时序、公会标记、地形/水材质、SpeedTree 数值与旧 GPU 接入仍待推进。没有 Windows、Android 或真实服务器动态验证。
|
||||
@@ -0,0 +1,32 @@
|
||||
# AVA2 Windows 第十八批修复:飞行尾迹几何与衰减
|
||||
|
||||
依据本地 `GameLib/FlyTrace.cpp::Create / Destroy / UpdateNewPosition / Render` 和 `EterLib/Camera.cpp::GetView / SetViewMatrix`,结合当前跨平台相机矩阵约定。只修改跨平台客户端。
|
||||
|
||||
## 修复
|
||||
|
||||
- 尾迹每段恢复六顶点三角带,转换成四个三角形索引,包括头/尾尖角及中间带面;不再用旧四顶点矩形段代替。
|
||||
- 方向基底按原版:B=旧点−新点,E=相机位置−新点,P=B×E,U=normalize(F×P),R=F×U。相机位置从当前刚性 view 矩阵反解,F 使用当前客户端保存的视线方向。顶点使用原版对应的两组三个端点偏移。
|
||||
- 同一尾迹的各段按 −dot(E,F) 升序提交。相同深度使用稳定顺序;原版 std::sort 的等键次序未验证。
|
||||
- diffuse 保持原始 TailColor,包括 alpha;原版当前启用代码并未做 alpha 衰减。非矩形尾迹只按 `1-age/tailLength` 缩小宽度,矩形维持固定宽度,不擅自 clamp 原版有限 rate。
|
||||
- 恢复六顶点 UV,保留加法混合,并启用 alpha>0 的 alpha test 绘制标记。
|
||||
- 直接保留有效的小 TailLength/TailSize,不再把小于 0.01/0.1 的参数替换成默认值。过期判断按原版 `sampleTime + tailLength < currentTime`,等号处保留节点。
|
||||
- 构造/清理状态回到零色、零长度、零尺寸;Clear 清空采样。Create 作为当前 API 的重新初始化仍清空旧记录。重复位置不再被旧“短线段跳过”分支删除,保留原版退化顶点语义。
|
||||
- 对零/非有限 tailLength、非有限尺寸和缺失相机矩阵不生成无效几何。这属于明确安全保护,不复现原版无效资源产生 NaN 的路径。
|
||||
|
||||
## 验证
|
||||
|
||||
flying_target 增加基于源公式的固定相机六顶点数值、四三角形数量、恒定 alpha、混合/alpha test 标记、矩形与收缩宽度、严格过期边界、极小有效参数、零长度保护、真正改变段提交顺序的深度测试及清理断言。
|
||||
|
||||
前批多附件用新尖角几何中的对称顶点恢复中心,继续验证四种附件偏移、实际 MSE 粒子中心和各自尾迹。本批也运行原 render_3d 的实际资源与尾迹回归。
|
||||
|
||||
日志位于 `build/verification/windows-flytrace-2026-10-13/`。
|
||||
|
||||
最终桌面完整构建成功,CTest 62/62 通过(51.52 秒);五项严格 ASan/UBSan 通过(12.55 秒,halt_on_error=1),详细执行日志无 sanitizer 诊断。Python C 依赖未同等全面插桩。46 模块方法清点无缺失/占位,395 个映射协议常量无差异,git diff --check 通过。SDK、Windows 参考和服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
## 剩余差异
|
||||
|
||||
原版逐段 ViewVolumeTest/frustum sphere 裁剪尚未恢复;当前由后续渲染流程裁剪,可能多提交段,宽尾迹边缘的可见性也可能不同。原版尾迹继承当时 ZWRITE 状态并临时用 LESS,当前绘制命令仍沿用不写深度的近似状态;完整 GPU 深度/混合状态和截图对照未验证。
|
||||
|
||||
本批相机反解针对当前客户端的刚性 view,非正交/缩放相机矩阵不承诺等价。原版相同深度的非稳定排序、首帧采样绝对时间、粒子发射顺序和浮点逐位输出仍待对照。尾迹重新 Create 时的当前清历史 API 行为区别于原版单纯设置字段,正常实例创建/销毁路径仍使用新实例或已清理实例。
|
||||
|
||||
其他尚未完成项包括 CRT 精确随机序列、近战完整受击流程、模型精确包围中心、骨骼/部件碰撞生命周期、原版 culling 遍历、完整 .mdatr 图元及 SpeedTree 独立碰撞、移动技能/root motion、选择节流、TCP 时序、公会标记、地形/水材质及 SpeedTree 数值和旧 GPU 接入。没有 Windows、Android 或真实服务器动态验证。
|
||||
@@ -0,0 +1,155 @@
|
||||
# AVA2 Windows 逐模块对照与修复 — 2026-10-13
|
||||
|
||||
> 最新状态进展:[第二十批视锥缓存与尾迹深度](WINDOWS-TAIL-STATE-2026-10-13.md)。更新阶段缓存、正交/偏轴粗球元数据及 LESS/继承深度写入已接通,并加入 GPU 像素回读;Windows 浮点逐位与全局相机切换仍待动态对照。以下旧记录保留各批当时状态。
|
||||
|
||||
> 最新裁剪进展:[第十九批尾迹逐段视锥裁剪](WINDOWS-TAIL-FRUSTUM-2026-10-13.md)。六平面、线段球和标准透视粗球已接通,并保留原版 FOV 单位混用;全局缓存时序、非标准投影粗球及 GPU 深度继承仍待对照。
|
||||
|
||||
> 最新尾迹进展:[第十八批尾迹几何与衰减](WINDOWS-FLYTRACE-2026-10-13.md)。尖角三角带、相机基底、深度排序及原色/宽度规则已恢复;逐段 frustum、GPU 深度继承与首帧绝对时序仍待验证。
|
||||
|
||||
> 最新视觉进展:[第十七批飞行附件与受击震动](WINDOWS-FLYING-VISUAL-2026-10-13.md)。多附件、独立尾迹、旋转/偏移和 100ms 震动已接通,CG51 图形 Y 已修正;精确随机序列、粒子时序和 GPU 逐帧对照仍待验证。
|
||||
|
||||
> 最新场景碰撞进展:[第十六批飞行物场景碰撞](WINDOWS-FLYING-COLLISION-2026-10-13.md)。BODY 球、额外角色穿透、地形及三维物体代理已接通;原版空间候选顺序、完整静态图元和树木碰撞仍待恢复。下方记录保留各批当时状态。
|
||||
|
||||
> 最新飞行生命周期进展:[第十五批目标追踪与生命周期](WINDOWS-FLYING-LIFECYCLE-2026-10-13.md)。对象持续追踪、线段命中、射程退出、homing、主目标穿透与受击动作已接通;背景/其他怪物碰撞、精确中心及视觉附件仍待恢复。
|
||||
|
||||
> 最新飞行目标进展:[第十四批追加飞行目标](WINDOWS-SKILL-FLIGHT-2026-10-13.md)。扇形/圆形排序、随机补足和 CG53 顺序已接入;精确包围球中心、骨骼碰撞和移动对象持续追踪仍待对齐。后面的批次记录保留当时状态。
|
||||
|
||||
> 最新距离进展:[第十三批技能距离与保留动作](WINDOWS-SKILL-RANGE-2026-10-13.md)。范围外靠近/重检、距离加成、2493 修正、阻挡与蓄力开场已接通;精确 root motion、选择节流和多目标等仍待对齐。
|
||||
|
||||
> 最新目标进展:[第十二批技能实际目标](WINDOWS-SKILL-TARGET-2026-10-13.md)。已补存活/尸体/友方/自用、拾取回退、前方自动选择及请求目标绑定;距离保留动作、选择节流和多目标仍待对齐。
|
||||
|
||||
> 最新资源进展:[第十一批技能资源与使用条件](WINDOWS-SKILL-COST-2026-10-13.md)。已补等级、武器、瓶子、HP/SP、冲刺例外和游戏阶段窗口回调;多目标/移动技能与其余模块仍待完成。
|
||||
|
||||
> 最新技能进展:[第十批技能许可与请求参数](WINDOWS-SKILL-PERMISSION-2026-10-13.md)。已接通变形/状态/骑乘/安全区限制、MSA 可取消技能规则和开关技能请求差异;其余技能条件与多目标/移动技能仍待完成。
|
||||
|
||||
> 最新进展:[第九批未定义行为与变形动作](WINDOWS-UBSAN-POLYMORPH-2026-10-13.md)。已复现的单例/颜色/道具未对齐访问已修复;变形识别、基础动作与 1.1 秒规则接通。完整变形状态流程、骨骼混合和其余模块仍需推进。
|
||||
|
||||
> 最新速度进展:[第八批攻击速度边界与生效时机](WINDOWS-ATTACK-SPEED-2026-10-13.md)。角色与坐骑接通零速/异常值规则;确认 AVA2 未启用 NPC 动作限速开关。变形倍率、混合与 root motion 仍待对齐。
|
||||
|
||||
> 最新动画进展:[第七批动画变体与播放速度](WINDOWS-MOTION-VARIANTS-SPEED-2026-10-13.md)。百分比选择、对应 MSA 数据和网络移动动画速度已修复;Windows 随机序列、骨骼混合、root motion 及特殊角色倍率仍待对齐。
|
||||
|
||||
> 最新双人进展:[第六批双人情绪调度、靠近与移动锁](WINDOWS-DUAL-EMOTION-2026-10-13.md)。500ms 调度、100 距离、职业/角色选择与锁已接通;完整 TCP 排序、root motion、混合/碰撞仍待对齐。
|
||||
|
||||
> 最新动作进展:[第五批情绪请求、钓鱼与挖矿队列修复](WINDOWS-PLAYER-MOTION-2026-10-13.md)。玩家情绪请求/查询和基本钓鱼、挖矿队列已接通;双人靠近/TCP 锁、钓鱼水面目标与动画混合仍待完成。
|
||||
|
||||
> 最新树木进展:[第四批默认 WIND_NONE 与叶片摆动分离](WINDOWS-SPEEDTREE-WIND-MODE-2026-10-13.md)。默认网格变形开关和固定风力帧步长已修复,叶片摆幅/风强传播与 DLL 数值仍待对照。
|
||||
|
||||
> 最新地形进展:[第三批地图配置、剔除与水面修复](WINDOWS-TERRAIN-SETTINGS-2026-10-13.md)。HeightScale、TerrainVisible 和本批列出的水格/剔除差异已修复;ViewRadius、阴影/雾/splat 仍待完成。
|
||||
|
||||
> 后续进展:[第二批目标特效、StoneDetect 与树木静态光照修复](WINDOWS-TARGET-EFFECTS-2026-10-13.md)。下方首次审计中的目标效果生命周期/StoneDetect 和树木动态光照问题已在第二批修复;其余待办仍保留。
|
||||
|
||||
这是首轮行为修复记录,不是“整个客户端已完全等价”的证明。所有 46 个实际编译的 Windows Python 模块完成了方法名清点;本轮深入对照网络、仓库、玩家规则、体力、技能冷却和地形纹理。其余模块只有接口清点或局部核查,下面明确保留后续工作。
|
||||
|
||||
## 对照依据与边界
|
||||
|
||||
- 行为依据仅为 `upstream/ava2-client` 的 AVA2 Windows 源码、Windows 工程实际编译文件及 `Locale_inc.h` / `ServiceDefs.h` 的有效开关,不使用其他客户端版本代替原版。
|
||||
- 开始时客户端 HEAD 为 `31c5b3dd`;桌面构建使用平级 `../sdk`(HEAD `62a5f5a`),不把嵌套 SDK 的固定版本混作同一份源码。
|
||||
- 修正审计脚本的目录:模块已经搬到 `src/scripting`。旧路径扫描会错误地产生“零问题”;现在找不到源码直接报错。
|
||||
- 28 个脚本桥接文件覆盖 46 个模块,方法名缺失 0,dummy 方法绑定 0;另有 71 个常量返回候选,必须阅读原版后才可判定。这个工具不识别全部带参数解析的空实现,也不证明常量、签名、调用顺序或渲染行为等价。
|
||||
- 395 个已映射协议常量对照无差异,不代表所有报文的语义都已验证。
|
||||
- 本轮没有 Windows DLL/原版进程动态输出对照,也没有 Android 设备或真实服务器验证。未修改原版参考源码、平级 SDK 或服务器。
|
||||
|
||||
## 已确认并修复的行为差异
|
||||
|
||||
| 模块/流程 | Windows 原版与此前差异 | 本轮修复与验证 |
|
||||
| --- | --- | --- |
|
||||
| `net` SMS | `SendMobileMessagePacket` 空操作;原版 CG107 有 WORD 长度、25 字节收件人和 NUL 文本 | 固定宽度编码,24 字符截断后终止;一个完整报文占一个发送序列边界;黄金字节与最大长度测试 |
|
||||
| `net` 67 属性 | 已启用的 CG208/209 接口不发送 | 恢复材料/辅助物及两个有符号短整型位置、关闭单字节包;黄金字节测试 |
|
||||
| `net` 日历 | 已启用 CG220 开启/关闭/事件接口不发送 | 恢复子头、32 位日期/索引、两个 6 字节时间;保留原版主角可行动条件,零填充未使用字段 |
|
||||
| `net` CatchKing | 开启窗口和游戏操作为空 | `OpenCatchKing` 只调用 `StartCatchKing`;CG163 操作按子头构造 4/5 字节报文,保持其原版行动条件差异 |
|
||||
| `safebox` 容量 | 把服务器传来的行数当成页数,乘 45 | 按原版每行 5 格:9 行=45 格,18 行=90 格;普通仓库/商城均修复,覆盖容量末端 |
|
||||
| `net` 仓库回调 | 丢失错误、开启、金钱及物品刷新回调 | 恢复 `OnSafeBoxError`、`OpenSafeboxWindow`、`OpenMallWindow`、`RefreshSafeboxMoney`;物品变化在一次接收后合并为 `RefreshSafebox` / `RefreshMall`,顺序依原版;覆盖分片和合并报文 |
|
||||
| `player` 体力 | Start/StopStaminaConsume 仅日志,状态和界面不变 | 保留浮点累计体力、帧更新、DWORD 状态转换与 `RefreshStamina`;停止/重置清理;两次半单位消耗不会分别丢弃小数 |
|
||||
| `player` 手机 | sms/nosms 修改网络标记但未通知玩家窗口 | 同步 `RefreshMobile`,通过真实命令接收分派验证 |
|
||||
| `player` PvP/安全区 | 查询恒为 0;实际攻击仅允许怪物/石头 | 恢复决斗、PVP/GVG、PK 模式、队伍、保护模式、阵营、善恶、杀手、观察者、可攻击种类及门模型条件;实际近战/范围攻击复用同一规则;安全区按实际角色位置查询 BANPK |
|
||||
| `skill` 冷却 | 普通/公会技能用点 19(移动速度)算施法冷却 | 改为原版点 21(施法速度);测试移动速度 1000、施法速度 200 时,20 秒公会技能为 10 秒 |
|
||||
| `background` 纹理 | TextureChange 无操作,所有纹理固定 world/500 UV | 读取纹理文件的比例/偏移等字段,按原版 1/(16×cellScale) 与地图坐标计算 UV;每个 splat 层使用自己的变换;换纹理清理缓存;验证坐标、偏移符号和错误输入回滚 |
|
||||
| 审计/树木测试 | 旧测试假定远距离自动广告牌,与 Windows Advance 强制 LOD=1 相反;仅凭原点在相机后断言剔除 | 校正为原版全几何、alpha=84;剔除测试保证完整包围球在相机后;SDK 广告牌能力单独验证 |
|
||||
|
||||
源码依据:`UserInterface/PythonNetworkStreamPhaseGame.cpp`、`PythonNetworkStreamPhaseGameItem.cpp`、`PythonNetworkStreamCommand.cpp`、`PythonSafeBox.cpp`、`PythonPlayer.cpp`、`PythonPlayerModule.cpp`、`InstanceBase.cpp`、`InstanceBaseEffect.cpp`、`Packet.h`、`PythonBackgroundModule.cpp`、`PRTerrainLib/TextureSet.cpp`、`GameLib/MapOutdoor.cpp`、`SpeedTreeLib/SpeedTreeWrapper.cpp`。本轮实现位置和测试可由 Git diff 及 `tests/windows_behavior_test.cpp` 复查。
|
||||
|
||||
SMS 超过 WORD 可表示长度时拒绝发送,避免复制原版长度溢出。日历开启/关闭中原版未初始化字段统一填零。损坏纹理的非有限数字/越界值拒绝并保留原集合。这些是明确的边界处理差异,正常报文字段保持原格式。
|
||||
|
||||
`bSplat`、Begin/End 虽已读取保存,本轮没有恢复按高度生成纹理 alpha;不能因此宣称完整 splat 等价。
|
||||
|
||||
## 逐模块清单
|
||||
|
||||
每行的方法数来自 Windows 有效方法表,全部方法名在移植侧存在。默认“待逐函数对照”意味着本轮没有完成该模块内部行为审计。名字存在不代表功能完成。
|
||||
|
||||
| 模块 | Windows 方法数 | 本轮行为审查/后续工作 | Windows 入口 → 移植入口 |
|
||||
| --- | ---: | --- | --- |
|
||||
| `ServerStateChecker` | 5 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/ServerStateCheckerModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `app` | 116 | 修复 UpdateGame 体力更新;帧时序、相机/诊断接口待逐函数对照 | `upstream/ava2-client/UserInterface/PythonApplicationModule.cpp` → `src/scripting/python_app.cpp` |
|
||||
| `background` | 52 | 修复 TextureChange 与纹理 UV;阴影、雾、splat、目标特效待完成 | `upstream/ava2-client/UserInterface/PythonBackgroundModule.cpp` → `src/scripting/python_background.cpp` |
|
||||
| `battlepass` | 8 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonBattlePass.cpp` → `src/scripting/python_battlepass.cpp` |
|
||||
| `chat` | 33 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonChatModule.cpp` → `src/scripting/python_chat.cpp` |
|
||||
| `chr` | 80 | 核查 PickAll/LookAt 已有实现或原版空操作;脚本骑乘和动作队列待完成 | `upstream/ava2-client/UserInterface/PythonCharacterModule.cpp` → `src/scripting/python_chr.cpp` |
|
||||
| `chrmgr` | 37 | 动作/效果注册需继续逐项对照;不能按接口存在认定等价 | `upstream/ava2-client/UserInterface/PythonCharacterManagerModule.cpp` → `src/scripting/python_chr.cpp` |
|
||||
| `cube_renewal` | 5 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonCubeRenewal.cpp` → `src/scripting/python_cube_renewal.cpp` |
|
||||
| `dbg` | 5 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/ScriptLib/PythonDebugModule.cpp` → `src/scripting/python_dbg.cpp` |
|
||||
| `drop_item` | 8 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonDropItem.cpp` → `src/scripting/python_drop_item.cpp` |
|
||||
| `dungeon_info` | 12 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonDungeonInfo.cpp` → `src/scripting/python_dungeon_info.cpp` |
|
||||
| `effect` | 7 | 注册/播放接口覆盖;目标跟随、特殊事件效果待完成 | `upstream/ava2-client/UserInterface/PythonEffectModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `event` | 29 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonEventManagerMoudle.cpp` → `src/scripting/python_event_manager.cpp` |
|
||||
| `eventMgr` | 1 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonGameEventManagerModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `exchange` | 23 | 本轮运行现有交易/仓库回归;完整交易状态机待对照 | `upstream/ava2-client/UserInterface/PythonExchangeModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `fly` | 2 | 接口覆盖;飞行目标实时跟踪、多目标/扇形技能待完成 | `upstream/ava2-client/UserInterface/PythonFlyModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `grp` | 54 | 接口覆盖;静态/动态光照、阴影、屏幕震动需专项对照 | `upstream/ava2-client/EterPythonLib/PythonGraphicModule.cpp` → `src/scripting/python_grp.cpp` |
|
||||
| `grpImage` | 15 | 接口覆盖;采样/混合/裁剪需图像对照 | `upstream/ava2-client/EterPythonLib/PythonGraphicImageModule.cpp` → `src/scripting/python_grp.cpp` |
|
||||
| `grpText` | 21 | 接口覆盖;字体度量/字形布局需专项对照 | `upstream/ava2-client/EterPythonLib/PythonGraphicTextModule.cpp` → `src/scripting/python_grp.cpp` |
|
||||
| `grpThing` | 8 | 接口覆盖;模型/骨骼/动画混合需专项对照 | `upstream/ava2-client/EterPythonLib/PythonGraphicThingModule.cpp` → `src/scripting/python_grp.cpp` |
|
||||
| `guild` | 34 | 数据接口覆盖;标记下载/上传、区域显示待完成 | `upstream/ava2-client/UserInterface/PythonGuild.cpp` → `src/scripting/python_guild.cpp` |
|
||||
| `ime` | 33 | 接口覆盖;系统输入法与 Python2 字节/光标行为需专项对照 | `upstream/ava2-client/UserInterface/PythonIMEModule.cpp` → `src/scripting/python_ime.cpp` |
|
||||
| `item` | 48 | 接口覆盖;资源/属性/选择状态仍需逐函数对照 | `upstream/ava2-client/UserInterface/PythonItemModule.cpp` → `src/scripting/python_gameplay_modules.cpp` |
|
||||
| `managerBankLogs` | 1 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonManagerBank.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `messenger` | 5 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonMessenger.cpp` → `src/scripting/python_messenger.cpp` |
|
||||
| `miniMap` | 27 | 接口覆盖;坐标、目标、公会区域显示需专项对照 | `upstream/ava2-client/UserInterface/PythonMiniMapModule.cpp` → `src/scripting/python_minimap.cpp` |
|
||||
| `net` | 154 | 修复 SMS、67 属性、日历、CatchKing 发送及仓库回调;公会标记链路待完成 | `upstream/ava2-client/UserInterface/PythonNetworkStreamModule.cpp` → `src/scripting/python_net.cpp` |
|
||||
| `nonplayer` | 24 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonNonPlayerModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `pack` | 2 | 接口覆盖;实际 FoxFS/加密包读写需专项对照 | `upstream/ava2-client/UserInterface/PythonPackModule.cpp` → `src/scripting/python_runtime.cpp` |
|
||||
| `petskill` | 4 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonSkillPet.cpp` → `src/scripting/python_pet_skill.cpp` |
|
||||
| `player` | 149 | 修复 PvP/安全区/攻击过滤/体力;情绪与完整技能动作流程待完成 | `upstream/ava2-client/UserInterface/PythonPlayerModule.cpp` → `src/scripting/python_gameplay_modules.cpp` |
|
||||
| `playerLoad` | 1 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonPlayerSettingsModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `privateShopSearch` | 12 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonPrivateShopSearch.cpp` → `src/scripting/python_shop_search.cpp` |
|
||||
| `profiler` | 2 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonProfilerModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `quest` | 6 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonQuest.cpp` → `src/scripting/python_quest.cpp` |
|
||||
| `renderTarget` | 24 | 接口覆盖;离屏生命周期、相机、裁剪需专项对照 | `upstream/ava2-client/UserInterface/CPythonRenderTargetModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `safebox` | 15 | 修复行数解释、容量、商城和 UI 刷新;本轮有行为回归 | `upstream/ava2-client/UserInterface/PythonSafeBox.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `sash` | 7 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonSash.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `shop` | 42 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonShop.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `skill` | 41 | 修复普通/公会技能施法速度索引;完整技能时序待对照 | `upstream/ava2-client/UserInterface/PythonSkill.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `snd` | 14 | 接口覆盖;声源衰减、重复抑制、地图环境音需专项对照 | `upstream/ava2-client/UserInterface/PythonSoundManagerModule.cpp` → `src/scripting/python_gameplay_modules.cpp` |
|
||||
| `switchbot` | 9 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonSwitchbot.cpp` → `src/scripting/python_switchbot.cpp` |
|
||||
| `systemSetting` | 73 | 接口覆盖;配置持久化与画质选项实际生效需专项对照 | `upstream/ava2-client/UserInterface/PythonSystemModule.cpp` → `src/scripting/python_system.cpp` |
|
||||
| `textTail` | 18 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonTextTailModule.cpp` → `src/scripting/python_native_modules.cpp` |
|
||||
| `wiki` | 22 | 接口名覆盖;内部状态、参数、回调及资源行为待逐函数对照 | `upstream/ava2-client/UserInterface/PythonWiki.cpp` → `src/scripting/python_wiki.cpp` |
|
||||
| `wndMgr` | 188 | 接口覆盖;MarkBox_Load 在原版也是空操作;窗口生命周期需专项对照 | `upstream/ava2-client/EterPythonLib/PythonWindowManagerModule.cpp` → `src/scripting/python_wndmgr.cpp` |
|
||||
|
||||
## 仍需推进的差异
|
||||
|
||||
| 优先级 | 子系统 | 已确认未完成/下一步 | 验收依据 |
|
||||
| --- | --- | --- | --- |
|
||||
| P1 | 公会标记 | SetMarkServer/UploadMark/UploadSymbol 仍不执行原版连接与传输;选择阶段缺少 __DownloadMark。先恢复独立标记连接与块缓存,再接 UI | 原版 GuildMarkDownloader/Uploader、MarkManager;使用隔离模拟端验证报文、CRC、缓存更新及失败结果,禁止把返回 0 当成功 |
|
||||
| P1 | 玩家动作/技能 | 情绪状态、挖掘/钓鱼队列、移动技能、扇形/多目标、精确扫掠碰撞仍需对照 | PythonPlayer、ActorInstanceMotionEvent、InstanceBase;逐事件时序和命中集合回归 |
|
||||
| P1 | 背景/特效 | 目标效果接口目前只保存 VID/位置,缺少完整绘制/跟随;StoneDetect 命令仍仅日志,SpecialEffect 空操作 | PythonBackground、GameEventManager、网络命令;验证创建/移动/销毁与作用距离 |
|
||||
| P1 | 地形 | 阴影图/角色阴影、逐 tile splat、按高度 alpha、雾带及 LOD、HeightScale/ViewRadius/TerrainVisible、环境音仍需实现或核查 | MapOutdoorLoad/RenderHTP、TextureSet、TerrainPatch、Area;字段解析加图像/数值对照 |
|
||||
| P1 | SpeedTree 客户端接入 | 当前端固定全几何与原版一致,但生成几何/随机分布等库差异仍需单独验证;旧 stash 的多碰撞体/GPU 修改尚未适配远端新代码 | 以共享 SDK 的恢复记录为库层依据;先检查新的坐标/顶点布局,再迁移必要接入逻辑,避免覆盖远端修复 |
|
||||
| P1 | SpeedTree 默认配置 | 原版定义 WRAPPER_USE_NO_WIND + STATIC_LIGHTING + CPU_LEAF_PLACEMENT,却还启用 LeafRockingState;当前移植对网格统一施加风矩阵并启用 draw.lighting | 分离枝干/叶片中心风变形与叶片卡片摆动;静态色/光照单独对照。不能简单清零风强或重新开启远景广告牌,也不能用 SDK 有风能力代替客户端默认配置等价 |
|
||||
| P2 | Actor 视觉 | 精炼光效、武器轨迹、烟尘、加权随机动作、混合时长、脚本骑乘需逐条核对;飞行弹道当前偏发射时目标位置 | Character/ActorInstance/RaceData/FlyingInstance;模拟目标移动与动作时间线;实体创建存在不等于视觉完整 |
|
||||
| P2 | 屏幕震动 | 移植事件路径存在空处理;原版 GameEventManager/GrpBase 保存震动结束时间/强度,需检查并恢复其实际渲染消费链 | 不能仅因 Actor 层某段注释就判为原版无效果;先对照调用链,再测试范围与时间 |
|
||||
| P2 | 其他脚本桥接/UI/资源 | 上表中仍待逐函数对照的模块;重点 IME 字节/光标、字体布局、窗口生命周期、音频衰减、FoxFS、配置选项生效 | 同输入的状态/回调序列、资源结果与截图比较;阶段测试通过不能替代这些专项审计 |
|
||||
|
||||
历史清单需要纠正的内容:伤害数字队列已经在开始时 HEAD 中实现;网络演员的 ConfigureMount 已创建骑乘实体,不应继续写“马实体完全没有”;chr.PickAll 有拾取实现;chr.LookAt 的执行代码在 Windows 本身被注释;wndMgr.MarkBox_Load 在 Windows 本身也是空操作。IsOpenPrivateShop 的原版状态写入路径未找到实际调用,不应只凭移植返回 0 就擅自添加新的状态语义。上述核查不证明相关整个模块完全等价。
|
||||
|
||||
## 验证结果与复现
|
||||
|
||||
- `cmake --build build/dev -j8`:桌面客户端及测试构建通过。
|
||||
- `ctest --test-dir build/dev --output-on-failure`:60/60 通过(47.77 秒)。
|
||||
- 新增 `ava2.windows_behavior`:报文字节、接收分片、批处理回调、体力、PvP/攻击、安全区、技能冷却、纹理坐标与换纹理回滚。
|
||||
- 单独 ASan/UBSan 构建的 `ava2.windows_behavior`:1/1 通过(1.63 秒);SDK/客户端 C++ 插桩,Python C 依赖未做同等插桩。
|
||||
- `python3 tools/audit_ava2_python_interfaces.py`、`python3 tools/audit_windows_parity.py`、`python3 tools/audit_ava2_packet_constants.py`:分别记录方法覆盖、71 个复核候选、395 个协议常量零差异。
|
||||
- `git diff --check`:通过。
|
||||
- `verify_baseline.py` 仍报告 5 个 Python 脚本历史哈希差异:game.py、interfacemodule.py、intrologin.py、serverinfo.py、ui.py。它们已存在于本轮开始的远端 HEAD,本轮未修改这些文件,未篡改基线以使检查变绿。
|
||||
- 完整日志:`build/verification/windows-module-parity-2026-10-13/full-tests.log` 与 `sanitizer-tests.log`。隔离测试使用临时资源和模拟网络字节,不访问或改动运行服务器。
|
||||
|
||||
以上结论仅覆盖静态原版对照及本地回归。下一批先完成公会标记连接/缓存和目标特效生命周期,再推进动作、地形和 SpeedTree 接入;其余模块按上表保持待审状态。
|
||||
@@ -0,0 +1,33 @@
|
||||
# AVA2 Windows 第七批修复:动画变体与播放速度
|
||||
|
||||
> 后续:[第八批攻速修复](WINDOWS-ATTACK-SPEED-2026-10-13.md) 已接通网络零攻速与异常值规则,并确认 NPC 限速开关在 AVA2 关闭;下方待办是第七批结束时的记录。
|
||||
|
||||
本批修复始终播放首个注册动作、变体动画与 MSA 事件数据不一致,以及服务端移动速度没有影响行走动画的问题。依据为本地 AVA2 Windows 源码,没有原版进程动态输出对照。
|
||||
|
||||
## 对照与实现
|
||||
|
||||
依据 `GameLib/ActorInstanceMotion.cpp::GetRandomMotionKey / __SetMotion / ReservingMotionProcess`、`GameLib/ActorInstance.cpp::SetMoveSpeed / Move / Walk` 和 `UserInterface/InstanceBaseMovement.cpp::SetMoveSpeed`。
|
||||
|
||||
- GENERAL 及其他动作模式按注册百分比选择变体,沿用原版 BYTE 权重逐项扣减规则,不重新归一化。权重不足 100 时剩余区间回退首项;超过 100 时尾部区间可能无法被选择。
|
||||
- 播放所选 GR2,同时绑定该变体的 MSA 数据,事件、循环次数和动作属性不再固定来自首项。LOD 使用同一个已选动画文件。队列在动作实际激活时抽取一次变体。
|
||||
- C++ 循环、插入和排队接口增加显式速度倍率;排队倍率保留到激活。既有调用保留普通攻击/连击的自动攻速选择。非有限值和非正显式倍率拒绝,不改变当前状态。
|
||||
- 网络创建/更新角色时,将移动速度除以 100 接入 WALK/RUN 动画倍率。运行中修改速度会重启动作循环;坐骑创建及更新也接入该倍率。
|
||||
- 移动速度 0 保持为 0,大于 1100 按原版归零;删除原先 0 速度自动替换为 100/250 的行为。主角输入位移使用归一化后的倍率,避免绕过该上限规则。
|
||||
|
||||
## 回归与证据
|
||||
|
||||
扩展 `tests/player_motion_test.cpp`,使用临时 MSA/race 与只读原版 body/wait/walk/run GR2:
|
||||
|
||||
- 注入全部 100 个随机取值,验证 15/25/60 区间、所选文件、MSA 时长及实际 GR2 时长;验证零权重、不足和超额权重。
|
||||
- 验证立即和排队的 2 倍/0.5 倍播放速度、激活时单次抽样及非法倍率保持状态。
|
||||
- 验证网络角色 150/200/0/1101 移动速度对应动画计时、运行中重启和零速度停止位移。坐骑接入经过源码核查,本批没有独立坐骑资源回归。
|
||||
|
||||
完整桌面构建成功;CTest 61/61 通过(49.58 秒);ASan/UBSan 的 player_motion、windows_behavior、attack_combo 3/3 通过(3.62 秒)。日志在 `build/verification/windows-motion-variants-speed-2026-10-13/`。资源回归本机实际执行通过,没有因资源缺失跳过。
|
||||
|
||||
## 仍待对齐
|
||||
|
||||
百分比选择区间与原版一致,但当前使用平台 std::rand,不保证 Windows 随机数序列和全局调用顺序一致。显式倍率是 C++ 接口补充,没有新增 Python 参数或完成 chr.BlendLoopMotion 的混合语义。
|
||||
|
||||
SDK 当前只提供单个外部动画片段的采样接口;原版多动画控制器权重、局部骨骼 TRS 混合和共享 CPU/GPU 骨骼结果仍需实现。队列混合提前开始时间、root motion、碰撞、精确事件时间及完整 TCP 调度尚未对齐。NPC 非移动动作的速度上限、变形角色倍率与攻击速度归零规则也不在本批范围。
|
||||
|
||||
未修改参考源码、服务器或平级 SDK;未提供 Windows/Android 视觉等价证明。其他模块待办见 [逐模块对照记录](WINDOWS-MODULE-AUDIT-2026-10-13.md)。
|
||||
@@ -1,5 +1,499 @@
|
||||
{
|
||||
"scope": "Static Python method-table inventory; excludes hidden no-ops, renderer and packet behavior. Full parity is NOT established.",
|
||||
"scope": "Static Python method-table inventory in src/scripting. Constant returns are review candidates, not proven defects. Packet/renderer behavior still requires source comparison. Full parity is NOT established.",
|
||||
"source_count": 28,
|
||||
"placeholder_count": 0,
|
||||
"placeholders": []
|
||||
"placeholders": [],
|
||||
"constant_return_candidate_count": 70,
|
||||
"constant_return_candidates": [
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 588,
|
||||
"api": "IsDevStage",
|
||||
"handler": "app_is_dev_stage",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 591,
|
||||
"api": "IsTestStage",
|
||||
"handler": "app_is_test_stage",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 594,
|
||||
"api": "IsLiveStage",
|
||||
"handler": "app_is_live_stage",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 642,
|
||||
"api": "Process",
|
||||
"handler": "app_process",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 188,
|
||||
"api": "MovieResetCamera",
|
||||
"handler": "app_movie_reset_camera",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 685,
|
||||
"api": "GetLoad",
|
||||
"handler": "app_get_load",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 691,
|
||||
"api": "GetFaceCount",
|
||||
"handler": "app_get_face_count",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 722,
|
||||
"api": "IsWebPageMode",
|
||||
"handler": "app_is_web_page_mode",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 730,
|
||||
"api": "MoveWebPage",
|
||||
"handler": "app_move_web_page",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 733,
|
||||
"api": "HideWebPage",
|
||||
"handler": "app_hide_web_page",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 756,
|
||||
"api": "IsLiarCursorOn",
|
||||
"handler": "app_is_liar_cursor_on",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 852,
|
||||
"api": "SetControlFP",
|
||||
"handler": "app_set_control_fp",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 883,
|
||||
"api": "OnLogoUpdate",
|
||||
"handler": "app_on_logo_update",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 886,
|
||||
"api": "OnLogoRender",
|
||||
"handler": "app_on_logo_render",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 894,
|
||||
"api": "OnLogoClose",
|
||||
"handler": "app_on_logo_close",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 897,
|
||||
"api": "FlashApplication",
|
||||
"handler": "app_flash_application",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 911,
|
||||
"api": "IsVisible",
|
||||
"handler": "app_is_visible",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_app.cpp",
|
||||
"line": 929,
|
||||
"api": "IsCanOpenRender",
|
||||
"handler": "app_is_can_open_render",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_background.cpp",
|
||||
"line": 1019,
|
||||
"api": "RenderDungeon",
|
||||
"handler": "background_RenderDungeon",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 338,
|
||||
"api": "SetMovingSpeed",
|
||||
"handler": "chrmgrSetMovingSpeed",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 788,
|
||||
"api": "DismountHorse",
|
||||
"handler": "chrDismountHorse",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 525,
|
||||
"api": "RenderCollision",
|
||||
"handler": "chrRenderCollision",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 777,
|
||||
"api": "Refresh",
|
||||
"handler": "chrRefresh",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 1066,
|
||||
"api": "SetMoveSpeed",
|
||||
"handler": "chrSetMoveSpeed",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 1067,
|
||||
"api": "SetAttackSpeed",
|
||||
"handler": "chrSetAttackSpeed",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 1076,
|
||||
"api": "WeaponTraceUseAlpha",
|
||||
"handler": "chrWeaponTraceUseAlpha",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_chr.cpp",
|
||||
"line": 1075,
|
||||
"api": "WeaponTraceUseTexture",
|
||||
"handler": "chrWeaponTraceUseTexture",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4068,
|
||||
"api": "GetItemBind",
|
||||
"handler": "player_GetItemBind",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4025,
|
||||
"api": "StartMouseWalking",
|
||||
"handler": "player_StartMouseWalking",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 3231,
|
||||
"api": "EndMouseWalking",
|
||||
"handler": "player_EndMouseWalking",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 3859,
|
||||
"api": "ResetCameraRotation",
|
||||
"handler": "player_ResetCameraRotation",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4077,
|
||||
"api": "GetItemUnbindTime",
|
||||
"handler": "player_GetItemUnbindTime",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 3541,
|
||||
"api": "IsOpenPrivateShop",
|
||||
"handler": "player_IsOpenPrivateShop",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4081,
|
||||
"api": "GetItemElementGrade",
|
||||
"handler": "player_GetItemElementGrade",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4085,
|
||||
"api": "GetItemElementAttack",
|
||||
"handler": "player_GetItemElementAttack",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4089,
|
||||
"api": "GetItemElementType",
|
||||
"handler": "player_GetItemElementType",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4093,
|
||||
"api": "GetItemElementValue",
|
||||
"handler": "player_GetItemElementValue",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 3849,
|
||||
"api": "Render",
|
||||
"handler": "player_Render",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4106,
|
||||
"api": "GetCombatZonePoints",
|
||||
"handler": "player_GetCombatZonePoints",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4110,
|
||||
"api": "CanSealItem",
|
||||
"handler": "player_CanSealItem",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4114,
|
||||
"api": "GetItemSealDate",
|
||||
"handler": "player_GetItemSealDate",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_gameplay_modules.cpp",
|
||||
"line": 4118,
|
||||
"api": "GetItemUnSealLeftTime",
|
||||
"handler": "player_GetItemUnSealLeftTime",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 339,
|
||||
"api": "InitScreenEffect",
|
||||
"handler": "grpInitScreenEffect",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 338,
|
||||
"api": "Culling",
|
||||
"handler": "grpCulling",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 340,
|
||||
"api": "ClearDepthBuffer",
|
||||
"handler": "grpClearDepthBuffer",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 345,
|
||||
"api": "Identity",
|
||||
"handler": "grpIdentity",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 342,
|
||||
"api": "PopState",
|
||||
"handler": "grpPopState",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 341,
|
||||
"api": "PushState",
|
||||
"handler": "grpPushState",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 343,
|
||||
"api": "PushMatrix",
|
||||
"handler": "grpPushMatrix",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 344,
|
||||
"api": "PopMatrix",
|
||||
"handler": "grpPopMatrix",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 361,
|
||||
"api": "SetColorRenderState",
|
||||
"handler": "grpSetColorRenderState",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 578,
|
||||
"api": "SetInterfaceRenderState",
|
||||
"handler": "grpSetInterfaceRenderState",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 579,
|
||||
"api": "SetGameRenderState",
|
||||
"handler": "grpSetGameRenderState",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_grp.cpp",
|
||||
"line": 608,
|
||||
"api": "SetOmniLight",
|
||||
"handler": "grpSetOmniLight",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_ime.cpp",
|
||||
"line": 70,
|
||||
"api": "GetCandidateCount",
|
||||
"handler": "ime_get_candidate_count",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_ime.cpp",
|
||||
"line": 78,
|
||||
"api": "GetCandidateSelection",
|
||||
"handler": "ime_get_candidate_selection",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_ime.cpp",
|
||||
"line": 86,
|
||||
"api": "GetReadingError",
|
||||
"handler": "ime_get_reading_error",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_native_modules.cpp",
|
||||
"line": 899,
|
||||
"api": "GetOfflineShopItemTransmutation",
|
||||
"handler": "shop_GetOfflineShopItemTransmutation",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_native_modules.cpp",
|
||||
"line": 1301,
|
||||
"api": "LoadSkillData",
|
||||
"handler": "skill_LoadSkillData",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 877,
|
||||
"api": "IsTest",
|
||||
"handler": "net_IsTest",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 903,
|
||||
"api": "ToggleGameDebugInfo",
|
||||
"handler": "net_ToggleGameDebugInfo",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 1008,
|
||||
"api": "SetOfflinePhase",
|
||||
"handler": "net_SetOfflinePhase",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 1041,
|
||||
"api": "DisconnectUploader",
|
||||
"handler": "net_DisconnectUploader",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 124,
|
||||
"api": "ElementsSpellClose",
|
||||
"handler": "net_ElementsSpellClose",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 125,
|
||||
"api": "ElementsSpellAdd",
|
||||
"handler": "net_ElementsSpellAdd",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 126,
|
||||
"api": "ElementsSpellChange",
|
||||
"handler": "net_ElementsSpellChange",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 127,
|
||||
"api": "SendCombatZoneRequestActionPacket",
|
||||
"handler": "net_SendCombatZoneRequestActionPacket",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 128,
|
||||
"api": "IsRunning",
|
||||
"handler": "net_CombatZone_IsRunning",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_net.cpp",
|
||||
"line": 131,
|
||||
"api": "GetDayActivate",
|
||||
"handler": "net_CombatZone_GetDayActivate",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
},
|
||||
{
|
||||
"file": "src/scripting/python_system.cpp",
|
||||
"line": 867,
|
||||
"api": "ReserveResource",
|
||||
"handler": "systemReserveResource",
|
||||
"status": "constant-return candidate; compare original behavior before treating as a defect"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
> Current status (2026-10-13): [module audit and first behavior repair batch](WINDOWS-MODULE-AUDIT-2026-10-13.md). Earlier sections below are historical snapshots, including placeholder counts and gaps since fixed. They are not the current backlog.
|
||||
|
||||
# AVA2 Windows parity audit — 2026-10-05
|
||||
|
||||
Full 1:1 behavior is NOT implemented. The original AVA2 C++/Python snapshot is the reference; successful compilation and visible original Python screens do not establish gameplay parity.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# AVA2 Windows 第五批修复:玩家情绪请求、钓鱼与挖矿动作队列
|
||||
|
||||
延续 [逐模块审计](WINDOWS-MODULE-AUDIT-2026-10-13.md),修复移植客户端的真实报文/动作桥接。没有修改 Windows 源码、共享 SDK 或服务器;并非完整高级动作或技能等价的结论。
|
||||
|
||||
## 原版依据与修复
|
||||
|
||||
| 流程 | Windows 依据 | 本批实现 |
|
||||
| --- | --- | --- |
|
||||
| player.ActEmotion | UserInterface/PythonPlayer.cpp::ActEmotion、PythonPlayerInput.cpp::__GetAliveTargetInstancePtr | 参数是 emotion ID,但原版忽略它;当前目标存在且存活时发送 `/kiss <目标名字>`,否则 OnCannotShotError(mainVID,"NEED_TARGET")。不把参数当 VID,不自行播放动作 |
|
||||
| player.IsActingEmotion | PythonPlayerModule.cpp、InstanceBaseMovement.cpp、GameLib/ActorInstanceBattle.cpp::IsActEmotion | 查询主角当前实际动作;有效开关关闭 Wolfman,只有 KISS/FRENCH_KISS 的四职业变体返回真。拍手、舞蹈、挖矿和 slap 不是此查询的 true 条件 |
|
||||
| Fishing START | PythonNetworkStreamPhaseGame.cpp::RecvFishing、InstanceBaseMotion.cpp::StartFishing | 朝向为 BYTE dir×5;推入 THROW 一次动作,再推入 WAIT 循环 |
|
||||
| Fishing STOP/REACT | 同上 | 仅实际处于 FISHING_WAIT/REACT 才生效;STOP 插入 STOP 一次动作后排 WAIT;REACT 使用已有 Emoticon 系统编号 11,再排 REACT 与 FISHING_WAIT |
|
||||
| Fishing SUCCESS/FAIL | 同上 | 插入 CATCH/FAIL 一次动作并清旧队列,再排普通 WAIT;仅主角失败回调 OnFishingFailure,远端演员不触发本地界面 |
|
||||
| Fishing 状态及鱼消息 | GameLib/ActorInstanceMotion.cpp::IsFishing、RecvFishing 的 FISH 分支 | 从实际 WAIT/REACT 动作及已绑定 motion data 查询,不把刚收到 START、排队 THROW 或 STOP/CATCH 认作正在等待鱼;移除矛盾的包驱动 m_isFishing 标记,玩家取消和鱼通知均使用真实动作状态 |
|
||||
| Mining | PythonNetworkStreamPhaseGame.cpp::RecvDigMotionPacket | actor 存在时朝向已有目标,按 BYTE count 排入准确次数的 NAME_DIG;不存在目标仍排动作,不存在 actor 则只消费报文 |
|
||||
|
||||
原有服务端单人情绪命令已调用 ActorInstance::ActEmotion 排一次动作,本批没有再造另一套情绪布尔状态。也没有把 IsActingEmotion 塞进 CanAct:原版 CanAct 是死亡/晕眩等健康状态检查,不能擅自让所有拍手/跳舞阻塞同样操作。
|
||||
|
||||
## 回归验证
|
||||
|
||||
扩展 `windows_behavior_test` 验证:无目标/死目标报错、不发送接吻包,存在存活目标时以目标名发出原版 chat 请求,即使 emotion ID 不同也不把它作为目标。选中目标自身会发送 TARGET 包,测试在选中后清理发送队列再验证 ActEmotion,明确分离两次用户操作。
|
||||
|
||||
新增 `ava2.player_motion`:在临时合成 race/MSA 中引用只读的原版战士 GR2 模型及 wait GR2 动画,真正运行 SDK 动画和 ActorInstance 队列,不只是检查一个 bool。覆盖:
|
||||
|
||||
- 抛竿→等待→反应→等待,以及收竿/成功/失败→普通等待。
|
||||
- THROW 时 STOP 按原版被忽略,非钓鱼状态的 REACT 被忽略;方向、未知演员、远端失败回调限制。
|
||||
- 分片 DIG 报文不会提前排动作,完整接收后恰好三次 DIG,再回 WAIT,并朝向目标。
|
||||
- 八个接吻动作的情绪查询为真,结束后恢复假;拍手/舞蹈/挖矿/slap 查询为假。
|
||||
|
||||
测试缺少原版 GR2 资源时显式 SKIP=77;本轮执行有资源、实际通过,未跳过。合成 MSA 统一引用 wait GR2 是为了验证状态机和时序,不证明实际钓鱼/情绪视觉与 Windows 一致。
|
||||
|
||||
## 仍待完成
|
||||
|
||||
双人情绪的 100 距离靠近、500ms 排程、双方职业动作选择、互相朝向、TCP 锁与 Start/EndEmotionProcess 尚未恢复完整;现有 ActorInstance::ActDualEmotion 仅排动作,不应宣称等价。移动技能、扇形/多目标和精确命中仍未完成。
|
||||
|
||||
钓鱼前方 600 的水面/抛竿特效目标尚未恢复;角色转向本批立即设置 yaw,原版 BlendRotation 的渐变时序及动作 blend/speed/随机选取仍待对照。完整模型/服饰资源、真实动画表现、事件音效、原版 Windows 动态和 Android 画面对照未做。
|
||||
|
||||
公会标记传输/缓存、地形阴影/雾/splat/水材质动画、树形生成与叶片摆幅/风强传播仍在其他模块待办中。
|
||||
|
||||
## 本轮结果
|
||||
|
||||
完整桌面构建通过,CTest 61/61 通过(31.98 秒),新增动作测试实际执行;ASan/UBSan windows_behavior 与 player_motion 2/2 通过(1.53 秒)。客户端/SDK C++ 插桩,Python C 依赖没有同等插桩。方法名审计 46 模块零缺失,395 个映射协议常量零差异;不代表全部行为等价。git diff --check 通过。日志位于 `build/verification/windows-player-motion-2026-10-13/`。
|
||||
@@ -0,0 +1,30 @@
|
||||
# AVA2 Windows 第十一批修复:技能资源与使用条件
|
||||
|
||||
依据本地 AVA2 `PythonPlayerSkill.cpp::__CheckSkillUsable / __CheckShortLife / __CheckShortMana / __HasItem / __HasEnoughArrow`,以及 PythonSkill 的费用和武器规则。继续沿用上一批的许可顺序,没有修改参考源码、SDK 或服务器。
|
||||
|
||||
## 已恢复
|
||||
|
||||
- 空瓶 27995、毒瓶 27996 检查扫描普通背包(含装备/腰带)、龙魂背包及五类特殊仓库;不把银行、商城或 switchbot 当成携带物品。
|
||||
- 普通技能在钓鱼模式下回调 REMOVE_FISHING_ROD。学习等级限制默认开启,ToggleLevelLimit 控制真正的 NOT_YET_LEARN 检查,不再只是独立返回值。
|
||||
- WEAPON_LIMITATION 使用已登记的物品类型/子类型与 needWeapon 位掩码,无武器为当前 AVA2 的 WEAPON_NONE=11;不匹配回调 NOT_MATCHABLE_WEAPON。需要弓的非骑乘技能复用已有箭/箭袋检查及 EMPTY_ARROW 回调。
|
||||
- 费用公式按技能当前有效百分比求值,再采用已有 skill.GetSkillNeedSP 的明确 Win32 int32 转换。正常小数截断为整数。非有限公式值按已有桥接规则归零,不复制原版浮点转整数的未定义行为。
|
||||
- USE_HP 先检查 POINT_HP=5;原版仍继续检查 POINT_SP=7,本批保留这一实际行为。费用恰等于资源允许,客户端不抢先扣除资源,等待服务器更新。
|
||||
- 非开关技能费用 0 时,保留原版信息聊天及 NOT_ENOUGH_SP 拒绝;费用 -1 跳过普通 SP 数量比较。CAN_USE_IF_NOT_ENOUGH 允许 SP 小于费用但必须大于 0。召唤技能 131 只豁免 mana 检查。
|
||||
- DASH 状态跳过 HP/SP 检查;CHARGE_ATTACK 在 DASH 下还跳过剩余冷却检查,其他技能仍检查冷却。没有把这些例外推广到其他技能。
|
||||
- 技能失败、冷却以及箭矢错误通知,改为原版网络 PHASE_WINDOW_GAME 接收,含公会技能;不再依赖 player.SetGameWindow 指向同一对象。新增 C++ 借用窗口查询,没有改变 Python 方法表。
|
||||
|
||||
## 本地回归
|
||||
|
||||
扩展 windows_behavior 的真实 SkillDesc/SkillTable 输入和 CG233 字节断言:未学习与调试开关、SP 19/20、HP 19/20、HP 技能仍检查 SP、零费用、-1、召唤、CAN_USE_IF_NOT_ENOUGH、无武器掩码/弓不匹配、龙魂/特殊仓库瓶子、钓鱼模式、小数费用 1.9、冲刺/蓄力冷却例外,以及不同玩家窗口/游戏阶段窗口的回调路由。
|
||||
|
||||
没有使用真实服务器;骑乘/技能无动作资源等前序测试仍保留。成功发送检查九字节请求;失败检查空队列和原版 reason,并确认没有启动新的冷却回调。
|
||||
|
||||
日志在 `build/verification/windows-skill-cost-2026-10-13/`。严格插桩使用 halt_on_error=1;Python C 依赖没有同等全面插桩,不能由这些路径推断整个客户端无未定义行为。
|
||||
|
||||
最终完整桌面构建成功,CTest 61/61 通过(47.53 秒),四项严格 ASan/UBSan 通过(11.84 秒),详细输出未出现 sanitizer 告警。46 模块方法清点无缺失、395 个映射协议常量无差异;git diff --check 通过,参考源码及平级 SDK 未修改。
|
||||
|
||||
## 仍待对齐
|
||||
|
||||
技能目标死亡/距离/尸体/阵营、多目标和自动寻找、移动技能及保留动作,右键模式与渐变朝向、精确事件和动作混合仍需恢复。费用公式各变量的全量数值对照、所有弓/箭袋资源组合和原版进程动态结果也未覆盖。
|
||||
|
||||
公会标记传输与缓存、完整 TCP 调度、root motion、完整变形模型切换、地形/水材质、SpeedTree 精确数值和旧碰撞/GPU 接入迁移继续保留在 [逐模块清单](WINDOWS-MODULE-AUDIT-2026-10-13.md)。本批没有宣称整体等价。
|
||||
@@ -0,0 +1,29 @@
|
||||
# AVA2 Windows 第十四批修复:技能追加飞行目标
|
||||
|
||||
对照本地 `PythonPlayerSkill.cpp::__UseSkill`、`InstanceBaseBattle.cpp::NEW_GetInstanceVectorInFanRange / NEW_GetInstanceVectorInCircleRange / NEW_GetRandomPositionInFanRange`、`ActorInstanceBattle.cpp::IsClickableDistanceDestInstance`、`ActorInstanceFly.cpp`、`PythonNetworkStreamPhaseGame.cpp::SendAddFlyTargetingPacket` 和 `EterBase/Random.cpp`。只修改跨平台客户端。
|
||||
|
||||
## 本批实现
|
||||
|
||||
- 目标数量按 targetCountFormula 和当前技能效率求值并截断;主目标占一个名额。0/1 不追加,无目标不扩展。
|
||||
- FAN_RANGE 优先于 CIRCLE_RANGE。扇形围绕主目标方向,半角为 40°−0.02×min(距离,1000),保持原版有符号角区间,不增加跨 ±180° 的绕回。
|
||||
- 扇形排序距离上限 1000,圆形使用实际平面距离;同距离按原版角色 map 的 VID 顺序。排除主角、主目标、不可攻击和死亡目标。
|
||||
- MSM DEFENDING 碰撞球保留位置、半径和骨骼附件信息。技能范围用 3D 球心距离,严格 `radius + range > distance`;缺失碰撞球不发明默认圆柱。碰撞球半径沿用原版不随 actor scale 缩放,球心按角色矩阵变换。
|
||||
- 追加目标不足时,包括没有 FAN/CIRCLE 标志的技能,使用已有 eter::frandom(原版 Park–Miller)在主目标方向 ±10° 生成 8000 长度的位置,取施法者脚下地形高度;使用图形 Y 的符号发送 CG53,随后加地图基址。真实目标也按图形坐标发送。
|
||||
- 追加飞行目标加入现有 Actor 队列,并在动作绑定及 CG233 使用技能前发包。保留原版绑定失败仍可能已经发出 CG53 的顺序。
|
||||
- 异常公式(非有限、负数或超过 4096)中止使用,避免原版无界 DWORD 循环产生大量分配和报文。该保护不是原版等价行为;正常资源数量不触发此限制。
|
||||
|
||||
## 验证范围
|
||||
|
||||
windows_behavior 使用实际 SkillDesc/SkillTable、MSM 和演员对象,断言 CG53/CG233 的字节、排序和目标数量。覆盖 FAN/CIRCLE 优先级、距离 1000 截断和 VID 同值排序、死亡目标、主目标排除、严格碰撞球边界/高度、缺失球、非零施法者位置、随机种子及 8000 锥形坐标、公式截断、0/1 数量、异常数量和绑定失败时序。
|
||||
|
||||
player_motion 使用真实 GR2 和 MSA LoopData 播放,验证演员目标和位置目标按队列逐次消费、动作完成恢复原主目标、ClearFlyTarget 清理状态。
|
||||
|
||||
最终桌面构建成功,完整 CTest 61/61 通过(33.73 秒);严格 ASan/UBSan 四项通过(10.85 秒,halt_on_error=1),详细执行日志无 sanitizer 诊断。Python C 依赖未同等全面插桩。46 个模块无缺失方法,395 个映射协议常量无差异,git diff --check 通过。SDK、Windows 参考和服务器未修改。日志保存于 `build/verification/windows-skill-flight-2026-10-13/`。
|
||||
|
||||
## 仍待对齐
|
||||
|
||||
现有 GetFlyTargetCenter 使用半高度近似,尚未恢复原版模型包围球精确中心。骨骼附件复用现有 Granny 姿态转换;原版 composite 骨骼矩阵与 bone translation 的组合、缺失骨骼回退到根骨骼、不同部件模型附件以及形状变化后碰撞实例生命周期尚未动态验证。本批测试验证无骨骼球和既有队列,不证明这些骨骼路径完全等价。
|
||||
|
||||
飞行实例在发射时取目标位置,持续追踪移动对象、命中/消失/受击回调及网络对端 CG53/GC 同步完整流程仍有差异。原版随机序列算法已复用,但未证明全客户端随机调用顺序和 Windows 浮点逐位一致。
|
||||
|
||||
移动技能、root motion、骨骼混合、选择节流/UI 生命周期、完整 TCP 时序,以及公会标记、地形/水材质、SpeedTree 数值与碰撞/GPU 接入等仍待处理。没有 Windows 动态对照、Android 或真实服务器验证。
|
||||
@@ -0,0 +1,32 @@
|
||||
# AVA2 Windows 第十批修复:技能许可与请求参数
|
||||
|
||||
> 后续:[第十一批资源条件](WINDOWS-SKILL-COST-2026-10-13.md) 补齐等级/武器/瓶子/HP/SP 等检查,并修正技能回调的接收窗口;下方仍保留第十批结束时的范围记录。
|
||||
|
||||
> 补充:[第十二批](WINDOWS-SKILL-TARGET-2026-10-13.md) 确认并恢复玩家入口的第二道 IsUsingSkill 锁;底层 LoopCancelEnable 许可不能单独证明点击可以替换技能。
|
||||
|
||||
继续修复角色/技能模块。依据仅为 AVA2 Windows 的 PythonPlayerSkill、InstanceBase 和 ActorInstanceBattle,不修改参考源码、SDK 或服务器。
|
||||
|
||||
## 已接通的行为
|
||||
|
||||
- 普通技能发送前拒绝缺失主角、观察模式、变形、婚服、镐头以及不能行动的演员;无动作技能和钓鱼/连击特殊技能也经过许可检查,避免只有动画分支才检查死亡/眩晕。
|
||||
- ActorInstance::CanUseSkill 对全部六个钓鱼动作保留原版例外;当前技能只有 MSA LoopData 的 LoopCancelEnable 非零才能被另一个技能替换。CanAct 仍先检查死亡、眩晕、麻痹、昏厥和睡眠。
|
||||
- 当前 AVA2 启用 ENABLE_CONQUEROR_LEVEL,骑乘使用槽位 107 的骑术检查:grade>=1 或 level>=20;坐骑还必须为军用等级。新增 mount_rules.h,严格恢复 GetMountLevelByVnum(vnum,false) 的 100 个有效 case,未知编号为 0。原版注释可能与分支结果冲突(例如 20228),采用实际代码结果,不根据注释重新分类。
|
||||
- 按原版顺序拒绝被动技能,检查 HORSE_SKILL 与骑乘状态,分别回调 NOT_HORSE_SKILL/HAVE_TO_RIDE;ATTACK_SKILL 在地图 BANPK 区域回调 IN_SAFE。拒绝不会发送技能/动作报文或触发新的冷却回调。
|
||||
- 普通已激活的开关技能关闭请求,目标字段改为当前技能槽位,匹配 __UseSkill;站立型开关技能采用 ClickSkillSlot 的单独分支,目标字段为 0,不套普通许可检查,但正在使用技能时仍拒绝。该差异来自原版代码,而非推断。
|
||||
- 外观判断使用请求的 PART_MAIN 形状,避免变形图形 shape=0 覆盖原版 InstanceBase 保留的形状状态。SetWeapon 的动物装/婚服限制及 ChangeArmor 的重复形状比较不再依赖该图形值。
|
||||
|
||||
## 验证
|
||||
|
||||
windows_behavior 使用真正 SkillDesc 空动作列和字节固定的 AVA2 CG233 请求,覆盖无主角、被动、变形、观察模式、婚服、镐头、眩晕、未骑乘、骑术 19/20、低级/军用坐骑、普通/骑乘技能、安全区攻击和两种开关技能关闭路径。检查拒绝时空发送队列及 UI 回调;接受时检查请求所有九字节。没有拿其他版本的报文头替代 AVA2。
|
||||
|
||||
player_motion 使用只读原版模型/GR2 与临时 MSA,验证 LoopCancelEnable=0/1、眩晕优先于可取消技能、复活恢复。坐骑等级回归使用临界及原版注释冲突 case;全部 100 case 另经静态映射比较,零差异。骑乘许可回归使用演员标志/网络状态,不证明真实坐骑技能画面。
|
||||
|
||||
严格 ASan/UBSan 四项测试(windows_behavior/player_motion/inventory_touch/attack_combo)通过,10.23 秒,启用 halt_on_error=1;详细日志保存在 `build/verification/windows-skill-permission-2026-10-13/`。Python C 依赖未同等全面插桩,没有 Windows/Android/真实服务器动态输出对照。
|
||||
|
||||
完整桌面构建成功,CTest 61/61 通过(49.71 秒)。严格插桩详细输出未出现 runtime error 或 AddressSanitizer ERROR。方法审计 46 个模块无缺失、395 个映射协议常量无差异;git diff --check 通过,平级 SDK 与参考源码未修改。
|
||||
|
||||
## 仍待恢复
|
||||
|
||||
本批不宣称完整技能系统等价。技能 SP/HP/武器/等级等其余可用性条件、目标死亡/距离/阵营/多目标和保留动作、移动技能、渐变朝向/骨骼混合/root motion、右键技能模式、完整 TCP 时间排序仍需逐项对照。私店状态的原版有效写入流程仍未确认,不擅自新增语义。
|
||||
|
||||
公会标记传输/缓存、地形 LOD/阴影/雾/splat/水材质、SpeedTree 精确数值及 collision/GPU 接入迁移、完整变形模型切换/还原和攻速异常检测也继续保留在 [逐模块清单](WINDOWS-MODULE-AUDIT-2026-10-13.md)。
|
||||
@@ -0,0 +1,35 @@
|
||||
# AVA2 Windows 第十三批修复:技能距离与保留动作
|
||||
|
||||
依据本地 AVA2 `PythonPlayerSkill.cpp::__GetSkillTargetRange / __ProcessEnemySkillTargetRange`、`PythonPlayerInput.cpp::__ReserveUseSkill`、`PythonPlayerInputMouse.cpp::MODE_USE_SKILL` 和 `ActorInstanceBattle.cpp::IS_HUGE_RACE`。只修改跨平台客户端。
|
||||
|
||||
## 实现
|
||||
|
||||
- 实际技能范围为 targetRange + POINT_BOW_DISTANCE(34)×100,采用 Win32 uint32 运算。范围 0 沿用原版不做距离和目标阻挡检查的分支。
|
||||
- 距离大于或等于范围时保留目标 VID、技能槽及范围,首次不直接向远处目标施放;范围大于 100 时保留范围减 10。到达判定严格小于保留范围,避免正好在边缘反复保留。
|
||||
- 当前帧接入 ProcessPlayerAttack 前的保留动作处理,目标移动时更新行走目的地;进入范围后恢复目标选择并重新走技能许可、资源和目标检查。通过后只施放一次并清理保留状态。
|
||||
- 敌方首次施放和保留动作检查对原版唯一 huge race 2493 减 200 距离。友方首次距离判断不减,保留动作判断按原版统一处理,不擅自改变两个位置的差异。
|
||||
- 范围内敌方位置带 ATTR_BLOCK 时回调 CANNOT_APPROACH。按原版顺序,范围外先保留,再在靠近后的技能重检中检查阻挡。
|
||||
- 蓄力技能首次范围外请求先发送 CG233(target=0) 并启动冷却;同槽保留不重复发送开场请求。服务器 DASH 状态到来后沿用前批蓄力冷却例外,进入范围时发送实际目标。
|
||||
- 不能行动、攻击/技能/情绪锁期间停止本控制器拥有的移动并保留任务,许可恢复后继续。目标删除、主角变化和实例替换取消任务;键盘/摇杆、攻击、手动地面目的地及相应鼠标状态清理任务。再次拾取相同保留目标不直接取消。
|
||||
- 使用弱实例引用防止删除后同 VID 的新演员继承旧技能,这比原版纯 VID 保留更保守。取消仅清理本控制器设置的移动目的地。自动狩猎暂停发出新命令,避免覆盖靠近;这属于现有移动端接入。
|
||||
- 应用入口不再将正式技能的 quickSlot=-1 通知交给旧演示技能回调,避免其固定冷却覆盖源公式和重复播放预览效果。正槽位演示调用保留;本批仅编译/静态核查该应用入口,没有实机画面对照。
|
||||
|
||||
## 回归
|
||||
|
||||
扩展 windows_behavior 的实际 SkillDesc/SkillTable、网络演员和 CG61/CG233 字节断言:
|
||||
|
||||
- 远处不立即发包,现有 Actor.Update 推进坐标,目的地跟随移动目标。
|
||||
- 200 范围保留为 190,190 不施放、189 施放;途中切换选中 VID 后恢复原目标,后续帧不重复施放。
|
||||
- 眩晕停止移动、复活继续;键盘、摇杆和攻击取消;目标删除、同 VID 实例替换、主角切换释放原移动。
|
||||
- 友方技能靠近、34 点距离加成、目标阻挡及范围 0 例外、2493 距离修正。
|
||||
- 蓄力开场 VID 0、冷却期间不重复,DASH 后保留动作完成时使用真实 VID。
|
||||
|
||||
使用临时地图和无动作技能验证状态/报文,不能据此证明原版 root motion 或视觉路径相同。前序真实 GR2/MSA 回归仍保留。日志在 `build/verification/windows-skill-range-2026-10-13/`。
|
||||
|
||||
最终完整桌面构建成功,CTest 61/61 通过(46.68 秒);四项严格 ASan/UBSan 使用 halt_on_error=1 通过(8.48 秒),详细日志没有 sanitizer 告警。46 模块方法清点无缺失、395 个映射协议常量无差异;git diff --check 通过。Python C 依赖未同等全面插桩,SDK/参考/服务器未修改。
|
||||
|
||||
## 剩余差异
|
||||
|
||||
自动靠近仍使用当前线性 Actor 移动与地形/物体碰撞接口,原版 root motion、路径避障、渐变转向、完整移动技能和移动/停止报文精确时序未对齐。保留动作复用当前技能入口;右键技能模式、站立开关等入口的所有交互还需继续审查。
|
||||
|
||||
选择的 1000/2000ms 节流、OnTargeted UI 生命周期、多目标 fan/circle/随机补足飞行目标和统一 TCP 调度仍待完成。公会标记、地形/水材质、SpeedTree 数值与旧碰撞/GPU 接入等也未完成。没有 Windows 动态输出、Android 或真实服务器验证,未修改 SDK/参考/服务器。
|
||||
@@ -0,0 +1,35 @@
|
||||
# AVA2 Windows 第十二批修复:技能实际目标
|
||||
|
||||
> 后续:[第十三批](WINDOWS-SKILL-RANGE-2026-10-13.md) 已接通距离保留/靠近重检、距离加成、2493 修正和目标阻挡。下方保留第十二批结束时的范围记录。
|
||||
|
||||
依据本地 AVA2 `PythonPlayerSkill.cpp::__UseSkill`、`PythonPlayerInput.cpp` 的存活/死亡目标查询及拾取回退、`InstanceBaseBattle.cpp::NEW_GetFrontInstance`。不修改原版参考、SDK 或服务器。
|
||||
|
||||
## 本批实现
|
||||
|
||||
- 将当前选中 VID 与本次技能的局部目标分开。没有 NEED_TARGET/CAN_CHANGE_DIRECTION/SEARCH_TARGET 的技能发送 VID 0,不能仅因 UI 选中了敌人就携带其 VID。
|
||||
- 根据 NEED_CORPSE 查询死亡目标,其余查询存活目标;不存在、删除或状态不符的 VID 不再直接用于技能请求。失败回调为 NEED_TARGET 或 ONLY_FOR_CORPSE,自用许可按原版分支回退主角。
|
||||
- 原目标不可用时采用现有本地拾取 VID,再验证状态。目标变更的 CG61 在技能 CG233 前发送;重复拾取同一非主角 VID 不重复发送,重复拾取自己清除选择。拾取帧的精确图形命中仍沿用现有实现。
|
||||
- ONLY_FOR_ALLIANCE 拒绝自己(未允许自用时)及可攻击/非玩家目标,使用 CANNOT_USE_SELF、ONLY_FOR_ALLIANCE;允许自用时相应回退主角。非友方分支按原版检查目标 BANPK 和攻击许可,回调 CANNOT_ATTACK_ENEMY_IN_SAFE_AREA/CANNOT_ATTACK。
|
||||
- SEARCH_TARGET 无可用目标时,恢复前方 2000 范围选择:原版有符号角度、随距离变化的半扇角,以及 min(distance,1000) 排序。等键按 VID 遍历次序,不能改为纯最近距离排序。保留原版分支在搜索后再处理自用许可的顺序。
|
||||
- 实际选定目标同时绑定飞行目标,包括无动作技能;演员朝向目标的水平位置。渐变旋转和精确骨骼/飞行中心视觉仍未对齐。
|
||||
- 有动作技能绑定失败立即返回,不发送动作/技能报文或启动冷却。
|
||||
|
||||
## 对第十批记录的补充
|
||||
|
||||
`ActorInstance::CanUseSkill` 确实根据 LoopCancelEnable 给出底层许可,但 `PythonPlayer::__UseSkill` 在资源检查后还有独立的 IsUsingSkill 拒绝。因此不能由底层可取消推断玩家点击可以替换当前技能。本批接通第二道检查,真实 GR2/MSA 回归验证底层许可为 true 时点击仍不发送。站立型开关技能等早返回分支仍保留其原版规则。
|
||||
|
||||
## 验证范围
|
||||
|
||||
windows_behavior 使用 SkillDesc/SkillTable 和 literal CG61/CG233,验证失效 VID、存活/尸体切换、自用和友方、自己拒绝、安全区、选中但无目标技能、拾取回退及重复 VID、飞行目标、朝向、前方/后方自动查找和动作绑定失败。测试使用网络演员状态和临时地图,不证明实际技能图像相同。
|
||||
|
||||
player_motion 使用只读原版模型/GR2 和注册前写好的多行 MSA 验证第二道技能锁。初次追加 fixture 不符合 loader/缓存顺序,已纠正后重建;失败日志保留,不用于最终验证结论。
|
||||
|
||||
日志在 `build/verification/windows-skill-target-2026-10-13/`。严格 ASan/UBSan 使用 halt_on_error=1;Python C 依赖未同等全面插桩。没有 Windows 动态进程、Android 或真实服务器对照。
|
||||
|
||||
最终桌面构建成功,完整 CTest 61/61 通过(48.43 秒),四项严格插桩通过(11.96 秒),详细日志没有 sanitizer 告警。随后只加强测试,增加删除对象、超过 1000 的排序键相等与 2000/2001 边界:普通定向回归通过(1.29 秒),严格插桩通过(2.26 秒)。方法审计 46 模块无缺失、395 个映射协议常量无差异;git diff --check 通过,平级 SDK 与参考源码未修改。
|
||||
|
||||
## 仍待恢复
|
||||
|
||||
远距离的技能保留动作/自动靠近、弓距离加成和大体型距离修正、目标阻挡检查、选择的 1000/2000ms 节流和 OnTargeted UI 生命周期尚未恢复。本批拾取变更沿用现有选择桥,不声称全套 SetTarget 等价。自动搜索已恢复源算法核心,但完整攻击许可、坏坐标及图形拾取仍继承现有桥接的边界。
|
||||
|
||||
多目标 fan/circle、随机补足飞行目标、移动技能、方向技能的拾取地面回退、右键保留技能、动画混合/root motion 继续待办。公会标记、地形水面、SpeedTree 精确数值和碰撞/GPU 适配等模块也未完成,见 [总对照记录](WINDOWS-MODULE-AUDIT-2026-10-13.md)。
|
||||
@@ -0,0 +1,34 @@
|
||||
# AVA2 Windows 第四批修复:SpeedTree 默认风力模式与帧步长
|
||||
|
||||
本批修复客户端接入,未修改平级共享 SDK、Windows 参考源码或服务器。延续 [逐模块审计](WINDOWS-MODULE-AUDIT-2026-10-13.md),不宣称完整树形或原版 DLL 输出等价。
|
||||
|
||||
## 确认差异与处理
|
||||
|
||||
原版 `SpeedTreeLib/SpeedTreeConfig.h` 定义 WRAPPER_USE_NO_WIND 和 WRAPPER_USE_CPU_LEAF_PLACEMENT;`SpeedTreeWrapper.cpp::LoadTree` 将 Branch/Leaf/FrondWindMethod 设为 WIND_NONE,但仍调用 SetLeafRockingState(true)。枝干/frond 顶点更新和风矩阵上传还受 CPU/GPU_WIND 编译开关限制,而 RenderLeaves 仍做 CPU leaf placement。因此不能把“无风”解释为关闭叶片朝向相机和卡片摆动。
|
||||
|
||||
移植此前对每个网格统一应用 SDK 风矩阵,造成原版默认配置下不应有的枝干/frond 变形和叶片中心位移。现在:
|
||||
|
||||
- `SpeedTreeModel::BuildDrawCommands` 增加末尾 `cpuWind=false` 参数,默认使用单位风矩阵;不能用空矩阵,因为 SDK 对空矩阵会自动合成风力。
|
||||
- 单位矩阵只取消网格的加权风力变换,保留 SDK 的叶片支点摆动、相机朝向、法线和世界 yaw/scale 变换;不把风强设为 0。
|
||||
- `SpeedTreeForest` 默认 CPU deformation 关闭,可通过 SetCpuWindEnabled(true) 显式启用已有 CPU 风力功能。风强参数本身不隐式启用 CPU 变形,符合原版编译模式与风强分别控制的关系。
|
||||
- 自定义 frameWind 的矩阵也不会绕过默认模式;叶片 phase/strength 保留。显式 CPU 模式才使用这些矩阵。
|
||||
- 背景 UpdateSystem 从固定 0.033 改为 GetGameFrameDelta,与游戏接受的帧步长一致;仍沿用现有 SetGameFrameDelta 的 0.001–0.25 限制,本批未改变整个游戏计时策略。
|
||||
- Forest 拒绝负数、非有限或造成累计时间溢出的步长,保持上一帧状态。
|
||||
|
||||
共享 SDK 的风力 API、GPU 参考着色器、随机/网格生成能力保持原样。原版客户端强制全几何 LOD、alpha=84 及已修复的静态光照也保持原样。
|
||||
|
||||
## 验证覆盖
|
||||
|
||||
`tests/speedtree_forest_test.cpp`:默认枝干和 frond 位置/法线随时间不变,叶片仍摆动;显式 CPU 模式能变形,关闭后恢复相同结果;负数/NaN 步长不推进状态。Authored leaf 夹具用世界 yaw=90、scale=2,检查摆动顶点到原支点的距离不变;即使传入大平移风矩阵,默认路径仍等价于单位矩阵,显式 CPU 路径才发生位移。相机朝向、索引、UV、远景全几何与原版静态光照仍有测试。
|
||||
|
||||
`tests/background_test.cpp`:将背景森林与独立森林在不同已接受帧步长下的实际绘制位置逐项比较,防止背景再次使用固定 0.033。测试曾发现期望值忽略现有应用 dt clamp,已按游戏实际接受的 dt 修正测试;没有为了测试修改应用计时策略。
|
||||
|
||||
## 仍未完成
|
||||
|
||||
默认网格风变形开关已对齐,但叶片摆幅、环境 wind strength 的单位与传播到既有/新树的时序,以及原版每棵树的 leaf rocking 状态仍需更精确对照。当前保留原先移植的 windStrength×0.05 和 SDK 的叶片角度/阶段算法,本批没有冒称这些已数值等价。原版 Forest 与 Wrapper 的初始强度不同,MapOutdoor 又在环境切换时设置强度,应对完整创建顺序恢复后再修改归一化。
|
||||
|
||||
树形生成/随机调用顺序/原版 DLL 数值、旧 stash 中碰撞与 GPU 接入的适配仍是独立待办。公会标记、高级动作/技能、地形阴影/雾/splat/水材质动画也未被本批解决。没有 Windows 动态输出或 Android 画面对照。
|
||||
|
||||
验证日志位于 `build/verification/windows-speedtree-wind-mode-2026-10-13/`。
|
||||
|
||||
验证结果:完整桌面构建及 60/60 CTests 通过(49.73 秒);ASan/UBSan 森林、背景与 windows_behavior 3/3 通过(2.38 秒)。46 模块的方法名对照零缺失、395 个映射协议常量零差异;这不证明完整行为等价。`git diff --check` 通过,参考文件未新增变更,共享 SDK 保持干净。
|
||||
@@ -0,0 +1,24 @@
|
||||
# AVA2 Windows 第十九批修复:尾迹逐段视锥裁剪
|
||||
|
||||
对照本地 `GameLib/FlyTrace.cpp::Render`、`SphereLib/frustum.cpp::BuildViewFrustum / BuildViewFrustum2 / ViewVolumeTest`、`EterLib/GrpScreen.cpp::BuildViewFrustum` 和 `GrpBase.cpp::SetPerspective`。只修改跨平台客户端。
|
||||
|
||||
## 本批修改位置
|
||||
|
||||
- `src/eter_effect/FlyTrace.cpp`:新增 TraceFrustum。按当前 view×projection 提取并归一化六个 D3D 0..w 深度平面;每段中点为球心,最长坐标轴跨度的一半为半径。尾迹宽度不扩大原版这个球。平面距离 `<= -radius` 判定在外,保留原版外侧相切也剔除的规则,裁剪发生在顶点生成及深度排序前。
|
||||
- 同文件恢复标准当前透视矩阵的粗裁剪球:反推 near/far/FOV/aspect,按原版 camera eye/view 和 P−Q 计算球心、半径。核对发现原版 SetPerspective 将 FOV 以度存储,但 BuildViewFrustum2 将该值直接传给 tan;本批保留该历史单位混用,不擅自纠正原版可见性。
|
||||
- 同文件保留退化平面的安全处理;正交、偏轴或非标准投影仅用六平面,不能从这些矩阵唯一恢复原版外部相机元数据。保留 SphereLib 来源和版权说明。
|
||||
- `tests/flying_target_test.cpp`:新增六面内外、外侧相切/部分相交、宽尾迹不扩大裁剪球、同一尾迹逐段过滤、移动相机矩阵乘法、标准透视 near/far/侧面,以及历史 FOV 单位导致“平面内但粗球外”的用例。旧几何/多附件测试改用明确的宽投影,避免新增裁剪掩盖这些测试原本核对的几何公式。
|
||||
- `tests/ava2_render_3d_test.cpp`:尾迹基础回归使用明确覆盖其世界坐标的投影矩阵;真实场景仍使用真实相机矩阵,不关闭裁剪。
|
||||
- `docs/PORT-PLAN.md`、`docs/WINDOWS-MODULE-AUDIT-2026-10-13.md`:更新进展及剩余差异,本文件记录实现和验证边界。
|
||||
|
||||
## 验证
|
||||
|
||||
使用真实渲染资源的 render_3d 和飞行附件/尾迹的 flying_target 专项通过。完整日志在 `build/verification/windows-tail-frustum-2026-10-13/`。
|
||||
|
||||
最终完整构建成功,62/62 CTest(50.78 秒);五项严格 ASan/UBSan(12.06 秒)通过,无执行路径诊断。Python C 代码未全部同等插桩。46 个模块的方法审计无缺失/占位,395 个映射协议常量无不匹配/未匹配;git diff --check 通过。SDK/参考/服务器未修改,本轮尚未提交或推送。
|
||||
|
||||
## 尚未完全对齐
|
||||
|
||||
当前直接使用提交绘制命令时的相机矩阵,没有复制原版全局 CScreen frustum 缓存更新时序。透视粗球的相机元数据由矩阵反推,原始 FOV 标量与浮点逐位差异仍未动态验证;非标准投影的粗球分支尚未恢复。六平面和历史单位规则的合成回归不能代替 Windows 实机输出。
|
||||
|
||||
深度状态继承(原版 ZWRITE/LESS)、首帧绝对采样时间、相同深度排序、精确 CRT 序列及 GPU 截图仍待对照。其余包括完整近战受击、模型精确包围中心、骨骼/部件碰撞、原版 culling 遍历、.mdatr 完整图元、SpeedTree 独立碰撞、移动技能/root motion、选择节流/TCP 时序、公会标记和地形/水/SpeedTree 其余差异。本批没有 Windows、Android 或真实服务器动态验证。
|
||||
@@ -0,0 +1,25 @@
|
||||
# AVA2 Windows 第二十批:视锥缓存、非标准投影与尾迹深度状态
|
||||
|
||||
对照 `UserInterface/PythonApplication.cpp::UpdateGame`、`EterLib/GrpScreen.cpp::BuildViewFrustum`、`GrpBase.cpp::SetPerspective / SetOrtho2D / SetOrtho3D`、`SphereLib/frustum.cpp::BuildViewFrustum2`、`GameLib/FlyTrace.cpp::Render` 和 `EffectLib/EffectInstance.cpp::Render`。只修改跨平台客户端。
|
||||
|
||||
## 修改位置
|
||||
|
||||
- `src/eter_render/ViewFrustum.h`:从尾迹内部提取视锥实现,使用独立保存的 FOV/aspect/near/far,而不是从矩阵反推。任何投影均可使用原版粗球公式,并保留 FOV 度值直接传 tan 的历史行为;无效浮点和平面仍安全处理。
|
||||
- `src/eter_render/Gr2ModelRenderer.h/.cpp`:保存透视参数;接通正交与自定义投影;它们不覆盖最近一次透视元数据。显式 BuildViewFrustum 生成更新阶段快照,修改相机/投影不自动刷新快照。缓存属于场景渲染器,离屏 RenderTarget 不污染游戏快照。提供继承深度状态。
|
||||
- `src/scripting/python_app.cpp`:UpdateGame 开头按系统 FOV、窗口 aspect、near=100 和背景 far clip 设置透视,再建立缓存,早于背景/角色/飞行更新。
|
||||
- `src/app/app_loop.cpp`:原生帧更新入口建立缓存,游戏阶段使用同样 near=100 的规则;尾迹绘制传入缓存与继承深度状态。Python UpdateGame 仍在实际调用边界显式更新。尾迹几何使用渲染阶段相机,裁剪读取更新阶段缓存,两者有意分离。
|
||||
- `src/scripting/python_grp.cpp`:SetOrtho2d / SetOrtho3d 从占位变为实际投影设置,继续保留透视元数据及已有快照。
|
||||
- `src/eter_effect/FlyTrace.h/.cpp`、`FlyingManager.h/.cpp`:传递缓存和 DepthState。生产路径不重建视锥;无更新阶段的独立测试调用保留推导回退。尾迹继承 ZENABLE/ZWRITE,临时使用 LESS,命令明确捕获状态,不影响后续绘制。原版效果会恢复 ZWRITE,所以不能从前一条粒子命令的 false 推导尾迹状态;普通场景默认为 true。
|
||||
- `src/eter_render/RenderCommands3D.h`:增加明确的 LESS 比较状态,默认仍为 LESSEQUAL。
|
||||
- `src/eter_render/HardwareScene.h/.cpp`:管线键与实例合批条件区分 LESS/LESSEQUAL,SDL_GPU 管线按状态选择比较函数。
|
||||
- `src/eter_render/Gr2ModelRenderer.cpp`:传递比较状态到硬件批次;软件路径使用同样比较,深度写入由 ZENABLE/ZWRITE 决定,不能因 alpha/additive 混合而擅自关闭。
|
||||
- `tests/flying_target_test.cpp`:验证更新快照跨相机/投影修改保持不变、下次更新刷新、正交/偏轴粗球保留透视参数、正交二维映射、尾迹深度继承、软件相等深度与加法深度写入。
|
||||
- `tests/hardware_scene_test.cpp`:真实 GPU 像素回读验证 LESS 与 LESSEQUAL、加法混合写入开关及禁用深度测试。原有几何/字体/纹理/实例等回归保留。
|
||||
|
||||
## 验证与边界
|
||||
|
||||
日志位于 `build/verification/windows-tail-state-2026-10-13/`。本机 GPU 回读用例已执行,没有跳过。独立无上下文调用无法恢复原版外部相机元数据,仍使用回退;游戏路径已传入真实更新快照与保存参数。
|
||||
|
||||
最终验证:完整开发构建通过,专项 3/3(6.59 秒),完整 CTest 62/62(62.48 秒),严格 ASan/UBSan 6/6(17.43 秒),包含真实 GPU 测试。执行日志无 sanitizer 诊断;Python C 代码未全部同等插桩。46 模块方法无缺失/占位,395 映射协议常量无不匹配/未匹配,git diff --check 通过。
|
||||
|
||||
尚无 Windows 实机输出,因此原版与当前后端的浮点逐位、驱动舍入、相同深度排序和全局相机切换仍未动态证明。SDL 几何备用后端没有原生深度缓冲,严格 GPU 深度行为仅适用于 SDL_GPU 管线及软件深度光栅器。首帧绝对采样/精确 CRT 序列、完整碰撞及其他模块差异仍在后续计划。本批不修改 SDK、Windows 参考或服务器,尚未提交或推送。
|
||||
@@ -0,0 +1,35 @@
|
||||
# AVA2 Windows 第二批行为修复:目标特效、StoneDetect 与树木光照
|
||||
|
||||
本批延续 [逐模块审计](WINDOWS-MODULE-AUDIT-2026-10-13.md),修改移植客户端,保留原版源码和共享 SDK。只覆盖以下明确差异;公会标记传输、完整动作队列/高级技能、地形阴影和雾、SpeedTree 默认风力等尚未完成。
|
||||
|
||||
## 目标报文与效果生命周期
|
||||
|
||||
原版依据:`UserInterface/PythonNetworkStreamPhaseGame.cpp` 的 RecvTargetCreatePacketNew/RecvTargetUpdatePacket/RecvTargetDeletePacket,`PythonBackground.cpp` 的 target maps/Reserve Target Effect,以及 `GameLib/MapOutdoor.cpp` 的 SpecialEffect_Create/Delete/Destroy。
|
||||
|
||||
- 新目标创建的非 LOCATION 类型,同时注册背景角色目标;坐标更新的类型 5 调用商店效果,其余调用普通目标效果;删除同时清理背景目标,不再仅更新小地图。
|
||||
- 保持原版 `insert` 的首次角色绑定语义;已有角色目标不会被同 ID 的坐标更新替换。每帧使用真实图形演员位置跟随,演员暂时不存在时跳过,保留原绑定和最后效果位置。
|
||||
- 普通资源为 `effect/etc/direction/direction_land.mse`;商店资源为 `effect/direction/direction_land2.mse`,目录按原版保留。
|
||||
- 坐标包是全局地图坐标,先减 MapOutdoor 的 BasePosition,再查询地形高度。特殊效果接口仍接收原版渲染坐标 `(localX,-localMapY,height)`,内部转换为移植 Y-up `(localX,height,localMapY)`。直接 LoadMap 和 Warp 都有回归,避免仅用 PythonBackground 的 warp 基准造成直接加载时坐标错误。
|
||||
- 高度为 0 时加入延迟创建集合;非零后创建并移除预约。原版普通/商店共用预约集合,预约兑现使用普通资源;本批忠实保留该行为,包括真实零高度暂不创建。
|
||||
- 活跃实例只更新位置,不每帧重新创建,亦不在同 ID 更新时替换已有资源;实例失效后可重新创建。删除清理普通/商店角色绑定、预约和实例关联;地图加载/销毁清理自身实例,保留其他系统创建的效果。
|
||||
- 原版 SpecialEffect_Delete 留下旧 ID 关联,失效后 Create 使用 insert 也可能留下旧关联。本批删除时移除旧关联、重新创建时更新实例 ID,避免复用目标 ID 后不能跟随及泄漏;这是明确的生命周期修复。
|
||||
|
||||
## StoneDetect
|
||||
|
||||
原版依据:`UserInterface/PythonNetworkStreamCommand.cpp`。
|
||||
|
||||
恢复 `StoneDetect VID distance angle` 的实际效果:距离 0 为 firecracker/find_out,1/2/3 为 compass/appear_small/middle/large;角度为 `fmod(540-angle,360)`,围绕移植 Y-up 的垂直轴旋转;位置来自当前图形演员。保持原版 BYTE 距离转换;参数数量错误、演员不存在和未知距离不创建效果,额外拒绝非有限角度以防传播坏矩阵。
|
||||
|
||||
## SpeedTree 静态光照
|
||||
|
||||
原版 `SpeedTreeConfig.h` 选择 WRAPPER_USE_STATIC_LIGHTING,`SpeedTreeForestDirectX8.cpp` 对树木关闭 D3DRS_LIGHTING、开启顶点颜色。移植此前设置 `draw.lighting=true`,会再叠加动态环境光。本批对枝干、叶片和 frond 关闭动态光照,保留 SDK 顶点 diffuse 色和原有 alpha/剔除规则。
|
||||
|
||||
这项不证明 SDK 静态颜色值与原版完全一致,也没有修改风力:WRAPPER_USE_NO_WIND 与仍启用的 LeafRockingState 需要分开对照枝干/中心变形和叶片卡片摆动。不能简单将风强全部清零。
|
||||
|
||||
## 回归与限制
|
||||
|
||||
`tests/windows_behavior_test.cpp` 新增真实接收分派覆盖:分片创建、非零地图基点、角色跟随、重复绑定、坐标更新不能替换角色目标、商店资源、共享预约行为、目标删除、ID 复用、失效实例重建、换图/销毁清理和不删除无关效果;通过生成的粒子绘制顶点验证实际中心位置,并检查 StoneDetect 四种资源与旋转。`tests/speedtree_forest_test.cpp` 增加枝干/叶片/frond 静态光照状态回归。
|
||||
|
||||
使用临时合成 MSE/地形及本地报文字节。没有真实服务器、Windows 原版运行输出或 Android 图像对照;图像、特效完整粒子/网格/光源和地形物件高度查询仍受已有引擎实现限制。验证日志位于 `build/verification/windows-target-effects-2026-10-13/`。
|
||||
|
||||
验证结果:桌面完整构建通过,完整 CTest 60/60 通过(52.67 秒);补强四种 StoneDetect 资源选择、BYTE 距离回绕及非有限角度测试后,相关 2/2 测试通过(1.75 秒),ASan/UBSan 2/2 通过(3.17 秒)。`git diff --check` 通过,Windows 参考源码没有本轮差异,共享 SDK 工作区保持干净。
|
||||
@@ -0,0 +1,40 @@
|
||||
# AVA2 Windows 第三批修复:地图配置、地形剔除与水面
|
||||
|
||||
延续 [逐模块审计](WINDOWS-MODULE-AUDIT-2026-10-13.md)。本批修改地形接入,不修改 Windows 参考文件、平级 SDK 或服务器。不是完整地形视觉等价的结论。
|
||||
|
||||
## 原版依据与修复
|
||||
|
||||
| 对照位置 | 确认差异 | 实现 |
|
||||
| --- | --- | --- |
|
||||
| GameLib/MapOutdoorLoad.cpp::LoadSetting、AreaTerrain.cpp | HeightScale 未读取,所有块固定乘 0.5 | 保存地图 HeightScale,传给首次加载和每次 3×3 分块加载;高度/法线/包围盒均由同一缩放后的数据生成 |
|
||||
| GameLib/MapOutdoorRender.cpp::RenderTerrain | 忽略 TerrainVisible | 地形绘制同时要求地图 TerrainVisible 与运行时 PART_TERRAIN;地图隐藏地形不影响水、物件或地形碰撞/高度查询 |
|
||||
| MapOutdoor::Clear/LoadSetting、纹理集合 | 新地图遗漏字段时沿用上张图的地图大小/基点/纹理;新高度与隐藏配置也需独立初始化 | 每次加载重置地图信息、高度比例、地图可见性和纹理集合及 UV/绘制缓存;默认可见性恢复 true;分块刷新不清空本图纹理 |
|
||||
| MapOutdoor::RenderTerrain、TerrainQuadtree | 相机剔除得到零 patch 时又通过备用路径绘制整张地图 | 有有效 view/projection 时尊重零绘制结果;只有未提供相机的开发调用使用整图备用绘制 |
|
||||
| AreaTerrain.cpp::CalculatePatch | 水面高度固定乘 0.5 后再减 200;坐标沿用带边框高度图起点(减一个 cell) | 水面使用地图 HeightScale,取消固定偏移;水格起点是 block×25600,首格不使用 height.raw 的边框偏移 |
|
||||
| PRTerrainLib/Terrain.cpp、AreaTerrain.cpp::CalculatePatch | 跳过奇数水格,扩大偶数水格覆盖;高度 -1 的层也被绘制 | 每个有效水格绘制自身两个三角形,保持干燥格/无效层边界;-1 层不计数也不绘制 |
|
||||
| 地图加载备用分支 | 单独 LoadRaw 路径遗留上一张图的原点/属性状态,且与分块路径不同 | 合法六位块名的备用入口复用同一分块加载器,保证比例、原点、属性清理、后续 streaming 使用一致流程 |
|
||||
|
||||
CellScale 保持原版固定 200;原版虽要求 setting.txt 中有 cellscale,但实际读取那行被注释。没有把该字段当作可自由改变的像素尺度。
|
||||
|
||||
## 保留边界与未完成项
|
||||
|
||||
- 原版完整地图要求 scripttype/viewradius/cellscale/heightscale/mapsize/textureset。本客户端仍容许既有最小测试/开发地图省略字段;省略 HeightScale 时为 0.5。这是现有兼容路径,不宣称原版对缺字段输入亦接受。
|
||||
- 显式 HeightScale 拒绝非数字尾缀和 NaN/Inf,避免坏坐标传播;原版 atof 对部分损坏文本更宽松。正常数值按 float 保存,未人为限制为正值。
|
||||
- ViewRadius 用于原版 patch 分配和转换区域,不能简单替代 FarClip。其精确区域、三级 LOD、阴影/雾带、按 tile splat、按高度生成 alpha、环境音仍待恢复。
|
||||
- 水面本批只修正格覆盖、缩放、起点和无效层。原版按水深生成的顶点 alpha、纹理动画、随机高度变化/混合、材质与颜色仍需对照。没有把更完整的网格当成视觉等价证明。
|
||||
- 备用地图加载是开发兼容路径;正常服务器传入的地图位置应位于地图内。它不代替原版严格地图验证。
|
||||
|
||||
## 回归覆盖
|
||||
|
||||
扩展 `tests/background_test.cpp`,使用 4×1 合成地图:
|
||||
|
||||
- HeightScale=2 时 raw 200→400;从第 0 块移到第 3 块后 raw 500→1000,活动 Terrain 指针保持一致。
|
||||
- TerrainVisible=0 时不输出地形,但仍能查询高度和绘制水面;运行时关闭 PART_TERRAIN 也生效;换图省略该项时恢复默认显示。
|
||||
- 换图清空基点/旧纹理和旧 UV 集合,高度比例恢复 0.5。
|
||||
- 相机距离剔除掉所有 patch 后不会再输出整图备用绘制。
|
||||
- 水面 odd row/column 的单格恰为两个三角形;相邻 -1 水层不计数/绘制;raw 水高 1000→2000,没有减 200;第 2 块首个 `(1,1)` 水格位于 `(51400,2000,200)`。
|
||||
- 备用块加载同样使用配置比例 1.25;非有限 HeightScale 返回失败且地图未就绪。
|
||||
|
||||
使用临时资源和本地测试,无真实服务器、Windows 输出对照或 Android 画面对照。完整日志在 `build/verification/windows-terrain-settings-2026-10-13/`。
|
||||
|
||||
验证结果:完整桌面构建通过,CTest 60/60 通过(52.49 秒);ASan/UBSan 下 background 与 windows_behavior 2/2 通过(1.51 秒)。`git diff --check` 通过;参考源码没有本轮变更,共享 SDK 工作区保持干净。
|
||||
@@ -0,0 +1,32 @@
|
||||
# AVA2 Windows 第九批修复:未定义行为与变形动作
|
||||
|
||||
本批继续修复逐模块清单。修复范围为上一批已复现的 UBSan 问题及变形角色的基础动作规则;公会标记、骨骼混合和地形渲染等较大模块仍未完成。
|
||||
|
||||
## 消除已复现的未定义行为
|
||||
|
||||
- `shared/common/Singleton.h` 保留现有单例接口和来源代码的单实例约束,注册真实基类子对象,访问时由编译器转换到派生类。删除通过地址 1 计算继承偏移的写法。回归采用单例基类不在对象起始位置的多重继承,验证 Instance/instance/InstancePtr、销毁后清空。没有修改原版参考头文件。
|
||||
- `wndMgr.SetFontColor` 对正常 0..1 RGB 保留 Windows 乘 255 后截断的转换,直接拼接 ARGB,删除 BYTE 数组强转 DWORD 的未对齐读取。超出范围的值夹到 0..1,NaN/Inf 变为 0;这是对原版未定义输入的明确边界处理,不声称与原版异常值结果一致。整数颜色路径不变。
|
||||
- 严格 UBSan 堆栈定位到仓库道具 `item_data` 的 sockets:压紧 Win32 结构中的 int32 数组被传入 std::copy_n,标准库会按对齐整数读取。改为 memcpy,同样修复普通道具更新和 switchbot 更新路径;报文尺寸、偏移和字节不变。
|
||||
- 道具属性的压紧 int16 字段先复制为对齐的局部值,再传入 std::pair,避免模板转发引用绑定到奇数地址。
|
||||
|
||||
## 变形角色规则
|
||||
|
||||
依据 `GameLib/ActorInstance.cpp::IsPoly`、`ActorInstanceMotion.cpp::InterceptMotion / __SetMotion`、`UserInterface/InstanceBase.cpp::RefreshState / SetShape / SetSash`。当前 AVA2 未启用 WOLFMAN,因此普通玩家模型范围为 0..7。
|
||||
|
||||
- 网络演员接收原始类型。TYPE_POLY=7,或 TYPE_PC=6 且 race>=8,均识别为变形;普通怪物不会仅因 race 较大而被认作变形。现有本地 SetPolymorph 标记仍被支持。
|
||||
- 变形强制 GENERAL 动作模式,不沿用手持武器、骑乘或婚服模式。
|
||||
- 插入动作(一次或循环)固定使用基础变体,不调用百分比随机选择;动画速度乘基础片段时长/1.1,再应用指定倍率。普通 SetLoop、排队和直接播放仍保留各自已有选择行为,不把插入规则扩展到所有动作。
|
||||
- 网络形状选择对变形演员使用图形 shape=0,并保留请求的 PART_MAIN 元数据;变形玩家拒绝 SetSash,与原版允许 IsPC 和 IsPoly 同时为真的规则一致。
|
||||
- 单人/双人情绪测试的临时 race 改为合法玩家编号 1/2,避免以前的 777/778 人为触发现在已恢复的变形判断。两职业映射和只读 GR2 状态机验证不变;新增独立怪物 race 验证变形路径。
|
||||
|
||||
## 验证与剩余范围
|
||||
|
||||
windows_behavior 新增多重继承单例及字体颜色精确值回归;player_motion 新增网络类型、模式、基础变体、随机调用次数、1.1 秒倍率、普通循环不归一化及变形 sash 拒绝回归。
|
||||
|
||||
完整桌面构建及 CTest 61/61 通过(50.12 秒)。随后仅加强测试,增加 Win32 固定偏移的非零 sockets 和负属性值校验;普通定向回归通过(1.23 秒),严格插桩回归通过(2.05 秒)。方法清点 46 个模块无缺失、395 个映射协议常量无差异,git diff --check 通过。
|
||||
|
||||
采用 `UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1`,windows_behavior/player_motion/inventory_touch/attack_combo 四项严格插桩测试通过(11.89 秒);完整输出没有 runtime error 或 AddressSanitizer ERROR。该结论只限于执行路径,不代表整个客户端没有未定义行为,Python C 依赖没有同等全面插桩。
|
||||
|
||||
日志位于 `build/verification/windows-ubsan-polymorph-2026-10-13/`。未修改平级 SDK、服务器或 Windows 参考源码;没有 Windows 动态进程输出、Android 或真实服务器验证。
|
||||
|
||||
仍需推进:完整变形模型切换/还原、技能可用规则及外观状态流程;骨骼局部 TRS 混合、root motion、精确动作队列/TCP 调度和多目标碰撞;公会标记连接/传输/缓存;地形 LOD/阴影/雾/splat、水深透明度及水面动画;SpeedTree 精确数值对照和旧 collision/GPU 接入迁移;攻速异常检测队列及尚未深审的 Python 模块行为。以上继续保留在 [逐模块对照](WINDOWS-MODULE-AUDIT-2026-10-13.md),没有将局部测试通过视为整体等价。
|
||||
@@ -10,14 +10,15 @@
|
||||
template <typename T>
|
||||
class CSingleton
|
||||
{
|
||||
static T * ms_singleton;
|
||||
static CSingleton<T> * ms_singleton;
|
||||
|
||||
public:
|
||||
CSingleton()
|
||||
{
|
||||
assert(!ms_singleton);
|
||||
intptr_t offset = (intptr_t) (T*) 1 - (intptr_t) (CSingleton <T>*) (T*) 1;
|
||||
ms_singleton = (T*) ((intptr_t) this + offset);
|
||||
// Register the actual base subobject. Convert to T only after its
|
||||
// construction starts, using the compiler's multiple-inheritance adjustment.
|
||||
ms_singleton = this;
|
||||
}
|
||||
|
||||
virtual ~CSingleton()
|
||||
@@ -29,19 +30,19 @@ public:
|
||||
__forceinline static T & Instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
return *static_cast<T*>(ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T * InstancePtr()
|
||||
{
|
||||
return (ms_singleton);
|
||||
return static_cast<T*>(ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T & instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
return *static_cast<T*>(ms_singleton);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T * CSingleton<T>::ms_singleton = nullptr;
|
||||
template <typename T> CSingleton<T> * CSingleton<T>::ms_singleton = nullptr;
|
||||
|
||||
+27
-10
@@ -740,6 +740,8 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
||||
// GameWindow.OnMouseLeftButtonDown sets player.SetMouseState; holding it for one
|
||||
// game update picks the target or ground under the finger like a mouse click.
|
||||
FlushRelease();
|
||||
if(auto* scene=ava2::TextTailManager::Instance().GetCurrentSceneRenderer())
|
||||
if(ava2::HandlePlayerTouchWorldTap(*scene,x,y)){ava2::TouchUiPointerIdle(*wm);return;}
|
||||
wm->RunMouseMove(long(x), long(y));
|
||||
wm->RunMouseLeftButtonDown(long(x), long(y));
|
||||
release_pending = true;
|
||||
@@ -753,6 +755,8 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
||||
// The finger is gone: no hover target / tooltip stays under the tap point.
|
||||
ava2::TouchUiPointerIdle(*wm);
|
||||
}
|
||||
int SkillAt(float x,float y) override {return wm?ava2::TouchSkillAt(*wm,long(x),long(y)):-1;}
|
||||
void Skill(int slot,float x,float y,bool repeat) override {ava2::UsePlayerTouchSkill(slot,x,y,camera->GetYaw(),repeat);}
|
||||
void Joystick(bool active, float x, float y) override { ava2::SetPlayerJoystick(active, x, y); }
|
||||
void Attack(bool pressed) override { ava2::SetPlayerAttackKey(pressed); }
|
||||
void CameraRotate(float dx, float dy) override {
|
||||
@@ -1030,6 +1034,9 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
||||
|
||||
std::unordered_map<int, float> skill_last_cast;
|
||||
auto cast_skill = [&](int quickSlot, int skillIndex) {
|
||||
// Native skill requests use -1 and already process MSA/events and
|
||||
// RunUseSkillEvent. Do not run the preview's fixed cooldown/effects.
|
||||
if (quickSlot < 0) return;
|
||||
if (last_phase != "game") return;
|
||||
if (player_actor.IsDead()) return;
|
||||
|
||||
@@ -1356,6 +1363,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
if (touch_mode) {
|
||||
touch_sink.FlushRelease();
|
||||
touch_router.SetWorldEnabled(last_phase == "game");
|
||||
if(last_phase!="game")ava2::CancelPlayerTouchInteraction();
|
||||
touch_router.Update(SDL_GetTicks());
|
||||
}
|
||||
#endif
|
||||
@@ -1380,7 +1388,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
ava2::CancelPlayerMovement(); orbit_camera.EndDrag();
|
||||
key_move_fwd = key_move_back = key_turn_left = key_turn_right = false;
|
||||
ava2::ReleaseAllKeys();
|
||||
if (touch_mode) touch_router.CancelAll();
|
||||
if (touch_mode) {touch_router.CancelAll();ava2::CancelPlayerTouchInteraction();}
|
||||
}
|
||||
if (touch_mode) {
|
||||
float tx = 0.0f, ty = 0.0f;
|
||||
@@ -1447,7 +1455,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
floating_text_mgr.AddText("Picked up item!", player_actor.GetX(), player_actor.GetY() + 180.0f, player_actor.GetZ(), 0xFFFFD700, 1.6f, 2.0f);
|
||||
ttm.DeleteItemTextTail(static_cast<uint32_t>(pickedItemVID));
|
||||
} else {
|
||||
player_actor.SetMoveTarget(ix, iz);
|
||||
ava2::CancelPlayerReservedSkill();player_actor.SetMoveTarget(ix, iz);
|
||||
target_mgr.AddGroundPickEffect(ix, tail->worldY, iz);
|
||||
}
|
||||
}
|
||||
@@ -1489,13 +1497,13 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
float approach_dist = dist - 100.0f;
|
||||
float app_x = player_actor.GetX() + (dx / dist) * approach_dist;
|
||||
float app_z = player_actor.GetZ() + (dz / dist) * approach_dist;
|
||||
player_actor.SetMoveTarget(app_x, app_z);
|
||||
ava2::CancelPlayerReservedSkill();player_actor.SetMoveTarget(app_x, app_z);
|
||||
}
|
||||
} else {
|
||||
// Pick terrain
|
||||
float pickX = 0.0f, pickY = 0.0f, pickZ = 0.0f;
|
||||
if (renderer3d->PickTerrain(bx, by, *active_terrain, pickX, pickY, pickZ)) {
|
||||
player_actor.SetMoveTarget(pickX, pickZ);
|
||||
ava2::CancelPlayerReservedSkill();player_actor.SetMoveTarget(pickX, pickZ);
|
||||
target_mgr.AddGroundPickEffect(pickX, pickY, pickZ);
|
||||
}
|
||||
}
|
||||
@@ -1824,7 +1832,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
ava2::CancelPlayerMovement(); orbit_camera.EndDrag();
|
||||
key_move_fwd = key_move_back = key_turn_left = key_turn_right = false;
|
||||
ava2::ReleaseAllKeys();
|
||||
if (touch_mode) touch_router.CancelAll();
|
||||
if (touch_mode) {touch_router.CancelAll();ava2::CancelPlayerTouchInteraction();}
|
||||
// The OS may kill a background app without another event.
|
||||
if (python) {
|
||||
ava2::CPythonSystem::Instance().SaveConfig();
|
||||
@@ -1950,6 +1958,12 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
if (frame_limit > 0) dt = 0.033f;
|
||||
else dt = std::clamp(dt, 0.001f, 0.25f);
|
||||
game_clock += dt;
|
||||
if(renderer3d) {
|
||||
#ifdef AVA2_HAS_PYTHON
|
||||
if(last_phase=="game")renderer3d->SetPerspective(ava2::CPythonSystem::Instance().GetFOVLevel(),static_cast<float>(view3d_w)/view3d_h,100,ava2::CPythonBackground::Instance().GetFarClip());
|
||||
#endif
|
||||
renderer3d->BuildViewFrustum();
|
||||
}
|
||||
|
||||
#ifdef AVA2_HAS_PYTHON
|
||||
if (python) {
|
||||
@@ -2083,11 +2097,14 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
ava2::SoundManager::Instance().SetPosition(player_actor.GetX(), player_actor.GetY(), player_actor.GetZ());
|
||||
ava2::SoundManager::Instance().Update(dt);
|
||||
ava2::EffectManager::Instance().Update(dt);
|
||||
ava2::FlyingManager::Instance().Update(dt, game_clock);
|
||||
std::function<float(float,float)> flyingGround;
|
||||
if(ava2::CPythonBackground::Instance().IsMapReady())flyingGround=[](float x,float z){return ava2::CPythonBackground::Instance().GetHeight(x,z);};
|
||||
ava2::FlyingManager::Instance().Update(dt,game_clock,active_terrain,active_map_objects,flyingGround);
|
||||
|
||||
// Drive PythonNetworkStream and NetworkActorManager
|
||||
ava2::PythonNetworkStream::Instance().ProcessRecvData();
|
||||
ava2::pump_python_net();
|
||||
ava2::ProcessPlayerTouchInteraction();
|
||||
ava2::NetworkActorManager::Instance().Update(dt, active_terrain);
|
||||
|
||||
// Update TextTail overhead positions
|
||||
@@ -2178,7 +2195,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
const bool attacking = ava2::IsPlayerAttacking();
|
||||
if (attacking) actor.ClearMoveTarget();
|
||||
const bool keyboardMoving = actor.CanAct() && !attacking && ava2::GetPlayerMovementYaw(orbit_camera.GetYaw(), moveYaw);
|
||||
actor.SetSpeed(340.0f * float(main->m_dwMovSpd) / 100.0f);
|
||||
actor.SetSpeed(340.0f * actor.GetMoveAnimationSpeed());
|
||||
if (keyboardMoving) {
|
||||
actor.ClearMoveTarget();
|
||||
actor.MoveInDirection(moveYaw, dt, active_terrain, active_map_objects);
|
||||
@@ -2189,7 +2206,7 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
UI::CWindowManager::Instance().GetMousePosition(mouseX,mouseY);
|
||||
float pickX=0,pickY=0,pickZ=0;
|
||||
if (renderer3d->PickTerrain(float(mouseX),float(mouseY),*active_terrain,pickX,pickY,pickZ))
|
||||
actor.SetMoveTarget(pickX,pickZ);
|
||||
ava2::CancelPlayerReservedSkill();actor.SetMoveTarget(pickX,pickZ);
|
||||
}
|
||||
}
|
||||
if (!actor.CanAct()) { actor.ClearMoveTarget(); actor.StopMoving(); }
|
||||
@@ -2430,9 +2447,9 @@ const auto profileActiveStart = std::chrono::steady_clock::now();
|
||||
// Add Particle effects, projectiles, and weapon ribbon trails
|
||||
float camPos[3] = {eyeX, eyeY, eyeZ};
|
||||
ava2::EffectManager::Instance().BuildDrawCommands(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), camPos, draws);
|
||||
ava2::FlyingManager::Instance().BuildDrawCommands(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), game_clock, draws);
|
||||
ava2::FlyingManager::Instance().BuildDrawCommands(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), game_clock, draws,renderer3d->GetCachedViewFrustum(),renderer3d->GetDepthState());
|
||||
if (!player_weapon_trace.IsEmpty()) {
|
||||
player_weapon_trace.BuildDrawCommands(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), game_clock, draws);
|
||||
player_weapon_trace.BuildDrawCommands(renderer3d->GetViewMatrix(), renderer3d->GetProjMatrix(), game_clock, draws,renderer3d->GetCachedViewFrustum(),renderer3d->GetDepthState());
|
||||
}
|
||||
} else {
|
||||
renderer3d->SetFog(false);
|
||||
|
||||
@@ -88,7 +88,7 @@ void TouchRouter::ReleaseDeferred() {
|
||||
|
||||
void TouchRouter::UpdateJoystick(float x, float y) {
|
||||
const float r = m_layout.joy_radius;
|
||||
float dx = x - m_joy.base_x, dy = y - m_joy.base_y;
|
||||
float dx = x - m_joy_touch_x, dy = y - m_joy_touch_y;
|
||||
const float dist = std::sqrt(dx * dx + dy * dy);
|
||||
if (dist > r && dist > 0.0f) {
|
||||
dx *= r / dist;
|
||||
@@ -118,6 +118,12 @@ void TouchRouter::FingerDown(std::uint64_t raw_id, float x, float y, std::uint64
|
||||
finger.y = finger.start_y = y;
|
||||
finger.start_ms = ms;
|
||||
|
||||
const int skill=m_world && m_sink ? m_sink->SkillAt(x,y) : -1;
|
||||
if(skill>=0) {
|
||||
// A second finger on the same shortcut cannot duplicate its repeat stream.
|
||||
for(const auto& entry:m_fingers)if(entry.second.owner==Owner::Skill && entry.second.skill_slot==skill)return;
|
||||
finger.owner=Owner::Skill;finger.skill_slot=skill;m_fingers[id]=finger;return;
|
||||
}
|
||||
const bool ui = m_sink && m_sink->IsUiAt(x, y);
|
||||
if (!m_world || ui) {
|
||||
// wndMgr tracks a single pointer; further fingers on UI are ignored.
|
||||
@@ -156,6 +162,7 @@ void TouchRouter::FingerDown(std::uint64_t raw_id, float x, float y, std::uint64
|
||||
m_joy_finger = id;
|
||||
m_fingers[id] = finger;
|
||||
const float r = m_layout.joy_radius;
|
||||
m_joy_touch_x=x;m_joy_touch_y=y;
|
||||
m_joy.active = true;
|
||||
m_joy.base_x = std::clamp(x, r, std::max(r, m_layout.screen_w - r));
|
||||
m_joy.base_y = std::clamp(y, r, std::max(r, m_layout.screen_h - r));
|
||||
@@ -197,6 +204,7 @@ void TouchRouter::FingerMove(std::uint64_t raw_id, float x, float y, std::uint64
|
||||
}
|
||||
m_sink->UiMouseMove(x, y);
|
||||
break;
|
||||
case Owner::Skill:
|
||||
case Owner::Attack:
|
||||
case Owner::Ignored:
|
||||
break;
|
||||
@@ -233,6 +241,13 @@ void TouchRouter::Release(std::uint64_t id, Finger& finger, bool cancelled) {
|
||||
// press the host took keeps the pointer (the item tooltip stays next to the action sheet).
|
||||
else if (finger.ui == Finger::Ui::Pending && m_sink) m_sink->UiPointerIdle();
|
||||
break;
|
||||
case Owner::Skill:
|
||||
if(!cancelled && !finger.skill_cast && m_sink) {
|
||||
const float dx=finger.x-finger.start_x,dy=finger.y-finger.start_y;
|
||||
const bool aimed=std::hypot(dx,dy)>m_layout.tap_slop;
|
||||
m_sink->Skill(finger.skill_slot,aimed?dx:0,aimed?dy:0,false);
|
||||
}
|
||||
break;
|
||||
case Owner::Attack:
|
||||
m_attack_finger = 0;
|
||||
if (!cancelled && m_attack_fresh)
|
||||
@@ -314,6 +329,16 @@ void TouchRouter::Update(std::uint64_t ms) {
|
||||
if (m_sink) m_sink->Attack(false);
|
||||
}
|
||||
if (m_joy_orphan && ms > m_joy_orphan_ms && ms - m_joy_orphan_ms > m_layout.joy_reacquire_ms) ReleaseJoystick();
|
||||
if(m_sink)for(auto& entry:m_fingers) {
|
||||
auto& finger=entry.second;if(finger.owner!=Owner::Skill || ms<finger.start_ms)continue;
|
||||
const float dx=finger.x-finger.start_x,dy=finger.y-finger.start_y;
|
||||
const bool aimed=std::hypot(dx,dy)>m_layout.tap_slop;
|
||||
if((!finger.skill_cast && (aimed || ms-finger.start_ms>=m_layout.skill_settle_ms))
|
||||
|| (finger.skill_cast && ms>=finger.skill_last_ms && ms-finger.skill_last_ms>=m_layout.skill_repeat_ms)) {
|
||||
m_sink->Skill(finger.skill_slot,aimed?dx:0,aimed?dy:0,finger.skill_cast);
|
||||
finger.skill_cast=true;finger.skill_last_ms=ms;
|
||||
}
|
||||
}
|
||||
if (!m_ui_finger || !m_sink) return;
|
||||
auto it = m_fingers.find(m_ui_finger);
|
||||
if (it == m_fingers.end()) return;
|
||||
|
||||
@@ -61,6 +61,9 @@ struct TouchSink {
|
||||
// Joystick vector in screen axes (x right, y down), length 0..1; active=false releases it.
|
||||
virtual void Joystick(bool active, float x, float y) = 0;
|
||||
virtual void Attack(bool pressed) = 0;
|
||||
// Pick only a visible skill shortcut under the finger; -1 means ordinary UI.
|
||||
virtual int SkillAt(float, float) { return -1; }
|
||||
virtual void Skill(int, float, float, bool) {} // slot, aim vector, repeated cast
|
||||
// Camera drag in UI pixels since the last call.
|
||||
virtual void CameraRotate(float dx, float dy) = 0;
|
||||
// Pinch ratio since the last call: > 1 fingers moved apart (zoom in).
|
||||
@@ -76,7 +79,8 @@ struct TouchLayout {
|
||||
// Attack button circle; radius 0 disables it.
|
||||
float attack_x = 0.0f, attack_y = 0.0f, attack_r = 0.0f;
|
||||
float tap_slop = 14.0f; // movement that turns a tap into a camera drag
|
||||
std::uint64_t tap_ms = 300; // longer presses are not taps
|
||||
std::uint64_t tap_ms = 300;
|
||||
std::uint64_t skill_settle_ms = 100, skill_repeat_ms = 200; // longer presses are not taps
|
||||
std::uint64_t double_tap_ms = 300; // first tap's lift to second tap's landing
|
||||
float double_tap_slop = 40.0f; // distance between the two taps
|
||||
std::uint64_t long_press_ms = 450;
|
||||
@@ -100,7 +104,7 @@ struct JoystickView {
|
||||
class TouchRouter {
|
||||
public:
|
||||
// Ignored: a world finger that landed in the bottom system-gesture strip.
|
||||
enum class Owner { Ui, Attack, Joystick, Camera, Ignored };
|
||||
enum class Owner { Ui, Attack, Skill, Joystick, Camera, Ignored };
|
||||
|
||||
void SetSink(TouchSink* sink) { m_sink = sink; }
|
||||
void SetLayout(const TouchLayout& layout) { m_layout = layout; }
|
||||
@@ -120,6 +124,11 @@ public:
|
||||
void CancelAll();
|
||||
|
||||
JoystickView GetJoystick() const { return m_joy; }
|
||||
JoystickView GetSkillAim() const {
|
||||
for(const auto& entry:m_fingers)if(entry.second.owner==Owner::Skill)
|
||||
return {true,entry.second.start_x,entry.second.start_y,entry.second.x,entry.second.y};
|
||||
return {};
|
||||
}
|
||||
bool IsAttackPressed() const { return m_attack_finger != 0 || m_attack_release_pending; }
|
||||
std::size_t FingerCount() const { return m_fingers.size(); }
|
||||
|
||||
@@ -129,6 +138,9 @@ private:
|
||||
float x = 0.0f, y = 0.0f; // last position
|
||||
float start_x = 0.0f, start_y = 0.0f;
|
||||
std::uint64_t start_ms = 0;
|
||||
int skill_slot = -1;
|
||||
bool skill_cast = false;
|
||||
std::uint64_t skill_last_ms = 0;
|
||||
bool tap = true; // still a tap candidate (camera fingers)
|
||||
// UI fingers: Pending holds the button press back, Pressed sent it, Consumed was a long
|
||||
// press the host took.
|
||||
@@ -153,6 +165,7 @@ private:
|
||||
std::map<std::uint64_t, Finger> m_fingers; // ids are offset by one so 0 means "none"
|
||||
std::uint64_t m_ui_finger = 0, m_joy_finger = 0, m_attack_finger = 0;
|
||||
JoystickView m_joy;
|
||||
float m_joy_touch_x=0, m_joy_touch_y=0;
|
||||
// Joystick whose finger the system cancelled; still active until m_joy_orphan_ms + reacquire.
|
||||
bool m_joy_orphan = false;
|
||||
std::uint64_t m_joy_orphan_ms = 0;
|
||||
|
||||
+67
-114
@@ -1,127 +1,80 @@
|
||||
#include "FlyTrace.h"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
namespace ava2 {
|
||||
|
||||
// Portions Copyright (C) John W. Ratcliff, 2001 (AVA2 SphereLib/frustum.cpp).
|
||||
// AVA2 GameLib/FlyTrace.cpp: six-vertex triangle strip, camera-eye basis,
|
||||
// constant diffuse color and width decay. Engine coordinates are already converted.
|
||||
FlyTrace::FlyTrace() = default;
|
||||
FlyTrace::~FlyTrace() = default;
|
||||
|
||||
void FlyTrace::Create(uint32_t color, float tailLength, float tailSize, bool rectShape) {
|
||||
m_color = color;
|
||||
m_tailLength = tailLength > 0.01f ? tailLength : 0.25f;
|
||||
m_tailSize = tailSize > 0.1f ? tailSize : 10.0f;
|
||||
m_rectShape = rectShape;
|
||||
m_history.clear();
|
||||
void FlyTrace::Create(uint32_t color,float tailLength,float tailSize,bool rectShape) {
|
||||
m_color=color;m_tailLength=tailLength;m_tailSize=tailSize;m_rectShape=rectShape;m_history.clear();
|
||||
}
|
||||
void FlyTrace::Clear(){m_history.clear();m_color=0;m_tailLength=0;m_tailSize=0;m_rectShape=false;}
|
||||
void FlyTrace::UpdateNewPosition(float x,float y,float z,float currentTime) {
|
||||
m_history.push_front({currentTime,{x,y,z}});
|
||||
while(!m_history.empty() && m_history.back().time+m_tailLength<currentTime)m_history.pop_back();
|
||||
}
|
||||
namespace {
|
||||
std::array<float,3> Cross(const std::array<float,3>& a,const std::array<float,3>& b) {
|
||||
return {a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]};
|
||||
}
|
||||
void Normalize(std::array<float,3>& v) {
|
||||
const float length=std::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
|
||||
if(length>0)for(auto& value:v)value/=length;
|
||||
}
|
||||
|
||||
void FlyTrace::Clear() {
|
||||
m_history.clear();
|
||||
|
||||
}
|
||||
|
||||
void FlyTrace::UpdateNewPosition(float x, float y, float z, float currentTime) {
|
||||
TraceNode node;
|
||||
node.time = currentTime;
|
||||
node.pos[0] = x;
|
||||
node.pos[1] = y;
|
||||
node.pos[2] = z;
|
||||
|
||||
m_history.push_front(node);
|
||||
|
||||
while (!m_history.empty() && (currentTime - m_history.back().time) > m_tailLength) {
|
||||
m_history.pop_back();
|
||||
void FlyTrace::BuildDrawCommands(const float* view,const float* projection,float now,std::vector<Render3DDraw>& out,const ViewFrustum* cachedFrustum,DepthState depthState) {
|
||||
if(m_history.size()<2 || !view || !projection || !std::isfinite(m_tailLength) || m_tailLength<=0 || !std::isfinite(m_tailSize))return;
|
||||
std::array<float,3> forward={view[2],view[6],view[10]};Normalize(forward);
|
||||
// Rigid camera inverse: eye=-R^T * translation.
|
||||
const std::array<float,3> eye={-(view[0]*view[12]+view[1]*view[13]+view[2]*view[14]),
|
||||
-(view[4]*view[12]+view[5]*view[13]+view[6]*view[14]),-(view[8]*view[12]+view[9]*view[13]+view[10]*view[14])};
|
||||
// Standalone callers have no update phase; production passes the UpdateGame snapshot.
|
||||
std::optional<ViewFrustum> fallback;
|
||||
if(!cachedFrustum) {
|
||||
PerspectiveMetadata inferred;const PerspectiveMetadata* metadata=nullptr;
|
||||
if(projection[11]==1 && projection[15]==0 && projection[8]==0 && projection[9]==0 && projection[0]>0 && projection[5]>0 && projection[10]>1) {
|
||||
inferred={2*std::atan(1/projection[5])*180/3.14159265358979323846f,projection[5]/projection[0],-projection[14]/projection[10],projection[14]/(1-projection[10])};metadata=&inferred;
|
||||
}
|
||||
fallback.emplace(view,projection,eye,forward,metadata);
|
||||
}
|
||||
const ViewFrustum& frustum=cachedFrustum?*cachedFrustum:*fallback;
|
||||
struct Segment {float depth;std::array<float,18> positions;};
|
||||
std::vector<Segment> segments;
|
||||
for(size_t index=0;index+1<m_history.size();++index) {
|
||||
const auto& first=m_history[index];const auto& second=m_history[index+1];
|
||||
std::array<float,3> b,e;for(int k=0;k<3;++k){b[k]=second.pos[k]-first.pos[k];e[k]=eye[k]-first.pos[k];}
|
||||
std::array<float,3> center;for(int k=0;k<3;++k)center[k]=first.pos[k]+b[k]*0.5f;
|
||||
const float radius=std::max({std::abs(b[0]),std::abs(b[1]),std::abs(b[2])})*0.5f;
|
||||
if(frustum.Outside(center,radius))continue;
|
||||
const auto p=Cross(b,e);auto up=Cross(forward,p);Normalize(up);const auto right=Cross(forward,up);
|
||||
// Source does not clamp valid aged rates or fade diffuse alpha.
|
||||
const float firstSize=m_rectShape?m_tailSize:m_tailSize*(1-(now-first.time)/m_tailLength);
|
||||
const float secondSize=m_rectShape?m_tailSize:m_tailSize*(1-(now-second.time)/m_tailLength);
|
||||
const float local[6][2]={{0,firstSize},{-firstSize,0},{firstSize,0},{-secondSize,0},{secondSize,0},{0,-secondSize}};
|
||||
Segment segment{};for(int k=0;k<3;++k)segment.depth-=e[k]*forward[k];
|
||||
for(int vertex=0;vertex<6;++vertex)for(int k=0;k<3;++k)
|
||||
segment.positions[vertex*3+k]=local[vertex][0]*right[k]+local[vertex][1]*up[k]+(vertex<3?first.pos[k]:second.pos[k]);
|
||||
segments.push_back(segment);
|
||||
}
|
||||
std::stable_sort(segments.begin(),segments.end(),[](const auto& a,const auto& b){return a.depth<b.depth;});
|
||||
Render3DDraw draw;draw.lighting=false;draw.z_enable=depthState.enabled;draw.z_write=depthState.write;draw.depth_less=true;draw.cull_mode=1;
|
||||
draw.alpha_blend=true;draw.blend_mode=1;draw.alpha_test=true;draw.alpha_ref=0;
|
||||
std::copy(view,view+16,draw.view);std::copy(projection,projection+16,draw.proj);
|
||||
for(int k=0;k<16;++k)draw.world[k]=(k%5==0)?1.0f:0.0f;
|
||||
for(const auto& segment:segments) {
|
||||
const uint32_t base=uint32_t(draw.positions.size()/3);
|
||||
draw.positions.insert(draw.positions.end(),segment.positions.begin(),segment.positions.end());
|
||||
draw.diffuse.insert(draw.diffuse.end(),6,m_color);
|
||||
draw.uv0.insert(draw.uv0.end(),{0,0,0,0.5f,0.5f,0,0.5f,1,1,0.5f,1,1});
|
||||
for(uint32_t index:{0u,1u,2u,2u,1u,3u,2u,3u,4u,4u,3u,5u})draw.indices.push_back(base+index);
|
||||
}
|
||||
if(!draw.indices.empty())out.push_back(std::move(draw));
|
||||
}
|
||||
|
||||
void FlyTrace::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws) {
|
||||
if (m_history.size() < 2) return;
|
||||
|
||||
Render3DDraw draw;
|
||||
draw.lighting = false;
|
||||
draw.z_enable = true;
|
||||
draw.z_write = false;
|
||||
draw.cull_mode = 1; // D3DCULL_NONE
|
||||
draw.alpha_blend = true;
|
||||
draw.blend_mode = 1; // Additive (D3DBLEND_ONE)
|
||||
|
||||
for (int m = 0; m < 16; ++m) {
|
||||
draw.view[m] = viewMatrix[m];
|
||||
draw.proj[m] = projMatrix[m];
|
||||
draw.world[m] = (m % 5 == 0) ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
float camDir[3] = {viewMatrix[2], viewMatrix[6], viewMatrix[10]};
|
||||
float camLen = std::sqrt(camDir[0]*camDir[0] + camDir[1]*camDir[1] + camDir[2]*camDir[2]);
|
||||
if (camLen > 1e-5f) { camDir[0] /= camLen; camDir[1] /= camLen; camDir[2] /= camLen; }
|
||||
|
||||
uint32_t vertexOffset = 0;
|
||||
|
||||
for (size_t i = 0; i + 1 < m_history.size(); ++i) {
|
||||
const auto& n0 = m_history[i];
|
||||
const auto& n1 = m_history[i + 1];
|
||||
|
||||
float age0 = currentTime - n0.time;
|
||||
float age1 = currentTime - n1.time;
|
||||
float rate0 = std::clamp(1.0f - age0 / m_tailLength, 0.0f, 1.0f);
|
||||
float rate1 = std::clamp(1.0f - age1 / m_tailLength, 0.0f, 1.0f);
|
||||
|
||||
float s0 = m_rectShape ? m_tailSize : m_tailSize * rate0;
|
||||
float s1 = m_rectShape ? m_tailSize : m_tailSize * rate1;
|
||||
|
||||
// Ribbon segment direction
|
||||
float seg[3] = {n1.pos[0] - n0.pos[0], n1.pos[1] - n0.pos[1], n1.pos[2] - n0.pos[2]};
|
||||
float segLen = std::sqrt(seg[0]*seg[0] + seg[1]*seg[1] + seg[2]*seg[2]);
|
||||
if (segLen < 1e-4f) continue;
|
||||
|
||||
// Normal perpendicular to segment and camera look
|
||||
float norm[3] = {
|
||||
seg[1] * camDir[2] - seg[2] * camDir[1],
|
||||
seg[2] * camDir[0] - seg[0] * camDir[2],
|
||||
seg[0] * camDir[1] - seg[1] * camDir[0]
|
||||
};
|
||||
float normLen = std::sqrt(norm[0]*norm[0] + norm[1]*norm[1] + norm[2]*norm[2]);
|
||||
if (normLen > 1e-5f) {
|
||||
norm[0] /= normLen; norm[1] /= normLen; norm[2] /= normLen;
|
||||
}
|
||||
|
||||
// Vertices for this quad segment
|
||||
float v0[3] = {n0.pos[0] + norm[0] * s0, n0.pos[1] + norm[1] * s0, n0.pos[2] + norm[2] * s0};
|
||||
float v1[3] = {n0.pos[0] - norm[0] * s0, n0.pos[1] - norm[1] * s0, n0.pos[2] - norm[2] * s0};
|
||||
float v2[3] = {n1.pos[0] - norm[0] * s1, n1.pos[1] - norm[1] * s1, n1.pos[2] - norm[2] * s1};
|
||||
float v3[3] = {n1.pos[0] + norm[0] * s1, n1.pos[1] + norm[1] * s1, n1.pos[2] + norm[2] * s1};
|
||||
|
||||
uint8_t baseA = (m_color >> 24) & 0xFF;
|
||||
uint8_t baseR = (m_color >> 16) & 0xFF;
|
||||
uint8_t baseG = (m_color >> 8) & 0xFF;
|
||||
uint8_t baseB = m_color & 0xFF;
|
||||
|
||||
uint8_t a0 = static_cast<uint8_t>(baseA * rate0);
|
||||
uint8_t a1 = static_cast<uint8_t>(baseA * rate1);
|
||||
|
||||
uint32_t diff0 = (static_cast<uint32_t>(a0) << 24) | (static_cast<uint32_t>(baseR) << 16) | (static_cast<uint32_t>(baseG) << 8) | baseB;
|
||||
uint32_t diff1 = (static_cast<uint32_t>(a1) << 24) | (static_cast<uint32_t>(baseR) << 16) | (static_cast<uint32_t>(baseG) << 8) | baseB;
|
||||
|
||||
draw.positions.insert(draw.positions.end(), {v0[0], v0[1], v0[2]});
|
||||
draw.positions.insert(draw.positions.end(), {v1[0], v1[1], v1[2]});
|
||||
draw.positions.insert(draw.positions.end(), {v2[0], v2[1], v2[2]});
|
||||
draw.positions.insert(draw.positions.end(), {v3[0], v3[1], v3[2]});
|
||||
|
||||
draw.diffuse.insert(draw.diffuse.end(), {diff0, diff0, diff1, diff1});
|
||||
draw.uv0.insert(draw.uv0.end(), {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f});
|
||||
|
||||
draw.indices.push_back(vertexOffset + 0);
|
||||
draw.indices.push_back(vertexOffset + 1);
|
||||
draw.indices.push_back(vertexOffset + 2);
|
||||
draw.indices.push_back(vertexOffset + 0);
|
||||
draw.indices.push_back(vertexOffset + 2);
|
||||
draw.indices.push_back(vertexOffset + 3);
|
||||
|
||||
vertexOffset += 4;
|
||||
}
|
||||
|
||||
if (!draw.indices.empty()) {
|
||||
outDraws.push_back(std::move(draw));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ava2
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "eter_render/RenderCommands3D.h"
|
||||
#include "eter_render/ViewFrustum.h"
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
void UpdateNewPosition(float x, float y, float z, float currentTime);
|
||||
void Clear();
|
||||
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws);
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws, const ViewFrustum* cachedFrustum = nullptr, DepthState depthState = {});
|
||||
|
||||
bool IsEmpty() const { return m_history.size() < 2; }
|
||||
|
||||
@@ -26,9 +27,9 @@ private:
|
||||
float pos[3] = {0.0f, 0.0f, 0.0f};
|
||||
};
|
||||
|
||||
uint32_t m_color = 0xFFFFFFFF;
|
||||
float m_tailLength = 0.25f;
|
||||
float m_tailSize = 10.0f;
|
||||
uint32_t m_color = 0;
|
||||
float m_tailLength = 0;
|
||||
float m_tailSize = 0;
|
||||
bool m_rectShape = false;
|
||||
|
||||
std::deque<TraceNode> m_history;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include "eter_base/Random.h"
|
||||
#include "eter_net/NetworkActorManager.h"
|
||||
#include "eter_render/MapObjectManager.h"
|
||||
|
||||
namespace ava2 {
|
||||
|
||||
@@ -86,6 +89,7 @@ bool FlyingData::LoadScriptFile(const std::string& filepath) {
|
||||
dir = filepath.substr(0, lastSlash + 1);
|
||||
}
|
||||
|
||||
attachments.clear();attach=FlyingAttachData();
|
||||
auto tokens = TokenizeScript(content);
|
||||
size_t idx = 0;
|
||||
size_t numTokens = tokens.size();
|
||||
@@ -101,6 +105,8 @@ bool FlyingData::LoadScriptFile(const std::string& filepath) {
|
||||
acceleration[0] = std::stof(tokens[idx++]);
|
||||
acceleration[1] = std::stof(tokens[idx++]);
|
||||
acceleration[2] = std::stof(tokens[idx++]);
|
||||
} else if (key == "angularvelocity" && idx + 2 < numTokens) {
|
||||
for(int k=0;k<3;++k)angular_velocity[k]=std::stof(tokens[idx++]);
|
||||
} else if (key == "bombrange" && idx < numTokens) {
|
||||
bomb_range = std::stof(tokens[idx++]);
|
||||
} else if (key == "bombeffect" && idx < numTokens) {
|
||||
@@ -114,11 +120,28 @@ bool FlyingData::LoadScriptFile(const std::string& filepath) {
|
||||
homing_flag = (std::stoi(tokens[idx++]) != 0);
|
||||
} else if (key == "homingmaxangle" && idx < numTokens) {
|
||||
homing_max_angle = std::stof(tokens[idx++]);
|
||||
} else if (key == "hitonbackground" && idx < numTokens) {
|
||||
hit_on_background=std::stoi(tokens[idx++])!=0;
|
||||
} else if (key == "hitonanothermonster" && idx < numTokens) {
|
||||
hit_on_another_monster=std::stoi(tokens[idx++])!=0;
|
||||
} else if (key == "spreadingflag" && idx < numTokens) {
|
||||
spreading = std::stoi(tokens[idx++]) != 0;
|
||||
} else if (key == "rollangle" && idx < numTokens) {
|
||||
roll_angle = std::stof(tokens[idx++]);
|
||||
} else if (key == "coneangle" && idx < numTokens) {
|
||||
cone_angle = std::stof(tokens[idx++]);
|
||||
} else if (key == "homingstarttime" && idx < numTokens) {
|
||||
homing_start_time = std::stof(tokens[idx++]);
|
||||
} else if (key == "piercecount" && idx < numTokens) {
|
||||
pierce_count = std::stoi(tokens[idx++]);
|
||||
} else if (key == "maintainparallelflag" && idx < numTokens) {
|
||||
maintain_parallel = std::stoi(tokens[idx++]) != 0;
|
||||
} else if (key == "range" && idx < numTokens) {
|
||||
range = std::stof(tokens[idx++]);
|
||||
} else if (key == "group" && idx < numTokens && ToLower(tokens[idx]) == "attachdata") {
|
||||
idx++; // skip attachdata
|
||||
if (idx < numTokens && tokens[idx] == "{") idx++;
|
||||
FlyingAttachData entry;
|
||||
int aDepth = 1;
|
||||
|
||||
while (idx < numTokens && aDepth > 0) {
|
||||
@@ -127,39 +150,78 @@ bool FlyingData::LoadScriptFile(const std::string& filepath) {
|
||||
|
||||
std::string aKey = ToLower(tokens[idx++]);
|
||||
if (aKey == "type" && idx < numTokens) {
|
||||
attach.type = std::stoi(tokens[idx++]);
|
||||
entry.type = std::stoi(tokens[idx++]);
|
||||
} else if (aKey == "flytype" && idx < numTokens) {
|
||||
attach.fly_type = std::stoi(tokens[idx++]);
|
||||
entry.fly_type = std::stoi(tokens[idx++]);
|
||||
} else if (aKey == "attachfile" && idx < numTokens) {
|
||||
std::string att = NormalizePath(tokens[idx++]);
|
||||
if (!dir.empty() && !std::filesystem::exists(att)) {
|
||||
std::string candidate = NormalizePath(dir + att);
|
||||
if (std::filesystem::exists(candidate)) att = candidate;
|
||||
}
|
||||
attach.attach_file = att;
|
||||
entry.attach_file = att;
|
||||
} else if (aKey == "tailflag" && idx < numTokens) {
|
||||
attach.has_tail = (std::stoi(tokens[idx++]) != 0);
|
||||
entry.has_tail = (std::stoi(tokens[idx++]) != 0);
|
||||
} else if (aKey == "tailcolor" && idx < numTokens) {
|
||||
std::string cStr = tokens[idx++];
|
||||
if (!cStr.empty() && (cStr.back() == 'd' || cStr.back() == 'D')) {
|
||||
cStr.pop_back();
|
||||
}
|
||||
attach.tail_color = static_cast<uint32_t>(std::stoul(cStr));
|
||||
entry.tail_color = static_cast<uint32_t>(std::stoul(cStr));
|
||||
} else if (aKey == "taillength" && idx < numTokens) {
|
||||
attach.tail_length = std::stof(tokens[idx++]);
|
||||
entry.tail_length = std::stof(tokens[idx++]);
|
||||
} else if (aKey == "tailsize" && idx < numTokens) {
|
||||
attach.tail_size = std::stof(tokens[idx++]);
|
||||
entry.tail_size = std::stof(tokens[idx++]);
|
||||
} else if (aKey == "roll" && idx < numTokens) {
|
||||
entry.roll=std::stof(tokens[idx++]);
|
||||
} else if (aKey == "distance" && idx < numTokens) {
|
||||
entry.distance=std::stof(tokens[idx++]);
|
||||
} else if (aKey == "period" && idx < numTokens) {
|
||||
entry.period=std::stof(tokens[idx++]);
|
||||
} else if (aKey == "amplitude" && idx < numTokens) {
|
||||
entry.amplitude=std::stof(tokens[idx++]);
|
||||
} else if (aKey == "tailshaperect" && idx < numTokens) {
|
||||
attach.rect_shape = (std::stoi(tokens[idx++]) != 0);
|
||||
entry.rect_shape = (std::stoi(tokens[idx++]) != 0);
|
||||
}
|
||||
}
|
||||
attachments.push_back(entry);if(attachments.size()==1)attach=entry;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
FlyingInstance::FlyingInstance(std::shared_ptr<FlyingData> data, const float* startPos, const float* targetPos)
|
||||
: m_data(std::move(data)) {
|
||||
namespace {
|
||||
void RotateQuaternion(const float* q,float* v) {
|
||||
float cross[3]={q[1]*v[2]-q[2]*v[1],q[2]*v[0]-q[0]*v[2],q[0]*v[1]-q[1]*v[0]};
|
||||
float second[3]={q[1]*cross[2]-q[2]*cross[1],q[2]*cross[0]-q[0]*cross[2],q[0]*cross[1]-q[1]*cross[0]};
|
||||
for(int k=0;k<3;++k)v[k]+=2*(q[3]*cross[k]+second[k]);
|
||||
}
|
||||
// D3DXQuaternionMultiply(first,second): apply first, then second (second * first).
|
||||
void Compose(const float* a,const float* b,float* out) {
|
||||
float q[4]={b[3]*a[0]+b[0]*a[3]+b[1]*a[2]-b[2]*a[1],
|
||||
b[3]*a[1]-b[0]*a[2]+b[1]*a[3]+b[2]*a[0],
|
||||
b[3]*a[2]+b[0]*a[1]-b[1]*a[0]+b[2]*a[3],
|
||||
b[3]*a[3]-b[0]*a[0]-b[1]*a[1]-b[2]*a[2]};std::copy(q,q+4,out);
|
||||
}
|
||||
void NativeYawPitchRoll(float yaw,float pitch,float roll,float* out) {
|
||||
const float c=3.14159265358979323846f/360;
|
||||
const float cy=std::cos(yaw*c),sy=std::sin(yaw*c),cp=std::cos(pitch*c),sp=std::sin(pitch*c),cr=std::cos(roll*c),sr=std::sin(roll*c);
|
||||
out[0]=cy*sp*cr+sy*cp*sr;out[1]=cy*cp*sr-sy*sp*cr;
|
||||
out[2]=-(sy*cp*cr-cy*sp*sr);out[3]=cy*cp*cr+sy*sp*sr;
|
||||
}
|
||||
void QuaternionMatrix(const float* q,const float* position,float* out) {
|
||||
const float x=q[0],y=q[1],z=q[2],w=q[3];
|
||||
std::fill(out,out+16,0.0f);out[15]=1;
|
||||
out[0]=1-2*y*y-2*z*z;out[1]=2*x*y+2*z*w;out[2]=2*x*z-2*y*w;
|
||||
out[4]=2*x*y-2*z*w;out[5]=1-2*x*x-2*z*z;out[6]=2*y*z+2*x*w;
|
||||
out[8]=2*x*z+2*y*w;out[9]=2*y*z-2*x*w;out[10]=1-2*x*x-2*y*y;
|
||||
std::copy(position,position+3,out+12);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FlyingInstance::FlyingInstance(std::shared_ptr<FlyingData> data, const float* startPos, const float* targetPos, FlyTargetResolver targetResolver)
|
||||
: m_data(std::move(data)), m_targetResolver(std::move(targetResolver)) {
|
||||
if (startPos) {
|
||||
m_position[0] = startPos[0];
|
||||
m_position[1] = startPos[1];
|
||||
@@ -171,107 +233,224 @@ FlyingInstance::FlyingInstance(std::shared_ptr<FlyingData> data, const float* st
|
||||
m_targetPosition[2] = targetPos[2];
|
||||
}
|
||||
|
||||
if(m_targetResolver && !m_targetResolver(m_targetPosition)) m_targetResolver={};
|
||||
m_remainingRange=m_data?m_data->range:10000;
|
||||
m_pierceCount=m_data?m_data->pierce_count:0;
|
||||
if(m_data) { // MSF acceleration is native Z-up, gravity is direct acceleration.
|
||||
m_acceleration[0]=m_data->acceleration[0];
|
||||
m_acceleration[1]=m_data->acceleration[2];
|
||||
m_acceleration[2]=-m_data->acceleration[1];
|
||||
}
|
||||
float dir[3] = {
|
||||
m_targetPosition[0] - m_position[0],
|
||||
m_targetPosition[1] - m_position[1],
|
||||
m_targetPosition[1] - m_position[1] + ((m_data && m_data->maintain_parallel)?50:0),
|
||||
m_targetPosition[2] - m_position[2]
|
||||
};
|
||||
float len = std::sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]);
|
||||
float speed = m_data ? m_data->initial_velocity : 1000.0f;
|
||||
if (speed < 100.0f) speed = 1000.0f;
|
||||
|
||||
if (len > 1e-4f) {
|
||||
m_velocity[0] = (dir[0] / len) * speed;
|
||||
m_velocity[1] = (dir[1] / len) * speed;
|
||||
m_velocity[2] = (dir[2] / len) * speed;
|
||||
for(int k=0;k<3;++k)dir[k]/=len;
|
||||
// __SetDataPointer uses native RotationYawPitchRoll(roll-90,0,cone),
|
||||
// followed by __SetTargetDirection's arc from native (0,-1,0).
|
||||
const float yaw=((m_data?m_data->roll_angle:0)-90)*3.14159265358979323846f/360;
|
||||
const float cone=(m_data?m_data->cone_angle:0)*3.14159265358979323846f/360;
|
||||
const float initial[4]={std::sin(yaw)*std::sin(cone),std::cos(yaw)*std::sin(cone),-std::sin(yaw)*std::cos(cone),std::cos(yaw)*std::cos(cone)};
|
||||
m_velocity[2]=speed;
|
||||
std::copy(initial,initial+4,m_orientation);
|
||||
if(m_data && m_data->spreading) {
|
||||
// FlyingInstance::__SetDataPointer. D3DX Multiply(Q1,Q2) applies Q1
|
||||
// then Q2: Z spread -> negative-Y spin -> initial roll/cone -> target arc.
|
||||
const float first=eter::frandom(-3.141592f/3,+3.141592f/3);
|
||||
const float second=eter::frandom(-3.141592f/3,+3.141592f/3);
|
||||
const float spread=(first+second)/4;
|
||||
const float spin=eter::frandom(0,2*3.14159265358979323846f)/2;
|
||||
const float spreadRotation[4]={0,std::sin(spread),0,std::cos(spread)};
|
||||
const float spinRotation[4]={0,0,std::sin(spin),std::cos(spin)};
|
||||
RotateQuaternion(spreadRotation,m_velocity);RotateQuaternion(spreadRotation,m_acceleration);
|
||||
RotateQuaternion(spinRotation,m_velocity);RotateQuaternion(spinRotation,m_acceleration);
|
||||
float spreading[4];Compose(spreadRotation,spinRotation,spreading);Compose(spreading,initial,m_orientation);
|
||||
}
|
||||
RotateQuaternion(initial,m_velocity);RotateQuaternion(initial,m_acceleration);
|
||||
float arc[4]={0,1,0,0};
|
||||
if(dir[2]>-1) {
|
||||
const float scale=std::sqrt((1+dir[2])*2);
|
||||
arc[0]=-dir[1]/scale;arc[1]=dir[0]/scale;arc[2]=0;arc[3]=scale*0.5f;
|
||||
}
|
||||
RotateQuaternion(arc,m_velocity);RotateQuaternion(arc,m_acceleration);Compose(m_orientation,arc,m_orientation);
|
||||
} else {
|
||||
m_velocity[0] = speed;
|
||||
m_velocity[1] = 0.0f;
|
||||
m_velocity[2] = 0.0f;
|
||||
std::fill(m_velocity,m_velocity+3,0.0f);
|
||||
}
|
||||
|
||||
if (m_data) {
|
||||
if (!m_data->attach.attach_file.empty()) {
|
||||
m_attachedEffectId = EffectManager::Instance().CreateEffect(m_data->attach.attach_file, m_position[0], m_position[1], m_position[2]);
|
||||
}
|
||||
if (m_data->attach.has_tail) {
|
||||
m_tail.Create(m_data->attach.tail_color, m_data->attach.tail_length, m_data->attach.tail_size, m_data->attach.rect_shape);
|
||||
if(m_data) {
|
||||
auto definitions=m_data->attachments;
|
||||
if(definitions.empty())definitions.push_back(m_data->attach);
|
||||
m_attachments.reserve(definitions.size());
|
||||
for(const auto& definition:definitions) {
|
||||
if(definition.type!=1)continue; // Source FLY_ATTACH_OBJECT is itself unimplemented.
|
||||
m_attachments.emplace_back();auto& entry=m_attachments.back();entry.data=definition;
|
||||
if(!definition.attach_file.empty())entry.effect=EffectManager::Instance().CreateEffect(definition.attach_file,m_position[0],m_position[1],m_position[2]);
|
||||
if(definition.has_tail)entry.tail.Create(definition.tail_color,definition.tail_length,definition.tail_size,definition.rect_shape);
|
||||
}
|
||||
}
|
||||
UpdateAttachments(0,0);
|
||||
}
|
||||
|
||||
FlyingInstance::~FlyingInstance() {
|
||||
if (m_attachedEffectId != 0) {
|
||||
EffectManager::Instance().DestroyEffectInstance(m_attachedEffectId);
|
||||
m_attachedEffectId = 0;
|
||||
}
|
||||
FlyingInstance::~FlyingInstance() {ClearAttachments();}
|
||||
void FlyingInstance::ClearAttachments() {
|
||||
for(auto& entry:m_attachments){if(entry.effect)EffectManager::Instance().DestroyEffectInstance(entry.effect);entry.effect=0;entry.tail.Clear();}
|
||||
}
|
||||
|
||||
bool FlyingInstance::Update(float dt, float currentTime) {
|
||||
if (!m_isAlive) return false;
|
||||
|
||||
m_age += dt;
|
||||
|
||||
// Move
|
||||
m_position[0] += m_velocity[0] * dt;
|
||||
m_position[1] += m_velocity[1] * dt;
|
||||
m_position[2] += m_velocity[2] * dt;
|
||||
|
||||
if (m_data) {
|
||||
m_velocity[0] += m_data->acceleration[0] * dt;
|
||||
m_velocity[1] += m_data->acceleration[1] * dt;
|
||||
m_velocity[2] += (m_data->acceleration[2] - m_data->gravity * 9.8f) * dt;
|
||||
|
||||
if (m_data->homing_flag) {
|
||||
float toTarget[3] = {
|
||||
m_targetPosition[0] - m_position[0],
|
||||
m_targetPosition[1] - m_position[1],
|
||||
m_targetPosition[2] - m_position[2]
|
||||
};
|
||||
float tLen = std::sqrt(toTarget[0]*toTarget[0] + toTarget[1]*toTarget[1] + toTarget[2]*toTarget[2]);
|
||||
if (tLen > 1e-4f) {
|
||||
float curSpeed = std::sqrt(m_velocity[0]*m_velocity[0] + m_velocity[1]*m_velocity[1] + m_velocity[2]*m_velocity[2]);
|
||||
float steer = std::min(1.0f, m_data->homing_max_angle * dt * 0.5f);
|
||||
m_velocity[0] = m_velocity[0] * (1.0f - steer) + (toTarget[0] / tLen) * curSpeed * steer;
|
||||
m_velocity[1] = m_velocity[1] * (1.0f - steer) + (toTarget[1] / tLen) * curSpeed * steer;
|
||||
m_velocity[2] = m_velocity[2] * (1.0f - steer) + (toTarget[2] / tLen) * curSpeed * steer;
|
||||
void FlyingInstance::UpdateAttachments(float dt,float currentTime) {
|
||||
float increment[4]={0,0,0,1};
|
||||
if(m_data)NativeYawPitchRoll(m_data->angular_velocity[1]*dt,m_data->angular_velocity[0]*dt,m_data->angular_velocity[2]*dt,increment);
|
||||
Compose(m_attachRotation,increment,m_attachRotation);
|
||||
float combined[4];Compose(m_attachRotation,m_orientation,combined);
|
||||
for(auto& entry:m_attachments) {
|
||||
const auto& definition=entry.data;float position[3];std::copy(m_position,m_position+3,position);
|
||||
const float* rotation=m_orientation;
|
||||
float amount=0;
|
||||
if(definition.fly_type!=1) {
|
||||
rotation=combined;
|
||||
if(definition.fly_type==2)amount=definition.distance;
|
||||
else if(definition.period>0 && std::isfinite(definition.period)) {
|
||||
const float phase=m_age/definition.period;
|
||||
if(definition.fly_type==3)amount=definition.amplitude*std::sin(phase*2*3.14159265358979323846f);
|
||||
else if(definition.fly_type==4)amount=definition.amplitude*std::exp(-phase)*phase;
|
||||
}
|
||||
const float roll=definition.roll*3.14159265358979323846f/180;
|
||||
float offset[3]={-std::sin(roll)*amount,-std::cos(roll)*amount,0};
|
||||
RotateQuaternion(rotation,offset);for(int k=0;k<3;++k)position[k]+=offset[k];
|
||||
}
|
||||
if(entry.effect){float matrix[16];QuaternionMatrix(rotation,position,matrix);EffectManager::Instance().SetEffectInstanceGlobalMatrix(entry.effect,matrix);}
|
||||
if(definition.has_tail)entry.tail.UpdateNewPosition(position[0],position[1],position[2],currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
float Length(const float* v) {return std::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);}
|
||||
// GrpMath SafeRotationNormalizedArc / FlyingInstance::AdjustDirectionForHoming.
|
||||
// The source clamps quaternion HALF-angle, once per update (not multiplied by dt).
|
||||
void Home(float* velocity,float* acceleration,const float* position,const float* target,float maxAngle,float* orientation) {
|
||||
float from[3],to[3];for(int k=0;k<3;++k){from[k]=velocity[k];to[k]=target[k]-position[k];}
|
||||
const float a=Length(from),b=Length(to);if(a==0 || b==0)return;
|
||||
float diff=0,dot=0;for(int k=0;k<3;++k){from[k]/=a;to[k]/=b;diff+=(from[k]-to[k])*(from[k]-to[k]);dot+=from[k]*to[k];}
|
||||
if(diff<0.001f)return;
|
||||
dot=std::clamp(dot,-1.0f,1.0f);
|
||||
float q[4]={0,1,0,0}; // native Z-axis becomes engine Y for exact antiparallel.
|
||||
if(dot>-1) {
|
||||
const float scale=std::sqrt((1+dot)*2);
|
||||
q[0]=(from[1]*to[2]-from[2]*to[1])/scale;
|
||||
q[1]=(from[2]*to[0]-from[0]*to[2])/scale;
|
||||
q[2]=(from[0]*to[1]-from[1]*to[0])/scale;q[3]=scale*0.5f;
|
||||
}
|
||||
if(maxAngle<=180) {
|
||||
const float angle=maxAngle*3.14159265358979323846f/180,c=std::cos(angle),sn=std::sin(angle);
|
||||
if(q[3]<=c && q[3]<=1-0.0001f) {
|
||||
const float factor=sn/std::sqrt(1-q[3]*q[3]);
|
||||
for(int k=0;k<3;++k)q[k]*=factor;q[3]=c;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_attachedEffectId != 0) {
|
||||
EffectManager::Instance().SetEffectInstancePosition(m_attachedEffectId, m_position[0], m_position[1], m_position[2]);
|
||||
RotateQuaternion(q,velocity);RotateQuaternion(q,acceleration);
|
||||
if(maxAngle>180)Compose(q,orientation,orientation);else Compose(orientation,q,orientation);
|
||||
}
|
||||
float SegmentDistanceSquared(const float* start,const float* end,const float* point) {
|
||||
float length=0,dot=0;for(int k=0;k<3;++k){const float d=end[k]-start[k];length+=d*d;dot+=(point[k]-start[k])*d;}
|
||||
const float t=length>0?std::clamp(dot/length,0.0f,1.0f):0;
|
||||
float distance=0;for(int k=0;k<3;++k){const float d=point[k]-start[k]-t*(end[k]-start[k]);distance+=d*d;}return distance;
|
||||
}
|
||||
// GameUtil DetectCollisionDynamicSphereVSDynamicSphere: closest points on
|
||||
// the two swept sphere-center segments, inclusive sum-of-radii boundary.
|
||||
float SegmentSegmentDistanceSquared(const float* a,const float* b,const float* c,const float* d) {
|
||||
float u[3],v[3],r[3];float uu=0,vv=0,uv=0,ur=0,vr=0;
|
||||
for(int k=0;k<3;++k){u[k]=b[k]-a[k];v[k]=d[k]-c[k];r[k]=a[k]-c[k];uu+=u[k]*u[k];vv+=v[k]*v[k];uv+=u[k]*v[k];ur+=u[k]*r[k];vr+=v[k]*r[k];}
|
||||
float s=0,t=0;
|
||||
if(uu==0 && vv==0)return SegmentDistanceSquared(a,b,c);
|
||||
if(uu==0)t=std::clamp(vr/vv,0.0f,1.0f);
|
||||
else if(vv==0)s=std::clamp(-ur/uu,0.0f,1.0f);
|
||||
else {
|
||||
const float denom=uu*vv-uv*uv;
|
||||
if(denom>0)s=std::clamp((uv*vr-ur*vv)/denom,0.0f,1.0f);
|
||||
t=(uv*s+vr)/vv;
|
||||
if(t<0){t=0;s=std::clamp(-ur/uu,0.0f,1.0f);}
|
||||
else if(t>1){t=1;s=std::clamp((uv-ur)/uu,0.0f,1.0f);}
|
||||
}
|
||||
m_tail.UpdateNewPosition(m_position[0], m_position[1], m_position[2], currentTime);
|
||||
float result=0;for(int k=0;k<3;++k){const float delta=r[k]+s*u[k]-t*v[k];result+=delta*delta;}return result;
|
||||
}
|
||||
|
||||
// Distance check to target
|
||||
float d[3] = {m_targetPosition[0] - m_position[0], m_targetPosition[1] - m_position[1], m_targetPosition[2] - m_position[2]};
|
||||
float dist = std::sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
|
||||
float hitThreshold = m_data ? std::max(m_data->bomb_range, 25.0f) : 25.0f;
|
||||
}
|
||||
|
||||
if (dist <= hitThreshold || m_age > 5.0f) {
|
||||
// Hit target
|
||||
m_isAlive = false;
|
||||
if (m_data && !m_data->bomb_effect.empty()) {
|
||||
EffectManager::Instance().CreateEffect(m_data->bomb_effect, m_position[0], m_position[1], m_position[2]);
|
||||
void FlyingInstance::Bomb() {
|
||||
if(m_data && !m_data->bomb_effect.empty())EffectManager::Instance().CreateEffect(m_data->bomb_effect,m_position[0],m_position[1],m_position[2]);
|
||||
}
|
||||
bool FlyingInstance::Explode(bool bomb) {
|
||||
m_isAlive=false;if(bomb)Bomb();
|
||||
ClearAttachments();
|
||||
return false;
|
||||
}
|
||||
bool FlyingInstance::Update(float dt,float currentTime,const TerrainHeightSource* terrain,const MapObjectManager* objects,const std::function<float(float,float)>& groundHeight) {
|
||||
if(!m_isAlive)return false;
|
||||
if(dt<0 || !std::isfinite(dt))return true;
|
||||
// CFlyTarget::NotifyTargetClear converts the object to its last sampled position.
|
||||
if(m_targetResolver && !m_targetResolver(m_targetPosition))m_targetResolver={};
|
||||
m_age+=dt;
|
||||
if(m_data && m_data->homing_flag && m_targetResolver && m_age>m_data->homing_start_time)
|
||||
Home(m_velocity,m_acceleration,m_position,m_targetPosition,m_data->homing_max_angle,m_orientation);
|
||||
float last[3];std::copy(m_position,m_position+3,last);
|
||||
float movement[3];
|
||||
for(int k=0;k<3;++k){m_velocity[k]+=m_acceleration[k]*dt;}
|
||||
if(m_data)m_velocity[1]+=m_data->gravity*dt;
|
||||
for(int k=0;k<3;++k){movement[k]=m_velocity[k]*dt;m_position[k]+=movement[k];}
|
||||
m_remainingRange-=Length(movement);
|
||||
UpdateAttachments(dt,currentTime);
|
||||
if(m_remainingRange<0) {if(m_rangeCallback)m_rangeCallback();return Explode(false);}
|
||||
const float radius=m_data?m_data->bomb_range:10;
|
||||
if((!m_targetResolver || !m_targetHit) && SegmentDistanceSquared(last,m_position,m_targetPosition)<radius*radius) {
|
||||
if(m_targetResolver) {
|
||||
m_targetHit=true;
|
||||
if(m_targetHitCallback)m_targetHitCallback();
|
||||
if(m_hitCallback)m_hitCallback(m_position);
|
||||
if(m_pierceCount) {--m_pierceCount;Bomb();return true;}
|
||||
} else if(m_hitCallback)m_hitCallback(m_position); // Existing native position callback.
|
||||
return Explode(true);
|
||||
}
|
||||
if(m_data && m_data->hit_on_another_monster) {
|
||||
auto& manager=NetworkActorManager::Instance();
|
||||
std::vector<uint32_t> vids;for(const auto& [vid,data]:manager.GetActorDict())vids.push_back(vid);
|
||||
std::sort(vids.begin(),vids.end()); // deterministic fallback; source culling traversal is not yet ported.
|
||||
const std::owner_less<std::weak_ptr<const uint8_t>> less;
|
||||
for(auto vid:vids) {
|
||||
auto instance=manager.GetActorInstance(vid);if(!instance)continue;
|
||||
const auto identity=instance->GetFlyCollisionIdentity();
|
||||
if(!less(identity,m_collision.owner) && !less(m_collision.owner,identity))continue;
|
||||
bool collided=false;
|
||||
for(const auto& sphere:instance->GetBodyCollisionSpheres()) {
|
||||
const float radius=10+sphere.radius;
|
||||
if(SegmentSegmentDistanceSquared(last,m_position,sphere.lastPosition.data(),sphere.position.data())<=radius*radius){collided=true;break;}
|
||||
}
|
||||
if(!collided)continue;
|
||||
// Source chooses its first colliding object BEFORE checking the hit set.
|
||||
// An already hit object can mask another candidate; retain that ordering.
|
||||
if(m_hitObjects.insert(identity).second) {
|
||||
if(m_collision.onAnotherTarget)m_collision.onAnotherTarget(vid);
|
||||
if(m_pierceCount){--m_pierceCount;Bomb();return true;}
|
||||
return Explode(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (m_attachedEffectId != 0) {
|
||||
EffectManager::Instance().DestroyEffectInstance(m_attachedEffectId);
|
||||
m_attachedEffectId = 0;
|
||||
}
|
||||
if(m_data && m_data->hit_on_background) {
|
||||
const bool ground=(groundHeight && groundHeight(m_position[0],m_position[2])>m_position[1])
|
||||
|| (!groundHeight && terrain && terrain->GetHeightAtWorld(m_position[0],m_position[2])>m_position[1]);
|
||||
if(ground || (objects && objects->CheckFlyingCollision(last,m_position,1))) {
|
||||
if(m_collision.onBackground)m_collision.onBackground();
|
||||
return Explode(true);
|
||||
}
|
||||
if (m_hitCallback) {
|
||||
m_hitCallback(m_position);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlyingInstance::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws) {
|
||||
if (!m_tail.IsEmpty()) {
|
||||
m_tail.BuildDrawCommands(viewMatrix, projMatrix, currentTime, outDraws);
|
||||
}
|
||||
void FlyingInstance::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws,const ViewFrustum* cachedFrustum,DepthState depthState) {
|
||||
for(auto& entry:m_attachments)if(!entry.tail.IsEmpty())entry.tail.BuildDrawCommands(viewMatrix,projMatrix,currentTime,outDraws,cachedFrustum,depthState);
|
||||
}
|
||||
|
||||
FlyingManager& FlyingManager::Instance() {
|
||||
@@ -315,13 +494,13 @@ bool FlyingManager::RegisterIndexedFlyData(uint32_t index, uint8_t type, const s
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t FlyingManager::CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb) {
|
||||
uint32_t FlyingManager::CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb, FlyTargetResolver targetResolver, std::function<void()> targetHitCb,FlyCollisionCallbacks collision) {
|
||||
uint32_t id = 0;
|
||||
if (!RegisterFlyingData(filename, &id)) return 0;
|
||||
return CreateFlyingInstance(id, startPos, targetPos, std::move(hitCb));
|
||||
return CreateFlyingInstance(id, startPos, targetPos, std::move(hitCb), std::move(targetResolver), std::move(targetHitCb),std::move(collision));
|
||||
}
|
||||
|
||||
uint32_t FlyingManager::CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb) {
|
||||
uint32_t FlyingManager::CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb, FlyTargetResolver targetResolver, std::function<void()> targetHitCb,FlyCollisionCallbacks collision) {
|
||||
auto it = m_dataCache.find(flyId);
|
||||
if (it == m_dataCache.end()) {
|
||||
auto indexedIt = m_indexedFlyData.find(flyId);
|
||||
@@ -331,22 +510,24 @@ uint32_t FlyingManager::CreateFlyingInstance(uint32_t flyId, const float* startP
|
||||
}
|
||||
if (it == m_dataCache.end()) return 0;
|
||||
|
||||
auto inst = std::make_shared<FlyingInstance>(it->second, startPos, targetPos);
|
||||
auto inst = std::make_shared<FlyingInstance>(it->second, startPos, targetPos, std::move(targetResolver));
|
||||
if (hitCb) inst->SetHitCallback(std::move(hitCb));
|
||||
inst->SetTargetHitCallback(std::move(targetHitCb));
|
||||
inst->SetCollisionCallbacks(std::move(collision));
|
||||
m_instances.push_back(inst);
|
||||
return static_cast<uint32_t>(m_instances.size());
|
||||
}
|
||||
|
||||
void FlyingManager::CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos) {
|
||||
void FlyingManager::CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos, FlyTargetResolver targetResolver) {
|
||||
auto it = m_indexedFlyData.find(index);
|
||||
if (it == m_indexedFlyData.end()) {
|
||||
std::cerr << "[AVA2 TraceError] CFlyingManager::CreateIndexedFly(dwIndex=" << index << ") - Not registered index" << std::endl;
|
||||
return;
|
||||
}
|
||||
auto frandom = [](float lo, float hi) { return lo + (hi - lo) * (static_cast<float>(std::rand()) / static_cast<float>(RAND_MAX)); };
|
||||
using eter::frandom;
|
||||
switch (it->second.type) {
|
||||
case INDEX_FLY_TYPE_NORMAL:
|
||||
CreateFlyingInstance(it->second.flyId, startPos, endTargetPos);
|
||||
CreateFlyingInstance(it->second.flyId, startPos, endTargetPos, {}, targetResolver);
|
||||
break;
|
||||
case INDEX_FLY_TYPE_FIRE_CRACKER: {
|
||||
constexpr float DEG = 3.14159265358979323846f / 180.0f;
|
||||
@@ -363,15 +544,15 @@ void FlyingManager::CreateIndexedFly(uint32_t index, const float* startPos, floa
|
||||
}
|
||||
case INDEX_FLY_TYPE_AUTO_FIRE: {
|
||||
const float start[3] = {startPos[0], startPos[1] + 100.0f, startPos[2]};
|
||||
CreateFlyingInstance(it->second.flyId, start, endTargetPos);
|
||||
CreateFlyingInstance(it->second.flyId, start, endTargetPos, {}, targetResolver);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlyingManager::Update(float dt, float currentTime) {
|
||||
void FlyingManager::Update(float dt,float currentTime,const TerrainHeightSource* terrain,const MapObjectManager* objects,const std::function<float(float,float)>& groundHeight) {
|
||||
for (auto it = m_instances.begin(); it != m_instances.end();) {
|
||||
if (!(*it)->Update(dt, currentTime)) {
|
||||
if (!(*it)->Update(dt,currentTime,terrain,objects,groundHeight)) {
|
||||
it = m_instances.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@@ -379,10 +560,10 @@ void FlyingManager::Update(float dt, float currentTime) {
|
||||
}
|
||||
}
|
||||
|
||||
void FlyingManager::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws) {
|
||||
void FlyingManager::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws,const ViewFrustum* cachedFrustum,DepthState depthState) {
|
||||
for (const auto& inst : m_instances) {
|
||||
if (inst && inst->IsAlive()) {
|
||||
inst->BuildDrawCommands(viewMatrix, projMatrix, currentTime, outDraws);
|
||||
inst->BuildDrawCommands(viewMatrix, projMatrix, currentTime, outDraws,cachedFrustum,depthState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
namespace ava2 {
|
||||
class TerrainHeightSource;
|
||||
class MapObjectManager;
|
||||
|
||||
struct FlyingAttachData {
|
||||
int type = 1;
|
||||
@@ -20,6 +23,7 @@ struct FlyingAttachData {
|
||||
float tail_length = 0.2f;
|
||||
float tail_size = 8.0f;
|
||||
bool rect_shape = false;
|
||||
float roll=0,distance=0,period=1,amplitude=0;
|
||||
};
|
||||
|
||||
class FlyingData {
|
||||
@@ -37,35 +41,67 @@ public:
|
||||
bool homing_flag = false;
|
||||
float homing_max_angle = 3.0f;
|
||||
float range = 10000.0f;
|
||||
float homing_start_time = 0;
|
||||
int pierce_count = 0;
|
||||
bool maintain_parallel = false;
|
||||
float roll_angle=0, cone_angle=0;
|
||||
bool spreading=false;
|
||||
bool hit_on_background=false,hit_on_another_monster=false;
|
||||
|
||||
FlyingAttachData attach;
|
||||
FlyingAttachData attach; // Legacy first attachment access.
|
||||
std::vector<FlyingAttachData> attachments;
|
||||
float angular_velocity[3]={};
|
||||
};
|
||||
|
||||
using FlyTargetResolver = std::function<bool(float*)>; // false: object disappeared; keep last position.
|
||||
|
||||
struct FlyCollisionCallbacks {
|
||||
std::weak_ptr<const uint8_t> owner;
|
||||
std::function<void(uint32_t)> onAnotherTarget;
|
||||
std::function<void()> onBackground;
|
||||
};
|
||||
|
||||
class FlyingInstance {
|
||||
public:
|
||||
FlyingInstance(std::shared_ptr<FlyingData> data, const float* startPos, const float* targetPos);
|
||||
FlyingInstance(std::shared_ptr<FlyingData> data, const float* startPos, const float* targetPos, FlyTargetResolver targetResolver = {});
|
||||
~FlyingInstance();
|
||||
|
||||
bool Update(float dt, float currentTime);
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws);
|
||||
bool Update(float dt,float currentTime,const TerrainHeightSource* terrain=nullptr,const MapObjectManager* objects=nullptr,const std::function<float(float,float)>& groundHeight={});
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws, const ViewFrustum* cachedFrustum = nullptr, DepthState depthState = {});
|
||||
|
||||
bool IsAlive() const { return m_isAlive; }
|
||||
const float* GetPosition() const { return m_position; }
|
||||
|
||||
void SetCollisionCallbacks(FlyCollisionCallbacks callbacks) { m_collision=std::move(callbacks); }
|
||||
void SetTargetHitCallback(std::function<void()> cb) { m_targetHitCallback=std::move(cb); }
|
||||
void SetRangeCallback(std::function<void()> cb) { m_rangeCallback=std::move(cb); }
|
||||
void SetHitCallback(std::function<void(const float*)> cb) { m_hitCallback = std::move(cb); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<FlyingData> m_data;
|
||||
bool m_isAlive = true;
|
||||
float m_age = 0.0f;
|
||||
float m_remainingRange = 0;
|
||||
int m_pierceCount = 0;
|
||||
bool m_targetHit = false;
|
||||
FlyTargetResolver m_targetResolver;
|
||||
float m_acceleration[3] = {};
|
||||
FlyCollisionCallbacks m_collision;
|
||||
std::set<std::weak_ptr<const uint8_t>,std::owner_less<std::weak_ptr<const uint8_t>>> m_hitObjects;
|
||||
void Bomb();
|
||||
bool Explode(bool bomb);
|
||||
|
||||
float m_position[3] = {0.0f, 0.0f, 0.0f};
|
||||
float m_velocity[3] = {0.0f, 0.0f, 0.0f};
|
||||
float m_targetPosition[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
||||
uint32_t m_attachedEffectId = 0;
|
||||
FlyTrace m_tail;
|
||||
struct Attachment {FlyingAttachData data;uint32_t effect=0;FlyTrace tail;};
|
||||
std::vector<Attachment> m_attachments;
|
||||
float m_orientation[4]={0,0,0,1},m_attachRotation[4]={0,0,0,1};
|
||||
void UpdateAttachments(float dt,float currentTime);
|
||||
void ClearAttachments();
|
||||
std::function<void(const float*)> m_hitCallback;
|
||||
std::function<void()> m_targetHitCallback, m_rangeCallback;
|
||||
};
|
||||
|
||||
class FlyingManager {
|
||||
@@ -102,15 +138,15 @@ public:
|
||||
|
||||
bool RegisterFlyingData(const std::string& filename, uint32_t* outId = nullptr);
|
||||
bool RegisterIndexedFlyData(uint32_t index, uint8_t type, const std::string& filename);
|
||||
uint32_t CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
||||
uint32_t CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr);
|
||||
uint32_t CreateFlyingInstance(uint32_t flyId, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr, FlyTargetResolver targetResolver = {}, std::function<void()> targetHitCb = {}, FlyCollisionCallbacks collision = {});
|
||||
uint32_t CreateFlyingInstance(const std::string& filename, const float* startPos, const float* targetPos, std::function<void(const float*)> hitCb = nullptr, FlyTargetResolver targetResolver = {}, std::function<void()> targetHitCb = {}, FlyCollisionCallbacks collision = {});
|
||||
|
||||
// CFlyingManager::CreateIndexedFly: start = the start actor's position (engine x, height, z) and
|
||||
// rotation (native degrees), end = the end actor's fly-target position.
|
||||
void CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos);
|
||||
void CreateIndexedFly(uint32_t index, const float* startPos, float startRotation, const float* endTargetPos, FlyTargetResolver targetResolver = {});
|
||||
|
||||
void Update(float dt, float currentTime);
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws);
|
||||
void Update(float dt,float currentTime,const TerrainHeightSource* terrain=nullptr,const MapObjectManager* objects=nullptr,const std::function<float(float,float)>& groundHeight={});
|
||||
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, float currentTime, std::vector<Render3DDraw>& outDraws, const ViewFrustum* cachedFrustum = nullptr, DepthState depthState = {});
|
||||
void DeleteAllInstances();
|
||||
|
||||
size_t GetActiveInstanceCount() const { return m_instances.size(); }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "eter_render/Gr2ModelRenderer.h"
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
@@ -18,6 +19,9 @@ namespace {
|
||||
|
||||
void RefreshState(SNetworkActorData& actor, uint32_t motion, bool loop);
|
||||
|
||||
// InstanceBaseMovement.cpp: both raw packet speeds clamp >1100 to zero.
|
||||
float PacketSpeedRatio(uint32_t speed) { return speed<=1100 ? float(speed)/100.0f : 0.0f; }
|
||||
|
||||
// AVA2 InstanceBase.cpp SHORSE::Create / __AttachHorseSaddle: mounts are
|
||||
// separate actors, and the rider's main model follows their "saddle" bone.
|
||||
void ConfigureMount(SNetworkActorData& data) {
|
||||
@@ -31,6 +35,8 @@ void ConfigureMount(SNetworkActorData& data) {
|
||||
if (mount->SetRace(data.m_dwMountVnum)) {
|
||||
mount->SetShape(0);mount->SetScale(rider.GetScale());
|
||||
mount->SetYaw(rider.GetYaw());mount->SetPosition(rider.GetX(),rider.GetY(),rider.GetZ());
|
||||
mount->SetMoveAnimationSpeed(data.m_dwMovSpd<=1100 ? float(data.m_dwMovSpd)/100 : 0);
|
||||
mount->SetAttackSpeed(PacketSpeedRatio(data.m_dwAtkSpd));
|
||||
mount->PlayMotion(MotionType::Wait,true);
|
||||
data.m_pMountInstance=std::move(mount);
|
||||
}
|
||||
@@ -102,7 +108,7 @@ void RefreshState(SNetworkActorData& actor, uint32_t motion, bool loop) {
|
||||
}
|
||||
int mode = MODE_GENERAL;
|
||||
const bool pickAxe = actor.m_awPart[RaceData::PART_WEAPON] >= 29101 && actor.m_awPart[RaceData::PART_WEAPON] <= 29110;
|
||||
if (actor.m_bType == 7) { // IsPoly
|
||||
if (inst.IsPolymorph()) {
|
||||
mode = MODE_GENERAL;
|
||||
} else if (actor.m_awPart[RaceData::PART_MAIN] == 201 || inst.GetShape() == 201) { // IsWearingDress
|
||||
mode = MODE_WEDDING_DRESS;
|
||||
@@ -135,7 +141,7 @@ void RefreshState(SNetworkActorData& actor, uint32_t motion, bool loop) {
|
||||
}
|
||||
inst.SetMotionMode(mode);
|
||||
inst.SetMountingHorse(mounting);
|
||||
inst.SetAttackSpeed(float(actor.m_dwAtkSpd > 0 ? actor.m_dwAtkSpd : 100) / 100.0f);
|
||||
inst.SetAttackSpeed(PacketSpeedRatio(actor.m_dwAtkSpd));
|
||||
if (!inst.InterceptMotionIndex(motion, loop)) inst.PlayMotion(static_cast<MotionType>(motion), loop);
|
||||
}
|
||||
|
||||
@@ -416,9 +422,9 @@ void NetworkActorManager::SetArmor(SNetworkActorData& actor, uint32_t armor) {
|
||||
SetShape(actor, armor);
|
||||
}
|
||||
|
||||
// CInstanceBase::SetShape (IsPoly() never holds for network actors in the port).
|
||||
// CInstanceBase::SetShape: poly renders shape zero but retains requested part metadata.
|
||||
void NetworkActorManager::SetShape(SNetworkActorData& actor, uint32_t shape, float specular) {
|
||||
if (actor.m_pActorInstance) actor.m_pActorInstance->SetShape(shape, specular);
|
||||
if (actor.m_pActorInstance) actor.m_pActorInstance->SetShape(actor.m_pActorInstance->IsPolymorph()?0:shape,specular);
|
||||
actor.m_awPart[RaceData::PART_MAIN] = shape;
|
||||
}
|
||||
|
||||
@@ -432,7 +438,7 @@ void NetworkActorManager::SetHair(SNetworkActorData& actor, uint32_t hair) {
|
||||
|
||||
// CInstanceBase::SetWeapon(eWeapon, eArrow). Weapon refine / shining effects are not ported.
|
||||
bool NetworkActorManager::SetWeapon(SNetworkActorData& actor, uint32_t weapon, uint32_t arrow) {
|
||||
const uint32_t shape = actor.m_pActorInstance ? actor.m_pActorInstance->GetShape() : actor.m_awPart[RaceData::PART_MAIN];
|
||||
const uint32_t shape = actor.m_awPart[RaceData::PART_MAIN];
|
||||
if (shape >= 100 && shape <= 103) return false; // __IsShapeAnimalWear
|
||||
actor.m_awPart[RaceData::PART_ARROW_TYPE] = arrow;
|
||||
// __IsChangableWeapon: the wedding dress (shape 201) only holds the bouquets.
|
||||
@@ -454,7 +460,7 @@ bool NetworkActorManager::SetWeapon(SNetworkActorData& actor, uint32_t weapon, u
|
||||
bool NetworkActorManager::ChangeArmor(SNetworkActorData& actor, uint32_t armor) {
|
||||
uint32_t shape;
|
||||
ArmorVnumToShape(armor, &shape);
|
||||
if (!actor.m_pActorInstance || actor.m_pActorInstance->GetShape() == shape) return false;
|
||||
if (!actor.m_pActorInstance || actor.m_awPart[RaceData::PART_MAIN] == shape) return false;
|
||||
const uint32_t hair = actor.m_awPart[RaceData::PART_HAIR];
|
||||
const uint32_t sash = actor.m_awPart[RaceData::PART_SASH];
|
||||
const uint32_t weapon = actor.m_awPart[RaceData::PART_WEAPON];
|
||||
@@ -623,9 +629,11 @@ void NetworkActorManager::AppendActor(const SNetworkActorData& data) {
|
||||
// Instantiate 3D ActorInstance
|
||||
auto actor = std::make_shared<ActorInstance>();
|
||||
actor->SetVID(data.m_dwVID);
|
||||
actor->SetActorType(data.m_bType);
|
||||
actor->SetName(data.m_stName);
|
||||
actor->SetYaw(data.m_fRot);
|
||||
actor->SetSpeed(static_cast<float>(data.m_dwMovSpd > 0 ? data.m_dwMovSpd : 100));
|
||||
actor->SetSpeed(data.m_dwMovSpd<=1100 ? float(data.m_dwMovSpd) : 0);
|
||||
actor->SetMoveAnimationSpeed(data.m_dwMovSpd<=1100 ? float(data.m_dwMovSpd)/100 : 0);
|
||||
actor->SetScale(0.8f);
|
||||
|
||||
// World position: Metin2 coordinates X, Y(Z in 3D), Z(Y in 3D)
|
||||
@@ -697,6 +705,7 @@ void NetworkActorManager::AppendActor(const SNetworkActorData& data) {
|
||||
}
|
||||
|
||||
void NetworkActorManager::RemoveActor(uint32_t vid) {
|
||||
CancelDualEmotions(vid);m_deferredMoves.erase(vid);
|
||||
auto it = m_actors.find(vid);
|
||||
if (it != m_actors.end()) {
|
||||
if (IsMainActorVID(vid)) {
|
||||
@@ -739,8 +748,9 @@ void NetworkActorManager::UpdateActor(const SNetworkUpdateActorData& data) {
|
||||
actorData.m_dwMovSpd = data.m_dwMovSpd;
|
||||
actorData.m_dwAtkSpd = data.m_dwAtkSpd;
|
||||
if (actorData.m_pActorInstance)
|
||||
actorData.m_pActorInstance->SetAttackSpeed(float(data.m_dwAtkSpd > 0 ? data.m_dwAtkSpd : 100) / 100.0f);
|
||||
actorData.m_pActorInstance->SetAttackSpeed(PacketSpeedRatio(data.m_dwAtkSpd));
|
||||
ConfigureMount(actorData);
|
||||
if(actorData.m_pMountInstance) actorData.m_pMountInstance->SetAttackSpeed(PacketSpeedRatio(data.m_dwAtkSpd));
|
||||
|
||||
// CNetworkActorManager::UpdateActor: ChangeArmor, ChangeWeapon(weapon, arrow), ChangeHair, ChangeSash.
|
||||
ChangeArmor(actorData, data.m_dwArmor);
|
||||
@@ -748,9 +758,10 @@ void NetworkActorManager::UpdateActor(const SNetworkUpdateActorData& data) {
|
||||
ChangeHair(actorData, data.m_dwHair);
|
||||
if (actorData.m_pActorInstance) {
|
||||
actorData.m_pActorInstance->SetSleep((data.m_affectFlags[0] & (1u<<5))!=0);
|
||||
if (data.m_dwMovSpd > 0) {
|
||||
actorData.m_pActorInstance->SetSpeed(static_cast<float>(data.m_dwMovSpd));
|
||||
}
|
||||
const float moveSpeed=data.m_dwMovSpd<=1100 ? float(data.m_dwMovSpd) : 0;
|
||||
actorData.m_pActorInstance->SetSpeed(moveSpeed);
|
||||
actorData.m_pActorInstance->SetMoveAnimationSpeed(moveSpeed/100);
|
||||
if(actorData.m_pMountInstance)actorData.m_pMountInstance->SetMoveAnimationSpeed(moveSpeed/100);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 64; ++i) {
|
||||
@@ -781,6 +792,9 @@ void NetworkActorManager::MoveActor(const SNetworkMoveActorData& data) {
|
||||
if (it == m_actors.end()) return;
|
||||
|
||||
auto& actorData = it->second;
|
||||
if(IsEmotionLocked(data.m_dwVID) || (actorData.m_pActorInstance && actorData.m_pActorInstance->IsActingEmotion())) {
|
||||
m_deferredMoves[data.m_dwVID].push_back(data);return;
|
||||
}
|
||||
actorData.m_lDstX = data.m_lPosX;
|
||||
actorData.m_lDstY = data.m_lPosY;
|
||||
actorData.m_fRot = data.m_fRot;
|
||||
@@ -857,11 +871,96 @@ void NetworkActorManager::SetActorOwner(uint32_t ownerVID, uint32_t victimVID) {
|
||||
}
|
||||
}
|
||||
|
||||
// InstanceBaseMotion::ActDualEmotion / InstanceBase::__ProcessFunctionEmotion.
|
||||
bool NetworkActorManager::IsEmotionLocked(uint32_t vid) const {
|
||||
for(const auto& [source,pair]:m_dualEmotions) if(source==vid || pair.target==vid) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkActorManager::IsEmotionProcessing() const {return IsEmotionLocked(m_mainVID);}
|
||||
|
||||
void NetworkActorManager::CancelDualEmotions(uint32_t vid) {
|
||||
for(auto it=m_dualEmotions.begin();it!=m_dualEmotions.end();) {
|
||||
if(it->first!=vid && it->second.target!=vid) {++it;continue;}
|
||||
for(uint32_t member:{it->first,it->second.target}) {
|
||||
auto* data=GetActorData(member);
|
||||
if(!data || !data->m_pActorInstance) continue;
|
||||
data->m_pActorInstance->SetEmotionMovementLocked(false);
|
||||
data->m_isMoving=false;data->m_pActorInstance->ClearMoveTarget();data->m_pActorInstance->StopMoving();
|
||||
data->m_pActorInstance->SetLoopMotionIndex(RaceData::NAME_WAIT);
|
||||
}
|
||||
it=m_dualEmotions.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkActorManager::BeginDualEmotion(uint32_t src,uint32_t dst,uint16_t lowMotion,uint16_t highMotion) {
|
||||
auto first=GetActorInstance(src),second=GetActorInstance(dst);
|
||||
if(src==dst || !first || !second || IsEmotionLocked(src) || IsEmotionLocked(dst)) return false;
|
||||
float dx=first->GetX()-second->GetX(),dz=first->GetZ()-second->GetZ();
|
||||
const float distance=std::hypot(dx,dz);
|
||||
if(!std::isfinite(distance)) return false;
|
||||
if(distance>0.001f) {dx/=distance;dz/=distance;}
|
||||
else {const float yaw=first->GetYaw()*3.14159265358979323846f/180;dx=-std::sin(yaw);dz=-std::cos(yaw);}
|
||||
for(uint32_t member:{src,dst}) {
|
||||
auto& data=*GetActorData(member);auto& actor=*data.m_pActorInstance;
|
||||
data.m_isMoving=false;actor.ClearMoveTarget();actor.StopMoving();actor.SetEmotionMovementLocked(true);
|
||||
if(actor.GetCurrentMotion()!=MotionType::Wait) actor.SetLoopMotionIndex(RaceData::NAME_WAIT);
|
||||
}
|
||||
const uint32_t now=m_now?NowMSec():(m_emotionNow?m_emotionNow():NowMSec());
|
||||
m_dualEmotions.emplace(src,DualEmotion{dst,now+500,second->GetX()+dx*100,second->GetZ()+dz*100,lowMotion,highMotion});
|
||||
return true;
|
||||
}
|
||||
|
||||
void NetworkActorManager::ProcessDualEmotions(float dt,const TerrainHeightSource* terrain) {
|
||||
if(!std::isfinite(dt) || dt<0) return;
|
||||
const uint32_t now=m_now?NowMSec():(m_emotionNow?m_emotionNow():NowMSec());
|
||||
for(auto it=m_dualEmotions.begin();it!=m_dualEmotions.end();) {
|
||||
auto* source=GetActorData(it->first);auto* target=GetActorData(it->second.target);
|
||||
if(!source || !target || !source->m_pActorInstance || !target->m_pActorInstance) {
|
||||
const uint32_t vid=it->first;++it;CancelDualEmotions(vid);continue;
|
||||
}
|
||||
auto& pair=it->second;auto& first=*source->m_pActorInstance;auto& second=*target->m_pActorInstance;
|
||||
if(std::bit_cast<int32_t>(now-pair.due)<0) {++it;continue;}
|
||||
const float dx=pair.x-first.GetX(),dz=pair.z-first.GetZ(),distance=std::hypot(dx,dz);
|
||||
if(!pair.walking && distance>100) {pair.walking=true;first.PlayMotion(MotionType::Run,true);}
|
||||
const float step=std::max(0.0f,first.GetSpeed())*dt;
|
||||
if(pair.walking && distance>step && distance>0.001f) {
|
||||
const float x=first.GetX()+dx/distance*step,z=first.GetZ()+dz/distance*step;
|
||||
first.SetPosition(x,terrain?terrain->GetHeightAtWorld(x,z):first.GetY(),z);
|
||||
first.SetYaw(std::fmod(std::atan2(dx,dz)*180/3.14159265358979323846f+360,360));
|
||||
source->m_lCurX=int32_t(x);source->m_lCurY=int32_t(z);source->m_lCurZ=int32_t(first.GetY());
|
||||
if(IsMainActorVID(it->first)) {m_mainPosX=source->m_lCurX;m_mainPosY=source->m_lCurY;}
|
||||
++it;continue;
|
||||
}
|
||||
first.SetPosition(pair.x,terrain?terrain->GetHeightAtWorld(pair.x,pair.z):first.GetY(),pair.z);
|
||||
first.StopMoving();second.StopMoving();first.SetEmotionMovementLocked(false);second.SetEmotionMovementLocked(false);
|
||||
source->m_isMoving=target->m_isMoving=false;
|
||||
source->m_lCurX=int32_t(pair.x);source->m_lCurY=int32_t(pair.z);source->m_lCurZ=int32_t(first.GetY());
|
||||
if(IsMainActorVID(it->first)) {m_mainPosX=source->m_lCurX;m_mainPosY=source->m_lCurY;}
|
||||
const float turnX=second.GetX()-first.GetX(),turnZ=second.GetZ()-first.GetZ();
|
||||
const float yaw=std::fmod(std::atan2(turnX,turnZ)*180/3.14159265358979323846f+360,360);
|
||||
first.SetYaw(yaw);second.SetYaw(std::fmod(yaw+180,360));
|
||||
// MAKELONG(low,high): source plays HIWORD + destination job, target LOWORD + source job.
|
||||
first.InterceptMotionIndex(pair.high+uint32_t(RaceToJob(int(second.GetRace()))),false);
|
||||
second.InterceptMotionIndex(pair.low+uint32_t(RaceToJob(int(first.GetRace()))),false);
|
||||
it=m_dualEmotions.erase(it); // EndEmotionProcess occurs when both motions begin.
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkActorManager::Update(float dt, const TerrainHeightSource* terrain) {
|
||||
ProcessDualEmotions(dt,terrain);
|
||||
for(auto it=m_deferredMoves.begin();it!=m_deferredMoves.end();) {
|
||||
auto actor=GetActorInstance(it->first);
|
||||
if(!actor) {it=m_deferredMoves.erase(it);continue;}
|
||||
if(IsEmotionLocked(it->first) || actor->IsActingEmotion()) {++it;continue;}
|
||||
const auto move=it->second.front();it->second.pop_front();
|
||||
if(it->second.empty()) it=m_deferredMoves.erase(it);else ++it;
|
||||
MoveActor(move);
|
||||
}
|
||||
for (auto& [vid, actorData] : m_actors) {
|
||||
if (!actorData.m_pActorInstance) continue;
|
||||
// CActorInstance::IsPC (m_eActorType == TYPE_PC): .mss frequency check and splash rules.
|
||||
actorData.m_pActorInstance->SetIsPC(actorData.m_bType == TYPE_PC);
|
||||
actorData.m_pActorInstance->SetActorType(actorData.m_bType);
|
||||
|
||||
if (actorData.m_isMoving) {
|
||||
float curX = static_cast<float>(actorData.m_lCurX);
|
||||
@@ -874,7 +973,7 @@ void NetworkActorManager::Update(float dt, const TerrainHeightSource* terrain) {
|
||||
float dist = std::sqrt(dx * dx + dz * dz);
|
||||
|
||||
float speed = actorData.m_pActorInstance->GetSpeed();
|
||||
if (speed <= 0.0f) speed = 250.0f;
|
||||
speed = std::max(0.0f,speed);
|
||||
float step = speed * dt;
|
||||
|
||||
if (dist <= step || dist < 1.0f) {
|
||||
@@ -937,8 +1036,10 @@ void NetworkActorManager::Update(float dt, const TerrainHeightSource* terrain) {
|
||||
}
|
||||
|
||||
void NetworkActorManager::Clear() {
|
||||
m_dualEmotions.clear();m_deferredMoves.clear();
|
||||
// CPythonCharacterManager::DeleteAllInstances: each CInstanceBase::Destroy detaches its text tail.
|
||||
for (auto& [vid, actorData] : m_actors) {
|
||||
if(actorData.m_pActorInstance)actorData.m_pActorInstance->SetEmotionMovementLocked(false);
|
||||
DestroyAttachedEffects(actorData);
|
||||
TextTailManager::Instance().DeleteCharacterTextTail(vid);
|
||||
}
|
||||
@@ -1119,8 +1220,8 @@ std::vector<Render3DDraw> NetworkActorManager::BuildDrawCommands(float animTime,
|
||||
void NetworkActorManager::SetSash(uint32_t vid, uint32_t sash) {
|
||||
auto* actor = GetActorData(vid);
|
||||
if (!actor) return;
|
||||
// IsPC() && IsPoly() can never both hold: both test the same instance type.
|
||||
if (actor->m_bType != TYPE_PC && actor->m_dwRace > 8) return;
|
||||
if (actor->m_bType==TYPE_PC && actor->m_pActorInstance && actor->m_pActorInstance->IsPolymorph()) return;
|
||||
|
||||
actor->m_dwSash = sash;
|
||||
const uint32_t vnum = sash + 85000;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
namespace ava2 {
|
||||
@@ -67,7 +68,6 @@ struct SNetworkActorData {
|
||||
|
||||
uint8_t m_duelMode = DUEL_NONE; // CInstanceBase::SetDuelMode
|
||||
uint8_t m_walkMode = 0; // CInstanceBase::SetRunMode/SetWalkMode (WALKMODE_RUN=0)
|
||||
bool m_isFishing = false; // IsFishing(): FISHING_WAIT/FISHING_REACT motion stand-in
|
||||
bool m_isMoving = false;
|
||||
float m_moveElapsed = 0.0f;
|
||||
uint32_t m_dwEmoticonTime = 0; // CInstanceBase::m_dwEmoticonTime (ELTimer_GetMSec)
|
||||
@@ -243,6 +243,9 @@ public:
|
||||
void ChangeGVG(uint32_t srcGuild, uint32_t dstGuild); // CPythonCharacterManager::ChangeGVG
|
||||
|
||||
void Update(float dt, const TerrainHeightSource* terrain = nullptr);
|
||||
bool BeginDualEmotion(uint32_t src, uint32_t dst, uint16_t lowMotion, uint16_t highMotion);
|
||||
bool IsEmotionProcessing() const;
|
||||
void SetEmotionTimeSource(uint32_t (*now)()) { m_emotionNow=now; }
|
||||
void Clear();
|
||||
// CPythonCharacterManager::Destroy: DeleteAllInstances + __Initialize (point effects too).
|
||||
void Destroy();
|
||||
@@ -313,6 +316,13 @@ private:
|
||||
uint32_t m_adwPointEffect[255] = {}; // POINT_MAX_NUM
|
||||
uint32_t (*m_now)() = nullptr;
|
||||
uint32_t NowMSec() const;
|
||||
uint32_t (*m_emotionNow)() = nullptr;
|
||||
struct DualEmotion { uint32_t target, due; float x,z; uint16_t low,high; bool walking=false; };
|
||||
std::map<uint32_t,DualEmotion> m_dualEmotions;
|
||||
std::map<uint32_t,std::deque<SNetworkMoveActorData>> m_deferredMoves;
|
||||
bool IsEmotionLocked(uint32_t vid) const;
|
||||
void CancelDualEmotions(uint32_t vid);
|
||||
void ProcessDualEmotions(float dt,const TerrainHeightSource* terrain);
|
||||
uint32_t AttachEffectByID(SNetworkActorData& actor, const std::string& bone, uint32_t crc, float offsetHeight);
|
||||
static void DestroyAttachedEffects(SNetworkActorData& actor);
|
||||
static std::pair<uint32_t,uint32_t> PVPKey(uint32_t src, uint32_t dst) { return src>dst?std::make_pair(dst,src):std::make_pair(src,dst); }
|
||||
|
||||
@@ -89,6 +89,7 @@ void PythonNetworkStream::StartGame() {
|
||||
void PythonNetworkStream::ResetConnection() {
|
||||
m_recvBuffer.clear();m_unportedPackets.clear();m_unknownPacketQuit=false;m_isObserverMode=m_bMobileFlag=false;std::memset(m_lastPacket,0,sizeof(m_lastPacket));ClearSendQueue();m_startGameRequested=m_refreshInventory=m_refreshStatus=m_refreshSkill=m_refreshCharacter=m_refreshShopSearch=m_stopGamePhase=m_warpRequested=m_selectRequested=false;m_selectLeftover.clear();
|
||||
m_refreshGuildInfo=m_refreshGuildBoard=m_refreshGuildMember=m_refreshGuildCombo=m_refreshGuildSkill=m_refreshGuildGrade=m_refreshMessenger=false;
|
||||
m_refreshSafebox=m_refreshMall=false;
|
||||
m_guildID=0;
|
||||
m_changeServerTime=m_changeClientTime=0;m_dungeonDestination={};
|
||||
ResetPlayerState();NetworkActorManager::Instance().Clear();
|
||||
@@ -243,6 +244,8 @@ bool PythonNetworkStream::ProcessRecvData() {
|
||||
if(m_refreshCharacter) { m_refreshCharacter=false;inventory_callback(m_phaseWindows[5],"RefreshCharacter",nullptr); }
|
||||
if(m_refreshInventory) { m_refreshInventory=false;inventory_callback(m_phaseWindows[5],"RefreshInventory",nullptr); }
|
||||
if(m_refreshSkill) {m_refreshSkill=false;inventory_callback(m_phaseWindows[5],"RefreshSkill",nullptr);}
|
||||
if(m_refreshSafebox) {m_refreshSafebox=false;inventory_callback(m_phaseWindows[5],"RefreshSafebox",nullptr);}
|
||||
if(m_refreshMall) {m_refreshMall=false;inventory_callback(m_phaseWindows[5],"RefreshMall",nullptr);}
|
||||
if(m_refreshStatus) { m_refreshStatus=false;inventory_callback(m_phaseWindows[5],"RefreshStatus",nullptr); }
|
||||
if(m_refreshMessenger) { m_refreshMessenger=false;inventory_callback(m_phaseWindows[5],"RefreshMessenger",nullptr); }
|
||||
if(m_refreshGuildInfo) { m_refreshGuildInfo=false;inventory_callback(m_phaseWindows[5],"RefreshGuildInfoPage",nullptr); }
|
||||
@@ -928,7 +931,7 @@ bool PythonNetworkStream::RecvPointChange() {
|
||||
namespace {
|
||||
template<class Packet> TItemData item_data(const Packet& p) {
|
||||
TItemData data{};data.vnum=p.vnum;data.count=p.count;
|
||||
std::copy_n(p.alSockets,ITEM_SOCKET_SLOT_MAX_NUM,data.alSockets);
|
||||
std::memcpy(data.alSockets,p.alSockets,sizeof(data.alSockets));
|
||||
std::copy_n(p.aAttr,ITEM_ATTRIBUTE_SLOT_MAX_NUM,data.aAttr);
|
||||
std::copy_n(p.randomAttr,GLOVE_ATTR_MAX_NUM,data.randomAttr);
|
||||
std::copy_n(p.name,25,data.name);data.name[24]=0;
|
||||
@@ -961,7 +964,7 @@ bool PythonNetworkStream::RecvItemUpdatePacket() {
|
||||
TPacketGCItemUpdate p;
|
||||
if(!Read(sizeof(p),&p)) return false;
|
||||
auto data=GetPlayerItemData(p.Cell.window_type,p.Cell.cell);data.count=p.count;
|
||||
std::copy_n(p.alSockets,ITEM_SOCKET_SLOT_MAX_NUM,data.alSockets);
|
||||
std::memcpy(data.alSockets,p.alSockets,sizeof(data.alSockets));
|
||||
std::copy_n(p.aAttr,ITEM_ATTRIBUTE_SLOT_MAX_NUM,data.aAttr);
|
||||
std::copy_n(p.randomAttr,GLOVE_ATTR_MAX_NUM,data.randomAttr);
|
||||
std::copy_n(p.name,25,data.name);data.name[24]=0;
|
||||
@@ -1051,7 +1054,7 @@ bool PythonNetworkStream::RecvCreateFlyPacket() {
|
||||
const float startPos[3] = {startActor->GetX(), startActor->GetY(), startActor->GetZ()};
|
||||
float endPos[3];
|
||||
endActor->GetFlyTargetCenter(endPos);
|
||||
FlyingManager::Instance().CreateIndexedFly(p.bType, startPos, startActor->GetYaw(), endPos);
|
||||
FlyingManager::Instance().CreateIndexedFly(p.bType, startPos, startActor->GetYaw(), endPos, endActor->CaptureFlyTargetResolver());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1292,6 +1295,27 @@ bool PythonNetworkStream::SendChatPacket(const std::string& input,uint8_t type)
|
||||
bool PythonNetworkStream::SendWhisperPacket(const std::string& name,const std::string& text) {
|
||||
auto bytes=wire::whisper(name,text);Send(bytes.data(),bytes.size());return true;
|
||||
}
|
||||
bool PythonNetworkStream::SendMobileMessagePacket(const std::string& name,const std::string& text) {
|
||||
auto bytes=wire::mobile_message(name,text);
|
||||
if(bytes.empty()) return false;
|
||||
Send(bytes.data(),bytes.size());return true;
|
||||
}
|
||||
bool PythonNetworkStream::Send67AttrPacket(int material,int support,int support_pos,int item_pos) {
|
||||
auto bytes=wire::attribute67(material,support,support_pos,item_pos);Send(bytes.data(),bytes.size());return true;
|
||||
}
|
||||
bool PythonNetworkStream::Send67AttrClosePacket() {
|
||||
uint8_t header=HEADER_CG_CLOSE_67_ATTR;Send(&header,1);return true;
|
||||
}
|
||||
bool PythonNetworkStream::SendCalendarPacket(uint8_t subheader,int day,int event,const std::string& start,const std::string& end) {
|
||||
if(!main_actor_can_act(m_dwMainActorVID)) return true;
|
||||
auto bytes=wire::calendar(subheader,day,event,start,end);Send(bytes.data(),bytes.size());return true;
|
||||
}
|
||||
bool PythonNetworkStream::SendCatchKingPacket(uint8_t subheader,int argument) {
|
||||
auto bytes=wire::catch_king(subheader,argument);Send(bytes.data(),bytes.size());return true;
|
||||
}
|
||||
void PythonNetworkStream::OpenCatchKing() {
|
||||
inventory_callback(m_phaseWindows[5],"StartCatchKing",nullptr);
|
||||
}
|
||||
|
||||
bool PythonNetworkStream::SendItemUsePacket(uint8_t window, uint16_t cell) {
|
||||
if(!main_actor_can_act(m_dwMainActorVID)) return true;
|
||||
@@ -1603,6 +1627,7 @@ bool PythonNetworkStream::RecvSafeBoxSetPacket() {
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
auto item=item_data(p);item.flags=p.flags;item.anti_flags=p.anti_flags;
|
||||
CPythonSafeBox::Instance().SetItemData(p.Cell.cell, item);
|
||||
m_refreshSafebox=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1610,12 +1635,14 @@ bool PythonNetworkStream::RecvSafeBoxDelPacket() {
|
||||
TPacketGCItemDel p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
CPythonSafeBox::Instance().DelItemData(p.pos);
|
||||
m_refreshSafebox=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PythonNetworkStream::RecvSafeBoxWrongPasswordPacket() {
|
||||
TPacketGCSafeboxWrongPassword p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
PyCallClassMemberFunc(m_phaseWindows[5],"OnSafeBoxError",Py_BuildValue("()"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1623,6 +1650,7 @@ bool PythonNetworkStream::RecvSafeBoxSizePacket() {
|
||||
TPacketGCSafeboxSize p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
CPythonSafeBox::Instance().OpenSafeBox(p.bSize);
|
||||
inventory_callback(m_phaseWindows[5],"OpenSafeboxWindow",Py_BuildValue("(i)",p.bSize));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1630,6 +1658,7 @@ bool PythonNetworkStream::RecvSafeBoxMoneyChangePacket() {
|
||||
TPacketGCSafeboxMoneyChange p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
CPythonSafeBox::Instance().SetMoney(p.dwMoney);
|
||||
inventory_callback(m_phaseWindows[5],"RefreshSafeboxMoney",nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1637,6 +1666,7 @@ bool PythonNetworkStream::RecvMallOpenPacket() {
|
||||
TPacketGCSafeboxSize p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
CPythonSafeBox::Instance().OpenMall(p.bSize);
|
||||
inventory_callback(m_phaseWindows[5],"OpenMallWindow",Py_BuildValue("(i)",p.bSize));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1645,6 +1675,7 @@ bool PythonNetworkStream::RecvMallSetPacket() {
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
auto item=item_data(p);item.flags=p.flags;item.anti_flags=p.anti_flags;
|
||||
CPythonSafeBox::Instance().SetMallItemData(p.Cell.cell, item);
|
||||
m_refreshMall=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1652,6 +1683,7 @@ bool PythonNetworkStream::RecvMallDelPacket() {
|
||||
TPacketGCItemDel p;
|
||||
if (!Read(sizeof(p), &p)) return false;
|
||||
CPythonSafeBox::Instance().DelMallItemData(p.pos);
|
||||
m_refreshMall=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
// ── Phase Management ──
|
||||
void SetPhaseWindow(int phase, PyObject* poWindow);
|
||||
void ClearPhaseWindow(int phase, PyObject* poWindow);
|
||||
PyObject* GetGamePhaseWindow() const { return m_phaseWindows[5]; } // Borrowed, PHASE_WINDOW_GAME.
|
||||
void SetHandler(PyObject* poHandler);
|
||||
void SetPhase(EPhase phase);
|
||||
EPhase GetPhase() const { return m_phase; }
|
||||
@@ -86,6 +87,12 @@ public:
|
||||
bool SendAttackPacket(uint8_t type, uint32_t victimVID);
|
||||
bool SendChatPacket(const std::string& text, uint8_t type = CHAT_TYPE_TALKING);
|
||||
bool SendWhisperPacket(const std::string& name, const std::string& text);
|
||||
bool SendMobileMessagePacket(const std::string& name,const std::string& text);
|
||||
bool Send67AttrPacket(int material,int support,int support_pos,int item_pos);
|
||||
bool Send67AttrClosePacket();
|
||||
bool SendCalendarPacket(uint8_t subheader,int day=0,int event=0,const std::string& start="",const std::string& end="");
|
||||
bool SendCatchKingPacket(uint8_t subheader,int argument=0);
|
||||
void OpenCatchKing();
|
||||
bool SendItemUsePacket(uint8_t window, uint16_t cell);
|
||||
bool SendItemMovePacket(uint8_t srcWindow, uint16_t srcCell, uint8_t dstWindow, uint16_t dstCell, uint32_t count);
|
||||
bool SendItemPickUpPacket(uint32_t vid);
|
||||
@@ -264,6 +271,7 @@ private:
|
||||
bool m_refreshGuildCombo=false,m_refreshGuildSkill=false,m_refreshGuildGrade=false,m_refreshMessenger=false;
|
||||
bool m_refreshShopSearch=false;
|
||||
bool m_refreshInventory=false,m_refreshStatus=false,m_refreshCharacter=false;
|
||||
bool m_refreshSafebox=false,m_refreshMall=false;
|
||||
std::vector<bool> m_sendSequence;
|
||||
// Handshake/HandshakeOK/HybridCrypt return from GamePhase() before the refresh block.
|
||||
bool m_stopGamePhase=false;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// Port of AVA2 UserInterface/PythonNetworkStreamCommand.cpp (ServerCommand / SplitToken)
|
||||
// and the emoticon helpers from PythonNetworkStreamPhaseGame.cpp / PythonNetworkStream.cpp.
|
||||
// Commands that only forward to the game window are 1:1; commands that need actor/effect
|
||||
// state the port does not have yet (emotions, StoneDetect, stamina) are TraceError'd and
|
||||
// listed in docs/WINDOWS-PARITY.md.
|
||||
// Commands forward to the game window or actor/effect systems. Dual-emotion
|
||||
// blend/collision and complete TCP scheduling limits are tracked in the parity docs.
|
||||
#include "PythonNetworkStream.h"
|
||||
#include "ava2_text_file.h"
|
||||
#include "shared/common/PythonUtils.h"
|
||||
#include "NetworkActorManager.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "eter_effect/EffectManager.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
@@ -169,17 +170,30 @@ void PythonNetworkStream::ServerCommand(const std::string& command) {
|
||||
} else if (!strcasecmp(szCmd, "StoneDetect")) {
|
||||
if (4 != TokenVector.size()) { strangeCount(); return; }
|
||||
// Needs CInstanceBase pixel position + CEffectManager compass effects.
|
||||
TraceError("ServerCommand StoneDetect not ported (effect): " + command);
|
||||
const auto* actor=NetworkActorManager::Instance().GetActorData(uint32_t(atoi(arg(1))));
|
||||
if(!actor || !actor->m_pActorInstance) {TraceError("StoneDetect: missing actor");return;}
|
||||
const uint8_t distance=uint8_t(atoi(arg(2)));
|
||||
const float angle=std::fmod(540.0f-float(atof(arg(3))),360.0f);
|
||||
if(distance>3 || !std::isfinite(angle)) {TraceError("StoneDetect: invalid distance/angle");return;}
|
||||
static const char* filenames[]={
|
||||
"d:/ymir work/effect/etc/firecracker/find_out.mse",
|
||||
"d:/ymir work/effect/etc/compass/appear_small.mse",
|
||||
"d:/ymir work/effect/etc/compass/appear_middle.mse",
|
||||
"d:/ymir work/effect/etc/compass/appear_large.mse"};
|
||||
const auto& instance=*actor->m_pActorInstance;
|
||||
EffectManager::Instance().CreateEffect(filenames[distance],instance.GetX(),instance.GetY(),instance.GetZ(),angle);
|
||||
} else if (!strcasecmp(szCmd, "StartStaminaConsume")) {
|
||||
if (3 != TokenVector.size()) { strangeCount(); return; }
|
||||
TraceError("ServerCommand StartStaminaConsume not ported (player stamina): " + command);
|
||||
StartPlayerStaminaConsume(uint32_t(atoi(arg(1))),uint32_t(atoi(arg(2))));
|
||||
} else if (!strcasecmp(szCmd, "StopStaminaConsume")) {
|
||||
if (2 != TokenVector.size()) { strangeCount(); return; }
|
||||
TraceError("ServerCommand StopStaminaConsume not ported (player stamina): " + command);
|
||||
StopPlayerStaminaConsume(uint32_t(atoi(arg(1))));
|
||||
} else if (!strcasecmp(szCmd, "sms")) {
|
||||
m_bMobileFlag = true;
|
||||
RefreshPlayerMobile();
|
||||
} else if (!strcasecmp(szCmd, "nosms")) {
|
||||
m_bMobileFlag = false;
|
||||
RefreshPlayerMobile();
|
||||
} else if (!strcasecmp(szCmd, "mobile_auth")) {
|
||||
call("OnMobileAuthority", Py_BuildValue("()"));
|
||||
} else if (!strcasecmp(szCmd, "messenger_auth")) {
|
||||
@@ -198,7 +212,7 @@ void PythonNetworkStream::ServerCommand(const std::string& command) {
|
||||
auto pInstance1 = NetworkActorManager::Instance().GetActorInstance(iVID1);
|
||||
auto pInstance2 = NetworkActorManager::Instance().GetActorInstance(iVID2);
|
||||
if (pInstance1 && pInstance2)
|
||||
pInstance1->ActDualEmotion(*pInstance2, CRaceMotionData::NAME_FRENCH_KISS_START, CRaceMotionData::NAME_FRENCH_KISS_START);
|
||||
NetworkActorManager::Instance().BeginDualEmotion(uint32_t(iVID1),uint32_t(iVID2),CRaceMotionData::NAME_FRENCH_KISS_START,CRaceMotionData::NAME_FRENCH_KISS_START);
|
||||
}
|
||||
} else if (!strcasecmp(szCmd, "kiss")) {
|
||||
if (TokenVector.size() >= 3) {
|
||||
@@ -207,7 +221,7 @@ void PythonNetworkStream::ServerCommand(const std::string& command) {
|
||||
auto pInstance1 = NetworkActorManager::Instance().GetActorInstance(iVID1);
|
||||
auto pInstance2 = NetworkActorManager::Instance().GetActorInstance(iVID2);
|
||||
if (pInstance1 && pInstance2)
|
||||
pInstance1->ActDualEmotion(*pInstance2, CRaceMotionData::NAME_KISS_START, CRaceMotionData::NAME_KISS_START);
|
||||
NetworkActorManager::Instance().BeginDualEmotion(uint32_t(iVID1),uint32_t(iVID2),CRaceMotionData::NAME_KISS_START,CRaceMotionData::NAME_KISS_START);
|
||||
}
|
||||
} else if (!strcasecmp(szCmd, "slap")) {
|
||||
if (TokenVector.size() >= 3) {
|
||||
@@ -216,7 +230,7 @@ void PythonNetworkStream::ServerCommand(const std::string& command) {
|
||||
auto pInstance1 = NetworkActorManager::Instance().GetActorInstance(iVID1);
|
||||
auto pInstance2 = NetworkActorManager::Instance().GetActorInstance(iVID2);
|
||||
if (pInstance1 && pInstance2)
|
||||
pInstance1->ActDualEmotion(*pInstance2, CRaceMotionData::NAME_SLAP_HURT_START, CRaceMotionData::NAME_SLAP_HIT_START);
|
||||
NetworkActorManager::Instance().BeginDualEmotion(uint32_t(iVID1),uint32_t(iVID2),CRaceMotionData::NAME_SLAP_HURT_START,CRaceMotionData::NAME_SLAP_HIT_START);
|
||||
}
|
||||
} else if (!strcasecmp(szCmd, "clap")) {
|
||||
if (TokenVector.size() >= 2) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// ENABLE_CHANNEL_CHANGE, ENABLE_ANTI_EXP, ENABLE_SASH_SYSTEM, ENABLE_KINGDOMS_WAR,
|
||||
// ENABLE_MINI_GAME_CATCH_KING, ENABLE_DEFENSAWESHIP; no LOCALE_SERVICE_GLOBAL, no XTrap).
|
||||
// Wire reads, Python callbacks and player/party state are 1:1. Work that needs systems the
|
||||
// port does not have yet (minimap/atlas marks, background target effects, fly targets,
|
||||
// port does not have yet (minimap/atlas marks, fly targets,
|
||||
// motion queues, guild symbols, hybrid-crypt packs, anticheat, sash/bank/chest-drop native
|
||||
// stores) is consumed and listed in docs/WINDOWS-PARITY.md.
|
||||
#include "PythonNetworkStream.h"
|
||||
@@ -25,6 +25,9 @@
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "python_native_modules.h"
|
||||
#include "python_minimap.h"
|
||||
#include "python_background.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include <cmath>
|
||||
#include "nonplayer_data.h"
|
||||
#include "python_event_manager.h"
|
||||
#include "item_sound.h"
|
||||
@@ -298,7 +301,7 @@ bool PythonNetworkStream::RecvSwitchbotPacket() {
|
||||
if(update.slot<6) {
|
||||
SetPlayerItemCount(11,update.slot,update.count);
|
||||
auto item=GetPlayerItemData(11,update.slot);
|
||||
std::copy_n(update.alSockets,ITEM_SOCKET_SLOT_MAX_NUM,item.alSockets);
|
||||
std::memcpy(item.alSockets,update.alSockets,sizeof(item.alSockets));
|
||||
std::copy_n(update.aAttr,ITEM_ATTRIBUTE_SLOT_MAX_NUM,item.aAttr);SetPlayerItemData(11,update.slot,item);
|
||||
}
|
||||
PyCallClassMemberFunc(m_phaseWindows[5],"RefreshSwitchbotItem",Py_BuildValue("(i)",int(update.slot)));
|
||||
@@ -754,16 +757,29 @@ bool PythonNetworkStream::RecvFishing() {
|
||||
SNetworkActorData* inst=nullptr;
|
||||
if(p.subheader!=FISHING_SUBHEADER_GC_FISH) {
|
||||
inst=NetworkActorManager::Instance().GetActorData(p.info);
|
||||
if(!inst) return true;
|
||||
if(!inst || !inst->m_pActorInstance) return true;
|
||||
}
|
||||
// Fishing motions/emoticons are not ported; m_isFishing mirrors IsFishing().
|
||||
auto* actor=inst ? inst->m_pActorInstance.get() : nullptr;
|
||||
// AVA2 InstanceBaseMotion: queue one-shot transitions followed by wait loops.
|
||||
switch(p.subheader) {
|
||||
case FISHING_SUBHEADER_GC_START: inst->m_isFishing=true;break;
|
||||
case FISHING_SUBHEADER_GC_STOP: if(inst->m_isFishing) inst->m_isFishing=false;break;
|
||||
case FISHING_SUBHEADER_GC_REACT: break;
|
||||
case FISHING_SUBHEADER_GC_SUCCESS: inst->m_isFishing=false;break;
|
||||
case FISHING_SUBHEADER_GC_START:
|
||||
actor->SetYaw(float(p.dir)*5);
|
||||
actor->PushMotionIndex(RaceData::NAME_FISHING_THROW,false);
|
||||
actor->PushMotionIndex(RaceData::NAME_FISHING_WAIT,true);break;
|
||||
case FISHING_SUBHEADER_GC_STOP:
|
||||
if(actor->IsFishing()) {actor->InterceptMotionIndex(RaceData::NAME_FISHING_STOP,false);actor->PushMotionIndex(RaceData::NAME_WAIT,true);}
|
||||
break;
|
||||
case FISHING_SUBHEADER_GC_REACT:
|
||||
if(actor->IsFishing()) {
|
||||
NetworkActorManager::Instance().SetEmoticon(p.info,11); // EMOTICON_FISH
|
||||
actor->PushMotionIndex(RaceData::NAME_FISHING_REACT,false);
|
||||
actor->PushMotionIndex(RaceData::NAME_FISHING_WAIT,true);
|
||||
}
|
||||
break;
|
||||
case FISHING_SUBHEADER_GC_SUCCESS:
|
||||
actor->InterceptMotionIndex(RaceData::NAME_FISHING_CATCH,false);actor->PushMotionIndex(RaceData::NAME_WAIT,true);break;
|
||||
case FISHING_SUBHEADER_GC_FAIL:
|
||||
inst->m_isFishing=false;
|
||||
actor->InterceptMotionIndex(RaceData::NAME_FISHING_FAIL,false);actor->PushMotionIndex(RaceData::NAME_WAIT,true);
|
||||
if(inst==MainInstance()) PyCallClassMemberFunc(game,"OnFishingFailure",Py_BuildValue("()"));
|
||||
break;
|
||||
case FISHING_SUBHEADER_GC_FISH: {
|
||||
@@ -773,7 +789,7 @@ bool PythonNetworkStream::RecvFishing() {
|
||||
auto* main=MainInstance();
|
||||
if(!main) return true;
|
||||
constexpr int ITEM_TYPE_FISH=12;
|
||||
PyCallClassMemberFunc(game,main->m_isFishing?"OnFishingNotify":"OnFishingSuccess",Py_BuildValue("(is)",int(type==ITEM_TYPE_FISH),name.c_str()));
|
||||
PyCallClassMemberFunc(game,(main->m_pActorInstance && main->m_pActorInstance->IsFishing())?"OnFishingNotify":"OnFishingSuccess",Py_BuildValue("(is)",int(type==ITEM_TYPE_FISH),name.c_str()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -911,14 +927,17 @@ bool PythonNetworkStream::RecvTargetUpdatePacket() {
|
||||
TPacketGCTargetUpdate p;
|
||||
if(!Read(sizeof(p),&p)) return false;
|
||||
CPythonMiniMap::Instance().UpdateTarget(p.lID,p.lX,p.lY);
|
||||
return true; // background CreateTargetEffect(Shop) (bType 5): not ported.
|
||||
if(p.bType==5) CPythonBackground::Instance().CreateTargetEffectShop(p.lID,long(p.lX),long(p.lY));
|
||||
else CPythonBackground::Instance().CreateTargetEffect(p.lID,long(p.lX),long(p.lY));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PythonNetworkStream::RecvTargetDeletePacket() {
|
||||
TPacketGCTargetDelete p;
|
||||
if(!Read(sizeof(p),&p)) return false;
|
||||
CPythonMiniMap::Instance().DeleteTarget(p.lID);
|
||||
return true; // background DeleteTargetEffect: not ported.
|
||||
CPythonBackground::Instance().DeleteTargetEffect(p.lID);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PythonNetworkStream::RecvTargetCreatePacket() {
|
||||
@@ -932,11 +951,13 @@ bool PythonNetworkStream::RecvTargetCreatePacket() {
|
||||
bool PythonNetworkStream::RecvTargetCreatePacketNew() {
|
||||
TPacketGCTargetCreateNew p;
|
||||
if(!Read(sizeof(p),&p)) return false;
|
||||
// CREATE_TARGET_TYPE_LOCATION (1); WJ_COMBAT_ZONE is off. Background CreateTargetEffect: not ported.
|
||||
// CREATE_TARGET_TYPE_LOCATION (1); WJ_COMBAT_ZONE is off.
|
||||
if(p.byType==1)
|
||||
CPythonMiniMap::Instance().CreateTarget(p.lID,text(p.szTargetName).c_str());
|
||||
else
|
||||
else {
|
||||
CPythonMiniMap::Instance().CreateTarget(p.lID,text(p.szTargetName).c_str(),p.dwVID);
|
||||
CPythonBackground::Instance().CreateTargetEffect(p.lID,p.dwVID);
|
||||
}
|
||||
PyCallClassMemberFunc(m_phaseWindows[5],"BINARY_OpenAtlasWindow",Py_BuildValue("()"));
|
||||
return true;
|
||||
}
|
||||
@@ -971,7 +992,16 @@ bool PythonNetworkStream::RecvLovePointUpdatePacket() {
|
||||
bool PythonNetworkStream::RecvDigMotionPacket() {
|
||||
TPacketGCDigMotion p;
|
||||
if(!Read(sizeof(p),&p)) return false;
|
||||
return true; // NEW_LookAtDestInstance + PushOnceMotion(NAME_DIG): motion queue not ported.
|
||||
auto& actors=NetworkActorManager::Instance();
|
||||
auto actor=actors.GetActorInstance(p.vid);
|
||||
if(!actor) return true;
|
||||
auto target=actors.GetActorInstance(p.target_vid);
|
||||
if(target) {
|
||||
const float dx=target->GetX()-actor->GetX(),dz=target->GetZ()-actor->GetZ();
|
||||
if(dx!=0 || dz!=0) actor->SetYaw(std::fmod(std::atan2(dx,dz)*180.0f/3.14159265358979323846f+360,360));
|
||||
}
|
||||
for(unsigned count=0;count<p.count;++count) actor->PushMotionIndex(RaceData::NAME_DIG,false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PythonNetworkStream::RecvAccountBankPacket() {
|
||||
|
||||
@@ -16,7 +16,7 @@ void CPythonSafeBox::OpenSafeBox(int iSize) {
|
||||
m_dwMoney = 0;
|
||||
m_itemInstanceVector.clear();
|
||||
if (iSize > 0) {
|
||||
m_itemInstanceVector.resize(SAFEBOX_PAGE_SIZE * iSize);
|
||||
m_itemInstanceVector.resize(SAFEBOX_SLOT_X_COUNT * iSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ bool CPythonSafeBox::GetItemDataPtr(uint32_t dwSlotIndex, TItemData** ppInstance
|
||||
void CPythonSafeBox::OpenMall(int iSize) {
|
||||
m_mallItemInstanceVector.clear();
|
||||
if (iSize > 0) {
|
||||
m_mallItemInstanceVector.resize(SAFEBOX_PAGE_SIZE * iSize);
|
||||
m_mallItemInstanceVector.resize(SAFEBOX_SLOT_X_COUNT * iSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
~CPythonSafeBox() = default;
|
||||
|
||||
// Safebox (Personal Bank/Warehouse)
|
||||
// iSize is the server row count, not a number of 45-slot pages.
|
||||
void OpenSafeBox(int iSize);
|
||||
void SetItemData(uint32_t dwSlotIndex, const TItemData& rItemData);
|
||||
void DelItemData(uint32_t dwSlotIndex);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "src/eter_resource/ResourceManager.h"
|
||||
#include <filesystem>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
@@ -168,6 +169,7 @@ bool ActorInstance::SetRace(uint32_t race) {
|
||||
m_raceData = nullptr;
|
||||
return false;
|
||||
}
|
||||
m_bodyPreviousCenters.clear();
|
||||
m_race = race;
|
||||
m_raceData = raceData;
|
||||
|
||||
@@ -194,7 +196,7 @@ bool ActorInstance::SetRace(uint32_t race) {
|
||||
for (auto name : kNames) {
|
||||
const auto* motions = raceData->GetMotions(name);
|
||||
if (!motions || motions->empty()) continue;
|
||||
// The percent-weighted random pick of CActorInstance is not ported: the first entry plays.
|
||||
// Preload a fallback path; playback resolves the active mode and weighted variant.
|
||||
std::string gr2 = ReadMotionFileName(motions->front().fileName);
|
||||
if (!gr2.empty()) RegisterMotion(static_cast<MotionType>(name), gr2);
|
||||
}
|
||||
@@ -204,6 +206,7 @@ bool ActorInstance::SetRace(uint32_t race) {
|
||||
|
||||
void ActorInstance::SetShape(uint32_t shape, float specular) {
|
||||
(void)specular; // SMaterialData specular / sphere map: not rendered by the port yet.
|
||||
m_bodyPreviousCenters.clear();
|
||||
m_shape = shape;
|
||||
RaceData* raceData = RaceManager::Instance().GetRaceDataPointer(m_race);
|
||||
if (!raceData) return;
|
||||
@@ -377,6 +380,10 @@ void ActorInstance::RegisterMotion(MotionType type, const std::string& motionGr2
|
||||
}
|
||||
|
||||
bool ActorInstance::PlayMotion(MotionType type, bool loop) {
|
||||
return PlayMotionResolved(type,loop,true);
|
||||
}
|
||||
|
||||
bool ActorInstance::PlayMotionResolved(MotionType type, bool loop, bool randomVariants) {
|
||||
if (!m_model) return false;
|
||||
auto it = m_motionPaths.find(type);
|
||||
if (it == m_motionPaths.end()) {
|
||||
@@ -385,14 +392,26 @@ bool ActorInstance::PlayMotion(MotionType type, bool loop) {
|
||||
it = m_motionPaths.find(MotionType::Attack);
|
||||
}
|
||||
}
|
||||
std::string motionPath;
|
||||
std::string motionPath,selectedMsa;
|
||||
// Resolve the active mode at playback time; SetRace/armor rebuilds must not
|
||||
// silently replace riding motions with GENERAL standing/walking motions.
|
||||
if (m_raceData && m_motionMode != 1) {
|
||||
if (m_raceData) {
|
||||
uint16_t actualMode = uint16_t(m_motionMode);
|
||||
if (m_raceData->GetMotionKey(actualMode, uint16_t(type), &actualMode)) {
|
||||
const auto* entries = m_raceData->GetMotions(actualMode, uint32_t(type));
|
||||
if (entries && !entries->empty()) motionPath = ReadMotionFileName(entries->front().fileName);
|
||||
if (entries && !entries->empty()) {
|
||||
size_t selected=0;
|
||||
if(randomVariants && entries->size()>1) {
|
||||
int percentage=int((m_motionRandom?m_motionRandom():uint32_t(std::rand()))%100);
|
||||
for(size_t i=0;i<entries->size();++i) {
|
||||
percentage-=uint8_t((*entries)[i].percent);
|
||||
if(percentage<0) {selected=i;break;}
|
||||
}
|
||||
}
|
||||
selectedMsa=(*entries)[selected].fileName;
|
||||
motionPath=ReadMotionFileName(selectedMsa);
|
||||
if(motionPath.empty()) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (motionPath.empty()) {
|
||||
@@ -406,6 +425,7 @@ bool ActorInstance::PlayMotion(MotionType type, bool loop) {
|
||||
if (!loaded) return false;
|
||||
|
||||
m_currentMotion = type;
|
||||
m_boundMotionMsa = std::move(selectedMsa);
|
||||
m_motionFile = resolved;
|
||||
m_animTime = 0.0f;
|
||||
m_motionDuration = std::max(0.1f, m_model->GetAnimationDuration());
|
||||
@@ -431,11 +451,7 @@ void ActorInstance::OnMotionBound(uint32_t type) {
|
||||
m_pendingLoopCount = 0;
|
||||
// ActorInstanceMotion.cpp __BindMotionData: the race motion data of the new motion.
|
||||
m_curRaceMotion = nullptr;
|
||||
uint16_t keyMode;
|
||||
if (m_raceData && m_raceData->GetMotionKey(uint16_t(m_motionMode), uint16_t(type), &keyMode)) {
|
||||
const auto* entries = m_raceData->GetMotions(keyMode, type);
|
||||
if (entries && !entries->empty()) m_curRaceMotion = GetRaceMotionData(entries->front().fileName);
|
||||
}
|
||||
if(!m_boundMotionMsa.empty()) m_curRaceMotion=GetRaceMotionData(m_boundMotionMsa);
|
||||
// SetMotionLoopCount(__GetLoopCount()) for once motions; NEW_UseSkill sets the skill's count.
|
||||
m_loopCount = (!m_loopMotion && m_curRaceMotion) ? m_curRaceMotion->loopCount : 0;
|
||||
if (skillLoopCount > 0) m_loopCount = skillLoopCount;
|
||||
@@ -443,7 +459,7 @@ void ActorInstance::OnMotionBound(uint32_t type) {
|
||||
if (m_flyEventHandler.onSetFlyTarget && IsNeedFlyTargetMotion()) m_flyEventHandler.onSetFlyTarget();
|
||||
if (!m_curRaceMotion) {
|
||||
m_comboIndex = 0;
|
||||
m_motionSpeed = 1.0f;
|
||||
m_motionSpeed = (m_currentMotion==MotionType::Walk || m_currentMotion==MotionType::Run) ? m_moveAnimationSpeed : 1.0f;
|
||||
return;
|
||||
}
|
||||
if (m_curRaceMotion->isAttackingMotion) m_hitDataMap.clear();
|
||||
@@ -452,7 +468,8 @@ void ActorInstance::OnMotionBound(uint32_t type) {
|
||||
const bool attackMotion = m_curRaceMotion->isAttackingMotion &&
|
||||
(m_curRaceMotion->motionType == RaceMotionData::MOTION_TYPE_NORMAL ||
|
||||
m_curRaceMotion->motionType == RaceMotionData::MOTION_TYPE_COMBO);
|
||||
m_motionSpeed = attackMotion ? m_atkSpd : 1.0f;
|
||||
m_motionSpeed = (m_currentMotion==MotionType::Walk || m_currentMotion==MotionType::Run)
|
||||
? m_moveAnimationSpeed : (attackMotion ? m_atkSpd : 1.0f);
|
||||
}
|
||||
|
||||
bool ActorInstance::IsWaiting() const {
|
||||
@@ -460,12 +477,48 @@ bool ActorInstance::IsWaiting() const {
|
||||
return index == RaceData::NAME_WAIT || index == RaceData::NAME_INTRO_WAIT || index == RaceData::NAME_STOP;
|
||||
}
|
||||
|
||||
void ActorInstance::SetAttackSpeed(float ratio) {
|
||||
// AVA2 stores zero too. A speed change applies when the next attack binds;
|
||||
// unlike SetMoveSpeed it does not restart or retime the current motion.
|
||||
if(std::isfinite(ratio) && ratio>=0) m_atkSpd=ratio;
|
||||
}
|
||||
|
||||
void ActorInstance::SetMoveAnimationSpeed(float ratio) {
|
||||
if(!std::isfinite(ratio) || ratio<0 || ratio==m_moveAnimationSpeed) return;
|
||||
m_moveAnimationSpeed=ratio;
|
||||
// Original SetMoveSpeed restarts the current move loop at the new ratio.
|
||||
if(m_currentMotion==MotionType::Walk || m_currentMotion==MotionType::Run) PlayMotion(m_currentMotion,true);
|
||||
}
|
||||
|
||||
bool ActorInstance::IsEmotionMovementLocked() const {
|
||||
const uint32_t index=uint32_t(m_currentMotion);
|
||||
return m_emotionMovementLocked || (index>=RaceData::NAME_KISS_START && index<RaceData::NAME_SLAP_HURT_START+4);
|
||||
}
|
||||
|
||||
bool ActorInstance::IsActingEmotion() const {
|
||||
const uint32_t index=uint32_t(m_currentMotion);
|
||||
return (index>=RaceData::NAME_KISS_START && index<RaceData::NAME_KISS_START+4)
|
||||
|| (index>=RaceData::NAME_FRENCH_KISS_START && index<RaceData::NAME_FRENCH_KISS_START+4);
|
||||
}
|
||||
|
||||
bool ActorInstance::IsFishing() const {
|
||||
const uint32_t index=uint32_t(m_currentMotion);
|
||||
return m_curRaceMotion && (index==RaceData::NAME_FISHING_WAIT || index==RaceData::NAME_FISHING_REACT);
|
||||
}
|
||||
|
||||
bool ActorInstance::IsUsingSkill() const {
|
||||
const uint32_t index = uint32_t(m_currentMotion);
|
||||
return (index >= RaceData::NAME_SKILL && index < RaceData::NAME_SKILL_END) ||
|
||||
(index >= RaceData::NAME_SPECIAL_1 && index <= RaceData::NAME_SPECIAL_6);
|
||||
}
|
||||
|
||||
bool ActorInstance::CanUseSkill() const {
|
||||
if(!CanAct()) return false;
|
||||
const uint32_t motion=uint32_t(m_currentMotion);
|
||||
if(motion>=RaceData::NAME_FISHING_THROW && motion<=RaceData::NAME_FISHING_FAIL) return true;
|
||||
return !IsUsingSkill() || (m_curRaceMotion && m_curRaceMotion->loopCancelEnable!=0);
|
||||
}
|
||||
|
||||
float ActorInstance::GetDefendingRadius() const {
|
||||
return m_raceData ? m_raceData->GetDefendingRadius() * m_scale : 0.0f;
|
||||
}
|
||||
@@ -633,15 +686,10 @@ bool ActorInstance::TestAttackHit(uint32_t victimVID, float x, float z, float ra
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ActorInstance::PlayMotionIndex(uint32_t index, bool loop) {
|
||||
bool ActorInstance::PlayMotionIndex(uint32_t index, bool loop, bool randomVariants) {
|
||||
uint16_t keyMode;
|
||||
if (!m_raceData || !m_raceData->GetMotionKey(uint16_t(m_motionMode), uint16_t(index), &keyMode)) return false;
|
||||
const auto* motions = m_raceData->GetMotions(keyMode, index);
|
||||
if (!motions || motions->empty()) return false;
|
||||
const std::string gr2 = ReadMotionFileName(motions->front().fileName);
|
||||
if (gr2.empty()) return false;
|
||||
RegisterMotion(static_cast<MotionType>(index), gr2);
|
||||
return PlayMotion(static_cast<MotionType>(index), loop);
|
||||
if (!m_raceData || !m_raceData->GetMotionKey(uint16_t(m_motionMode),uint16_t(index),&keyMode)) return false;
|
||||
return PlayMotionResolved(static_cast<MotionType>(index),loop,randomVariants);
|
||||
}
|
||||
|
||||
bool ActorInstance::SetLoopMotionIndex(uint32_t index) {
|
||||
@@ -655,7 +703,11 @@ bool ActorInstance::InterceptMotionIndex(uint32_t index, bool loop) {
|
||||
uint16_t keyMode;
|
||||
if (!m_raceData || !m_raceData->GetMotionKey(uint16_t(m_motionMode), uint16_t(index), &keyMode)) return false;
|
||||
m_motionQueue.clear(); // __ClearMotion
|
||||
return PlayMotionIndex(index, loop);
|
||||
const bool played=PlayMotionIndex(index,loop,!IsPolymorph());
|
||||
// AVA2 InterceptMotion passes the base key for poly actors and normalizes
|
||||
// its clip duration to 1.1 seconds before applying the requested ratio.
|
||||
if(played && IsPolymorph()) m_motionSpeed*=m_motionDuration/1.1f;
|
||||
return played;
|
||||
}
|
||||
|
||||
bool ActorInstance::InterceptMotionIndex(uint32_t index, bool loop, uint32_t skill, int loopCount) {
|
||||
@@ -670,17 +722,32 @@ bool ActorInstance::InterceptMotionIndex(uint32_t index, bool loop, uint32_t ski
|
||||
bool ActorInstance::PushMotionIndex(uint32_t index, bool loop) {
|
||||
uint16_t keyMode;
|
||||
if (!m_raceData || !m_raceData->GetMotionKey(uint16_t(m_motionMode), uint16_t(index), &keyMode)) return false;
|
||||
m_motionQueue.emplace_back(index, loop);
|
||||
m_motionQueue.push_back({index,loop});
|
||||
return true;
|
||||
}
|
||||
|
||||
// Original motion nodes retain fSpeedRatio until activation. Existing two-argument
|
||||
// native calls keep attack-speed selection; explicit ratios override it.
|
||||
bool ActorInstance::SetLoopMotionIndex(uint32_t index,float speedRatio) {
|
||||
if(!std::isfinite(speedRatio) || speedRatio<=0 || !SetLoopMotionIndex(index)) return false;
|
||||
m_motionSpeed=speedRatio;return true;
|
||||
}
|
||||
bool ActorInstance::InterceptMotionIndex(uint32_t index,bool loop,float speedRatio) {
|
||||
if(!std::isfinite(speedRatio) || speedRatio<=0 || !InterceptMotionIndex(index,loop)) return false;
|
||||
m_motionSpeed=speedRatio*(IsPolymorph()?m_motionDuration/1.1f:1.0f);return true;
|
||||
}
|
||||
bool ActorInstance::PushMotionIndex(uint32_t index,bool loop,float speedRatio) {
|
||||
if(!std::isfinite(speedRatio) || speedRatio<=0 || !PushMotionIndex(index,loop)) return false;
|
||||
m_motionQueue.back().speed=speedRatio;m_motionQueue.back().explicitSpeed=true;return true;
|
||||
}
|
||||
|
||||
bool ActorInstance::IsMotionFinished() const {
|
||||
if (m_loopMotion) return false;
|
||||
return m_animTime >= m_motionDuration;
|
||||
}
|
||||
|
||||
void ActorInstance::MoveInDirection(float moveYaw, float dt, const TerrainHeightSource* terrain, const MapObjectManager* mapObjects) {
|
||||
if (dt <= 0.0f) return;
|
||||
if (dt <= 0.0f || IsEmotionMovementLocked()) return;
|
||||
float rad = moveYaw * DEG_TO_RAD;
|
||||
m_yaw = moveYaw;
|
||||
|
||||
@@ -744,7 +811,10 @@ void ActorInstance::StopMoving() {
|
||||
}
|
||||
|
||||
void ActorInstance::Update(float dt, const TerrainHeightSource* terrain, const MapObjectManager* mapObjects) {
|
||||
if (dt <= 0.0f) return;
|
||||
if (dt <= 0.0f) {UpdateShake();return;}
|
||||
std::fill(m_shakeOffset,m_shakeOffset+3,0.0f); // Transform resets last frame's graphic shake.
|
||||
const auto body=GetBodyCollisionSpheres();
|
||||
m_bodyPreviousCenters.clear();for(const auto& sphere:body)m_bodyPreviousCenters.push_back(sphere.position);
|
||||
|
||||
// 0. Click-to-Move destination pathing (aligned with 40250 CPythonPlayer)
|
||||
if (m_hasMoveTarget && !m_isAttacking && m_curHP > 0) {
|
||||
@@ -816,11 +886,12 @@ void ActorInstance::Update(float dt, const TerrainHeightSource* terrain, const M
|
||||
m_backupFlyTarget = FlyTarget();
|
||||
}
|
||||
UpdateAttachedEffects();
|
||||
UpdateShake();
|
||||
if (!m_motionQueue.empty() && m_animTime >= m_motionDuration) {
|
||||
// ReservingMotionProcess: the next pushed motion takes over when the current one ends.
|
||||
const auto next = m_motionQueue.front();
|
||||
m_motionQueue.pop_front();
|
||||
PlayMotionIndex(next.first, next.second);
|
||||
if(PlayMotionIndex(next.index,next.loop) && next.explicitSpeed) m_motionSpeed=next.speed;
|
||||
} else if (m_loopMotion) {
|
||||
if (m_motionDuration > 0.001f && m_animTime >= m_motionDuration) {
|
||||
m_animTime = std::fmod(m_animTime, m_motionDuration);
|
||||
@@ -945,7 +1016,7 @@ bool ActorInstance::IsTargetInAttackRange(const ActorInstance& target, float max
|
||||
std::vector<Render3DDraw> ActorInstance::BuildDrawCommands(const float* worldOverride) {
|
||||
if (!m_model || m_isHiding) return {}; // __HideEvent: alpha 0
|
||||
float world[16];
|
||||
MakeTransformMatrix(m_yaw, m_posX, m_posY + m_modelYOffset * m_scale, m_posZ, m_scale, world);
|
||||
GetWorldMatrix(world);
|
||||
auto draws = DrawModel()->BuildDrawCommands(PoseTime(), worldOverride ? worldOverride : world);
|
||||
|
||||
// Shining system (ENABLE_SHINING_SYSTEM): weapon aura / glow
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Gr2ModelRenderer.h"
|
||||
#include "TerrainHeightmap.h"
|
||||
#include <deque>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -100,23 +101,24 @@ public:
|
||||
bool IsAttacking() const { return m_isAttacking; }
|
||||
|
||||
// CActorInstance::SetMotionMode / GetMotionMode (m_wcurMotionMode; polymorphs stay GENERAL).
|
||||
void SetMotionMode(int mode) { m_motionMode = m_isPolymorph ? 1 : mode; }
|
||||
void SetMotionMode(int mode) { m_motionMode = IsPolymorph() ? 1 : mode; }
|
||||
int GetMotionMode() const { return m_motionMode; }
|
||||
// CActorInstance::SetLoopMotion / InterceptMotion / PushOnceMotion / PushLoopMotion: the motion
|
||||
// index resolves through CRaceData::GetMotionKey(m_wcurMotionMode, index). Blend times, speed
|
||||
// ratios and the percent-weighted random pick are not ported (the first registered motion plays);
|
||||
// Index resolves through the active mode. Blend times remain unported;
|
||||
// explicit speeds are retained, and variants use original percentage selection.
|
||||
// a pushed motion starts when the current one ends (a loop at its cycle end).
|
||||
bool SetLoopMotionIndex(uint32_t index);
|
||||
bool SetLoopMotionIndex(uint32_t index, float speedRatio);
|
||||
bool InterceptMotionIndex(uint32_t index, bool loop);
|
||||
bool InterceptMotionIndex(uint32_t index, bool loop, float speedRatio);
|
||||
// CInstanceBase::NEW_UseSkill -> InterceptOnceMotion(motion, speed, uSkill) + SetMotionLoopCount:
|
||||
// uSkill is reported by FLY / SPECIAL_ATTACKING events; loopCount > 0 overrides the race loop count.
|
||||
bool InterceptMotionIndex(uint32_t index, bool loop, uint32_t skill, int loopCount);
|
||||
bool PushMotionIndex(uint32_t index, bool loop);
|
||||
bool PushMotionIndex(uint32_t index, bool loop, float speedRatio);
|
||||
void SetMotionRandomSourceForTest(uint32_t (*random)()) { m_motionRandom=random; }
|
||||
void ActEmotion(uint32_t motionIndex) { PushMotionIndex(motionIndex, false); }
|
||||
void ActDualEmotion(ActorInstance& target, uint32_t motion1, uint32_t motion2) {
|
||||
PushMotionIndex(motion1, false);
|
||||
target.PushMotionIndex(motion2, false);
|
||||
}
|
||||
|
||||
|
||||
// World transform
|
||||
void SetPosition(float x, float y, float z) { m_posX = x; m_posY = y; m_posZ = z; }
|
||||
@@ -137,6 +139,7 @@ public:
|
||||
|
||||
// Click-to-Move Target Destination (aligned with 40250 CPythonPlayer)
|
||||
void SetMoveTarget(float targetX, float targetZ) {
|
||||
if (IsEmotionMovementLocked()) return;
|
||||
m_targetX = targetX;
|
||||
m_targetZ = targetZ;
|
||||
m_hasMoveTarget = true;
|
||||
@@ -158,7 +161,8 @@ public:
|
||||
// Polymorph System (变身系统)
|
||||
bool SetPolymorph(uint32_t mobVnum);
|
||||
void ClearPolymorph();
|
||||
bool IsPolymorph() const { return m_isPolymorph; }
|
||||
bool IsPolymorph() const { return m_isPolymorph || m_actorType==7 || (m_actorType==6 && m_race>=8); }
|
||||
void SetActorType(uint8_t type) { m_actorType=type; m_isPC=type==6; }
|
||||
uint32_t GetPolymorphVnum() const { return m_polymorphVnum; }
|
||||
|
||||
// Shining System (ENABLE_SHINING_SYSTEM 高强装备流光系统)
|
||||
@@ -185,6 +189,7 @@ public:
|
||||
// CActorInstance::Revive: clears the sleep/paralysis/faint/dead/stun states (HP back to max).
|
||||
void Revive() { m_sleep=m_paralysis=m_faint=m_stunned=false; m_curHP=m_maxHP; }
|
||||
bool CanAct() const { return !IsDead() && !m_stunned && !m_paralysis && !m_faint && !m_sleep; }
|
||||
bool CanUseSkill() const;
|
||||
bool IsDead() const { return m_curHP <= 0; }
|
||||
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
@@ -215,12 +220,18 @@ public:
|
||||
uint32_t GetComboIndex() const { return m_comboIndex; }
|
||||
// m_fAtkSpd (atkspd / 100): attack motions advance this much faster, like the original motion
|
||||
// speed ratio passed to InterceptOnceMotion.
|
||||
void SetAttackSpeed(float ratio) { m_atkSpd = ratio > 0.0f ? ratio : 1.0f; }
|
||||
void SetAttackSpeed(float ratio);
|
||||
float GetAttackSpeed() const { return m_atkSpd; }
|
||||
void SetMoveAnimationSpeed(float ratio);
|
||||
float GetMoveAnimationSpeed() const { return m_moveAnimationSpeed; }
|
||||
// GetAttackingElapsedTime: motion local time scaled by the attack speed.
|
||||
float GetAttackingElapsedTime() const { return m_animTime; }
|
||||
const RaceMotionData* GetCurrentRaceMotionData() const { return m_curRaceMotion; }
|
||||
bool IsWaiting() const; // __IsWaitMotion: WAIT / INTRO_WAIT / STOP
|
||||
void SetEmotionMovementLocked(bool locked) { m_emotionMovementLocked=locked; }
|
||||
bool IsEmotionMovementLocked() const;
|
||||
bool IsActingEmotion() const; // AVA2: only KISS/FRENCH_KISS variants, not all emotes.
|
||||
bool IsFishing() const; // AVA2: current WAIT or REACT, not queued THROW.
|
||||
bool IsUsingSkill() const; // NAME_SKILL..NAME_SKILL_END or SPECIAL_1..6
|
||||
bool IsBowMode() const { return m_motionMode == 5 || m_motionMode == 13 || m_motionMode == 17; }
|
||||
bool IsHandMode() const { return m_motionMode == 1 || m_motionMode == 9; }
|
||||
@@ -235,6 +246,7 @@ public:
|
||||
// once per hit data in a combo motion, else again after the invisible time.
|
||||
// The race's DEFENDING sphere radius (.msm AttachingData), 0 when unknown.
|
||||
float GetDefendingRadius() const;
|
||||
bool IsClickableDistanceDestInstance(const ActorInstance& target, float distance) const;
|
||||
bool TestAttackHit(uint32_t victimVID, float x, float z, float radius, float frameDt, bool huge = false);
|
||||
|
||||
// ActorInstanceMotionEvent.cpp: .msa motion events and .mss sounds fire per 60 Hz motion frame
|
||||
@@ -257,10 +269,19 @@ public:
|
||||
bool GetFlyTargetPosition(float* outXYZ) const;
|
||||
// OnGetFlyTargetPosition: bounding-sphere centre (approximated by half the head height), +110 mounted.
|
||||
void GetFlyTargetCenter(float* outXYZ) const;
|
||||
std::function<bool(float*)> CaptureFlyTargetResolver() const;
|
||||
void OnShootDamage();
|
||||
void SetShakeSourcesForTest(uint32_t (*now)(),uint32_t (*random)()) {m_shakeNow=now;m_shakeRandom=random;}
|
||||
std::weak_ptr<const uint8_t> GetFlyCollisionIdentity() const { return m_flyLifetime; }
|
||||
struct BodyCollisionSphere {float radius=0;std::array<float,3> position{},lastPosition{};};
|
||||
std::vector<BodyCollisionSphere> GetBodyCollisionSpheres() const;
|
||||
// IFlyEventHandler (CPythonPlayerEventHandler::CNormalBowAttack_FlyEventHandler_AutoClear).
|
||||
struct FlyEventHandler {
|
||||
std::function<void()> onSetFlyTarget;
|
||||
std::function<void(uint32_t skill)> onShoot;
|
||||
std::function<void(uint32_t skill)> onExplodingAtTarget;
|
||||
std::function<void(uint32_t skill,uint32_t vid)> onExplodingAtAnotherTarget;
|
||||
std::function<void()> onExplodingAtBackground;
|
||||
};
|
||||
void SetFlyEventHandler(FlyEventHandler handler) { m_flyEventHandler = std::move(handler); }
|
||||
void ClearFlyEventHandler() { m_flyEventHandler = FlyEventHandler(); }
|
||||
@@ -364,6 +385,8 @@ private:
|
||||
std::vector<SLodModel> m_lodModels; // loaded on first use, same order as m_lodPaths
|
||||
uint32_t m_lodLevel = 0; // == m_lodPaths.size(): main model
|
||||
std::vector<std::pair<std::string, std::string>> m_mainSkins; // shape skins, applied to every LOD
|
||||
std::string m_boundMotionMsa;
|
||||
uint32_t (*m_motionRandom)() = nullptr;
|
||||
std::string m_motionFile; // resolved animation on m_model
|
||||
bool m_hasLodModel = false;
|
||||
float m_lodDistance = 5000.0f; // LODDISTANCE_ACTOR, LODDISTANCE_BUILDING for size >= 500
|
||||
@@ -380,14 +403,16 @@ private:
|
||||
float m_motionDuration = 1.0f;
|
||||
bool m_loopMotion = true;
|
||||
int m_motionMode = 1; // CRaceMotionData::MODE_GENERAL
|
||||
std::deque<std::pair<uint32_t, bool>> m_motionQueue; // m_MotionDeque (index, loop)
|
||||
bool PlayMotionIndex(uint32_t index, bool loop);
|
||||
struct QueuedMotion {uint32_t index;bool loop;float speed=1;bool explicitSpeed=false;};
|
||||
std::deque<QueuedMotion> m_motionQueue; // m_MotionDeque (index, loop)
|
||||
bool PlayMotionIndex(uint32_t index, bool loop, bool randomVariants=true);
|
||||
bool PlayMotionResolved(MotionType type, bool loop, bool randomVariants);
|
||||
bool m_isAttacking = false;
|
||||
uint32_t m_comboIndex = 0;
|
||||
// Combo state (CActorInstance m_isPreInput / m_isNextPreInput / m_fAtkDirRot / m_HitDataMap).
|
||||
const RaceMotionData* m_curRaceMotion = nullptr;
|
||||
bool m_isPreInput = false, m_isNextPreInput = false, m_isMountingHorse = false, m_reportAttacks = false;
|
||||
float m_atkDirYaw = 0.0f, m_atkSpd = 1.0f, m_motionSpeed = 1.0f;
|
||||
float m_atkDirYaw = 0.0f, m_atkSpd = 1.0f, m_motionSpeed = 1.0f, m_moveAnimationSpeed = 1.0f;
|
||||
std::deque<uint16_t> m_attackMotions;
|
||||
// m_HitDataMap: hit data index -> (vid -> local time the victim may be hit again).
|
||||
std::unordered_map<size_t, std::unordered_map<uint32_t, float>> m_hitDataMap;
|
||||
@@ -403,7 +428,12 @@ private:
|
||||
bool CurrentMotionLoopProcess();
|
||||
bool IsNeedFlyTargetMotion() const;
|
||||
bool GetBoneLocalMatrix(const std::string& boneName, float* outLocal16) const;
|
||||
void GetWorldMatrix(float* out16) const;
|
||||
void GetWorldMatrix(float* out16,bool includeShake=true) const;
|
||||
void UpdateShake();
|
||||
uint32_t m_shakeEnd=0;
|
||||
float m_shakeOffset[3]={};
|
||||
uint32_t (*m_shakeNow)()=nullptr;
|
||||
uint32_t (*m_shakeRandom)()=nullptr;
|
||||
uint32_t m_curFrame = 0, m_frameCount = 0; // m_kCurMotNode.dwcurFrame / dwFrameCount
|
||||
uint32_t m_curSkill = 0; // m_kCurMotNode.uSkill
|
||||
int m_loopCount = 0; // m_kCurMotNode.iLoopCount
|
||||
@@ -419,6 +449,8 @@ private:
|
||||
FlyTarget m_flyTarget, m_backupFlyTarget;
|
||||
std::deque<FlyTarget> m_flyTargetQueue;
|
||||
FlyEventHandler m_flyEventHandler;
|
||||
std::vector<std::array<float,3>> m_bodyPreviousCenters;
|
||||
std::shared_ptr<const uint8_t> m_flyLifetime=std::make_shared<const uint8_t>(0);
|
||||
struct AttachedEffect {
|
||||
uint32_t instanceId = 0;
|
||||
std::string bone; // empty: actor root
|
||||
@@ -461,12 +493,14 @@ private:
|
||||
float m_heightOffset = 180.0f;
|
||||
|
||||
// Click-to-Move Target
|
||||
bool m_emotionMovementLocked = false;
|
||||
bool m_hasMoveTarget = false;
|
||||
float m_targetX = 0.0f;
|
||||
float m_targetZ = 0.0f;
|
||||
|
||||
// Polymorph state
|
||||
bool m_isPolymorph = false;
|
||||
uint8_t m_actorType = 0; // AVA2 TYPE_PC=6, TYPE_POLY=7; playable races 0..7.
|
||||
uint32_t m_polymorphVnum = 0;
|
||||
std::string m_origModelPath;
|
||||
float m_origScale = 1.0f;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "src/eter_sound/SoundManager.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include "eter_base/Timer.h"
|
||||
|
||||
namespace ava2 {
|
||||
|
||||
@@ -62,8 +64,9 @@ ActorInstance* ActorInstance::ResolveActor(uint32_t vid) {
|
||||
return Resolver() ? Resolver()(vid) : nullptr;
|
||||
}
|
||||
|
||||
void ActorInstance::GetWorldMatrix(float* out16) const {
|
||||
void ActorInstance::GetWorldMatrix(float* out16,bool includeShake) const {
|
||||
MakeTransformMatrix(m_yaw, m_posX, m_posY + m_modelYOffset * m_scale, m_posZ, m_scale, out16);
|
||||
if(includeShake)for(int k=0;k<3;++k)out16[12+k]+=m_shakeOffset[k];
|
||||
}
|
||||
|
||||
void ActorInstance::GetFlyTargetCenter(float* out) const {
|
||||
@@ -71,6 +74,81 @@ void ActorInstance::GetFlyTargetCenter(float* out) const {
|
||||
out[1] = m_posY + (m_heightOffset * 0.5f + m_modelYOffset) * m_scale;
|
||||
out[2] = m_posZ;
|
||||
if (m_isMountingHorse) out[1] += 110.0f;
|
||||
for(int k=0;k<3;++k)out[k]+=m_shakeOffset[k];
|
||||
}
|
||||
|
||||
// ActorInstanceBattle.cpp: strict 3D sphere-distance test, no fallback when a
|
||||
// race has no defending spheres. GetPixelPosition on CActorInstance already
|
||||
// returns graphic coordinates (SetCurPixelPosition negates the game Y).
|
||||
bool ActorInstance::IsClickableDistanceDestInstance(const ActorInstance& target, float distance) const {
|
||||
if(!target.m_raceData) return false;
|
||||
float world[16];target.GetWorldMatrix(world,false);
|
||||
for(const auto& sphere:target.m_raceData->GetDefendingSpheres()) {
|
||||
float transform[16];std::copy(world,world+16,transform);
|
||||
float bone[16];
|
||||
if(sphere.attached && target.GetBoneLocalMatrix(sphere.bone,bone)) Multiply(bone,world,transform);
|
||||
float local[3];ModelToEngine(sphere.position,local);
|
||||
float center[3];
|
||||
for(int k=0;k<3;++k)center[k]=local[0]*transform[k]+local[1]*transform[4+k]+local[2]*transform[8+k]+transform[12+k];
|
||||
const float dx=center[0]-m_posX,dh=center[1]-m_posY,dy=center[2]-m_posZ;
|
||||
// Original instance sphere radius is not multiplied by actor scale.
|
||||
if(sphere.radius+distance>std::sqrt(dx*dx+dh*dh+dy*dy)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<ActorInstance::BodyCollisionSphere> ActorInstance::GetBodyCollisionSpheres() const {
|
||||
std::vector<BodyCollisionSphere> result;
|
||||
if(!m_raceData)return result;
|
||||
float world[16];GetWorldMatrix(world,false);
|
||||
for(const auto& sphere:m_raceData->GetBodySpheres()) {
|
||||
float transform[16];std::copy(world,world+16,transform);
|
||||
float bone[16];if(sphere.attached && GetBoneLocalMatrix(sphere.bone,bone))Multiply(bone,world,transform);
|
||||
float local[3];ModelToEngine(sphere.position,local);
|
||||
BodyCollisionSphere output;output.radius=sphere.radius;
|
||||
for(int k=0;k<3;++k)output.position[k]=local[0]*transform[k]+local[1]*transform[4+k]+local[2]*transform[8+k]+transform[12+k];
|
||||
output.lastPosition=result.size()<m_bodyPreviousCenters.size()?m_bodyPreviousCenters[result.size()]:output.position;
|
||||
result.push_back(output);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::function<bool(float*)> ActorInstance::CaptureFlyTargetResolver() const {
|
||||
// Weak identity prevents a replacement actor with the same VID inheriting a flight.
|
||||
std::weak_ptr<const uint8_t> lifetime=m_flyLifetime;
|
||||
const uint32_t vid=m_vid;
|
||||
return [lifetime,vid,this](float* out) {
|
||||
if(lifetime.expired() || ResolveActor(vid)!=this)return false;
|
||||
GetFlyTargetCenter(out);return true;
|
||||
};
|
||||
}
|
||||
|
||||
// ActorInstanceBattle ShakeProcess: sample once per transform, never move game coordinates.
|
||||
void ActorInstance::UpdateShake() {
|
||||
std::fill(m_shakeOffset,m_shakeOffset+3,0.0f);
|
||||
if(!m_shakeEnd)return;
|
||||
const uint32_t now=m_shakeNow?m_shakeNow():ELTimer_GetMSec();
|
||||
if(m_shakeEnd<now){m_shakeEnd=0;return;}
|
||||
auto random=[&](){return m_shakeRandom?m_shakeRandom():uint32_t(std::rand());};
|
||||
float native[3];for(int k=0;k<3;++k){const auto sign=random()%2;const float amount=float(random()%10);native[k]=sign?-amount:amount;}
|
||||
ModelToEngine(native,m_shakeOffset);
|
||||
}
|
||||
|
||||
void ActorInstance::OnShootDamage() {
|
||||
// ActorInstanceBattle.cpp: visual reaction only, not client-side HP deduction.
|
||||
if(IsStun()){Die();return;}
|
||||
m_shakeEnd=(m_shakeNow?m_shakeNow():ELTimer_GetMSec())+100u;
|
||||
const uint32_t motion=uint32_t(m_currentMotion);
|
||||
const bool locked=(motion>=RaceData::NAME_NORMAL_ATTACK && motion<=RaceData::NAME_COMBO_ATTACK_8)
|
||||
|| (motion>=RaceData::NAME_SPECIAL_1 && motion<=RaceData::NAME_SPECIAL_6)
|
||||
|| (motion>=RaceData::NAME_FISHING_THROW && motion<=RaceData::NAME_FISHING_FAIL)
|
||||
|| (motion>=RaceData::NAME_CLAP && motion<RaceData::NAME_DIG)
|
||||
|| (motion>=RaceData::NAME_DANCE_1 && motion<=RaceData::NAME_DANCE_6)
|
||||
|| (motion>=RaceData::NAME_CONGRATULATION && motion<=RaceData::NAME_JOY)
|
||||
|| (IsUsingSkill() && (!m_curRaceMotion || !m_curRaceMotion->loopCancelEnable));
|
||||
if(IsDead() || locked || motion==RaceData::NAME_DAMAGE_FLYING || motion==RaceData::NAME_DAMAGE_FLYING_BACK
|
||||
|| motion==RaceData::NAME_STAND_UP || motion==RaceData::NAME_STAND_UP_BACK)return;
|
||||
if(InterceptMotionIndex(RaceData::NAME_DAMAGE,false))PushMotionIndex(RaceData::NAME_WAIT,true);
|
||||
}
|
||||
|
||||
// CFlyTarget::SetFlyTarget / AddFlyTarget / Clear.
|
||||
@@ -313,9 +391,25 @@ void ActorInstance::ProcessMotionEventFrame(uint32_t frame) {
|
||||
start[1] += bone[13];
|
||||
start[2] += bone[14];
|
||||
}
|
||||
// The flying instance flies to the target position at launch (CFlyTarget tracking of a
|
||||
// moving actor is not modelled by FlyingManager).
|
||||
FlyingManager::Instance().CreateFlyingInstance(ev.index, start, targetPos);
|
||||
FlyTargetResolver resolver;
|
||||
std::function<void()> hit;
|
||||
if(auto* target=m_flyTarget.vid?ResolveActor(m_flyTarget.vid):nullptr) {
|
||||
resolver=target->CaptureFlyTargetResolver();
|
||||
const auto handler=m_flyEventHandler.onExplodingAtTarget;
|
||||
const uint32_t skill=m_curSkill;
|
||||
hit=[target,identity=resolver,handler,skill]() {
|
||||
float position[3];if(!identity(position))return;
|
||||
target->OnShootDamage();
|
||||
if(handler)handler(skill);
|
||||
};
|
||||
}
|
||||
FlyCollisionCallbacks collision;
|
||||
collision.owner=m_flyLifetime;
|
||||
const auto another=m_flyEventHandler.onExplodingAtAnotherTarget;
|
||||
const uint32_t skill=m_curSkill;
|
||||
if(another)collision.onAnotherTarget=[another,skill](uint32_t vid){another(skill,vid);};
|
||||
collision.onBackground=m_flyEventHandler.onExplodingAtBackground;
|
||||
FlyingManager::Instance().CreateFlyingInstance(ev.index,start,targetPos,{},std::move(resolver),std::move(hit),std::move(collision));
|
||||
if (m_flyEventHandler.onShoot) m_flyEventHandler.onShoot(m_curSkill);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -316,9 +316,11 @@ CRenderTargetManager& CRenderTargetManager::Instance() {
|
||||
|
||||
CRenderTargetManager::CRenderTargetManager() = default;
|
||||
CRenderTargetManager::~CRenderTargetManager() {
|
||||
m_targets.clear();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CRenderTargetManager::Destroy() { m_targets.clear(); }
|
||||
|
||||
std::shared_ptr<CRenderTarget> CRenderTargetManager::GetRenderTarget(int index) {
|
||||
auto it = m_targets.find(index);
|
||||
if (it != m_targets.end()) return it->second;
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
std::shared_ptr<CRenderTarget> GetRenderTarget(int index);
|
||||
std::shared_ptr<CRenderTarget> CreateRenderTarget(int index, int w = 384, int h = 384);
|
||||
void DestroyRenderTarget(int index);
|
||||
void Destroy();
|
||||
int GetFreeIndex(int minIdx, int maxIdx);
|
||||
|
||||
private:
|
||||
|
||||
@@ -339,6 +339,7 @@ void Gr2SceneRenderer::SetCameraLookAtRH(float eyeX, float eyeY, float eyeZ,
|
||||
}
|
||||
|
||||
void Gr2SceneRenderer::SetPerspective(float fovYDegrees, float aspect, float zNear, float zFar) {
|
||||
m_perspective={fovYDegrees,aspect,zNear,zFar};
|
||||
float fovRad = fovYDegrees * 3.1415926535f / 180.0f;
|
||||
float h = 1.0f / std::tan(fovRad * 0.5f);
|
||||
float w = h / aspect;
|
||||
@@ -352,6 +353,18 @@ void Gr2SceneRenderer::SetPerspective(float fovYDegrees, float aspect, float zNe
|
||||
m_proj[14] = -q * zNear;
|
||||
}
|
||||
|
||||
void Gr2SceneRenderer::SetOrtho3D(float width,float height,float nearPlane,float farPlane) {
|
||||
std::fill_n(m_proj,16,0.f);m_proj[0]=2/width;m_proj[5]=2/height;
|
||||
m_proj[10]=1/(farPlane-nearPlane);m_proj[14]=-nearPlane/(farPlane-nearPlane);m_proj[15]=1;
|
||||
}
|
||||
void Gr2SceneRenderer::SetOrtho2D(float width,float height,float length) {
|
||||
SetOrtho3D(width,height,0,length);m_proj[5]=-2/height;m_proj[12]=-1;m_proj[13]=1;
|
||||
}
|
||||
void Gr2SceneRenderer::SetProjectionMatrix(const float* matrix) {std::copy_n(matrix,16,m_proj);}
|
||||
void Gr2SceneRenderer::BuildViewFrustum() {
|
||||
const std::array<float,3> eye={m_eye[0],m_eye[1],m_eye[2]},forward={m_view[2],m_view[6],m_view[10]};
|
||||
m_frustum=std::make_unique<ViewFrustum>(m_view,m_proj,eye,forward,&m_perspective);
|
||||
}
|
||||
void Gr2SceneRenderer::Clear(uint32_t color, float depth) {
|
||||
std::fill(m_depthBuffer.begin(), m_depthBuffer.end(), depth);
|
||||
}
|
||||
@@ -566,7 +579,7 @@ void Gr2SceneRenderer::RenderDraw(SDL_Surface* targetSurface, const Render3DDraw
|
||||
int depth_y = py - m_viewport[1];
|
||||
if (depth_x < 0 || depth_x >= vpWidth || depth_y < 0 || depth_y >= vpHeight) continue;
|
||||
int depth_idx = depth_y * vpWidth + depth_x;
|
||||
if (depth >= 0.0f && depth <= 1.0f && (!draw.z_enable || depth <= m_depthBuffer[depth_idx])) {
|
||||
if (depth >= 0.0f && depth <= 1.0f && (!draw.z_enable || (draw.depth_less ? depth < m_depthBuffer[depth_idx] : depth <= m_depthBuffer[depth_idx]))) {
|
||||
// Smooth Phong Normal Interpolation
|
||||
float nx = b0 * v0.nx + b1 * v1.nx + b2 * v2.nx;
|
||||
float ny = b0 * v0.ny + b1 * v1.ny + b2 * v2.ny;
|
||||
@@ -665,7 +678,7 @@ void Gr2SceneRenderer::RenderDraw(SDL_Surface* targetSurface, const Render3DDraw
|
||||
}
|
||||
}
|
||||
|
||||
if (draw.z_write && !is_blended) {
|
||||
if (draw.z_enable && draw.z_write) {
|
||||
m_depthBuffer[depth_idx] = depth;
|
||||
}
|
||||
|
||||
@@ -966,7 +979,7 @@ void Gr2SceneRenderer::RenderSceneGPU(SDL_Renderer* renderer, const std::vector<
|
||||
if (m_hardware) {
|
||||
SDL_GPUTexture* texture=ord.texture;
|
||||
HardwareBatch batch{};batch.texture=texture;batch.cull=draw.cull_mode;
|
||||
batch.depth=draw.z_enable;batch.depthWrite=draw.z_enable&&draw.z_write;
|
||||
batch.depthLess=draw.depth_less;batch.depth=draw.z_enable;batch.depthWrite=draw.z_enable&&draw.z_write;
|
||||
batch.blend=draw.alpha_blend;batch.additive=draw.blend_mode==1;
|
||||
batch.alphaRef=draw.alpha_test ? draw.alpha_ref/255.f : -1.f;
|
||||
batch.geometry=draw.geometry;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "RenderCommands3D.h"
|
||||
#include "HardwareScene.h"
|
||||
#include "ViewFrustum.h"
|
||||
#include <gr2/gr2.h>
|
||||
#include <gr2_render/gr2_render.h>
|
||||
#include <SDL3/SDL.h>
|
||||
@@ -82,6 +83,13 @@ public:
|
||||
|
||||
void SetPerspective(float fovYDegrees, float aspect, float zNear, float zFar);
|
||||
|
||||
void SetOrtho2D(float width,float height,float length);
|
||||
void SetOrtho3D(float width,float height,float nearPlane,float farPlane);
|
||||
void SetProjectionMatrix(const float* matrix); // Retains the last perspective metadata.
|
||||
void BuildViewFrustum(); // Explicit UpdateGame boundary; setters do not invalidate the snapshot.
|
||||
const ViewFrustum* GetCachedViewFrustum() const {return m_frustum.get();}
|
||||
DepthState GetDepthState() const {return m_depthState;}
|
||||
void SetDepthState(DepthState state) {m_depthState=state;}
|
||||
void SetViewport(int x, int y, int width, int height);
|
||||
|
||||
void Clear(uint32_t color = 0xFF101520, float depth = 1.0f);
|
||||
@@ -159,6 +167,9 @@ private:
|
||||
float m_eye[3] = {0.0f, 0.0f, 0.0f};
|
||||
float m_view[16];
|
||||
float m_proj[16];
|
||||
PerspectiveMetadata m_perspective;
|
||||
std::unique_ptr<ViewFrustum> m_frustum;
|
||||
DepthState m_depthState;
|
||||
int m_viewport[4];
|
||||
int m_logicalWidth = 0;
|
||||
int m_logicalHeight = 0;
|
||||
|
||||
@@ -149,7 +149,7 @@ SDL_GPUGraphicsPipeline* HardwareScene::Pipeline(const HardwareBatch& b) {
|
||||
info.rasterizer_state.fill_mode=SDL_GPU_FILLMODE_FILL;
|
||||
info.rasterizer_state.front_face=SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;
|
||||
info.rasterizer_state.cull_mode=b.cull==1 ? SDL_GPU_CULLMODE_NONE : b.cull==2 ? SDL_GPU_CULLMODE_BACK : SDL_GPU_CULLMODE_FRONT;
|
||||
info.depth_stencil_state.compare_op=SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
info.depth_stencil_state.compare_op=b.depthLess?SDL_GPU_COMPAREOP_LESS:SDL_GPU_COMPAREOP_LESS_OR_EQUAL;
|
||||
info.depth_stencil_state.enable_depth_test=b.depth;
|
||||
info.depth_stencil_state.enable_depth_write=b.depthWrite;
|
||||
SDL_GPUColorTargetDescription target{};target.format=SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
|
||||
@@ -311,7 +311,7 @@ bool HardwareScene::Render(SDL_Renderer* renderer,int width,int height,const std
|
||||
if(mesh && !batch.blend && !batch.additive && batch.depthWrite && batch.transform.skin[0]==0 && batch.transform.modes[0]>0.5f)
|
||||
while(i+count<batches.size()) {
|
||||
const auto& next=batches[i+count];
|
||||
if(meshes[i+count]!=mesh || next.firstIndex!=batch.firstIndex || next.indexCount!=batch.indexCount || next.texture!=batch.texture || next.cull!=batch.cull || next.depth!=batch.depth || next.depthWrite!=batch.depthWrite || next.blend || next.additive || next.alphaRef!=batch.alphaRef || next.transform.skin[0]!=0 || next.transform.modes[0]<.5f)break;
|
||||
if(meshes[i+count]!=mesh || next.firstIndex!=batch.firstIndex || next.indexCount!=batch.indexCount || next.texture!=batch.texture || next.cull!=batch.cull || next.depth!=batch.depth || next.depthWrite!=batch.depthWrite || next.depthLess!=batch.depthLess || next.blend || next.additive || next.alphaRef!=batch.alphaRef || next.transform.skin[0]!=0 || next.transform.modes[0]<.5f)break;
|
||||
++count;
|
||||
}
|
||||
SDL_GPUBuffer* vertexBuffer=mesh ? mesh->vertices : vertices_;SDL_GPUBuffer* indexBuffer=mesh ? mesh->indices : indices_;
|
||||
|
||||
@@ -33,12 +33,13 @@ struct HardwareBatch {
|
||||
uint32_t cull;
|
||||
bool depth, depthWrite, blend, additive;
|
||||
float alphaRef;
|
||||
bool depthLess=false;
|
||||
HardwareTransform transform{};
|
||||
std::shared_ptr<const Render3DDraw> geometry;
|
||||
std::shared_ptr<const std::vector<float>> palette;
|
||||
};
|
||||
inline unsigned PipelineKey(const HardwareBatch& b) {
|
||||
return b.cull|(unsigned(b.depth)<<3)|(unsigned(b.depthWrite)<<4)|(unsigned(b.blend)<<5)|(unsigned(b.additive)<<6);
|
||||
return b.cull|(unsigned(b.depth)<<3)|(unsigned(b.depthWrite)<<4)|(unsigned(b.blend)<<5)|(unsigned(b.additive)<<6)|(unsigned(b.depthLess)<<7);
|
||||
}
|
||||
class HardwareScene {
|
||||
public:
|
||||
|
||||
@@ -356,6 +356,18 @@ bool MapObjectManager::CheckCollision(float worldX, float worldZ, float actorRad
|
||||
return false;
|
||||
}
|
||||
|
||||
// FlyingInstance FCheckBackgroundDuringFlying uses radius 1 and the two
|
||||
// endpoints for OBBs. These are current mesh OBB proxies; .mdatr primitives remain a gap.
|
||||
bool MapObjectManager::CheckFlyingCollision(const float* start,const float* end,float radius) const {
|
||||
const float dx=end[0]-start[0],dy=end[1]-start[1],dz=end[2]-start[2];
|
||||
const float query=2*std::sqrt(dx*dx+dy*dy+dz*dz)+radius;
|
||||
for(auto index:CollisionCandidates(start[0],start[2],query)) {
|
||||
const auto& object=m_objects[index];
|
||||
if(object.has_collision && (object.obb.IntersectsSphere3D(start,radius) || object.obb.IntersectsSphere3D(end,radius)))return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MapObjectManager::CheckCollisionNormal(float worldX, float worldZ, float actorRadius, float& outNx, float& outNz) const {
|
||||
for (auto index : CollisionCandidates(worldX,worldZ,actorRadius)) {
|
||||
const auto& obj=m_objects[index];
|
||||
|
||||
@@ -40,6 +40,13 @@ struct OrientedBoundingBox {
|
||||
return (diffX * diffX + diffZ * diffZ) < (radius * radius);
|
||||
}
|
||||
|
||||
bool IntersectsSphere3D(const float* point,float radius) const {
|
||||
const float dx=point[0]-centerX,dz=point[2]-centerZ,c=std::cos(yawRad),s=std::sin(yawRad);
|
||||
const float local[3]={dx*c+dz*s,point[1]-centerY,-dx*s+dz*c};
|
||||
float distance=0;for(int k=0;k<3;++k){const float d=local[k]-std::clamp(local[k],-halfExtents[k],halfExtents[k]);distance+=d*d;}
|
||||
return distance<=radius*radius;
|
||||
}
|
||||
|
||||
bool GetPenetrationAndNormal(float circleX, float circleZ, float radius, float& outNx, float& outNz, float& outPenetration) const {
|
||||
float dx = circleX - centerX;
|
||||
float dz = circleZ - centerZ;
|
||||
@@ -130,6 +137,7 @@ public:
|
||||
|
||||
// 3D Oriented Bounding Box (OBB) Building Collision Detection
|
||||
bool CheckCollision(float worldX, float worldZ, float actorRadius = 30.0f) const;
|
||||
bool CheckFlyingCollision(const float* start,const float* end,float radius=1) const;
|
||||
bool CheckCollisionNormal(float worldX, float worldZ, float actorRadius, float& outNx, float& outNz) const;
|
||||
|
||||
// Build 3D draw commands for all instantiated objects
|
||||
|
||||
@@ -127,18 +127,31 @@ bool RaceData::LoadRaceData(const std::string& fileName) {
|
||||
}
|
||||
loader.setParent();
|
||||
}
|
||||
// AttachingData: only COLLISION_TYPE_DEFENDING sphere radii are kept (CActorInstance defending
|
||||
// spheres, approximated by one cylinder for the attack hit test). Attached effects are not ported.
|
||||
// Keep DEFENDING positions for skill range checks; normal attacks still use the
|
||||
// largest-radius cylinder. Attached effects remain separate.
|
||||
m_defendingSpheres.clear();m_bodySpheres.clear();
|
||||
m_defendingRadius=0;
|
||||
if (loader.setChildNode("attachingdata")) {
|
||||
for (size_t i = 0; i < loader.childCount(); ++i) {
|
||||
if (!loader.setChild(i)) continue;
|
||||
int collisionType = 0;
|
||||
if (loader.tokenInteger("collisiontype", &collisionType) && collisionType == 3) {
|
||||
if (loader.tokenInteger("collisiontype", &collisionType) && (collisionType == 3 || collisionType == 1)) {
|
||||
int attached=0;std::string bone;
|
||||
loader.tokenInteger("isattaching", &attached);
|
||||
loader.tokenString("attachingbonename", &bone);
|
||||
for (size_t j = 0; j < loader.childCount(); ++j) {
|
||||
if (!loader.setChild(j)) continue;
|
||||
std::string radius;
|
||||
if (loader.tokenString("radius", &radius))
|
||||
m_defendingRadius = std::max(m_defendingRadius, float(std::atof(radius.c_str())));
|
||||
if (loader.tokenString("radius", &radius)) {
|
||||
DefendingSphere sphere;sphere.radius=float(std::atof(radius.c_str()));
|
||||
sphere.attached=attached!=0;sphere.bone=bone;
|
||||
const auto* position=loader.tokenVector("position");
|
||||
if(position && position->size()==3) {
|
||||
for(int k=0;k<3;++k)sphere.position[k]=float(std::atof((*position)[k].c_str()));
|
||||
(collisionType==3?m_defendingSpheres:m_bodySpheres).push_back(sphere);
|
||||
}
|
||||
if(collisionType==3)m_defendingRadius=std::max(m_defendingRadius,sphere.radius);
|
||||
}
|
||||
loader.setParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,11 +122,19 @@ public:
|
||||
void RegisterComboAttack(uint16_t mode, uint16_t comboType, uint32_t comboIndex, uint16_t motion);
|
||||
const std::vector<uint32_t>* GetComboData(uint16_t mode, uint16_t comboType) const;
|
||||
|
||||
struct DefendingSphere {
|
||||
float radius=0, position[3]={}; // Granny/model space (Z up).
|
||||
bool attached=false;
|
||||
std::string bone;
|
||||
};
|
||||
const std::vector<DefendingSphere>& GetDefendingSpheres() const { return m_defendingSpheres; }
|
||||
const std::vector<DefendingSphere>& GetBodySpheres() const { return m_bodySpheres; }
|
||||
// Largest COLLISION_TYPE_DEFENDING sphere radius of the .msm AttachingData (0 when none).
|
||||
float GetDefendingRadius() const { return m_defendingRadius; }
|
||||
|
||||
private:
|
||||
float m_defendingRadius = 0.0f;
|
||||
std::vector<DefendingSphere> m_defendingSpheres, m_bodySpheres;
|
||||
uint32_t m_race = 0;
|
||||
std::string m_baseModelFileName, m_treeFileName, m_attributeFileName, m_smokeBoneName;
|
||||
std::string m_motionListFileName = "motlist.txt";
|
||||
|
||||
@@ -97,6 +97,7 @@ struct Render3DDraw {
|
||||
// Render states
|
||||
bool z_enable = true;
|
||||
bool z_write = true;
|
||||
bool depth_less = false; // D3DCMP_LESS; default is LESSEQUAL.
|
||||
std::uint32_t cull_mode = 2; // 1: None, 2: CW, 3: CCW
|
||||
bool alpha_blend = false;
|
||||
std::uint32_t blend_mode = 0; // 0: Alpha (D3DBLEND_INVSRCALPHA), 1: Additive (D3DBLEND_ONE)
|
||||
|
||||
@@ -190,6 +190,7 @@ bool SpeedTreeForest::HasMainTree(uint32_t crc) const {
|
||||
}
|
||||
|
||||
void SpeedTreeForest::UpdateSystem(float dt) {
|
||||
if (!std::isfinite(dt) || dt<0 || !std::isfinite(m_wind_time+dt)) return;
|
||||
m_wind_time += dt;
|
||||
m_frame_wind.time = m_wind_time;
|
||||
m_frame_wind.strength = m_wind_strength * 0.05f;
|
||||
@@ -235,7 +236,7 @@ std::vector<Render3DDraw> SpeedTreeForest::BuildDrawCommands(const float* viewMa
|
||||
auto inst_draws = inst->model->BuildDrawCommands(inst->x, inst->y, inst->z,
|
||||
inst->yaw, inst->scale,
|
||||
m_wind_time, m_wind_strength,
|
||||
m_frame_wind.matrices.empty() ? nullptr : &m_frame_wind, &camera);
|
||||
m_frame_wind.matrices.empty() ? nullptr : &m_frame_wind, &camera, m_cpuWind);
|
||||
for (auto& id : inst_draws) {
|
||||
draws.push_back(std::move(id));
|
||||
}
|
||||
|
||||
@@ -50,10 +50,14 @@ public:
|
||||
|
||||
void SetWindStrength(float s) { m_wind_strength = s; }
|
||||
float GetWindStrength() const { return m_wind_strength; }
|
||||
// The shipped AVA2 configuration uses WIND_NONE. CPU deformation is opt-in.
|
||||
void SetCpuWindEnabled(bool enabled) { m_cpuWind = enabled; }
|
||||
bool IsCpuWindEnabled() const { return m_cpuWind; }
|
||||
|
||||
private:
|
||||
speedtree::LegacyWindController m_wind_controller;
|
||||
speedtree::WindParameters m_frame_wind;
|
||||
bool m_cpuWind = false;
|
||||
float m_wind_time = 0.0f;
|
||||
float m_wind_strength = 16.0f;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ std::shared_ptr<SpeedTreeModel> SpeedTreeModel::CreateProcedural(const std::stri
|
||||
std::vector<Render3DDraw> SpeedTreeModel::BuildDrawCommands(float worldX, float worldY, float worldZ,
|
||||
float yawDeg, float scale,
|
||||
float windTime, float windStrength, const speedtree::WindParameters* frameWind,
|
||||
const std::array<float,3>* camera) const {
|
||||
const std::array<float,3>* camera, bool cpuWind) const {
|
||||
std::vector<Render3DDraw> results;
|
||||
if (!m_impl) return results;
|
||||
|
||||
@@ -37,6 +37,12 @@ std::vector<Render3DDraw> SpeedTreeModel::BuildDrawCommands(float worldX, float
|
||||
wind.time = windTime;
|
||||
wind.strength = windStrength * 0.05f;
|
||||
if (frameWind) wind = *frameWind;
|
||||
if (!cpuWind) {
|
||||
// WRAPPER_USE_NO_WIND disables branch/frond deformation and leaf-center
|
||||
// translation, but SetLeafRockingState(true) still rotates leaf cards.
|
||||
// Empty matrices would select synthesized SDK wind, not WIND_NONE.
|
||||
wind.matrices.assign(1, std::array<float,16>{1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1});
|
||||
}
|
||||
|
||||
auto build_draw = [&](const speedtree::SpeedTreeMesh& mesh, bool is_canopy, float alpha = 84) {
|
||||
if (mesh.vertices.empty() || mesh.indices.empty()) return;
|
||||
@@ -68,16 +74,18 @@ std::vector<Render3DDraw> SpeedTreeModel::BuildDrawCommands(float worldX, float
|
||||
draw.diffuse[i] = mesh.vertices[i].diffuse;
|
||||
}
|
||||
|
||||
// AVA2 SpeedTreeConfig selects static lighting; ForestDirectX8 renders
|
||||
// the SDK vertex diffuse colors with D3DRS_LIGHTING=FALSE.
|
||||
if (is_canopy) {
|
||||
draw.alpha_test = true;
|
||||
draw.alpha_ref = static_cast<uint8_t>(std::clamp(alpha,0.0f,255.0f));
|
||||
draw.cull_mode = 1; // Double sided
|
||||
draw.lighting = true;
|
||||
draw.lighting = false;
|
||||
} else {
|
||||
draw.alpha_test = alpha>84;
|
||||
draw.alpha_ref = alpha>84 ? static_cast<uint8_t>(std::clamp(alpha,0.0f,255.0f)) : 0;
|
||||
draw.cull_mode = 2; // CW
|
||||
draw.lighting = true;
|
||||
draw.lighting = false;
|
||||
}
|
||||
|
||||
results.push_back(std::move(draw));
|
||||
|
||||
@@ -29,7 +29,8 @@ public:
|
||||
float yawDeg, float scale,
|
||||
float windTime, float windStrength = 15.0f,
|
||||
const speedtree::WindParameters* frameWind = nullptr,
|
||||
const std::array<float,3>* camera = nullptr) const;
|
||||
const std::array<float,3>* camera = nullptr,
|
||||
bool cpuWind = false) const;
|
||||
|
||||
float GetHeight() const { return m_impl ? m_impl->GetHeight() : 1000.0f; }
|
||||
float GetRadius() const { return m_impl ? m_impl->GetRadius() : 350.0f; }
|
||||
|
||||
@@ -340,48 +340,51 @@ bool TerrainHeightmap::LoadTextureSet(const std::string& textureset_path) {
|
||||
}
|
||||
|
||||
bool TerrainHeightmap::LoadTextureSetFromString(const std::string& content) {
|
||||
m_patchDrawCache.clear();
|
||||
std::istringstream file(content);
|
||||
std::string line;
|
||||
int current_id = 0;
|
||||
bool in_texture = false;
|
||||
|
||||
while (std::getline(file, line)) {
|
||||
while (!line.empty() && (line.back() == '\r' || line.back() == ' ' || line.back() == '\t')) {
|
||||
line.pop_back();
|
||||
}
|
||||
size_t start = line.find_first_not_of(" \t");
|
||||
if (start == std::string::npos) continue;
|
||||
std::string trim = line.substr(start);
|
||||
|
||||
if (trim.rfind("Start Texture", 0) == 0) {
|
||||
std::string id_str = trim.substr(13);
|
||||
current_id = std::atoi(id_str.c_str());
|
||||
in_texture = true;
|
||||
} else if (trim.rfind("End Texture", 0) == 0) {
|
||||
in_texture = false;
|
||||
current_id = 0;
|
||||
} else if (in_texture && current_id > 0) {
|
||||
if (trim.front() == '"' || trim.find(".dds") != std::string::npos || trim.find(".tga") != std::string::npos) {
|
||||
std::string path = trim;
|
||||
if (path.front() == '"' && path.back() == '"') {
|
||||
path = path.substr(1, path.size() - 2);
|
||||
std::istringstream file(content);std::string line,path;
|
||||
std::unordered_map<uint8_t,std::string> textures;
|
||||
std::unordered_map<uint8_t,TextureCoordinates> coordinates;
|
||||
int id=0,field=0;TextureCoordinates current;
|
||||
while(std::getline(file,line)) {
|
||||
size_t start=line.find_first_not_of(" \t\r"),end=line.find_last_not_of(" \t\r");
|
||||
if(start==std::string::npos) continue;
|
||||
std::string trim=line.substr(start,end-start+1);
|
||||
if(trim.rfind("Start Texture",0)==0) {id=std::atoi(trim.substr(13).c_str());field=0;path.clear();current={};}
|
||||
else if(trim.rfind("End Texture",0)==0) {
|
||||
if(id>0 && id<=255 && !path.empty()) {textures[uint8_t(id)]=path;coordinates[uint8_t(id)]=current;}
|
||||
id=0;
|
||||
} else if(id>0 && id<=255) {
|
||||
if(field==0) {
|
||||
path=trim;if(path.front()=='"' && path.back()=='"')path=path.substr(1,path.size()-2);
|
||||
if(path.size()>=3 && (path[0]=='d'||path[0]=='D') && path[1]==':')path.erase(0,3);
|
||||
std::replace(path.begin(),path.end(),'\\','/');
|
||||
while(!path.empty() && path.front()=='/')path.erase(0,1);
|
||||
} else {
|
||||
std::istringstream value(trim);float number;
|
||||
if(!(value>>number) || !std::isfinite(number)) return false;
|
||||
if(field>=6 && (double(number)<-2147483648.0 || double(number)>2147483647.0)) return false;
|
||||
switch(field) {
|
||||
case 1:current.u_scale=number;break;case 2:current.v_scale=number;break;
|
||||
case 3:current.u_offset=number;break;case 4:current.v_offset=number;break;
|
||||
case 5:current.splat=number!=0;break;
|
||||
case 6:current.begin=uint16_t(int(number));break;case 7:current.end=uint16_t(int(number));break;
|
||||
default:return false;
|
||||
}
|
||||
if (path.size() >= 3 && (path[0] == 'd' || path[0] == 'D') && path[1] == ':') {
|
||||
path = path.substr(3);
|
||||
}
|
||||
for (char& c : path) {
|
||||
if (c == '\\') c = '/';
|
||||
}
|
||||
while (!path.empty() && path.front() == '/') {
|
||||
path = path.substr(1);
|
||||
}
|
||||
m_textureSet[static_cast<uint8_t>(current_id)] = path;
|
||||
in_texture = false;
|
||||
}
|
||||
++field;
|
||||
}
|
||||
}
|
||||
return !m_textureSet.empty();
|
||||
if(textures.empty()) return false;
|
||||
m_textureSet=std::move(textures);m_textureCoordinates=std::move(coordinates);m_patchDrawCache.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::array<float,2> TerrainHeightmap::GetTextureUv(uint8_t tile,float x,float z) const {
|
||||
auto found=m_textureCoordinates.find(tile);
|
||||
if(found==m_textureCoordinates.end()) return {(x-m_world_min_x)/500,(z-m_world_min_z)/500};
|
||||
// TextureSet::SetTexture, row-vector world texgen. Source rendering Y is
|
||||
// -map Y, so the SDK positive map-Z axis gives +VScale and -VOffset.
|
||||
const auto& t=found->second;float base=1.0f/(16*m_cell_scale);
|
||||
return {x*base*t.u_scale+t.u_offset,z*base*t.v_scale-t.v_offset};
|
||||
}
|
||||
|
||||
void TerrainHeightmap::GenerateProcedural(int width, int height, float cell_scale, float hill_amplitude) {
|
||||
@@ -801,8 +804,8 @@ Render3DDraw TerrainHeightmap::BuildPatchDraw(int patch_x, int patch_y, int step
|
||||
draw.normals.push_back(ny);
|
||||
draw.normals.push_back(nz);
|
||||
|
||||
float u = (vx - m_world_min_x) / 500.0f;
|
||||
float v = (vz - m_world_min_z) / 500.0f;
|
||||
auto uv=GetTextureUv(4,vx,vz);
|
||||
float u=uv[0],v=uv[1];
|
||||
draw.uv0.push_back(u);
|
||||
draw.uv0.push_back(v);
|
||||
|
||||
@@ -877,6 +880,10 @@ std::vector<Render3DDraw> TerrainHeightmap::BuildPatchDraws(int patch_x, int pat
|
||||
for (const auto& [tile, layer] : weights) {
|
||||
auto draw = base;
|
||||
draw.texture0 = GetTexturePathForTile(tile);
|
||||
for(size_t v=0;v<count;++v) {
|
||||
auto uv=GetTextureUv(tile,draw.positions[v*3],draw.positions[v*3+2]);
|
||||
draw.uv0[v*2]=uv[0];draw.uv0[v*2+1]=uv[1];
|
||||
}
|
||||
draw.alpha_blend = true;
|
||||
draw.z_write = false;
|
||||
draw.indices.clear();
|
||||
@@ -933,8 +940,8 @@ Render3DDraw TerrainHeightmap::BuildDrawCommand(const float world[16], int step)
|
||||
draw.normals.push_back(ny);
|
||||
draw.normals.push_back(nz);
|
||||
|
||||
float u = (vx - m_world_min_x) / 500.0f;
|
||||
float v = (vz - m_world_min_z) / 500.0f;
|
||||
auto uv=GetTextureUv(4,vx,vz);
|
||||
float u=uv[0],v=uv[1];
|
||||
draw.uv0.push_back(u);
|
||||
draw.uv0.push_back(v);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "RenderCommands3D.h"
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
@@ -97,6 +98,9 @@ public:
|
||||
// Load TextureSet file (e.g. textureset/metin2_map1.txt)
|
||||
bool LoadTextureSet(const std::string& textureset_path);
|
||||
bool LoadTextureSetFromString(const std::string& content);
|
||||
void ClearTextureSet() { m_textureSet.clear(); m_textureCoordinates.clear(); m_patchDrawCache.clear(); }
|
||||
struct TextureCoordinates { float u_scale=1,v_scale=1,u_offset=0,v_offset=0; bool splat=false; uint16_t begin=0,end=0; };
|
||||
std::array<float,2> GetTextureUv(uint8_t tile,float x,float z) const;
|
||||
|
||||
// Procedural terrain generation for testing
|
||||
void GenerateProcedural(int width = 64, int height = 64, float cell_scale = 100.0f, float hill_amplitude = 80.0f);
|
||||
@@ -197,6 +201,7 @@ private:
|
||||
std::vector<uint8_t> m_attr; // m_attr_width * m_attr_height attribute flags
|
||||
|
||||
std::unordered_map<uint8_t, std::string> m_textureSet; // tile_id -> texture dds path
|
||||
std::unordered_map<uint8_t,TextureCoordinates> m_textureCoordinates;
|
||||
|
||||
mutable std::map<std::tuple<int,int,int>, std::vector<Render3DDraw>> m_patchDrawCache;
|
||||
std::vector<TerrainPatch> m_patches; // m_patch_count_x * m_patch_count_z (8x8 per block)
|
||||
|
||||
@@ -265,7 +265,7 @@ void TextTailManager::HideAllTextTail() {
|
||||
m_itemList.clear();
|
||||
}
|
||||
|
||||
int TextTailManager::Pick(int ixMouse, int iyMouse) {
|
||||
int TextTailManager::Pick(int ixMouse, int iyMouse,float padding) {
|
||||
float mx = static_cast<float>(ixMouse);
|
||||
float my = static_cast<float>(iyMouse);
|
||||
|
||||
@@ -281,6 +281,17 @@ int TextTailManager::Pick(int ixMouse, int iyMouse) {
|
||||
return static_cast<int>(tail->dwVirtualID);
|
||||
}
|
||||
}
|
||||
if(padding>0) {
|
||||
std::shared_ptr<TextTailItem> picked;float best=padding*padding;
|
||||
for(const auto& tail:m_itemList) {
|
||||
if(!tail)continue;
|
||||
const float dx=mx-std::clamp(mx,tail->x+tail->xStart,tail->x+tail->xEnd);
|
||||
const float dy=my-std::clamp(my,tail->y+tail->yStart,tail->y+tail->yEnd);
|
||||
const float distance=dx*dx+dy*dy;
|
||||
if(distance<best || (distance==best && (!picked || tail->dwVirtualID<picked->dwVirtualID))) {best=distance;picked=tail;}
|
||||
}
|
||||
if(picked){SelectItemName(picked->dwVirtualID);return int(picked->dwVirtualID);}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
void EnablePKTitle(bool bFlag) { m_pkTitleEnable = bFlag; }
|
||||
|
||||
// Screen Position & Mouse Picking
|
||||
int Pick(int ixMouse, int iyMouse);
|
||||
int Pick(int ixMouse, int iyMouse,float padding=0);
|
||||
void SelectItemName(uint32_t vid);
|
||||
bool GetTextTailPosition(uint32_t vid, float& x, float& y, float& z) const;
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
namespace ava2 {
|
||||
// Portions Copyright (C) John W. Ratcliff, 2001 (AVA2 SphereLib/frustum.cpp).
|
||||
struct PerspectiveMetadata {float fovDegrees=0,aspect=0,nearPlane=0,farPlane=0;};
|
||||
struct DepthState {bool enabled=true,write=true;};
|
||||
struct ViewFrustum {
|
||||
std::array<std::array<float,4>,6> planes{};
|
||||
std::array<float,3> sphereCenter{};
|
||||
float sphereRadius=-1;
|
||||
ViewFrustum(const float* view,const float* projection,const std::array<float,3>& eye,const std::array<float,3>& forward,const PerspectiveMetadata* metadata=nullptr) {
|
||||
float matrix[16]={};for(int r=0;r<4;++r)for(int c=0;c<4;++c)for(int k=0;k<4;++k)matrix[r*4+c]+=view[r*4+k]*projection[k*4+c];
|
||||
for(int k=0;k<4;++k) {
|
||||
planes[0][k]=matrix[k*4+2];planes[1][k]=matrix[k*4+3]-matrix[k*4+2];
|
||||
planes[2][k]=matrix[k*4+3]+matrix[k*4];planes[3][k]=matrix[k*4+3]-matrix[k*4];
|
||||
planes[4][k]=matrix[k*4+3]+matrix[k*4+1];planes[5][k]=matrix[k*4+3]-matrix[k*4+1];
|
||||
}
|
||||
for(auto& plane:planes) {
|
||||
const float length=std::sqrt(plane[0]*plane[0]+plane[1]*plane[1]+plane[2]*plane[2]);
|
||||
if(length>0 && std::isfinite(length))for(auto& value:plane)value/=length;
|
||||
else plane={0,0,0,1}; // Invalid/degenerate plane cannot safely reject a segment.
|
||||
}
|
||||
// BuildViewFrustum2 uses saved perspective metadata even for ortho/off-axis matrices.
|
||||
if(metadata) {
|
||||
const float near=metadata->nearPlane,far=metadata->farPlane;
|
||||
const float length=far-near,half=near+length*0.5f;
|
||||
const float h=length*std::tan(metadata->fovDegrees*0.5f),w=h*metadata->aspect,z=half-length;
|
||||
const float radius=std::sqrt(w*w+h*h+z*z);
|
||||
if(std::isfinite(radius)) {
|
||||
sphereRadius=radius;for(int k=0;k<3;++k)sphereCenter[k]=eye[k]+forward[k]*half;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool Outside(const std::array<float,3>& center,float radius) const {
|
||||
if(sphereRadius>=0) {
|
||||
float distance=0;for(int k=0;k<3;++k){const float delta=center[k]-sphereCenter[k];distance+=delta*delta;}
|
||||
if((radius+sphereRadius)*(radius+sphereRadius)<distance)return true;
|
||||
}
|
||||
for(const auto& plane:planes)if(plane[0]*center[0]+plane[1]*center[1]+plane[2]*center[2]+plane[3]<=-radius)return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace ava2
|
||||
@@ -74,7 +74,7 @@ bool WaterManager::LoadWater(const std::string& filepath, float cell_scale, floa
|
||||
|
||||
size_t valid_cells = 0;
|
||||
for (uint8_t b : m_water_grid) {
|
||||
if (b != 0xFF && b < m_water_heights.size()) {
|
||||
if (b != 0xFF && b < m_water_heights.size() && m_water_heights[b] != -1) {
|
||||
valid_cells++;
|
||||
}
|
||||
}
|
||||
@@ -177,12 +177,13 @@ Render3DDraw WaterManager::BuildDrawCommand(float anim_time) const {
|
||||
return draw;
|
||||
}
|
||||
|
||||
// Step sampling for 128x128 water map to optimize draw call vertex counts
|
||||
const int step = 2;
|
||||
// AreaTerrain::CalculatePatch emits each valid water cell independently.
|
||||
// Skipping odd rows/columns erased thin rivers and extended water onto dry cells.
|
||||
const int step = 1;
|
||||
for (int j = 0; j < m_height; j += step) {
|
||||
for (int i = 0; i < m_width; i += step) {
|
||||
uint8_t layer = m_water_grid[j * m_width + i];
|
||||
if (layer == 0xFF || layer >= m_water_heights.size()) continue;
|
||||
if (layer == 0xFF || layer >= m_water_heights.size() || m_water_heights[layer] == -1) continue;
|
||||
|
||||
float base_y = static_cast<float>(m_water_heights[layer]) * m_height_scale - m_height_bias + wave_offset;
|
||||
float x0 = m_world_min_x + static_cast<float>(i) * m_cell_scale;
|
||||
|
||||
@@ -364,6 +364,7 @@ namespace UI
|
||||
void SetMultiLine(BOOL bFlag) { m_TextInstance.SetMultiLine(bFlag); }
|
||||
void SetFontName(const char * c_szFontName) { m_TextInstance.SetFontName(c_szFontName); }
|
||||
void SetFontColor(DWORD dwColor) { m_TextInstance.SetFontColor(dwColor); }
|
||||
DWORD GetFontColor() const { return m_TextInstance.GetColor(); }
|
||||
void SetLimitWidth(float fWidth) { m_TextInstance.SetLimitWidth(fWidth); }
|
||||
void ShowCursor() { m_TextInstance.ShowCursor(); }
|
||||
void HideCursor() { m_TextInstance.HideCursor(); }
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
namespace ava2 {
|
||||
// AVA2 InstanceBase.cpp GetMountLevelByVnum(vnum,false).
|
||||
// ENABLE_NO_MOUNT_CHECK is disabled; comments on mounts do not override cases.
|
||||
inline unsigned MountLevel(uint32_t vnum) {
|
||||
switch(vnum) {
|
||||
case 20107: case 20108: case 20110: case 20111: case 20112: case 20113: case 20114: case 20115:
|
||||
case 20116: case 20117: case 20118: case 20205: case 20206: case 20207: case 20208: case 20120:
|
||||
case 20121: case 20122: case 20123: case 20124: case 20125: case 20209: case 20210: case 20211:
|
||||
case 20212: case 20215: case 20218: case 20225: case 20230: case 20231: case 20232: case 20224:
|
||||
case 20221: case 20219: case 32000: case 32001: case 32002: case 32003: case 32004: case 32005:
|
||||
case 32006: case 32007: case 32009: case 32010: case 32011: case 32012: case 32013: case 32014:
|
||||
case 32015: case 32016: case 32017: case 32018: case 32019: case 32020: case 32021: case 32022:
|
||||
case 32023: case 32024: case 32025: case 32028: case 20244: case 20245: case 32026: case 32027:
|
||||
case 32029: case 32030: case 32031: case 32032: case 32033: case 32034: case 32035: case 32036:
|
||||
case 20109: case 20226: case 20227: case 20228: case 20229: case 20142: case 20143: case 20144:
|
||||
case 20145: case 20146:
|
||||
return 3;
|
||||
case 20104: case 20105: case 20106: case 20119: case 20214: case 20217: case 20220: case 20222:
|
||||
return 2;
|
||||
case 20101: case 20102: case 20103: case 20213: case 20216: case 20201: case 20202: case 20203:
|
||||
case 20204: case 20223:
|
||||
return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,31 @@ Bytes whisper(const std::string& name, const std::string& text) {
|
||||
return out;
|
||||
}
|
||||
|
||||
Bytes mobile_message(const std::string& name,const std::string& text) {
|
||||
// AVA2 TPacketCGSMS: BYTE + WORD + char[25], followed by NUL text.
|
||||
if(text.size()>65535-29) return {}; // Do not emit a wrapped WORD frame.
|
||||
Bytes out{HEADER_CG_SMS};u16(out,static_cast<std::uint16_t>(29+text.size()));
|
||||
char recipient[25]{};std::strncpy(recipient,name.c_str(),24);
|
||||
out.insert(out.end(),recipient,recipient+25);
|
||||
out.insert(out.end(),text.begin(),text.end());out.push_back(0);return out;
|
||||
}
|
||||
Bytes attribute67(int material,int support,int support_pos,int item_pos) {
|
||||
Bytes out{HEADER_CG_67_ATTR,uint8_t(material),uint8_t(support)};
|
||||
u16(out,uint16_t(support_pos));u16(out,uint16_t(item_pos));return out;
|
||||
}
|
||||
Bytes calendar(uint8_t subheader,int day,int event,const std::string& start,const std::string& end) {
|
||||
Bytes out{HEADER_CG_CALENDAR_SYSTEM,subheader};
|
||||
u32(out,uint32_t(day));u32(out,uint32_t(event));
|
||||
for(const auto& text:{start,end}) {
|
||||
char value[6]{};std::strncpy(value,text.c_str(),6);out.insert(out.end(),value,value+6);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Bytes catch_king(uint8_t subheader,int argument) {
|
||||
Bytes out{HEADER_CG_MINI_GAME_CATCH_KING,uint8_t(subheader==0||subheader==2?5:4),0,subheader};
|
||||
if(subheader==0 || subheader==2)out.push_back(uint8_t(argument));return out;
|
||||
}
|
||||
|
||||
Bytes entergame(std::uint8_t language) {
|
||||
return {HEADER_CG_ENTERGAME, language};
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ Bytes item_move(std::uint8_t src_window, std::uint16_t src_cell, std::uint8_t ds
|
||||
Bytes item_drop(std::uint8_t window_type, std::uint16_t cell, std::uint32_t count);
|
||||
Bytes chat(const std::string& text, std::uint8_t type = 0);
|
||||
Bytes whisper(const std::string& name, const std::string& text);
|
||||
Bytes mobile_message(const std::string& name, const std::string& text);
|
||||
Bytes attribute67(int material,int support,int support_pos,int item_pos);
|
||||
Bytes calendar(uint8_t subheader,int day=0,int event=0,const std::string& start="",const std::string& end="");
|
||||
Bytes catch_king(uint8_t subheader,int argument=0);
|
||||
Bytes entergame(std::uint8_t language=1);
|
||||
Bytes on_click(std::uint32_t vid);
|
||||
Bytes warp();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "eter_base/Random.h"
|
||||
#include "eter_base/Timer.h"
|
||||
#include "python_background.h"
|
||||
#include "python_system.h"
|
||||
#include "eter_ui/PythonWindowManager.h"
|
||||
#include "eter_effect/EffectManager.h"
|
||||
#include "eter_effect/FlyingManager.h"
|
||||
@@ -319,6 +320,10 @@ PyObject* app_get_cursor_position(PyObject*, PyObject*) {
|
||||
|
||||
static float gameFrameDelta = 0.033f;
|
||||
PyObject* app_update_game(PyObject*, PyObject*) {
|
||||
if(auto* scene=TextTailManager::Instance().GetCurrentSceneRenderer()) {
|
||||
scene->SetPerspective(CPythonSystem::Instance().GetFOVLevel(),UI::CWindowManager::Instance().GetAspect(),100,CPythonBackground::Instance().GetFarClip());
|
||||
scene->BuildViewFrustum();
|
||||
}
|
||||
long lx = 0, ly = 0;
|
||||
UI::CWindowManager::Instance().GetMousePosition(lx, ly);
|
||||
float camX = 0.0f, camY = 0.0f, camZ = 0.0f;
|
||||
@@ -330,11 +335,13 @@ PyObject* app_update_game(PyObject*, PyObject*) {
|
||||
}
|
||||
CPythonBackground::Instance().Update(camX, camY, camZ);
|
||||
float dt = gameFrameDelta;
|
||||
ProcessPlayerTouchInteraction();
|
||||
NetworkActorManager::Instance().Update(dt, CPythonBackground::Instance().GetTerrain());
|
||||
UpdatePlayerStamina(dt);
|
||||
EffectManager::Instance().Update(dt);
|
||||
static float s_flyingTime = 0.0f;
|
||||
s_flyingTime += dt;
|
||||
FlyingManager::Instance().Update(dt, s_flyingTime);
|
||||
FlyingManager::Instance().Update(dt,s_flyingTime,CPythonBackground::Instance().GetTerrain(),CPythonBackground::Instance().GetMapObjects(),[](float x,float z){return CPythonBackground::Instance().GetHeight(x,z);});
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -84,6 +86,8 @@ void CPythonBackground::Initialize() {
|
||||
m_eShadowLevel = SHADOW_NONE;
|
||||
m_dwRenderShadowTime = 0;
|
||||
m_iSplatLimit = 0;
|
||||
m_terrainHeightScale = TerrainHeightmap::DEFAULT_HEIGHT_SCALE;
|
||||
m_settingTerrainVisible = true;
|
||||
m_bSoftwareTilingEnable = false;
|
||||
m_bSnowEnable = false;
|
||||
m_bTransparentTree = false;
|
||||
@@ -95,9 +99,7 @@ void CPythonBackground::Initialize() {
|
||||
m_v3PickingPoint[1] = 0.0f;
|
||||
m_v3PickingPoint[2] = 0.0f;
|
||||
m_kSet_strDungeonMapName.clear();
|
||||
m_targetEffects.clear();
|
||||
m_targetEffectsShop.clear();
|
||||
m_targetPositions.clear();
|
||||
ClearTargetEffects();
|
||||
m_privateShopPosVID = 0;
|
||||
m_pCurrentEnvironment = &m_defaultEnvironment;
|
||||
}
|
||||
@@ -207,6 +209,7 @@ void CPythonBackground::LocalPositionToGlobalPosition(long& rLocalX, long& rLoca
|
||||
bool CPythonBackground::LoadMap(const std::string& mapName, float x, float y, float z) {
|
||||
(void)z;
|
||||
Create();
|
||||
ClearTargetEffects();
|
||||
|
||||
if (m_mapObjects) m_mapObjects->ClearObjects();
|
||||
if (m_forest) m_forest->Clear();
|
||||
@@ -240,7 +243,13 @@ bool CPythonBackground::LoadMap(const std::string& mapName, float x, float y, fl
|
||||
return false;
|
||||
}
|
||||
|
||||
// MapOutdoor::Clear/LoadSetting must not carry the previous map's settings.
|
||||
m_outdoorMap = OutdoorMapInfo{};
|
||||
m_outdoorMap.name = mapName;
|
||||
m_strMapName.clear();
|
||||
m_terrainHeightScale = TerrainHeightmap::DEFAULT_HEIGHT_SCALE;
|
||||
m_settingTerrainVisible = true;
|
||||
m_terrain->ClearTextureSet();
|
||||
std::string setting_path = found_base + "/setting.txt";
|
||||
std::string setting_content;
|
||||
try { setting_content = ReadPackedText(setting_path); } catch (...) {}
|
||||
@@ -255,6 +264,16 @@ bool CPythonBackground::LoadMap(const std::string& mapName, float x, float y, fl
|
||||
if (!setting_content.empty()) {
|
||||
std::map<std::string, std::vector<std::string>> tokens;
|
||||
ava2LoadMultipleTextData(setting_content, tokens);
|
||||
auto scale = tokens.find("heightscale");
|
||||
if (scale != tokens.end() && !scale->second.empty()) {
|
||||
char* end = nullptr;
|
||||
const float value = std::strtof(scale->second[0].c_str(), &end);
|
||||
if (!end || *end || end == scale->second[0].c_str() || !std::isfinite(value)) return false;
|
||||
m_terrainHeightScale = value;
|
||||
}
|
||||
auto visible = tokens.find("terrainvisible");
|
||||
if (visible != tokens.end() && !visible->second.empty())
|
||||
m_settingTerrainVisible = std::atoi(visible->second[0].c_str()) != 0;
|
||||
auto size = tokens.find("mapsize");
|
||||
if (size != tokens.end() && size->second.size() >= 2) {
|
||||
m_outdoorMap.terrainCountX = static_cast<int16_t>(std::atoi(size->second[0].c_str()));
|
||||
@@ -295,30 +314,16 @@ bool CPythonBackground::LoadMap(const std::string& mapName, float x, float y, fl
|
||||
m_mapBaseDir = found_base;
|
||||
ok = LoadTerrainBlocks(bx, by);
|
||||
} else {
|
||||
// Fallback: look for 000000 or any block in the directory
|
||||
// Compatibility fallback for an initial position outside the map. Use
|
||||
// the same block loader, so origin, scale, attributes and future streaming
|
||||
// cannot inherit the previous map's raw-loader state.
|
||||
for (const auto& entry : std::filesystem::directory_iterator(found_base)) {
|
||||
if (entry.is_directory()) {
|
||||
std::string hpath = entry.path().string() + "/height.raw";
|
||||
if (std::filesystem::exists(hpath)) {
|
||||
ok = m_terrain->LoadRaw(hpath);
|
||||
std::string tpath = entry.path().string() + "/tile.raw";
|
||||
if (std::filesystem::exists(tpath)) m_terrain->LoadTileRaw(tpath);
|
||||
std::string apath = entry.path().string() + "/attr.atr";
|
||||
if (std::filesystem::exists(apath)) m_terrain->LoadAttr(apath);
|
||||
std::string adpath = entry.path().string() + "/areadata.txt";
|
||||
if (std::filesystem::exists(adpath) && m_mapObjects) {
|
||||
m_mapObjects->LoadAreaData(adpath, 1.0f, m_forest.get(), true);
|
||||
}
|
||||
std::string wpath = entry.path().string() + "/water.wtr";
|
||||
if (std::filesystem::exists(wpath)) {
|
||||
m_waters.push_back(std::make_unique<WaterManager>());
|
||||
m_waters.back()->LoadWater(wpath, m_terrain ? m_terrain->GetCellScale() : 200.0f, 0.5f, 200.0f,
|
||||
m_terrain ? m_terrain->GetWorldMinX() : -2560.0f,
|
||||
m_terrain ? m_terrain->GetWorldMinZ() : -2560.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!entry.is_directory() || !std::filesystem::exists(entry.path()/"height.raw")) continue;
|
||||
const std::string blockName = entry.path().filename().string();
|
||||
if (blockName.size()!=6 || !std::all_of(blockName.begin(),blockName.end(),[](unsigned char c){return std::isdigit(c);})) continue;
|
||||
m_mapBaseDir = found_base;
|
||||
ok = LoadTerrainBlocks(std::atoi(blockName.substr(0,3).c_str()), std::atoi(blockName.substr(3,3).c_str()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +360,7 @@ bool CPythonBackground::LoadTerrainBlocks(int blockX, int blockY) {
|
||||
}
|
||||
}
|
||||
if (!m_terrain) m_terrain = std::make_unique<TerrainHeightmap>();
|
||||
const bool ok = m_terrain->LoadBlockDirs(nx, ny, dirs, x0 * 25600.0f, y0 * 25600.0f);
|
||||
const bool ok = m_terrain->LoadBlockDirs(nx, ny, dirs, x0 * 25600.0f, y0 * 25600.0f, m_terrainHeightScale);
|
||||
m_centerBlockX = blockX;
|
||||
m_centerBlockY = blockY;
|
||||
|
||||
@@ -373,7 +378,7 @@ bool CPythonBackground::LoadTerrainBlocks(int blockX, int blockY) {
|
||||
if (std::filesystem::exists(water_path)) {
|
||||
const int bx = x0 + static_cast<int>(i) % nx, by = y0 + static_cast<int>(i) / nx;
|
||||
auto water = std::make_unique<WaterManager>();
|
||||
if (water->LoadWater(water_path, cell, 0.5f, 200.0f, bx * 25600.0f - cell, by * 25600.0f - cell))
|
||||
if (water->LoadWater(water_path, cell, m_terrainHeightScale, 0.0f, bx * 25600.0f, by * 25600.0f))
|
||||
m_waters.push_back(std::move(water));
|
||||
}
|
||||
}
|
||||
@@ -589,33 +594,72 @@ void CPythonBackground::DeletePrivateShopPos() {
|
||||
m_privateShopPosVID = 0;
|
||||
}
|
||||
|
||||
// AVA2 PythonBackground target maps and MapOutdoor::SpecialEffect_Create.
|
||||
namespace {
|
||||
constexpr const char* targetEffect="d:/ymir work/effect/etc/direction/direction_land.mse";
|
||||
constexpr const char* shopTargetEffect="d:/ymir work/effect/direction/direction_land2.mse";
|
||||
}
|
||||
|
||||
void CPythonBackground::ClearTargetEffects() {
|
||||
auto& effects=EffectManager::Instance();
|
||||
for(const auto& entry:m_specialEffects) effects.DestroyEffectInstance(entry.second);
|
||||
m_specialEffects.clear();m_targetEffects.clear();m_targetEffectsShop.clear();m_targetPositions.clear();
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateTargetEffect(uint32_t dwID, uint32_t dwChrVID) {
|
||||
m_targetEffects[dwID] = dwChrVID;
|
||||
m_targetEffects.emplace(dwID,dwChrVID); // Original insert keeps the first binding.
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateCoordinateTarget(uint32_t id,long x,long y,bool shop) {
|
||||
const auto& bindings=shop?m_targetEffectsShop:m_targetEffects;
|
||||
if(bindings.count(id)) return;
|
||||
const float localX=float(MapCoordinates::signedBits(uint32_t(x)-m_outdoorMap.baseX));
|
||||
const float localY=float(MapCoordinates::signedBits(uint32_t(y)-m_outdoorMap.baseY));
|
||||
const float height=GetHeight(localX,localY);
|
||||
if(height==0) {
|
||||
// Both original target kinds share this reserve map; its update uses
|
||||
// direction_land.mse even for a deferred shop coordinate.
|
||||
m_targetPositions.emplace(id,std::make_pair(localX,localY));
|
||||
return;
|
||||
}
|
||||
CreateSpecialEffect(id,localX,-localY,height,shop?shopTargetEffect:targetEffect);
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateTargetEffect(uint32_t dwID, long lx, long ly) {
|
||||
m_targetPositions[dwID] = {static_cast<float>(lx), static_cast<float>(ly)};
|
||||
CreateCoordinateTarget(dwID,lx,ly,false);
|
||||
}
|
||||
|
||||
void CPythonBackground::DeleteTargetEffect(uint32_t dwID) {
|
||||
m_targetEffects.erase(dwID);
|
||||
m_targetPositions.erase(dwID);
|
||||
m_targetEffects.erase(dwID);m_targetEffectsShop.erase(dwID);m_targetPositions.erase(dwID);
|
||||
DeleteSpecialEffect(dwID);
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateTargetEffectShop(uint32_t dwID, uint32_t dwChrVID) {
|
||||
m_targetEffectsShop[dwID] = dwChrVID;
|
||||
m_targetEffectsShop.emplace(dwID,dwChrVID);
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateTargetEffectShop(uint32_t dwID, long lx, long ly) {
|
||||
m_targetPositions[dwID] = {static_cast<float>(lx), static_cast<float>(ly)};
|
||||
CreateCoordinateTarget(dwID,lx,ly,true);
|
||||
}
|
||||
|
||||
void CPythonBackground::CreateSpecialEffect(uint32_t dwID, float fx, float fy, float fz, const char* szFileName) {
|
||||
(void)dwID; (void)fx; (void)fy; (void)fz; (void)szFileName;
|
||||
if(!szFileName || !IsMapReady()) return;
|
||||
auto& effects=EffectManager::Instance();
|
||||
auto found=m_specialEffects.find(dwID);
|
||||
if(found!=m_specialEffects.end() && effects.IsAliveEffect(found->second)) {
|
||||
effects.SetEffectInstancePosition(found->second,fx,fz,-fy);
|
||||
return;
|
||||
}
|
||||
const uint32_t instance=effects.CreateEffect(szFileName,fx,fz,-fy);
|
||||
if(instance) m_specialEffects[dwID]=instance;
|
||||
}
|
||||
|
||||
void CPythonBackground::DeleteSpecialEffect(uint32_t dwID) {
|
||||
(void)dwID;
|
||||
auto found=m_specialEffects.find(dwID);
|
||||
if(found==m_specialEffects.end()) return;
|
||||
EffectManager::Instance().DestroyEffectInstance(found->second);
|
||||
// Drop the stale association so reusing a target ID can still follow/move.
|
||||
m_specialEffects.erase(found);
|
||||
}
|
||||
|
||||
void CPythonBackground::Update(float fCenterX, float fCenterY, float fCenterZ) {
|
||||
@@ -638,8 +682,25 @@ void CPythonBackground::Update(float fCenterX, float fCenterY, float fCenterZ) {
|
||||
m_skybox->Update(GetGameFrameDelta());
|
||||
}
|
||||
if (m_forest) {
|
||||
m_forest->UpdateSystem(0.033f);
|
||||
m_forest->UpdateSystem(GetGameFrameDelta());
|
||||
}
|
||||
if(!IsMapReady()) return;
|
||||
auto follow=[&](const auto& targets,const char* filename) {
|
||||
for(const auto& [id,vid]:targets) {
|
||||
const auto* actor=NetworkActorManager::Instance().GetActorData(vid);
|
||||
if(!actor || !actor->m_pActorInstance) continue;
|
||||
const auto& instance=*actor->m_pActorInstance;
|
||||
CreateSpecialEffect(id,instance.GetX(),-instance.GetZ(),instance.GetY(),filename);
|
||||
}
|
||||
};
|
||||
follow(m_targetEffects,targetEffect);
|
||||
for(auto it=m_targetPositions.begin();it!=m_targetPositions.end();) {
|
||||
const auto [x,y]=it->second;const float height=GetHeight(x,y);
|
||||
if(height==0) {++it;continue;}
|
||||
CreateSpecialEffect(it->first,x,-y,height,targetEffect);
|
||||
it=m_targetPositions.erase(it);
|
||||
}
|
||||
follow(m_targetEffectsShop,shopTargetEffect);
|
||||
}
|
||||
|
||||
void CPythonBackground::Render() {
|
||||
@@ -695,17 +756,14 @@ void CPythonBackground::BuildDrawCommands(const float* viewMatrix, const float*
|
||||
for (auto& sd : sdraws) outDraws.push_back(std::move(sd));
|
||||
}
|
||||
|
||||
if (m_bVisiblePart[PART_TERRAIN] && m_terrain) {
|
||||
if (m_bVisiblePart[PART_TERRAIN] && m_settingTerrainVisible && m_terrain) {
|
||||
std::vector<Render3DDraw> tdraws;
|
||||
bool referenced = false;
|
||||
if (viewMatrix && projMatrix && outRefs) {
|
||||
const size_t refCount = outRefs->size();
|
||||
m_terrain->AppendCulledDrawRefs(viewMatrix, projMatrix, GetFarClip(), outDraws.size(), *outRefs, refLightDir, refLightAmbient);
|
||||
referenced = outRefs->size() != refCount;
|
||||
} else if (viewMatrix && projMatrix) {
|
||||
tdraws = m_terrain->BuildCulledDraws(viewMatrix, projMatrix, GetFarClip());
|
||||
}
|
||||
if (!referenced && tdraws.empty()) {
|
||||
if (!viewMatrix || !projMatrix) {
|
||||
auto td = m_terrain->BuildDrawCommand(nullptr, 2);
|
||||
if (!td.positions.empty()) tdraws.push_back(std::move(td));
|
||||
}
|
||||
@@ -790,6 +848,7 @@ PyObject* background_EnableSoftwareTiling(PyObject*, PyObject* args) {
|
||||
PyObject* background_TextureChange(PyObject*, PyObject* args) {
|
||||
char* szFileName = nullptr;
|
||||
if (!PyTuple_GetString(args, 0, &szFileName)) return Py_BuildException();
|
||||
CPythonBackground::Instance().TextureChange(szFileName);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -1242,6 +1301,15 @@ TerrainHeightmap* GetActiveBackgroundTerrain() {
|
||||
return CPythonBackground::Instance().GetTerrain();
|
||||
}
|
||||
|
||||
bool CPythonBackground::TextureChange(const std::string& filename) {
|
||||
if(!m_terrain) return false;
|
||||
std::string path=CResourceManager::NormalizePath(filename.c_str());
|
||||
// Preserve AVA2 CMapOutdoor::TextureChange's literal prefix rule.
|
||||
if(path.find_first_of("textureset")!=0) path="textureset/"+path;
|
||||
try {return m_terrain->LoadTextureSetFromString(ReadPackedText(path));}
|
||||
catch(const std::exception&) {return false;}
|
||||
}
|
||||
|
||||
void SetActiveBackgroundTerrain(std::unique_ptr<TerrainHeightmap> terrain) {
|
||||
(void)terrain;
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
bool IsMapReady() const;
|
||||
|
||||
bool LoadMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f);
|
||||
bool TextureChange(const std::string& path);
|
||||
bool Warp(uint32_t x, uint32_t y);
|
||||
|
||||
const std::string& GetCurrentMapName() const { return m_strMapName; }
|
||||
@@ -212,6 +213,8 @@ public:
|
||||
|
||||
private:
|
||||
void LoadAtlas();
|
||||
void ClearTargetEffects();
|
||||
void CreateCoordinateTarget(uint32_t id, long x, long y, bool shop);
|
||||
|
||||
std::string m_strMapName;
|
||||
std::string m_strWarpMapName;
|
||||
@@ -225,6 +228,8 @@ private:
|
||||
int m_eShadowLevel = SHADOW_NONE;
|
||||
uint32_t m_dwRenderShadowTime = 0;
|
||||
int m_iSplatLimit = 0;
|
||||
float m_terrainHeightScale = TerrainHeightmap::DEFAULT_HEIGHT_SCALE;
|
||||
bool m_settingTerrainVisible = true;
|
||||
|
||||
bool m_bSoftwareTilingEnable = false;
|
||||
bool m_bSnowEnable = false;
|
||||
@@ -261,6 +266,7 @@ private:
|
||||
std::map<uint32_t, uint32_t> m_targetEffects;
|
||||
std::map<uint32_t, uint32_t> m_targetEffectsShop;
|
||||
std::map<uint32_t, std::pair<float, float>> m_targetPositions;
|
||||
std::map<uint32_t, uint32_t> m_specialEffects;
|
||||
uint32_t m_privateShopPosVID = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
#include "eter_image/GrpImageInstance.h"
|
||||
#include "eter_image/GrpImage.h"
|
||||
#include "eter_base/Timer.h"
|
||||
#include "eter_base/Random.h"
|
||||
#include "skill_description.h"
|
||||
#include "python_chat.h"
|
||||
#include <bit>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include "mount_rules.h"
|
||||
#include <Python.h>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
@@ -58,6 +64,40 @@ static std::map<int, PlayerSkill> s_playerSkills;
|
||||
static std::map<int,int> s_skillSlots;
|
||||
static uint32_t s_targetVID = 0;
|
||||
static bool s_coolTimeEnabled = true;
|
||||
static bool s_levelLimit = true; // AVA2 CPythonPlayer::__Initialize
|
||||
struct ReservedSkill {
|
||||
uint32_t mainVID,targetVID,range;
|
||||
int slot;
|
||||
std::weak_ptr<ActorInstance> main,target;
|
||||
bool ownsMove=false;
|
||||
};
|
||||
static std::optional<ReservedSkill> s_reservedSkill;
|
||||
static void CancelReservedSkillImpl() {
|
||||
if(s_reservedSkill && s_reservedSkill->ownsMove)
|
||||
if(auto actor=s_reservedSkill->main.lock()) {actor->ClearMoveTarget();actor->StopMoving();}
|
||||
s_reservedSkill.reset();
|
||||
}
|
||||
static void ProcessReservedSkillImpl() {
|
||||
if(!s_reservedSkill) return;
|
||||
const auto reserved=*s_reservedSkill;
|
||||
auto& manager=NetworkActorManager::Instance();
|
||||
auto* main=manager.GetMainInstance();auto* target=manager.GetActorData(reserved.targetVID);
|
||||
auto actor=reserved.main.lock(),victim=reserved.target.lock();
|
||||
if(!main || main->m_dwVID!=reserved.mainVID || !target || !actor || !victim
|
||||
|| main->m_pActorInstance!=actor || target->m_pActorInstance!=victim) {CancelPlayerReservedSkill();return;}
|
||||
if(!actor->CanAct() || actor->IsUsingSkill() || actor->IsAttacking() || actor->IsEmotionMovementLocked() || manager.IsEmotionProcessing()) {
|
||||
if(reserved.ownsMove) {actor->ClearMoveTarget();actor->StopMoving();s_reservedSkill->ownsMove=false;}
|
||||
return;
|
||||
}
|
||||
const float distance=std::hypot(victim->GetX()-actor->GetX(),victim->GetZ()-actor->GetZ())-(victim->GetRace()==2493?200.0f:0.0f);
|
||||
if(distance<float(reserved.range)) {
|
||||
if(reserved.ownsMove) {actor->ClearMoveTarget();actor->StopMoving();s_reservedSkill->ownsMove=false;}
|
||||
if(s_targetVID!=reserved.targetVID) {s_targetVID=reserved.targetVID;PythonNetworkStream::Instance().SendTargetPacket(s_targetVID);}
|
||||
ClickSkillSlot(reserved.slot);
|
||||
} else {
|
||||
actor->SetMoveTarget(victim->GetX(),victim->GetZ());s_reservedSkill->ownsMove=true;
|
||||
}
|
||||
}
|
||||
static SkillCastCallback s_skillCastCallback = nullptr;
|
||||
static int s_curSkillSlotIndex = 0;
|
||||
static std::unordered_map<int, long long> s_playerPoints;
|
||||
@@ -65,6 +105,8 @@ struct PlayerQuickSlot { int type=0; int pos=0; };
|
||||
static std::array<PlayerQuickSlot,36> s_playerQuickSlots{};
|
||||
static int s_quickPage=0;
|
||||
static PyObject* s_playerGameWindow=nullptr;
|
||||
static bool s_consumingStamina=false;
|
||||
static float s_staminaRate=0,s_currentStamina=0;
|
||||
static PyObject* player_SetGameWindow(PyObject*,PyObject* args) {
|
||||
PyObject* window;if(!PyArg_ParseTuple(args,"O",&window)) return nullptr;
|
||||
if(window==Py_None || (PyInt_Check(window) && PyInt_AsLong(window)==0)) window=nullptr;
|
||||
@@ -87,6 +129,9 @@ static bool player_window_call(const char* name, PyObject* args = nullptr) {
|
||||
}
|
||||
return PyCallClassMemberFunc(s_playerGameWindow, name, args);
|
||||
}
|
||||
static bool skill_window_call(const char* name,PyObject* args) {
|
||||
return PyCallClassMemberFunc(PythonNetworkStream::Instance().GetGamePhaseWindow(),name,args);
|
||||
}
|
||||
static PyObject* player_GetQuickPage(PyObject*,PyObject*) {return PyInt_FromLong(s_quickPage);}
|
||||
static PyObject* player_SetQuickPage(PyObject*,PyObject* args) {
|
||||
int page;if(!PyArg_ParseTuple(args,"i",&page)) return nullptr;
|
||||
@@ -955,6 +1000,9 @@ static PyObject* player_IsBeltInventorySlot(PyObject*, PyObject* args) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void CancelPlayerReservedSkill() { CancelReservedSkillImpl(); }
|
||||
void ProcessPlayerReservedSkill() { ProcessReservedSkillImpl(); }
|
||||
|
||||
int AffectIndexToSkillIndex(int affect) {
|
||||
// AVA2 PythonPlayer::__Initialize: this map is independent of skill registration.
|
||||
static const int mapping[][2]={{14,3},{15,4},{16,19},{17,49},{18,34},{20,64},{21,65},{22,94},{23,95},{24,110},{29,96},{30,111},{32,66},{33,19},{19,63},{26,78},{25,79},{46,182}};
|
||||
@@ -972,13 +1020,13 @@ void UseGuildSkill(int skillSlot) {
|
||||
|
||||
float now = CTimer::Instance().GetCurrentSecond();
|
||||
if (it->second.cooldown.cooling(now, s_coolTimeEnabled)) {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "WAIT_COOLTIME"));
|
||||
skill_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "WAIT_COOLTIME"));
|
||||
return;
|
||||
}
|
||||
|
||||
bool onlyGuildWar = pSkillData && (pSkillData->attributes & (1u << 19 /* SKILL_ATTRIBUTE_ONLY_FOR_GUILD_WAR */));
|
||||
if (onlyGuildWar && !GetGuildState().IsDoingGuildWar()) {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "ONLY_FOR_GUILD_WAR"));
|
||||
skill_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "ONLY_FOR_GUILD_WAR"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -986,7 +1034,7 @@ void UseGuildSkill(int skillSlot) {
|
||||
|
||||
float baseCoolTime = pSkillData ? EvaluateSkillFormula(pSkillData->cooldownFormula, it->second.currentPower) : 0.0f;
|
||||
long long castSpd = 0;
|
||||
auto spdIt = s_playerPoints.find(19 /* POINT_CASTING_SPEED */);
|
||||
auto spdIt = s_playerPoints.find(21 /* POINT_CASTING_SPEED */);
|
||||
if (spdIt != s_playerPoints.end()) castSpd = spdIt->second;
|
||||
int iSpd = 100 - int(castSpd);
|
||||
if (iSpd > 0) iSpd = 100 + iSpd;
|
||||
@@ -994,7 +1042,7 @@ void UseGuildSkill(int skillSlot) {
|
||||
else iSpd = 100;
|
||||
float coolTime = baseCoolTime * float(iSpd) / 100.0f;
|
||||
it->second.cooldown = {coolTime, now};
|
||||
player_window_call("RunUseSkillEvent", Py_BuildValue("(if)", skillSlot, coolTime));
|
||||
skill_window_call("RunUseSkillEvent", Py_BuildValue("(if)", skillSlot, coolTime));
|
||||
}
|
||||
|
||||
static bool s_isAtkKey = false;
|
||||
@@ -1002,6 +1050,9 @@ static std::array<bool, 256> s_movementKeys{};
|
||||
static bool s_joystickActive = false;
|
||||
static float s_joystickX = 0.0f, s_joystickY = 0.0f;
|
||||
bool GetPlayerMovementYaw(float cameraYaw, float& movementYaw) {
|
||||
if(NetworkActorManager::Instance().IsEmotionProcessing()) return false;
|
||||
const auto* main=NetworkActorManager::Instance().GetMainInstance();
|
||||
if(main && main->m_pActorInstance && main->m_pActorInstance->IsEmotionMovementLocked()) return false;
|
||||
float x = float(int(s_movementKeys[32] || s_movementKeys[205]) - int(s_movementKeys[30] || s_movementKeys[203]));
|
||||
float z = float(int(s_movementKeys[31] || s_movementKeys[208]) - int(s_movementKeys[17] || s_movementKeys[200]));
|
||||
// Joystick screen-down is "back" like DIK_S, so it maps onto the same camera-relative axes.
|
||||
@@ -1030,9 +1081,10 @@ static void SetPlayerHitTarget(uint32_t vid) {
|
||||
|
||||
static float s_attackCameraYaw = 0.0f;
|
||||
// CPythonPlayer::NEW_Attack + CInstanceBase::NEW_Attack(fDirRot). Not ported from __CanAttack:
|
||||
// emotion / private shop / observer / new-mount skill checks. Bow mode needs a live target (the
|
||||
// private shop / observer / new-mount skill checks. Pending emotion blocks input below. Bow needs a live target (the
|
||||
// clickable-distance reserve and arrow flight are not ported).
|
||||
static bool PlayerNewAttack() {
|
||||
if(NetworkActorManager::Instance().IsEmotionProcessing()) return false;
|
||||
auto& manager = NetworkActorManager::Instance();
|
||||
auto* main = manager.GetMainInstance();
|
||||
if (!main || !main->m_pActorInstance) return false;
|
||||
@@ -1067,7 +1119,9 @@ bool IsPlayerAttacking() {
|
||||
}
|
||||
|
||||
bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving) {
|
||||
ProcessPlayerTouchInteraction();
|
||||
s_attackCameraYaw = cameraYaw;
|
||||
ProcessPlayerReservedSkill();
|
||||
auto& manager = NetworkActorManager::Instance();
|
||||
auto* main = manager.GetMainInstance();
|
||||
if (!main || !main->m_pActorInstance) return false;
|
||||
@@ -1075,7 +1129,7 @@ bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving) {
|
||||
inst.SetReportAttacks(true);
|
||||
// CInstanceBase::Update: ComboProcess, then CPythonPlayer input (m_isAtkKey -> NEW_Attack).
|
||||
inst.ComboProcess();
|
||||
if (s_isAtkKey) PlayerNewAttack();
|
||||
if (s_isAtkKey && !s_reservedSkill) PlayerNewAttack();
|
||||
// CPythonPlayerEventHandler::OnAttack: SendCharacterStatePacket(pos, rot, FUNC_COMBO, motion).
|
||||
uint16_t motion;
|
||||
bool stopSent = false;
|
||||
@@ -1091,8 +1145,8 @@ bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving) {
|
||||
uint8_t(std::fmod(inst.GetYaw() + 360.0f, 360.0f) / 5.0f),
|
||||
int32_t(inst.GetX()), int32_t(inst.GetZ()), GetServerMSec());
|
||||
}
|
||||
// CInstanceBase::AttackProcess: hit-test every attackable instance (enemies and stones; PvP
|
||||
// rules are not ported). Each hit is OnHit: SetTarget + SendAttackPacket(0, vid).
|
||||
// CInstanceBase::AttackProcess uses the same attackability rules as the UI.
|
||||
// Each hit is OnHit: SetTarget + SendAttackPacket(0, vid).
|
||||
// CNormalBowAttack_FlyEventHandler_AutoClear (SetTarget): the fly event handler reports the
|
||||
// fly target and every shot. SetTarget sets the main fly target; a skill target set by
|
||||
// ClickSkillSlot is kept while its motion runs.
|
||||
@@ -1104,7 +1158,7 @@ bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving) {
|
||||
[&inst]() {
|
||||
float pos[3];
|
||||
if (!inst.GetFlyTargetPosition(pos)) return;
|
||||
PythonNetworkStream::Instance().SendFlyTargetingPacket(inst.GetFlyTargetVID(), int32_t(pos[0]), int32_t(pos[2]));
|
||||
PythonNetworkStream::Instance().SendFlyTargetingPacket(inst.GetFlyTargetVID(),int32_t(pos[0]),int32_t(-pos[2]));
|
||||
},
|
||||
[](uint32_t skill) { PythonNetworkStream::Instance().SendShootPacket(skill); },
|
||||
});
|
||||
@@ -1116,7 +1170,7 @@ bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving) {
|
||||
if (!inst.CanCheckAttacking()) return stopSent;
|
||||
for (const auto& [vid, victim] : manager.GetActorDict()) {
|
||||
if (vid == main->m_dwVID || !victim.m_pActorInstance) continue;
|
||||
if (victim.m_bType != 0 && victim.m_bType != 2) continue; // TYPE_ENEMY / TYPE_STONE
|
||||
if (!CanPlayerAttackInstance(vid)) continue;
|
||||
const auto& v = *victim.m_pActorInstance;
|
||||
if (v.IsDead()) continue;
|
||||
// __SplashAttackProcess (SPECIAL_ATTACKING motion events): OnHit + SendAttackPacket(skill).
|
||||
@@ -1166,7 +1220,8 @@ static int PointPercent(int cur, int max) {
|
||||
}
|
||||
|
||||
void ProcessAutoHunt() {
|
||||
if (!s_autoHunt.IsOn()) return;
|
||||
if(s_reservedSkill) return; // Do not overwrite a skill's approach with another auto-hunt command.
|
||||
if (!s_autoHunt.IsOn() || NetworkActorManager::Instance().IsEmotionProcessing()) return;
|
||||
auto& manager = NetworkActorManager::Instance();
|
||||
auto* main = manager.GetMainInstance();
|
||||
if (!main || !main->m_pActorInstance) return;
|
||||
@@ -1257,7 +1312,7 @@ static bool IsMainActorFishingMode() {
|
||||
|
||||
static bool IsMainActorFishing() {
|
||||
const auto* pActor = player_main_actor();
|
||||
return pActor && pActor->m_isFishing;
|
||||
return pActor && pActor->m_pActorInstance && pActor->m_pActorInstance->IsFishing();
|
||||
}
|
||||
|
||||
static bool NEW_CancelFishing() {
|
||||
@@ -1313,6 +1368,68 @@ static void NEW_Fishing() {
|
||||
}
|
||||
}
|
||||
|
||||
static void SendPlayerSkillUse(int skillSlot,uint32_t targetVID) {
|
||||
auto it=s_playerSkills.find(skillSlot);if(it==s_playerSkills.end()) return;
|
||||
const int skillIndex=it->second.index;
|
||||
const auto* pSkillData=FindSkillDescription(uint32_t(skillIndex));
|
||||
const float now=CTimer::Instance().GetCurrentSecond();
|
||||
// Send use skill packet
|
||||
PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex), targetVID);
|
||||
|
||||
// Run cooltime
|
||||
float baseCoolTime = pSkillData ? EvaluateSkillFormula(pSkillData->cooldownFormula, it->second.currentPower) : 0.0f;
|
||||
long long castSpd = 0;
|
||||
auto spdIt = s_playerPoints.find(21 /* POINT_CASTING_SPEED */);
|
||||
if (spdIt != s_playerPoints.end()) castSpd = spdIt->second;
|
||||
int iSpd = 100 - int(castSpd);
|
||||
if (iSpd > 0) iSpd = 100 + iSpd;
|
||||
else if (iSpd < 0) iSpd = 10000 / (100 - iSpd);
|
||||
else iSpd = 100;
|
||||
float coolTime = baseCoolTime * float(iSpd) / 100.0f;
|
||||
it->second.cooldown = {coolTime, now};
|
||||
skill_window_call("RunUseSkillEvent", Py_BuildValue("(if)", skillSlot, coolTime));
|
||||
|
||||
if (s_skillCastCallback) {
|
||||
s_skillCastCallback(-1, skillSlot);
|
||||
}
|
||||
}
|
||||
|
||||
// Mobile gesture adapter; all actual permissions, motion and packets remain in ClickSkillSlot.
|
||||
void UsePlayerTouchSkill(int skillSlot,float aimX,float aimY,float cameraYaw,bool repeat) {
|
||||
if(!repeat)CancelPlayerTouchInteraction();
|
||||
const auto it=s_playerSkills.find(skillSlot);if(it==s_playerSkills.end())return;
|
||||
const auto* data=FindSkillDescription(uint32_t(it->second.index));if(!data)return;
|
||||
auto& manager=NetworkActorManager::Instance();auto* main=manager.GetMainInstance();
|
||||
if(!main || !main->m_pActorInstance)return;
|
||||
auto& actor=*main->m_pActorInstance;
|
||||
if(actor.IsEmotionMovementLocked() || manager.IsEmotionProcessing() || PythonNetworkStream::Instance().IsObserverMode())return;
|
||||
if(repeat) {
|
||||
// Toggle, buff, guild and utility skills are single-shot, not continuously retriggered.
|
||||
if(!(data->attributes&(1u<<14)) || (data->attributes&((1u<<1)|(1u<<17))) || GetSkillTypeById(it->second.index)==3
|
||||
|| actor.IsUsingSkill() || !actor.CanUseSkill() || s_reservedSkill
|
||||
|| it->second.cooldown.cooling(CTimer::Instance().GetCurrentSecond(),s_coolTimeEnabled))return;
|
||||
}
|
||||
const bool aimed=std::isfinite(aimX) && std::isfinite(aimY) && std::isfinite(cameraYaw) && std::hypot(aimX,aimY)>0;
|
||||
if(!actor.IsUsingSkill() && actor.CanUseSkill() && (data->attributes&(1u<<14)) && !(data->attributes&((1u<<7)|(1u<<9)))) {
|
||||
const float yaw=aimed?std::fmod(std::atan2(aimX,aimY)*180/3.14159265358979323846f-cameraYaw+720,360):actor.GetYaw();
|
||||
if(aimed)actor.SetYaw(yaw);
|
||||
const auto* selected=manager.GetActorData(s_targetVID);
|
||||
const bool selectedAlive=selected && selected->m_pActorInstance && !selected->m_pActorInstance->IsDead() && CanPlayerAttackInstance(s_targetVID);
|
||||
if((aimed || !selectedAlive) && (data->attributes&((1u<<0)|(1u<<5)|(1u<<23)))) {
|
||||
uint32_t target=0;float best=std::numeric_limits<float>::max();
|
||||
const float range=data->targetRange?float(data->targetRange)+float(GetPlayerStatusPoint(34))*100:2000;
|
||||
for(const auto& [vid,candidate]:manager.GetActorDict()) {
|
||||
if(!candidate.m_pActorInstance || candidate.m_pActorInstance->IsDead() || !CanPlayerAttackInstance(vid))continue;
|
||||
const float dx=candidate.m_pActorInstance->GetX()-actor.GetX(),dz=candidate.m_pActorInstance->GetZ()-actor.GetZ();
|
||||
const float distance=std::hypot(dx,dz);const float angle=std::atan2(dx,dz)*180/3.14159265358979323846f;
|
||||
if(distance>range || (aimed && std::abs(std::remainder(angle-yaw,360.f))>35))continue;
|
||||
if(distance<best || (distance==best && vid<target)){best=distance;target=vid;}
|
||||
}
|
||||
if(target!=s_targetVID){s_targetVID=target;PythonNetworkStream::Instance().SendTargetPacket(target);}
|
||||
}
|
||||
}
|
||||
ClickSkillSlot(skillSlot);
|
||||
}
|
||||
void ClickSkillSlot(int skillSlot) {
|
||||
if (uint32_t(skillSlot) >= 255) return;
|
||||
auto it = s_playerSkills.find(skillSlot);
|
||||
@@ -1328,12 +1445,32 @@ void ClickSkillSlot(int skillSlot) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!pSkillData || (pSkillData->attributes & (1u<<17))) return; // IsCanUseSkill: PASSIVE
|
||||
auto* main=NetworkActorManager::Instance().GetMainInstance();
|
||||
if(!main || !main->m_pActorInstance) return;
|
||||
auto& actor=*main->m_pActorInstance;
|
||||
// ClickSkillSlot's active standing toggle bypasses __UseSkill, but not the
|
||||
// current-skill lock. Preserve that branch before the general permission gate.
|
||||
if((pSkillData->attributes & (1u<<6)) && (pSkillData->attributes & (1u<<1)) && it->second.active) {
|
||||
if(!actor.IsUsingSkill()) PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex),0);
|
||||
return;
|
||||
}
|
||||
if(PythonNetworkStream::Instance().IsObserverMode() || actor.IsPolymorph()
|
||||
|| main->m_awPart[RaceData::PART_MAIN]==201
|
||||
|| (main->m_awPart[RaceData::PART_WEAPON]>=29101 && main->m_awPart[RaceData::PART_WEAPON]<=29110)
|
||||
|| !actor.CanUseSkill()) return;
|
||||
if(actor.IsMountingHorse()) {
|
||||
const auto riding=s_playerSkills.find(107); // AVA2 ENABLE_CONQUEROR_LEVEL enabled.
|
||||
const auto mount=main->m_pMountInstance ? main->m_pMountInstance->GetRace() : main->m_dwMountVnum;
|
||||
if(riding==s_playerSkills.end() || (riding->second.grade<1 && riding->second.level<20) || MountLevel(mount)<=2) return;
|
||||
}
|
||||
|
||||
// Special skill check (fishing)
|
||||
if (skillIndex == 123 /* SKILL_INDEX_FISHING */ || skillIndex == 121) {
|
||||
if (IsMainActorFishingMode()) {
|
||||
NEW_Fishing();
|
||||
} else {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "EQUIP_FISHING_ROD"));
|
||||
skill_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "EQUIP_FISHING_ROD"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1343,7 +1480,7 @@ void ClickSkillSlot(int skillSlot) {
|
||||
if (it->second.level > 0) {
|
||||
PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex), 0);
|
||||
} else {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "NOT_YET_LEARN"));
|
||||
skill_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "NOT_YET_LEARN"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1351,29 +1488,220 @@ void ClickSkillSlot(int skillSlot) {
|
||||
// Toggle skill active check (turns off if already active)
|
||||
bool isToggle = pSkillData && (pSkillData->attributes & (1u << 1 /* SKILL_ATTRIBUTE_TOGGLE */));
|
||||
if (isToggle && it->second.active) {
|
||||
PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex), 0);
|
||||
PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex), uint32_t(skillSlot));
|
||||
return;
|
||||
}
|
||||
|
||||
const bool horseSkill=(pSkillData->attributes & (1u<<21))!=0;
|
||||
if(actor.IsMountingHorse() && !horseSkill) {
|
||||
skill_window_call("OnCannotUseSkill",Py_BuildValue("(is)",PythonNetworkStream::Instance().GetMainActorVID(),"NOT_HORSE_SKILL"));return;
|
||||
}
|
||||
if(horseSkill && !actor.IsMountingHorse()) {
|
||||
skill_window_call("OnCannotUseSkill",Py_BuildValue("(is)",PythonNetworkStream::Instance().GetMainActorVID(),"HAVE_TO_RIDE"));return;
|
||||
}
|
||||
if((pSkillData->attributes & (1u<<14)) && CPythonBackground::Instance().IsAttrOn(actor.GetX(),actor.GetZ(),TerrainAttr::ATTR_BANPK)) {
|
||||
skill_window_call("OnCannotUseSkill",Py_BuildValue("(is)",PythonNetworkStream::Instance().GetMainActorVID(),"IN_SAFE"));return;
|
||||
}
|
||||
|
||||
auto failSkill=[&](const char* reason) {
|
||||
skill_window_call("OnCannotUseSkill",Py_BuildValue("(is)",PythonNetworkStream::Instance().GetMainActorVID(),reason));
|
||||
};
|
||||
auto hasItem=[&](uint32_t vnum) {
|
||||
// __HasItem: inventory (including equipment/belt), dragon soul and
|
||||
// the five active special inventories, not warehouse/mall/switchbot.
|
||||
for(uint8_t window : {1,5,6,7,8,9,10})
|
||||
for(uint16_t cell=0;valid_player_item_position(window,cell);++cell)
|
||||
if(GetPlayerItemData(window,cell).vnum==vnum) return true;
|
||||
return false;
|
||||
};
|
||||
if((pSkillData->attributes&(1u<<12)) && !hasItem(27995)) {failSkill("NEED_EMPTY_BOTTLE");return;}
|
||||
if((pSkillData->attributes&(1u<<13)) && !hasItem(27996)) {failSkill("NEED_POISON_BOTTLE");return;}
|
||||
if(actor.GetMotionMode()==8) {failSkill("REMOVE_FISHING_ROD");return;}
|
||||
if(s_levelLimit && it->second.level<=0) {failSkill("NOT_YET_LEARN");return;}
|
||||
if(pSkillData->attributes&(1u<<2)) {
|
||||
int type=0,subtype=11; // AVA2 WEAPON_NONE (WOLFMAN off).
|
||||
if(!GetItemTypeAndSubType(main->m_awPart[RaceData::PART_WEAPON],&type,&subtype) || type!=1) subtype=11;
|
||||
if(subtype<0 || subtype>=32 || !(pSkillData->needWeapon&(1u<<subtype))) {failSkill("NOT_MATCHABLE_WEAPON");return;}
|
||||
if(!horseSkill && (pSkillData->needWeapon&(1u<<2)) && !HasEnoughArrow()) return;
|
||||
}
|
||||
|
||||
// Cooltime check
|
||||
float now = CTimer::Instance().GetCurrentSecond();
|
||||
if (it->second.cooldown.cooling(now, s_coolTimeEnabled)) {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "WAIT_COOLTIME"));
|
||||
const bool dash=(main->m_affectFlags[0]&(1u<<31))!=0;
|
||||
const bool charge=(pSkillData->attributes&(1u<<16))!=0;
|
||||
if (!(dash && charge) && it->second.cooldown.cooling(now, s_coolTimeEnabled)) {
|
||||
skill_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "WAIT_COOLTIME"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Target check
|
||||
uint32_t targetVID = s_targetVID;
|
||||
bool needTarget = pSkillData && (pSkillData->attributes & (1u << 0 /* SKILL_ATTRIBUTE_NEED_TARGET */));
|
||||
bool canUseForMe = pSkillData && (pSkillData->attributes & (1u << 8 /* SKILL_ATTRIBUTE_CAN_USE_FOR_ME */));
|
||||
if (needTarget && targetVID == 0 && !canUseForMe) {
|
||||
player_window_call("OnCannotUseSkill", Py_BuildValue("(is)", PythonNetworkStream::Instance().GetMainActorVID(), "NEED_TARGET"));
|
||||
return;
|
||||
if(!dash) {
|
||||
// Match the existing skill.GetSkillNeedSP Win32 conversion, including -1.
|
||||
const float formula=EvaluateSkillFormula(pSkillData->needSPFormula,it->second.currentPower);
|
||||
double wrapped=std::isfinite(formula)?std::fmod(std::trunc(double(formula)),4294967296.0):0;
|
||||
if(wrapped<0) wrapped+=4294967296.0;
|
||||
const int32_t need=std::bit_cast<int32_t>(uint32_t(wrapped));
|
||||
if((pSkillData->attributes&(1u<<4)) && uint32_t(need)>uint32_t(GetPlayerStatusPoint(5))) {failSkill("NOT_ENOUGH_HP");return;}
|
||||
if(skillIndex!=131) { // Summon bypasses only mana checking.
|
||||
if(!isToggle && need==0) {
|
||||
CPythonChat::Instance().AppendChat(CPythonChat::CHAT_TYPE_INFO,"!!! Find strange game data. Please reinstall metin2.");
|
||||
failSkill("NOT_ENOUGH_SP");return;
|
||||
}
|
||||
const auto sp=std::bit_cast<int32_t>(uint32_t(GetPlayerStatusPoint(7)));
|
||||
if((pSkillData->attributes&(1u<<11)) ? sp<=0 : (need!=-1 && need>sp)) {failSkill("NOT_ENOUGH_SP");return;}
|
||||
}
|
||||
}
|
||||
|
||||
// __UseSkill resolves a local target; selection alone must not leak into
|
||||
// a skill whose attributes do not enter the targeting branch.
|
||||
if(actor.IsUsingSkill()) return; // Original second gate, even for cancel-enabled skills.
|
||||
uint32_t targetVID=0;
|
||||
const bool needCorpse=(pSkillData->attributes&(1u<<9))!=0;
|
||||
const bool canUseForMe=(pSkillData->attributes&(1u<<8))!=0;
|
||||
const bool search=(pSkillData->attributes&(1u<<23))!=0;
|
||||
const bool targetBranch=(pSkillData->attributes&((1u<<0)|(1u<<5)|(1u<<23)))!=0;
|
||||
auto& actorManager=NetworkActorManager::Instance();
|
||||
const uint32_t skillRange=pSkillData->targetRange+uint32_t(GetPlayerStatusPoint(34))*100u;
|
||||
auto checkRange=[&](const SNetworkActorData& target,bool enemy) {
|
||||
if(!skillRange) return true;
|
||||
const auto& victim=*target.m_pActorInstance;
|
||||
float distance=std::hypot(victim.GetX()-actor.GetX(),victim.GetZ()-actor.GetZ());
|
||||
if(enemy && victim.GetRace()==2493) distance-=200;
|
||||
if(distance>=float(skillRange)) {
|
||||
if(enemy && charge && (!s_reservedSkill || s_reservedSkill->slot!=skillSlot)) SendPlayerSkillUse(skillSlot,0);
|
||||
CancelPlayerReservedSkill();
|
||||
s_reservedSkill=ReservedSkill{main->m_dwVID,target.m_dwVID,skillRange>100?skillRange-10:skillRange,skillSlot,
|
||||
main->m_pActorInstance,target.m_pActorInstance};
|
||||
return false;
|
||||
}
|
||||
if(enemy && CPythonBackground::Instance().IsAttrOn(victim.GetX(),victim.GetZ(),TerrainAttr::ATTR_BLOCK)) {failSkill("CANNOT_APPROACH");return false;}
|
||||
return true;
|
||||
};
|
||||
auto selectSkillTarget=[&](uint32_t vid) {
|
||||
if(vid==s_targetVID) {
|
||||
if(vid==main->m_dwVID) {s_targetVID=0;PythonNetworkStream::Instance().SendTargetPacket(0);}
|
||||
return;
|
||||
}
|
||||
s_targetVID=vid;PythonNetworkStream::Instance().SendTargetPacket(vid);
|
||||
};
|
||||
auto validTarget=[&](uint32_t vid) -> const SNetworkActorData* {
|
||||
auto* target=actorManager.GetActorData(vid);
|
||||
return target && target->m_pActorInstance && target->m_pActorInstance->IsDead()==needCorpse ? target : nullptr;
|
||||
};
|
||||
auto targetAngle=[&](const ActorInstance& target) {
|
||||
const float dx=target.GetX()-actor.GetX(),dz=target.GetZ()-actor.GetZ(),dy=target.GetY()-actor.GetY();
|
||||
const float length=std::sqrt(dx*dx+dz*dz+dy*dy);
|
||||
if(length==0) return 90.0f; // D3DX normalized zero direction -> acos(0).
|
||||
const float angle=std::acos(std::clamp(dz/length,-1.0f,1.0f))*180.0f/3.14159265358979323846f;
|
||||
return dx<0?-angle:angle;
|
||||
};
|
||||
if(targetBranch) {
|
||||
auto* target=validTarget(s_targetVID);
|
||||
if(!target) {
|
||||
uint32_t picked;
|
||||
if(actorManager.OLD_GetPickedInstanceVID(&picked)) {
|
||||
selectSkillTarget(picked);
|
||||
target=validTarget(s_targetVID);
|
||||
}
|
||||
}
|
||||
if(target) {
|
||||
const uint32_t vid=target->m_dwVID;
|
||||
if(pSkillData->attributes&(1u<<7)) { // ONLY_FOR_ALLIANCE
|
||||
if(vid==main->m_dwVID) {
|
||||
if(!canUseForMe) {failSkill("CANNOT_USE_SELF");return;}
|
||||
} else if(!CanPlayerAttackInstance(vid) && target->m_bType==6) {
|
||||
if(!checkRange(*target,false)) return;
|
||||
} else {
|
||||
if(canUseForMe) target=main;
|
||||
else {failSkill("ONLY_FOR_ALLIANCE");return;}
|
||||
}
|
||||
} else {
|
||||
const auto& enemy=*target->m_pActorInstance;
|
||||
if(CPythonBackground::Instance().IsAttrOn(enemy.GetX(),enemy.GetZ(),TerrainAttr::ATTR_BANPK)) {failSkill("CANNOT_ATTACK_ENEMY_IN_SAFE_AREA");return;}
|
||||
if(!CanPlayerAttackInstance(vid)) {failSkill("CANNOT_ATTACK");return;}
|
||||
if(!checkRange(*target,true)) return;
|
||||
}
|
||||
} else {
|
||||
if(search) {
|
||||
// NEW_GetFrontInstance: signed degrees, distance-dependent cone,
|
||||
// clamped distance sort and VID traversal order for equal keys.
|
||||
std::vector<uint32_t> vids;for(const auto& [vid,data]:actorManager.GetActorDict()) vids.push_back(vid);
|
||||
std::sort(vids.begin(),vids.end());
|
||||
float yaw=actor.GetYaw();if(yaw>180)yaw-=360;else if(yaw<-180)yaw+=360;
|
||||
float best=std::numeric_limits<float>::infinity();
|
||||
for(auto vid:vids) {
|
||||
auto* candidate=actorManager.GetActorData(vid);
|
||||
if(!candidate->m_pActorInstance || vid==main->m_dwVID || !CanPlayerAttackInstance(vid)) continue;
|
||||
auto& instance=*candidate->m_pActorInstance;
|
||||
const float distance=std::hypot(instance.GetX()-actor.GetX(),instance.GetZ()-actor.GetZ());
|
||||
if(distance>2000) continue;
|
||||
const float key=std::min(distance,1000.0f),half=50.0f-0.04f*key,angle=targetAngle(instance);
|
||||
if(angle>=yaw-half && angle<=yaw+half && key<best) {target=candidate;best=key;}
|
||||
}
|
||||
if(!target) {failSkill("NEED_TARGET");return;}
|
||||
selectSkillTarget(target->m_dwVID);
|
||||
if(!checkRange(*target,true)) return;
|
||||
}
|
||||
// Original branch applies self fallback after automatic search too.
|
||||
if(canUseForMe) target=main;
|
||||
else if(!target) {failSkill(needCorpse?"ONLY_FOR_CORPSE":"NEED_TARGET");return;}
|
||||
}
|
||||
targetVID=target->m_dwVID;
|
||||
actor.SetFlyTarget(targetVID);
|
||||
if(targetVID!=main->m_dwVID) {
|
||||
const auto& instance=*target->m_pActorInstance;
|
||||
const float dx=instance.GetX()-actor.GetX(),dz=instance.GetZ()-actor.GetZ();
|
||||
if(dx!=0 || dz!=0) actor.SetYaw(std::fmod(std::atan2(dx,dz)*180/3.14159265358979323846f+360,360));
|
||||
}
|
||||
}
|
||||
|
||||
// PythonPlayerSkill::__UseSkill expands flight targets before the motion bind
|
||||
// and CG_USE_SKILL. The primary consumes one slot even for corpse/self skills.
|
||||
if(targetVID && !pSkillData->targetCountFormula.empty()) {
|
||||
const float evaluated=EvaluateSkillFormula(pSkillData->targetCountFormula,it->second.currentPower);
|
||||
// Avoid malformed formulas allocating billions of entries (original is unbounded).
|
||||
if(!std::isfinite(evaluated) || evaluated<0 || evaluated>4096) return;
|
||||
const uint32_t maximum=uint32_t(evaluated);
|
||||
uint32_t count=1;
|
||||
const bool fan=(pSkillData->attributes&(1u<<10))!=0;
|
||||
const bool circle=(pSkillData->attributes&(1u<<22))!=0;
|
||||
const auto* primary=actorManager.GetActorData(targetVID);
|
||||
const float direction=targetAngle(*primary->m_pActorInstance);
|
||||
if(maximum>1 && (fan || circle)) {
|
||||
std::vector<std::pair<float,uint32_t>> candidates;
|
||||
for(const auto& [vid,data]:actorManager.GetActorDict()) {
|
||||
if(vid==main->m_dwVID || vid==targetVID || !data.m_pActorInstance
|
||||
|| !CanPlayerAttackInstance(vid) || data.m_pActorInstance->IsDead()) continue;
|
||||
const auto& instance=*data.m_pActorInstance;
|
||||
if(!actor.IsClickableDistanceDestInstance(instance,float(skillRange))) continue;
|
||||
const float distance=std::hypot(instance.GetX()-actor.GetX(),instance.GetZ()-actor.GetZ());
|
||||
const float key=fan?std::min(distance,1000.0f):distance;
|
||||
const float half=40.0f-0.02f*key,angle=targetAngle(instance);
|
||||
if(fan && !(angle>=direction-half && angle<=direction+half)) continue;
|
||||
candidates.emplace_back(key,vid);
|
||||
}
|
||||
std::sort(candidates.begin(),candidates.end()); // distance, then source map VID order.
|
||||
for(const auto& [distance,vid]:candidates) {
|
||||
if(count>=maximum) break;
|
||||
actor.AddFlyTarget(vid);
|
||||
float center[3];actorManager.GetActorInstance(vid)->GetFlyTargetCenter(center);
|
||||
PythonNetworkStream::Instance().SendAddFlyTargetingPacket(vid,int32_t(center[0]),int32_t(-center[2]));
|
||||
++count;
|
||||
}
|
||||
}
|
||||
while(count<maximum) {
|
||||
const float rotation=eter::frandom(direction-10,direction+10)*3.14159265358979323846f/180.0f;
|
||||
const float x=actor.GetX()+8000*std::sin(rotation);
|
||||
const float graphicY=-(actor.GetZ()+8000*std::cos(rotation));
|
||||
const float height=CPythonBackground::Instance().GetHeight(actor.GetX(),actor.GetZ());
|
||||
actor.AddFlyTarget(x,height,-graphicY);
|
||||
PythonNetworkStream::Instance().SendAddFlyTargetingPacket(0,int32_t(x),int32_t(graphicY));
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
CancelPlayerReservedSkill(); // __ClearReservedAction before NEW_UseSkill (including failed binds).
|
||||
// __UseSkill: SetFlyTargetInstance(target, or self for CAN_USE_FOR_ME), then
|
||||
// NEW_UseSkill(index, GetSkillMotionIndex(grade), GetMotionLoopCount(power)). Fan/circle
|
||||
// multi-target AddFlyTargetInstance, moving skills and the look-at turn are not ported.
|
||||
// NEW_UseSkill(index, GetSkillMotionIndex(grade), GetMotionLoopCount(power)).
|
||||
// Moving skill motion/physics are still pending.
|
||||
if (pSkillData && !pSkillData->noMotion) {
|
||||
auto* main = NetworkActorManager::Instance().GetMainInstance();
|
||||
if (main && main->m_pActorInstance) {
|
||||
@@ -1384,9 +1712,7 @@ void ClickSkillSlot(int skillSlot) {
|
||||
if (IsSkillEffectUpgradeEnabled() && grade >= 0 && grade < 4) motion = pSkillData->gradeMotions[size_t(grade)];
|
||||
const int loopCount = pSkillData->motionLoopCountFormula.empty() ? 0
|
||||
: int(uint32_t(EvaluateSkillFormula(pSkillData->motionLoopCountFormula, it->second.currentPower)));
|
||||
if (targetVID && NetworkActorManager::Instance().GetActorData(targetVID)) inst.SetFlyTarget(targetVID);
|
||||
else if (canUseForMe) inst.SetFlyTarget(PythonNetworkStream::Instance().GetMainActorVID());
|
||||
inst.InterceptMotionIndex(RaceData::NAME_SKILL + motion, false, uint32_t(skillIndex), loopCount);
|
||||
if(!inst.InterceptMotionIndex(RaceData::NAME_SKILL + motion, false, uint32_t(skillIndex), loopCount)) return;
|
||||
// __OnUseSkill -> CPythonPlayerEventHandler::OnUseSkill: FUNC_SKILL|motion, arg = loop
|
||||
// count (| 1 << 4 for moving skills, not ported).
|
||||
PythonNetworkStream::Instance().SendCharacterMovePacket(uint8_t(0x80 | (motion & 0x7f)), uint8_t(loopCount),
|
||||
@@ -1395,25 +1721,7 @@ void ClickSkillSlot(int skillSlot) {
|
||||
}
|
||||
}
|
||||
|
||||
// Send use skill packet
|
||||
PythonNetworkStream::Instance().SendUseSkillPacket(uint32_t(skillIndex), targetVID);
|
||||
|
||||
// Run cooltime
|
||||
float baseCoolTime = pSkillData ? EvaluateSkillFormula(pSkillData->cooldownFormula, it->second.currentPower) : 0.0f;
|
||||
long long castSpd = 0;
|
||||
auto spdIt = s_playerPoints.find(19 /* POINT_CASTING_SPEED */);
|
||||
if (spdIt != s_playerPoints.end()) castSpd = spdIt->second;
|
||||
int iSpd = 100 - int(castSpd);
|
||||
if (iSpd > 0) iSpd = 100 + iSpd;
|
||||
else if (iSpd < 0) iSpd = 10000 / (100 - iSpd);
|
||||
else iSpd = 100;
|
||||
float coolTime = baseCoolTime * float(iSpd) / 100.0f;
|
||||
it->second.cooldown = {coolTime, now};
|
||||
player_window_call("RunUseSkillEvent", Py_BuildValue("(if)", skillSlot, coolTime));
|
||||
|
||||
if (s_skillCastCallback) {
|
||||
s_skillCastCallback(-1, skillSlot);
|
||||
}
|
||||
SendPlayerSkillUse(skillSlot,targetVID);
|
||||
}
|
||||
|
||||
void SetPlayerAffect(unsigned affect) {
|
||||
@@ -1491,6 +1799,26 @@ static uint32_t s_dwWeaponMinMagicPower = 0;
|
||||
static uint32_t s_dwWeaponMaxMagicPower = 0;
|
||||
static uint32_t s_dwWeaponAddPower = 0;
|
||||
static void UpdateBattleStatus();
|
||||
void StartPlayerStaminaConsume(uint32_t rate,uint32_t current) {
|
||||
s_consumingStamina=true;s_staminaRate=float(rate);s_currentStamina=float(current);
|
||||
SetPlayerStatusPoint(9,current);
|
||||
}
|
||||
void StopPlayerStaminaConsume(uint32_t current) {
|
||||
s_consumingStamina=false;s_staminaRate=0;s_currentStamina=float(current);
|
||||
SetPlayerStatusPoint(9,current);
|
||||
}
|
||||
void UpdatePlayerStamina(float elapsed) {
|
||||
if(!s_consumingStamina || !std::isfinite(elapsed) || elapsed<0) return;
|
||||
float current=s_currentStamina-elapsed*s_staminaRate;
|
||||
if(!std::isfinite(current)) return;
|
||||
s_currentStamina=current;
|
||||
// Original DWORD conversion truncates and retains the low Win32 bits.
|
||||
double wrapped=std::fmod(std::trunc(double(current)),4294967296.0);
|
||||
if(wrapped<0) wrapped+=4294967296.0;
|
||||
SetPlayerStatusPoint(9,uint32_t(wrapped));
|
||||
player_window_call("RefreshStamina");
|
||||
}
|
||||
void RefreshPlayerMobile() {player_window_call("RefreshMobile");}
|
||||
long long GetPlayerStatusPoint(int type) {if(uint32_t(type)>=255)return 0;auto it=s_playerPoints.find(type);return it==s_playerPoints.end()?0:it->second;}
|
||||
void SetPlayerStatusPoint(int type, long long value) {
|
||||
if(uint32_t(type)>=255)return;
|
||||
@@ -1942,13 +2270,15 @@ bool HasEnoughArrow() {
|
||||
}
|
||||
}
|
||||
uint32_t vid = PythonNetworkStream::Instance().GetMainActorVID();
|
||||
player_window_call("OnCannotShotError", Py_BuildValue("(is)", vid, "EMPTY_ARROW"));
|
||||
skill_window_call("OnCannotShotError", Py_BuildValue("(is)", vid, "EMPTY_ARROW"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void ResetPlayerState() {
|
||||
CancelPlayerReservedSkill();
|
||||
s_consumingStamina=false;s_staminaRate=0;s_currentStamina=0;
|
||||
CancelPlayerMovement();
|
||||
s_coolTimeEnabled=true;
|
||||
s_coolTimeEnabled=true;s_levelLimit=true;
|
||||
s_playerName.clear();s_mainActorPos={};s_playerPoints.clear();s_playerSkills.clear();s_skillSlots.clear();
|
||||
s_quickPage=0;s_playTime=0;s_playerQuickSlots.fill({});s_playerItems.fill({});s_windowItems.clear();
|
||||
s_partyMembers.clear();s_challengeInstances.clear();s_revengeInstances.clear();s_cantFightInstances.clear();s_killLog.fill(0);
|
||||
@@ -1964,7 +2294,12 @@ void SetPlayerItemData(uint8_t window,uint16_t cell,const TItemData& data) {
|
||||
if(window==1 && cell<s_playerItems.size()) {
|
||||
auto& slot=s_playerItems[cell];slot={};slot.vnum=data.vnum;slot.count=data.count;
|
||||
for(size_t i=0;i<ITEM_SOCKET_SLOT_MAX_NUM;++i) slot.sockets[i]=data.alSockets[i];
|
||||
for(size_t i=0;i<ITEM_ATTRIBUTE_SLOT_MAX_NUM;++i) slot.attrs[i]={data.aAttr[i].bType,data.aAttr[i].sValue};
|
||||
for(size_t i=0;i<ITEM_ATTRIBUTE_SLOT_MAX_NUM;++i) {
|
||||
// Packed Win32 attribute values may be odd-aligned. Materialize
|
||||
// a value before std::pair's constructor binds a forwarding reference.
|
||||
const int16_t value=data.aAttr[i].sValue;
|
||||
slot.attrs[i]={data.aAttr[i].bType,value};
|
||||
}
|
||||
}
|
||||
if (window == 1 && (cell == 184 || cell == 202)) {
|
||||
UpdateEquippedWeaponPower();
|
||||
@@ -2790,53 +3125,67 @@ static std::map<int, AutoPotionInfo> s_autoPotionInfo;
|
||||
static std::map<int, uint32_t> s_emotionIcons;
|
||||
static int s_mouseFunc[8] = {0};
|
||||
static int s_mouseState[8] = {0};
|
||||
bool IsPlayerMouseMoving() { return s_mouseState[0] == 1 && (s_mouseFunc[0] == 0 || s_mouseFunc[0] == 1); }
|
||||
bool IsPlayerMouseMoving() {
|
||||
const auto* main=NetworkActorManager::Instance().GetMainInstance();
|
||||
return !NetworkActorManager::Instance().IsEmotionProcessing()
|
||||
&& !(main && main->m_pActorInstance && main->m_pActorInstance->IsEmotionMovementLocked())
|
||||
&& s_mouseState[0]==1 && (s_mouseFunc[0]==0 || s_mouseFunc[0]==1);
|
||||
}
|
||||
bool IsPlayerCameraDragging() { return s_mouseState[1] == 1 && s_mouseFunc[1] == 2; }
|
||||
void CancelPlayerMovement() { s_movementKeys.fill(false); s_joystickActive=false; std::fill(std::begin(s_mouseState),std::end(s_mouseState),0); }
|
||||
void SetPlayerJoystick(bool active, float x, float y) { s_joystickActive=active; s_joystickX=active?x:0.0f; s_joystickY=active?y:0.0f; }
|
||||
void CancelPlayerMovement() { CancelPlayerTouchInteraction();CancelPlayerReservedSkill();s_movementKeys.fill(false); s_joystickActive=false; std::fill(std::begin(s_mouseState),std::end(s_mouseState),0); }
|
||||
void SetPlayerJoystick(bool active, float x, float y) { if(active && (x!=0 || y!=0))CancelPlayerTouchInteraction();if(active && (x!=0 || y!=0)) CancelPlayerReservedSkill();s_joystickActive=active; s_joystickX=active?x:0.0f; s_joystickY=active?y:0.0f; }
|
||||
bool IsPlayerGameWindow(const void* handler) { return handler && handler==s_playerGameWindow; }
|
||||
static int s_mouseMiddleButtonState = 0;
|
||||
static bool s_playerVisible = true;
|
||||
static bool s_levelLimit = false;
|
||||
static int s_eventGame = 0;
|
||||
|
||||
static PyObject* player_ActEmotion(PyObject*, PyObject* args) {
|
||||
int vid = 0;
|
||||
if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException();
|
||||
int emotion=0;
|
||||
if(!PyTuple_GetInteger(args,0,&emotion)) return Py_BuildException();
|
||||
// CPythonPlayer::ActEmotion ignores the ID and requests /kiss for its alive target.
|
||||
const auto* target=NetworkActorManager::Instance().GetActorData(s_targetVID);
|
||||
if(!s_targetVID || !target || !target->m_pActorInstance || target->m_pActorInstance->IsDead()) {
|
||||
player_window_call("OnCannotShotError",Py_BuildValue("(is)",PythonNetworkStream::Instance().GetMainActorVID(),"NEED_TARGET"));
|
||||
} else {
|
||||
PythonNetworkStream::Instance().SendChatPacket(("/kiss "+target->m_stName).c_str());
|
||||
}
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* player_CanAttackInstance(PyObject*, PyObject* args) {
|
||||
int vid = 0;
|
||||
if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException();
|
||||
const auto* mainActor = player_main_actor();
|
||||
const auto* target = NetworkActorManager::Instance().GetActorData(vid);
|
||||
if (!mainActor || !target) return Py_BuildValue("i", 0);
|
||||
if (mainActor->m_dwVID == target->m_dwVID) return Py_BuildValue("i", 0);
|
||||
|
||||
// If target is PC (bType == 6)
|
||||
if (target->m_bType == 6) {
|
||||
if (target->m_dwStateFlags & NetworkActorManager::ADD_CHARACTER_STATE_KILLER) return Py_BuildValue("i", 1);
|
||||
if (mainActor->m_byPKMode == 1 /* PK_MODE_FREE */ && target->m_byPKMode != 4 /* PK_MODE_PROTECT */)
|
||||
return Py_BuildValue("i", 1);
|
||||
if (mainActor->m_dwEmpireID != target->m_dwEmpireID)
|
||||
return Py_BuildValue("i", 1);
|
||||
if (mainActor->m_byPKMode == 2 /* PK_MODE_GUILD */ && mainActor->m_dwGuildID != 0 && mainActor->m_dwGuildID != target->m_dwGuildID)
|
||||
return Py_BuildValue("i", 1);
|
||||
if (mainActor->m_byPKMode == 3 /* PK_MODE_REVENGE */) {
|
||||
if ((mainActor->m_sAlignment < 0 && target->m_sAlignment >= 0) || (mainActor->m_sAlignment >= 0 && target->m_sAlignment < 0))
|
||||
return Py_BuildValue("i", 1);
|
||||
}
|
||||
return Py_BuildValue("i", 0);
|
||||
// AVA2 InstanceBase::IsAttackableInstance with the active Windows feature set.
|
||||
bool CanPlayerAttackInstance(uint32_t vid) {
|
||||
const auto* main=player_main_actor();auto& actors=NetworkActorManager::Instance();
|
||||
const auto* target=actors.GetActorData(vid);
|
||||
if(!main || !target || main->m_dwVID==vid || PythonNetworkStream::Instance().IsObserverMode()) return false;
|
||||
auto type=[](const SNetworkActorData* actor) {
|
||||
return actor->m_pActorInstance && actor->m_pActorInstance->IsPolymorph()?7:int(actor->m_bType);
|
||||
};
|
||||
const int sourceType=type(main),targetType=type(target);
|
||||
if(sourceType==2) return targetType==6; // Stone attacks PCs.
|
||||
if(sourceType==0) return targetType==6 || targetType==5; // Enemy -> PC/building.
|
||||
if(sourceType==7) return targetType==6 || targetType==0; // Polymorph -> PC/enemy.
|
||||
if(sourceType!=6) return false;
|
||||
if(targetType==2 || targetType==0) return true;
|
||||
if(targetType==4) return target->m_dwRace==13000 || (target->m_dwRace>=30111 && target->m_dwRace<=30119);
|
||||
if(targetType!=6 || CheckBossSafeRange()) return false;
|
||||
if(main->m_duelMode==DUEL_CANNOTATTACK) return false;
|
||||
if(main->m_duelMode==DUEL_START) return actors.FindDUELKey(main->m_dwVID,vid);
|
||||
const bool sameParty=IsPartyMemberByVID(main->m_dwVID) && IsPartyMemberByVID(vid);
|
||||
if(main->m_byPKMode==2 && main->m_dwGuildID==target->m_dwGuildID) return false;
|
||||
if((target->m_dwStateFlags & NetworkActorManager::ADD_CHARACTER_STATE_KILLER) && !sameParty) return true;
|
||||
if(main->m_byPKMode!=4 && target->m_byPKMode!=4 && !sameParty) {
|
||||
if(main->m_byPKMode==1) return true;
|
||||
if(main->m_byPKMode==2 && main->m_dwGuildID!=target->m_dwGuildID) return true;
|
||||
}
|
||||
|
||||
// If target is Mob / Monster (bType == 0)
|
||||
if (target->m_bType == 0) {
|
||||
return Py_BuildValue("i", 1);
|
||||
}
|
||||
|
||||
// Friendly NPC (bType == 1, etc.)
|
||||
return Py_BuildValue("i", 0);
|
||||
if(main->m_dwEmpireID!=target->m_dwEmpireID) return true;
|
||||
if(main->m_duelMode!=DUEL_NONE || actors.FindPVPKey(main->m_dwVID,vid)
|
||||
|| actors.FindGVGKey(main->m_dwGuildID,target->m_dwGuildID)) return true;
|
||||
return main->m_byPKMode==3 && target->m_byPKMode!=4 && !sameParty
|
||||
&& ((main->m_sAlignment<0)!=(target->m_sAlignment<0));
|
||||
}
|
||||
static PyObject* player_CanAttackInstance(PyObject*,PyObject* args) {
|
||||
int vid=0;if(!PyTuple_GetInteger(args,0,&vid)) return Py_BuildException();
|
||||
return PyInt_FromLong(CanPlayerAttackInstance(uint32_t(vid)));
|
||||
}
|
||||
|
||||
static PyObject* player_ChangeCurrentSkillNumberOnly(PyObject*, PyObject* args) {
|
||||
@@ -3038,9 +3387,88 @@ static PyObject* player_SetMouseFunc(PyObject*, PyObject* args) {
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct TouchInteraction {
|
||||
uint32_t vid=0;bool item=false;uint64_t generation=0;
|
||||
std::weak_ptr<ActorInstance> main,target;
|
||||
};
|
||||
std::optional<TouchInteraction> s_touchInteraction;
|
||||
uint32_t s_touchNextClick=0;
|
||||
}
|
||||
void CancelPlayerTouchInteraction() {
|
||||
if(s_touchInteraction)if(auto main=s_touchInteraction->main.lock())main->ClearMoveTarget();
|
||||
s_touchInteraction.reset();
|
||||
}
|
||||
void ProcessPlayerTouchInteraction() {
|
||||
if(!s_touchInteraction)return;
|
||||
auto& manager=NetworkActorManager::Instance();auto* current=manager.GetMainInstance();
|
||||
auto main=s_touchInteraction->main.lock();
|
||||
if(!current || current->m_pActorInstance!=main || !main || main->IsDead()) {CancelPlayerTouchInteraction();return;}
|
||||
float x=0,z=0;float range=500;
|
||||
if(s_touchInteraction->item) {
|
||||
const auto& items=CPythonItem::Instance().GetGroundItems();auto it=items.find(s_touchInteraction->vid);
|
||||
if(it==items.end() || it->second->generation!=s_touchInteraction->generation){CancelPlayerTouchInteraction();return;}
|
||||
x=it->second->v3EndPosition.x;z=-it->second->v3EndPosition.y;range=150;
|
||||
} else {
|
||||
auto target=s_touchInteraction->target.lock();auto* currentTarget=manager.GetActorData(s_touchInteraction->vid);
|
||||
if(!target || !currentTarget || currentTarget->m_pActorInstance!=target || target->IsDead()){CancelPlayerTouchInteraction();return;}
|
||||
x=target->GetX();z=target->GetZ();
|
||||
}
|
||||
if(!main->CanAct() || main->IsUsingSkill() || main->IsEmotionMovementLocked() || manager.IsEmotionProcessing()) {main->ClearMoveTarget();return;}
|
||||
if(std::hypot(x-main->GetX(),z-main->GetZ())>range) {main->SetMoveTarget(x,z);return;}
|
||||
main->ClearMoveTarget();main->StopMoving();
|
||||
if(s_touchInteraction->item)PythonNetworkStream::Instance().SendItemPickUpPacket(s_touchInteraction->vid);
|
||||
else {
|
||||
const uint32_t now=ELTimer_GetMSec();
|
||||
if(now<s_touchNextClick)return; // Original click-actor TCP throttle, 1 second.
|
||||
s_touchNextClick=now+1000;PythonNetworkStream::Instance().SendOnClickPacket(s_touchInteraction->vid);
|
||||
}
|
||||
s_touchInteraction.reset();
|
||||
}
|
||||
bool HandlePlayerTouchWorldTap(const Gr2SceneRenderer& scene,float x,float y) {
|
||||
CancelPlayerTouchInteraction();CancelPlayerReservedSkill();
|
||||
auto& manager=NetworkActorManager::Instance();auto* main=manager.GetMainInstance();
|
||||
if(!main || !main->m_pActorInstance)return false;
|
||||
// Prefer exact item-name hits, then padded names/projected ground items. Never pick through UI.
|
||||
auto& items=CPythonItem::Instance();uint32_t pickedItem=0;float best=28*28;
|
||||
for(const auto& [vid,entry]:items.GetGroundItems()) {
|
||||
float sx,sy;if(!scene.ProjectToScreen(entry->v3EndPosition.x,entry->v3EndPosition.z,-entry->v3EndPosition.y,sx,sy))continue;
|
||||
const float distance=(sx-x)*(sx-x)+(sy-y)*(sy-y);
|
||||
if(distance<best || (distance==best && vid<pickedItem)){best=distance;pickedItem=vid;}
|
||||
}
|
||||
const int named=TextTailManager::Instance().Pick(int(x),int(y),16);
|
||||
if(named>0 && items.GetGroundItems().count(uint32_t(named)))pickedItem=uint32_t(named);
|
||||
if(pickedItem) {
|
||||
items.SetPickedItemID(pickedItem);manager.ClearPickedInstance();
|
||||
const auto* entry=items.GetGroundItems().at(pickedItem);
|
||||
s_touchInteraction=TouchInteraction{pickedItem,true,entry->generation,main->m_pActorInstance,{}};
|
||||
ProcessPlayerTouchInteraction();return true;
|
||||
}
|
||||
uint32_t pickedActor=0;best=std::numeric_limits<float>::max();
|
||||
for(const auto& [vid,candidate]:manager.GetActorDict()) {
|
||||
if(vid==main->m_dwVID || !candidate.m_pActorInstance || !candidate.m_pActorInstance->HitTestScreen(x,y,scene,28))continue;
|
||||
const float distance=std::hypot(candidate.m_pActorInstance->GetX()-main->m_pActorInstance->GetX(),candidate.m_pActorInstance->GetZ()-main->m_pActorInstance->GetZ());
|
||||
if(distance<best || (distance==best && vid<pickedActor)){pickedActor=vid;best=distance;}
|
||||
}
|
||||
items.SetPickedItemID(CPythonItem::INVALID_ID);
|
||||
if(!pickedActor){manager.ClearPickedInstance();return false;}
|
||||
manager.SetPickedInstanceVID(pickedActor);
|
||||
if(s_targetVID!=pickedActor){s_targetVID=pickedActor;PythonNetworkStream::Instance().SendTargetPacket(pickedActor);}
|
||||
auto* target=manager.GetActorData(pickedActor);
|
||||
if(target->m_bType==1) { // NPC/portal; server remains responsible for the actual interaction.
|
||||
s_touchInteraction=TouchInteraction{pickedActor,false,0,main->m_pActorInstance,target->m_pActorInstance};
|
||||
ProcessPlayerTouchInteraction();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static PyObject* player_SetMouseState(PyObject*, PyObject* args) {
|
||||
int btn = 0, state = 0;
|
||||
if (!PyTuple_GetInteger(args, 0, &btn) || !PyTuple_GetInteger(args, 1, &state)) return Py_BuildException();
|
||||
if(btn==0 && state==1 && (s_mouseFunc[0]==0 || s_mouseFunc[0]==1)) {
|
||||
uint32_t picked=0;
|
||||
if(!s_reservedSkill || !NetworkActorManager::Instance().OLD_GetPickedInstanceVID(&picked)
|
||||
|| picked!=s_reservedSkill->targetVID) CancelPlayerReservedSkill();
|
||||
}
|
||||
if (btn >= 0 && btn < 8) s_mouseState[btn] = state;
|
||||
return Py_BuildNone();
|
||||
}
|
||||
@@ -3075,7 +3503,8 @@ static PyObject* player_ShowPlayer(PyObject*, PyObject*) {
|
||||
}
|
||||
|
||||
static PyObject* player_IsActingEmotion(PyObject*, PyObject*) {
|
||||
return Py_BuildValue("i", 0);
|
||||
const auto* main=player_main_actor();
|
||||
return PyInt_FromLong(main && main->m_pActorInstance && main->m_pActorInstance->IsActingEmotion());
|
||||
}
|
||||
|
||||
static PyObject* player_IsEquippingBelt(PyObject*, PyObject*) {
|
||||
@@ -3097,7 +3526,11 @@ static PyObject* player_IsAvailableBeltInventoryCell(PyObject*, PyObject* args)
|
||||
}
|
||||
|
||||
static PyObject* player_IsInSafeArea(PyObject*, PyObject*) {
|
||||
return Py_BuildValue("i", 0);
|
||||
const auto* actor=player_main_actor();
|
||||
if(!actor) return PyInt_FromLong(0);
|
||||
float x=actor->m_lCurX,y=actor->m_lCurY;
|
||||
if(actor->m_pActorInstance) {x=actor->m_pActorInstance->GetX();y=actor->m_pActorInstance->GetZ();}
|
||||
return PyInt_FromLong(CPythonBackground::Instance().IsAttrOn(x,y,TerrainAttr::ATTR_BANPK));
|
||||
}
|
||||
|
||||
static PyObject* player_IsMountingHorse(PyObject*, PyObject*) {
|
||||
@@ -3112,7 +3545,11 @@ static PyObject* player_IsOpenPrivateShop(PyObject*, PyObject*) {
|
||||
static PyObject* player_IsPVPInstance(PyObject*, PyObject* args) {
|
||||
int vid = 0;
|
||||
if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException();
|
||||
return Py_BuildValue("i", 0);
|
||||
const auto* main=player_main_actor();auto& actors=NetworkActorManager::Instance();
|
||||
const auto* target=actors.GetActorData(uint32_t(vid));
|
||||
return PyInt_FromLong(main && target && (main->m_duelMode!=DUEL_NONE
|
||||
|| actors.FindPVPKey(main->m_dwVID,target->m_dwVID)
|
||||
|| actors.FindGVGKey(main->m_dwGuildID,target->m_dwGuildID)));
|
||||
}
|
||||
|
||||
static PyObject* player_IsSameEmpire(PyObject*, PyObject* args) {
|
||||
@@ -3465,6 +3902,7 @@ static PyObject* player_SendDragonSoulRefine(PyObject*, PyObject* args) {
|
||||
}
|
||||
|
||||
void SetPlayerAttackKey(bool pressed) {
|
||||
if(pressed) {CancelPlayerTouchInteraction();CancelPlayerReservedSkill();}
|
||||
if (pressed && IsMainActorFishingMode()) {
|
||||
NEW_Fishing();
|
||||
return;
|
||||
@@ -3573,6 +4011,7 @@ static PyObject* player_SetSingleDIKKeyState(PyObject*, PyObject* args) {
|
||||
return Py_BuildException();
|
||||
if (NEW_CancelFishing())
|
||||
return Py_BuildNone();
|
||||
if(pressed && (dik==17 || dik==31 || dik==30 || dik==32 || dik==200 || dik==208 || dik==203 || dik==205)) {CancelPlayerTouchInteraction();CancelPlayerReservedSkill();}
|
||||
if (dik >= 0 && dik < int(s_movementKeys.size())) s_movementKeys[dik] = pressed != 0;
|
||||
return Py_BuildNone();
|
||||
}
|
||||
@@ -3768,6 +4207,7 @@ static PyObject* player_GetAutoHuntOption(PyObject*, PyObject* args) {
|
||||
}
|
||||
|
||||
void initPlayer() {
|
||||
NetworkActorManager::Instance().SetEmotionTimeSource(GetServerMSec);
|
||||
static PyMethodDef methods[] = {
|
||||
{"GetAutoPotionInfo", player_GetAutoPotionInfo, METH_VARARGS, nullptr},
|
||||
{"SetAutoPotionInfo", player_SetAutoPotionInfo, METH_VARARGS, nullptr},
|
||||
|
||||
@@ -19,6 +19,11 @@ void SetSkillCoolTime(int skillIndex, float coolTime);
|
||||
void SetSkillCoolTimeAt(int skillIndex,float coolTime,float now);
|
||||
void EndSkillCoolTime(uint32_t skillIndex);
|
||||
void ClickSkillSlot(int skillSlot);
|
||||
void UsePlayerTouchSkill(int skillSlot,float aimX,float aimY,float cameraYaw,bool repeat);
|
||||
class Gr2SceneRenderer;
|
||||
bool HandlePlayerTouchWorldTap(const Gr2SceneRenderer& scene,float x,float y);
|
||||
void ProcessPlayerTouchInteraction();
|
||||
void CancelPlayerTouchInteraction();
|
||||
void UseGuildSkill(int skillSlot);
|
||||
void SetPlayerAffect(uint32_t affect);
|
||||
void ResetPlayerAffect(uint32_t affect);
|
||||
@@ -35,6 +40,10 @@ struct PlayerItemSlot {
|
||||
PlayerItemSlot GetPlayerItem(int slot);
|
||||
void SetPlayerItem(int slot, uint32_t vnum, int count);
|
||||
void ResetPlayerState();
|
||||
void StartPlayerStaminaConsume(uint32_t rate,uint32_t current);
|
||||
void StopPlayerStaminaConsume(uint32_t current);
|
||||
void UpdatePlayerStamina(float elapsed);
|
||||
void RefreshPlayerMobile();
|
||||
void AppendPartyMember(uint32_t pid,const std::string& name);
|
||||
void LinkPartyMember(uint32_t pid,uint32_t vid);
|
||||
void UnlinkPartyMember(uint32_t pid);
|
||||
@@ -97,8 +106,11 @@ void SetPlayerAttackKey(bool pressed);
|
||||
// state packets for started attack motions, and the attack hit test (SendAttackPacket). wasMoving:
|
||||
// a walk is in progress on the server; its stop packet is sent first. Returns true when it sent it.
|
||||
bool ProcessPlayerAttack(float cameraYaw, float frameDt, bool wasMoving);
|
||||
void ProcessPlayerReservedSkill();
|
||||
void CancelPlayerReservedSkill();
|
||||
// The main actor is playing an attack motion (movement input is ignored meanwhile).
|
||||
bool IsPlayerAttacking();
|
||||
bool CanPlayerAttackInstance(uint32_t vid);
|
||||
// Mobile auto hunt (src/game/auto_hunt.h), per frame before ProcessPlayerAttack: steers the main
|
||||
// actor and presses attack / skills / pick-up while player.SetAutoHunt(1) is on.
|
||||
void ProcessAutoHunt();
|
||||
|
||||
@@ -398,6 +398,7 @@ static PyObject* grpSetOrtho2D(PyObject*, PyObject* poArgs) {
|
||||
float width = 0, height = 0, length = 0;
|
||||
if (!PyTuple_GetFloat(poArgs, 0, &width) || !PyTuple_GetFloat(poArgs, 1, &height) || !PyTuple_GetFloat(poArgs, 2, &length))
|
||||
return Py_BuildException();
|
||||
if(auto* renderer=TextTailManager::Instance().GetCurrentSceneRenderer())renderer->SetOrtho2D(width,height,length);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -405,6 +406,7 @@ static PyObject* grpSetOrtho3D(PyObject*, PyObject* poArgs) {
|
||||
float width = 0, height = 0, zmin = 0, zmax = 0;
|
||||
if (!PyTuple_GetFloat(poArgs, 0, &width) || !PyTuple_GetFloat(poArgs, 1, &height) || !PyTuple_GetFloat(poArgs, 2, &zmin) || !PyTuple_GetFloat(poArgs, 3, &zmax))
|
||||
return Py_BuildException();
|
||||
if(auto* renderer=TextTailManager::Instance().GetCurrentSceneRenderer())renderer->SetOrtho3D(width,height,zmin,zmax);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
struct TGroundItemInstance {
|
||||
uint32_t dwVirtualNumber = 0;
|
||||
uint64_t generation = 0;
|
||||
TPixelPosition v3EndPosition{};
|
||||
uint32_t eDropSoundType = DROPSOUND_DEFAULT;
|
||||
bool bAnimEnded = true;
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
uint64_t m_touchGeneration=0;
|
||||
using TGroundItemInstanceMap = std::map<uint32_t, TGroundItemInstance*>;
|
||||
|
||||
CPythonItem() = default;
|
||||
@@ -114,6 +116,7 @@ public:
|
||||
m_GroundItemInstanceMap[dwVirtualID] = pInst;
|
||||
}
|
||||
|
||||
pInst->generation=++m_touchGeneration;
|
||||
pInst->dwVirtualNumber = dwVirtualNumber;
|
||||
pInst->v3EndPosition = {x, y, z};
|
||||
pInst->bAnimEnded = !bDrop;
|
||||
|
||||
@@ -797,7 +797,7 @@ void initeffect() {
|
||||
static PyObject* fly_Update(PyObject*, PyObject*) {
|
||||
static float flyingTime = 0.0f;
|
||||
flyingTime += ava2::GetGameFrameDelta();
|
||||
ava2::FlyingManager::Instance().Update(ava2::GetGameFrameDelta(), flyingTime);
|
||||
ava2::FlyingManager::Instance().Update(ava2::GetGameFrameDelta(),flyingTime,ava2::CPythonBackground::Instance().GetTerrain(),ava2::CPythonBackground::Instance().GetMapObjects(),[](float x,float z){return ava2::CPythonBackground::Instance().GetHeight(x,z);});
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1014,6 +1014,7 @@ static PyObject* net_SendMobileMessagePacket(PyObject*, PyObject* poArgs) {
|
||||
char* szLine = nullptr;
|
||||
if (!PyTuple_GetString(poArgs, 0, &szName) || !PyTuple_GetString(poArgs, 1, &szLine))
|
||||
return Py_BuildException();
|
||||
PythonNetworkStream::Instance().SendMobileMessagePacket(szName,szLine);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -1101,18 +1102,22 @@ static PyObject* net_Send67AttrPacket(PyObject*, PyObject* poArgs) {
|
||||
!PyTuple_GetInteger(poArgs, 2, &iSupportPos) ||
|
||||
!PyTuple_GetInteger(poArgs, 3, &iItemPos))
|
||||
return Py_BuildException();
|
||||
PythonNetworkStream::Instance().Send67AttrPacket(iMaterialCount,iSupportCount,iSupportPos,iItemPos);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_Send67AttrClosePacket(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().Send67AttrClosePacket();
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_CalendarOpen(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().SendCalendarPacket(0);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_CalendarClose(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().SendCalendarPacket(1);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -1125,6 +1130,7 @@ static PyObject* net_CalendarSend(PyObject*, PyObject* poArgs) {
|
||||
!PyTuple_GetString(poArgs, 2, &hora_inicio) ||
|
||||
!PyTuple_GetString(poArgs, 3, &hora_final))
|
||||
return Py_BuildException();
|
||||
PythonNetworkStream::Instance().SendCalendarPacket(2,day,index_event,hora_inicio,hora_final);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -1132,10 +1138,12 @@ static PyObject* net_SendMiniGameCatchKingStart(PyObject*, PyObject* poArgs) {
|
||||
int ibetNumber = 0;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &ibetNumber))
|
||||
return Py_BuildException();
|
||||
PythonNetworkStream::Instance().SendCatchKingPacket(0,ibetNumber);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_SendMiniGameCatchKingDeckCardClick(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().SendCatchKingPacket(1);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
@@ -1143,14 +1151,17 @@ static PyObject* net_SendMiniGameCatchKingFieldCardClick(PyObject*, PyObject* po
|
||||
int icardNumber = 0;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &icardNumber))
|
||||
return Py_BuildException();
|
||||
PythonNetworkStream::Instance().SendCatchKingPacket(2,icardNumber);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_SendMiniGameCatchKingReward(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().SendCatchKingPacket(3);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
static PyObject* net_OpenCatchKing(PyObject*, PyObject*) {
|
||||
PythonNetworkStream::Instance().OpenCatchKing();
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pet_skill_state.h"
|
||||
#include "eter_ui/PythonWindowManager.h"
|
||||
#include "eter_render/CRenderTarget.h"
|
||||
#include "src/eter_image/GrpImageInstance.h"
|
||||
#include "src/eter_image/GrpExpandedImageInstance.h"
|
||||
#include "src/eter_image/GrpMarkInstance.h"
|
||||
@@ -267,6 +268,9 @@ sys.meta_path.insert(0, _AVA2PackImporter())
|
||||
m_windowManager.reset();
|
||||
}
|
||||
CPythonMiniMap::Instance().Destroy();
|
||||
// Windows PythonApplication::Destroy releases preview backgrounds/models
|
||||
// before image pools and resource caches. The singleton otherwise outlives them.
|
||||
CRenderTargetManager::Instance().Destroy();
|
||||
CGraphicExpandedImageInstance::DestroySystem();
|
||||
CGraphicImageInstance::DestroySystem();
|
||||
CGraphicMarkInstance::DestroySystem();
|
||||
@@ -300,6 +304,7 @@ PythonRuntime::~PythonRuntime() {
|
||||
m_windowManager.reset();
|
||||
}
|
||||
CPythonMiniMap::Instance().Destroy();
|
||||
CRenderTargetManager::Instance().Destroy();
|
||||
CGraphicExpandedImageInstance::DestroySystem();
|
||||
CGraphicImageInstance::DestroySystem();
|
||||
CGraphicMarkInstance::DestroySystem();
|
||||
|
||||
@@ -20,6 +20,10 @@ PyObject* touch_get_joystick(PyObject*, PyObject*) {
|
||||
return Py_BuildValue("(iffff)", joy.active ? 1 : 0, joy.base_x, joy.base_y, joy.knob_x, joy.knob_y);
|
||||
}
|
||||
|
||||
PyObject* touch_get_skill_aim(PyObject*,PyObject*) {
|
||||
const auto aim=GetTouchRouter().GetSkillAim();
|
||||
return Py_BuildValue("(iffff)",aim.active?1:0,aim.base_x,aim.base_y,aim.knob_x,aim.knob_y);
|
||||
}
|
||||
PyObject* touch_is_attack_pressed(PyObject*, PyObject*) {
|
||||
return PyInt_FromLong(GetTouchRouter().IsAttackPressed() ? 1 : 0);
|
||||
}
|
||||
@@ -114,6 +118,17 @@ void TouchUiMouseUp(UI::CWindowManager& wm, long x, long y) {
|
||||
TouchUiPointerIdle(wm);
|
||||
}
|
||||
|
||||
int TouchSkillAt(UI::CWindowManager& wm,long x,long y) {
|
||||
if(wm.IsAttaching())return -1; // Dropping an icon remains an ordinary slot click.
|
||||
auto* window=wm.PickWindow(x,y);if(!window || !window->GetHandler())return -1;
|
||||
PyObject* method=PyObject_GetAttrString(window->GetHandler(),"GetTouchSkillSlot");
|
||||
if(!method){PyErr_Clear();return -1;}
|
||||
PyObject* result=PyObject_CallObject(method,nullptr);Py_DECREF(method);
|
||||
if(!result){PyErr_Print();return -1;}
|
||||
const long slot=PyInt_AsLong(result);Py_DECREF(result);
|
||||
if(PyErr_Occurred()){PyErr_Clear();return -1;}
|
||||
return slot>=0 && slot<255?int(slot):-1;
|
||||
}
|
||||
bool TouchUiLongPress(UI::CWindowManager& wm, long x, long y) {
|
||||
if (wm.IsAttaching()) return false;
|
||||
wm.RunMouseMove(x, y);
|
||||
@@ -132,6 +147,7 @@ void inittouch() {
|
||||
static PyMethodDef methods[] = {
|
||||
{"IsEnabled", touch_is_enabled, METH_NOARGS, nullptr},
|
||||
{"GetJoystick", touch_get_joystick, METH_NOARGS, nullptr},
|
||||
{"GetSkillAim", touch_get_skill_aim, METH_NOARGS, nullptr},
|
||||
{"IsAttackPressed", touch_is_attack_pressed, METH_NOARGS, nullptr},
|
||||
{"SetAttackButton", touch_set_attack_button, METH_VARARGS, nullptr},
|
||||
{"SetJoystickArea", touch_set_joystick_area, METH_VARARGS, nullptr},
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ava2 {
|
||||
// `touch` module: lets the mobile HUD place the attack button / joystick area of the native
|
||||
// touch router (src/app/input/touch_router.h) and draw the joystick it drives.
|
||||
void inittouch();
|
||||
int TouchSkillAt(UI::CWindowManager& wm,long x,long y);
|
||||
// Long press on a slot: calls the touch.SetLongPressEvent function with the slot window's Python
|
||||
// object; true when it took the touch.
|
||||
bool RunTouchLongPress(PyObject* slot_window, unsigned long slot_number, unsigned long item_count, long x, long y,
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <strings.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#ifndef stricmp
|
||||
#define stricmp strcasecmp
|
||||
@@ -2370,16 +2372,12 @@ PyObject * wndTextSetFontColor(PyObject * poSelf, PyObject * poArgs)
|
||||
float fb;
|
||||
if (!PyTuple_GetFloat(poArgs, 3, &fb))
|
||||
return Py_BuildException();
|
||||
float fa = 1.0f;
|
||||
|
||||
BYTE argb[4] =
|
||||
{
|
||||
(BYTE) (255.0f * fb),
|
||||
(BYTE) (255.0f * fg),
|
||||
(BYTE) (255.0f * fr),
|
||||
(BYTE) (255.0f * fa)
|
||||
// Preserve Win32 truncation for valid normalized components; define
|
||||
// malformed inputs without float-to-byte overflow or unaligned type punning.
|
||||
auto component=[](float value) -> DWORD {
|
||||
return std::isfinite(value) ? DWORD(255.0f*std::clamp(value,0.0f,1.0f)) : 0;
|
||||
};
|
||||
((UI::CTextLine*)pWindow)->SetFontColor(*((DWORD *) argb));
|
||||
((UI::CTextLine*)pWindow)->SetFontColor(0xff000000u | (component(fr)<<16) | (component(fg)<<8) | component(fb));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -171,6 +171,23 @@ void TestComboStateMachine(const char* model) {
|
||||
fast.Update(0.1f);
|
||||
assert(Near(fast.GetAttackingElapsedTime(), 0.15f, 1e-3f));
|
||||
|
||||
// SetAttackSpeed stores zero but does not retime the already bound attack.
|
||||
fast.SetAttackSpeed(0);
|
||||
fast.Update(0.1f);
|
||||
assert(Near(fast.GetAttackingElapsedTime(), 0.30f, 1e-3f));
|
||||
assert(fast.RunComboAttack(0, RaceData::NAME_COMBO_ATTACK_1));
|
||||
fast.Update(0.1f);
|
||||
assert(Near(fast.GetAttackingElapsedTime(), 0));
|
||||
assert(!fast.IsMotionFinished());
|
||||
fast.SetAttackSpeed(2);
|
||||
fast.Update(0.1f);
|
||||
assert(Near(fast.GetAttackingElapsedTime(), 0));
|
||||
assert(fast.RunComboAttack(0, RaceData::NAME_COMBO_ATTACK_1));
|
||||
fast.Update(0.1f);
|
||||
assert(Near(fast.GetAttackingElapsedTime(), 0.2f, 1e-3f));
|
||||
fast.SetAttackSpeed(-1);
|
||||
assert(Near(fast.GetAttackSpeed(), 2));
|
||||
|
||||
// Without SetReportAttacks nothing is queued (remote actors).
|
||||
ava2::ActorInstance remote;
|
||||
assert(remote.SetRace(0) && remote.SetModel(model));
|
||||
|
||||
@@ -1382,7 +1382,8 @@ int main(int argc, char** argv) {
|
||||
trace.UpdateNewPosition(25.0f, 110.0f, 15.0f, 0.10f);
|
||||
assert(!trace.IsEmpty() && "FlyTrace must contain positions");
|
||||
std::vector<ava2::Render3DDraw> traceDraws;
|
||||
trace.BuildDrawCommands(dummyView, dummyProj, 0.12f, traceDraws);
|
||||
float traceProjection[16]={};traceProjection[0]=traceProjection[5]=0.001f;traceProjection[10]=0.0005f;traceProjection[14]=0.5f;traceProjection[15]=1;
|
||||
trace.BuildDrawCommands(dummyView,traceProjection,0.12f,traceDraws);
|
||||
assert(!traceDraws.empty() && "FlyTrace must generate ribbon quad draw commands");
|
||||
assert(traceDraws[0].blend_mode == 1 && "FlyTrace must use Additive blend mode");
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "python_background.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "python_runtime.h"
|
||||
#include "python_app.h"
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
@@ -177,6 +178,78 @@ int main(int argc, char** argv) {
|
||||
"assert bg.GetCurrentMapName() == ''\n"
|
||||
);
|
||||
|
||||
std::cout << "[TEST] Map height scale, visibility, streaming and water parity..." << std::endl;
|
||||
// MapOutdoorLoad::LoadSetting -> AreaTerrain scaled raw heights and water vertices.
|
||||
spit(root/"map/scaled_map/setting.txt","ScriptType MapSetting\nMapSize 4 1\nBasePosition 50000 60000\nHeightScale 2\nTerrainVisible 0\nTextureSet textureset/scaled.txt\n");
|
||||
spit(root/"textureset/scaled.txt","Start Texture004\n\"scaled.dds\"\n2\n3\n0\n0\n1\n0\n0\nEnd Texture004\n");
|
||||
std::string water(7+128*128+8,char(0xff));
|
||||
auto word=[&](size_t offset,uint16_t value) {water[offset]=char(value);water[offset+1]=char(value>>8);};
|
||||
word(0,5426);word(2,128);word(4,128);water[6]=2;
|
||||
water[7+128+1]=0;water[7+128+2]=1; // Odd row/column cell; second layer is -1 (no water).
|
||||
const size_t waterHeightOffset=7+128*128;
|
||||
for(int byte=0;byte<4;++byte)water[waterHeightOffset+byte]=char(uint32_t(1000)>>(8*byte));
|
||||
for(int block=0;block<4;++block) {
|
||||
char name[16];std::snprintf(name,sizeof(name),"%03d000",block);
|
||||
std::vector<uint16_t> scaledRaw(131*131,uint16_t(200+block*100));
|
||||
spit(root/"map/scaled_map"/name/"height.raw",std::string(reinterpret_cast<const char*>(scaledRaw.data()),scaledRaw.size()*2));
|
||||
spit(root/"map/scaled_map"/name/"water.wtr",water);
|
||||
}
|
||||
auto& background=CPythonBackground::Instance();
|
||||
for(int part=0;part<CPythonBackground::PART_NUM;++part)background.SetVisiblePart(part,false);
|
||||
background.SetVisiblePart(CPythonBackground::PART_TERRAIN,true);
|
||||
require(background.LoadMap("scaled_map"),"scaled map load");
|
||||
require(background.GetHeight(100,100)==400 && background.GetTerrain()->GetHeightScale()==2,"map HeightScale ignored");
|
||||
require(background.GetTerrain()->GetCellScale()==200,"original fixed CellScale changed");
|
||||
std::vector<Render3DDraw> draws;background.BuildDrawCommands(nullptr,nullptr,nullptr,draws);
|
||||
require(draws.empty() && background.IsVisiblePart(CPythonBackground::PART_TERRAIN),"map TerrainVisible must independently suppress draws");
|
||||
auto* firstTerrain=background.GetTerrain();background.Update(3*25600+100,100,0);
|
||||
require(background.GetTerrain()==firstTerrain && background.GetHeight(3*25600+100,100)==1000,"streamed blocks lost HeightScale or replaced active terrain");
|
||||
auto* loadedWater=background.GetWater();require(loadedWater && loadedWater->GetWaterLevel()==2000,"water scale/bias diverged from original");
|
||||
require(loadedWater->GetWaterFaceCount()==2,"invalid -1 water layer counted");
|
||||
auto waterDraw=loadedWater->BuildDrawCommand(0);
|
||||
require(waterDraw.positions.size()==12 && waterDraw.indices.size()==6,"odd water cell skipped or expanded across dry cells");
|
||||
require(waterDraw.positions[0]==2*25600+200 && waterDraw.positions[1]==2000 && waterDraw.positions[2]==200,"water uses bordered terrain origin or fixed height offset");
|
||||
background.SetVisiblePart(CPythonBackground::PART_WATER,true);
|
||||
draws.clear();background.BuildDrawCommands(nullptr,nullptr,nullptr,draws);
|
||||
require(draws.size()==2,"TerrainVisible disabled water or emitted hidden terrain");
|
||||
// Missing optional settings in existing minimal fixtures must reset to defaults, not leak.
|
||||
spit(root/"map/reset_map/setting.txt","ScriptType MapSetting\nMapSize 1 1\n");
|
||||
std::vector<uint16_t> resetRaw(131*131,200);
|
||||
spit(root/"map/reset_map/000000/height.raw",std::string(reinterpret_cast<const char*>(resetRaw.data()),resetRaw.size()*2));
|
||||
require(background.LoadMap("reset_map"),"default map load");
|
||||
require(background.GetHeight(100,100)==100 && background.GetOutdoorMap()->baseX==0 && background.GetTerrain()->GetTextureSet().empty(),"map settings/textures inherited");
|
||||
draws.clear();background.BuildDrawCommands(nullptr,nullptr,nullptr,draws);
|
||||
require(!draws.empty(),"default TerrainVisible not restored");
|
||||
background.SetVisiblePart(CPythonBackground::PART_TERRAIN,false);draws.clear();
|
||||
background.BuildDrawCommands(nullptr,nullptr,nullptr,draws);require(draws.empty(),"runtime terrain visibility ignored");
|
||||
background.SetVisiblePart(CPythonBackground::PART_TERRAIN,true);
|
||||
// A valid camera whose entire map is beyond its draw distance must not trigger an uncullable full-map fallback.
|
||||
const float view[16]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,1000000,1};
|
||||
const float proj[16]={1,0,0,0,0,1,0,0,0,0,1,1,0,0,-1,0};
|
||||
const float eye[3]={0,0,-1000000};
|
||||
std::vector<Render3DDrawRef> refs;draws.clear();background.BuildDrawCommands(view,proj,eye,draws,&refs);
|
||||
require(draws.empty() && refs.empty(),"culled terrain reappeared through full-map fallback");
|
||||
spit(root/"map/reset_map/setting.txt","ScriptType MapSetting\nMapSize 1 1\nHeightScale 1.25\n");
|
||||
require(background.LoadMap("reset_map",100000,0),"fallback terrain load");
|
||||
require(background.GetHeight(100,100)==250,"fallback terrain ignored scale");
|
||||
spit(root/"map/reset_map/setting.txt","ScriptType MapSetting\nMapSize 1 1\nHeightScale nan\n");
|
||||
require(!background.LoadMap("reset_map") && !background.IsMapReady(),"non-finite terrain heights accepted");
|
||||
background.Destroy();
|
||||
require(background.LoadMap("test_bg_map"),"forest clock map load");
|
||||
SpeedTreeForest reference;
|
||||
reference.CreateInstance(0,0,300,191919,0,1,"clock");
|
||||
background.GetForest()->CreateInstance(0,0,300,191919,0,1,"clock");
|
||||
const float treeView[16]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
|
||||
const float treeProj[16]={1,0,0,0,0,1,0,0,0,0,1,1,0,0,-1,0};
|
||||
for(float elapsed:{0.125f,0.375f,0.0f}) {
|
||||
SetGameFrameDelta(elapsed);background.Update(0,0,0);reference.UpdateSystem(GetGameFrameDelta());
|
||||
auto expected=reference.BuildDrawCommands(treeView,treeProj,0,50,0);
|
||||
auto actual=background.GetForest()->BuildDrawCommands(treeView,treeProj,0,50,0);
|
||||
require(!actual.empty() && actual.size()==expected.size(),"forest clock draw fixture");
|
||||
for(size_t i=0;i<actual.size();++i)require(actual[i].positions==expected[i].positions,"background wind uses fixed 0.033 instead of frame delta");
|
||||
}
|
||||
SetGameFrameDelta(0.033f);background.Destroy();
|
||||
|
||||
std::cout << "[TEST] Running block 4 (app camera bindings)..." << std::endl;
|
||||
python.execute(
|
||||
"import app\n"
|
||||
|
||||
@@ -77,9 +77,9 @@ void TestSafeBoxCpp() {
|
||||
std::cout << "[Test 2] Testing CPythonSafeBox storeroom..." << std::endl;
|
||||
auto& sb = CPythonSafeBox::Instance();
|
||||
|
||||
// Open 3 pages (3 * 45 = 135 slots)
|
||||
// Windows OpenSafeBox takes rows: three rows * five columns, not three pages.
|
||||
sb.OpenSafeBox(3);
|
||||
assert(sb.GetCurrentSafeBoxSize() == 135);
|
||||
assert(sb.GetCurrentSafeBoxSize() == 15);
|
||||
|
||||
sb.SetMoney(9876543);
|
||||
assert(sb.GetMoney() == 9876543);
|
||||
@@ -106,8 +106,8 @@ void TestSafeBoxCpp() {
|
||||
assert(sb.GetSlotItemID(5, &queriedVnum) && queriedVnum == 0);
|
||||
|
||||
// Mall
|
||||
sb.OpenMall(2); // 2 * 45 = 90 slots
|
||||
assert(sb.GetMallSize() == 90);
|
||||
sb.OpenMall(2); // Two rows * five columns.
|
||||
assert(sb.GetMallSize() == 10);
|
||||
|
||||
TItemData mallItem;
|
||||
mallItem.vnum = 70005; // Teleportation Ring
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
#include "eter_effect/FlyingManager.h"
|
||||
#include "eter_render/ActorInstance.h"
|
||||
#include "eter_render/Gr2ModelRenderer.h"
|
||||
#include "eter_base/Random.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "eter_render/MapObjectManager.h"
|
||||
#include "eter_net/NetworkActorManager.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
using namespace ava2;
|
||||
static void check(bool valid,const char* message){if(!valid)throw std::runtime_error(message);}
|
||||
static bool near(float a,float b){return std::abs(a-b)<0.001f;}
|
||||
static uint32_t ShakeClock(){return 1000;}
|
||||
static uint32_t ShakeValue(){return 6;}
|
||||
int main(){
|
||||
namespace fs=std::filesystem;
|
||||
const auto path=fs::temp_directory_path()/("ava2-flight-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count())+".msf");
|
||||
try {
|
||||
{std::ofstream(path)<<"InitialVelocity 10\nRange 1000\nHomingStartTime 0.5\nHomingMaxAngle 15\nHomingFlag 1\nPierceCount 2\nMaintainParallelFlag 1\nHitOnBackground 1\nHitOnAnotherMonster 1\nSpreadingFlag 1\nGravity -7\nAcceleration 1 2 3\n";}
|
||||
FlyingData loaded;check(loaded.LoadScriptFile(path.string()) && loaded.pierce_count==2 && loaded.maintain_parallel && loaded.spreading && loaded.hit_on_background && loaded.hit_on_another_monster
|
||||
&& loaded.homing_start_time==0.5f && loaded.initial_velocity==10 && loaded.gravity==-7,"MSF flight parameters");fs::remove(path);
|
||||
auto data=std::make_shared<FlyingData>();data->initial_velocity=100;data->bomb_range=1;data->range=10000;
|
||||
float start[3]={},target[3]={100,0,0};int hits=0,ranges=0;
|
||||
FlyingInstance swept(data,start,target);swept.SetHitCallback([&](const float*){++hits;});
|
||||
check(!swept.Update(2,2) && hits==1,"swept target skipped by high-speed flight");
|
||||
check(!swept.Update(2,4) && hits==1,"terminated flight callback duplicated");
|
||||
|
||||
// Launch along X, move the object to a tangent afterwards.
|
||||
bool live=true;float moving[3]={100,0,0};
|
||||
auto resolver=[&](float* out){if(!live)return false;std::copy(moving,moving+3,out);return true;};
|
||||
FlyingInstance strict(data,start,target,resolver);moving[1]=1;
|
||||
check(strict.Update(2,2),"strict bomb-range boundary accepted");moving[1]=0;
|
||||
data->range=99;FlyingInstance range(data,start,target);range.SetRangeCallback([&]{++ranges;});range.SetHitCallback([&](const float*){++hits;});
|
||||
check(!range.Update(1,1) && ranges==1 && hits==1,"range exhaustion reported as target hit");
|
||||
data->range=100;FlyingInstance equalRange(data,start,target);check(!equalRange.Update(1,1),"zero remaining range prevented valid hit");
|
||||
data->range=10000;data->initial_velocity=1;float far[3]={1000,0,0};
|
||||
FlyingInstance slow(data,start,far);int timeoutHits=0;slow.SetHitCallback([&](const float*){++timeoutHits;});
|
||||
check(slow.Update(6,6) && near(slow.GetPosition()[0],6) && timeoutHits==0,"five-second timeout/fake velocity remains");
|
||||
data->initial_velocity=100;data->gravity=-10;
|
||||
FlyingInstance gravity(data,start,far);check(gravity.Update(1,1) && near(gravity.GetPosition()[1],-10) && near(gravity.GetPosition()[2],0),"native gravity axis/units/order");
|
||||
data->gravity=0;data->acceleration[2]=5;FlyingInstance acceleration(data,start,far);
|
||||
check(acceleration.Update(1,1) && near(acceleration.GetPosition()[2],5),"initial roll and target arc not applied to acceleration");data->acceleration[2]=0;
|
||||
data->homing_flag=true;data->homing_start_time=0.5f;data->homing_max_angle=15;
|
||||
moving[0]=1000;moving[1]=0;moving[2]=0;
|
||||
FlyingInstance homing(data,start,moving,resolver);moving[0]=0;moving[2]=1000;
|
||||
check(homing.Update(0.5f,0.5f) && near(homing.GetPosition()[0],50) && near(homing.GetPosition()[2],0),"homing start boundary not strict");
|
||||
check(homing.Update(0.5f,1) && near(homing.GetPosition()[0],50+50*std::cos(3.14159265358979323846f/6))
|
||||
&& near(homing.GetPosition()[2],25),"homing quaternion angle limit/speed preservation");
|
||||
// Static positions do not home, even when the script has homing enabled.
|
||||
FlyingInstance position(data,start,far);check(position.Update(1,1) && near(position.GetPosition()[0],100),"static flight changed direction");
|
||||
data->homing_start_time=0;data->homing_max_angle=181;
|
||||
moving[0]=1000;moving[2]=0;FlyingInstance unrestricted(data,start,moving,resolver);moving[0]=0;moving[2]=1000;
|
||||
check(unrestricted.Update(0.1f,0.1f) && near(unrestricted.GetPosition()[0],0) && near(unrestricted.GetPosition()[2],10),"unlimited homing does not follow moving actor");
|
||||
moving[0]=100;moving[2]=0;data->homing_flag=false;data->pierce_count=1;
|
||||
FlyingInstance piercing(data,start,moving,resolver);int objectHits=0;piercing.SetTargetHitCallback([&]{++objectHits;});
|
||||
check(piercing.Update(1,1) && objectHits==1 && piercing.Update(0,1) && objectHits==1,"piercing primary hit not one-shot");
|
||||
data->pierce_count=0;moving[0]=300;FlyingInstance tracking(data,start,moving,resolver);moving[0]=100;
|
||||
tracking.SetTargetHitCallback([&]{++objectHits;});check(!tracking.Update(1,1) && objectHits==2,"non-homing flight used stale target point");
|
||||
moving[0]=100;FlyingInstance cleared(data,start,moving,resolver);live=false;moving[0]=1000;
|
||||
cleared.SetTargetHitCallback([&]{++objectHits;});check(!cleared.Update(1,1) && objectHits==2,"deleted object did not become last position");
|
||||
// Independent fixed-seed source trajectory: three Park–Miller draws and
|
||||
// native Z -> negative-Y -> initial roll -> target arc composition.
|
||||
data->spreading=true;float spreadTarget[3]={0,0,1000};eter::srandom(1);
|
||||
FlyingInstance spread(data,start,spreadTarget);check(spread.Update(1,1),"spread flight terminated");
|
||||
check(near(spread.GetPosition()[0],-78.86724f) && near(spread.GetPosition()[1],-2.778796f)
|
||||
&& near(spread.GetPosition()[2],61.41853f),"source spreading direction/composition");
|
||||
check(eter::random()==984943658u,"spreading RNG consumed wrong draw count");
|
||||
data->acceleration[1]=-100;eter::srandom(1);FlyingInstance spreadAcceleration(data,start,spreadTarget);
|
||||
check(spreadAcceleration.Update(1,1) && near(spreadAcceleration.GetPosition()[0],-157.73448f)
|
||||
&& near(spreadAcceleration.GetPosition()[1],-5.557592f) && near(spreadAcceleration.GetPosition()[2],122.83706f),"spread acceleration not rotated with velocity");
|
||||
data->acceleration[1]=0;data->spreading=false;eter::srandom(1);FlyingInstance noSpread(data,start,spreadTarget);
|
||||
check(eter::random()==16807u,"disabled spreading consumed RNG");
|
||||
// Extra actors use BODY spheres, not DEFENDING, enemy filters or health.
|
||||
{std::ofstream(path)<<"Group AttachingData\n{\nGroup AttachingData00\n{\nCollisionType 1\nGroup SphereData00\n{\nRadius 5\nPosition 0 0 0\n}\n}\n}\n";}
|
||||
auto* bodyRace=RaceManager::Instance().CreateRace(50002);check(bodyRace->LoadRaceData(path.string()),"BODY fixture");
|
||||
check(bodyRace->GetBodySpheres().size()==1 && bodyRace->GetDefendingSpheres().empty() && bodyRace->GetDefendingRadius()==0,"BODY misclassified as DEFENDING");
|
||||
auto& actors=NetworkActorManager::Instance();actors.Clear();
|
||||
auto addBody=[&](uint32_t vid,float x,float z){SNetworkActorData actor{};actor.m_dwVID=vid;actor.m_dwRace=50002;actor.m_bType=6;actors.AppendActor(actor);auto instance=actors.GetActorInstance(vid);instance->SetPosition(x,20,z);return instance;};
|
||||
auto owner=addBody(1,0,0),other=addBody(2,50,0);other->Die();
|
||||
owner->SetShakeSourcesForTest(ShakeClock,ShakeValue);owner->OnShootDamage();owner->Update(0);
|
||||
const auto bodyUnshaken=owner->GetBodyCollisionSpheres();float shakenCenter[3];owner->GetFlyTargetCenter(shakenCenter);
|
||||
check(bodyUnshaken.size()==1 && bodyUnshaken[0].position[0]==0 && bodyUnshaken[0].position[1]==20 && bodyUnshaken[0].position[2]==0
|
||||
&& shakenCenter[0]==6 && shakenCenter[2]==-6,"shake changed BODY geometry or missing graphic target offset");
|
||||
owner->SetShakeSourcesForTest(nullptr,nullptr);
|
||||
float sceneStart[3]={0,20,0},sceneTarget[3]={1000,20,0};
|
||||
std::vector<uint32_t> extraHits;int backgroundHits=0;
|
||||
FlyCollisionCallbacks callbacks;callbacks.owner=owner->GetFlyCollisionIdentity();callbacks.onAnotherTarget=[&](uint32_t vid){extraHits.push_back(vid);};callbacks.onBackground=[&]{++backgroundHits;};
|
||||
data->hit_on_another_monster=true;data->pierce_count=1;
|
||||
FlyingInstance extra(data,sceneStart,sceneTarget);extra.SetCollisionCallbacks(callbacks);
|
||||
check(extra.Update(1,1) && extraHits==std::vector<uint32_t>{2},"owner filter/dead friendly BODY collision");
|
||||
other->SetPosition(100,20,0);check(extra.Update(0,1) && extraHits.size()==1,"piercing duplicate object callback");
|
||||
// Previously-hit first candidate masks another, matching source hit-set ordering.
|
||||
addBody(3,100,0);check(extra.Update(0,1) && extraHits.size()==1,"already-hit candidate incorrectly skipped before query");actors.RemoveActor(3);
|
||||
auto oldOther=other;actors.RemoveActor(2);other=addBody(2,100,0);
|
||||
check(!extra.Update(0,1) && extraHits==std::vector<uint32_t>({2,2}),"same VID replacement inherited collision hit set");
|
||||
extraHits.clear();data->pierce_count=0;other->SetPosition(50,20,-50);other->SetSpeed(100);other->SetMoveTarget(50,50);other->Update(1);
|
||||
FlyingInstance crossing(data,sceneStart,sceneTarget);crossing.SetCollisionCallbacks(callbacks);
|
||||
check(!crossing.Update(1,1) && extraHits==std::vector<uint32_t>{2},"moving BODY sphere sweep missed crossing");
|
||||
other->SetPosition(50,35,0);other->Update(0.01f);extraHits.clear();
|
||||
FlyingInstance tangentBody(data,sceneStart,sceneTarget);tangentBody.SetCollisionCallbacks(callbacks);
|
||||
check(!tangentBody.Update(1,1) && extraHits==std::vector<uint32_t>{2},"BODY inclusive radius boundary");
|
||||
actors.RemoveActor(2);extraHits.clear();FlyingInstance ownerOnly(data,sceneStart,sceneTarget);ownerOnly.SetCollisionCallbacks(callbacks);
|
||||
check(ownerOnly.Update(1,1) && extraHits.empty(),"owner hit itself");
|
||||
// Primary hit returns before actor/background checks; range exhaustion returns first.
|
||||
other=addBody(2,50,0);data->pierce_count=1;data->hit_on_background=true;
|
||||
struct Ground:TerrainHeightSource {float height=100;float GetHeightAtWorld(float,float)const override{return height;}bool HasAttrMap()const override{return false;}bool IsAttrOn(float,float,uint8_t)const override{return false;}} ground;
|
||||
float primary[3]={100,20,0};FlyingInstance primaryFirst(data,sceneStart,primary,[](float* out){out[0]=100;out[1]=20;out[2]=0;return true;});primaryFirst.SetCollisionCallbacks(callbacks);
|
||||
check(primaryFirst.Update(1,1,&ground) && backgroundHits==0 && extraHits.empty(),"primary piercing priority changed");
|
||||
data->range=99;FlyingInstance exhausted(data,sceneStart,sceneTarget);exhausted.SetCollisionCallbacks(callbacks);
|
||||
check(!exhausted.Update(1,1,&ground) && backgroundHits==0 && extraHits.empty(),"range collision priority changed");data->range=10000;
|
||||
data->pierce_count=0;FlyingInstance actorFirst(data,sceneStart,sceneTarget);actorFirst.SetCollisionCallbacks(callbacks);
|
||||
check(!actorFirst.Update(1,1,&ground) && extraHits==std::vector<uint32_t>{2} && backgroundHits==0,"actor/background priority changed");
|
||||
data->hit_on_another_monster=false;FlyingInstance buried(data,sceneStart,sceneTarget);buried.SetCollisionCallbacks(callbacks);
|
||||
check(!buried.Update(1,1,&ground) && backgroundHits==1,"below-ground impact not dispatched");ground.height=20;
|
||||
FlyingInstance groundEqual(data,sceneStart,sceneTarget);groundEqual.SetCollisionCallbacks(callbacks);
|
||||
check(groundEqual.Update(1,1,&ground) && backgroundHits==1,"ground equality exploded");
|
||||
FlyingInstance compositeGround(data,sceneStart,sceneTarget);compositeGround.SetCollisionCallbacks(callbacks);
|
||||
check(!compositeGround.Update(1,1,&ground,nullptr,[](float,float){return 100.0f;}) && backgroundHits==2,"composite map height override ignored");
|
||||
data->hit_on_background=false;ground.height=100;FlyingInstance noBackground(data,sceneStart,sceneTarget);noBackground.SetCollisionCallbacks(callbacks);
|
||||
check(noBackground.Update(1,1,&ground) && backgroundHits==2,"disabled background flag ignored");
|
||||
// A 3D box proxy must not behave as a ground cylinder; original OBB tests endpoints.
|
||||
OrientedBoundingBox box;box.centerX=50;box.centerY=20;box.halfExtents[0]=5;box.halfExtents[1]=5;box.halfExtents[2]=10;
|
||||
const float above[3]={50,100,0},onBoundary[3]={56,20,0};check(!box.IntersectsSphere3D(above,1) && box.IntersectsSphere3D(onBoundary,1),"OBB 3D height/inclusive radius");
|
||||
box.yawRad=3.14159265358979323846f/2;const float rotated[3]={60,20,0};check(box.IntersectsSphere3D(rotated,1),"OBB yaw ignored");
|
||||
actors.Clear();fs::remove(path);
|
||||
// Four parsed attachments produce four independently positioned ribbons.
|
||||
{std::ofstream script(path);script<<"InitialVelocity 100\nRange 10000\nRollAngle 90\nAngularVelocity 0 0 90\n";
|
||||
for(int type=1;type<=4;++type)script<<"Group AttachData\n{\nType 1\nFlyType "<<type<<"\nTailFlag 1\nTailColor 4294967295d\nTailLength 5\nTailSize 2\nRoll 90\nDistance 10\nPeriod 1\nAmplitude 20\n}\n";}
|
||||
auto visualData=std::make_shared<FlyingData>();check(visualData->LoadScriptFile(path.string()) && visualData->attachments.size()==4
|
||||
&& visualData->attach.fly_type==1 && visualData->attachments[3].amplitude==20 && visualData->angular_velocity[2]==90,"multi attachment script parsing");
|
||||
const auto effectPath=fs::path(path.string()+".mse");
|
||||
{std::ofstream(effectPath)<<"Group Particle { List TimeEventPosition { 0 MOVING_TYPE_DIRECT 0 0 0 } Group EmitterProperty { MaxEmissionCount 1 CycleLength 1 CycleLoopEnable 1 List TimeEventEmissionCountPerSecond { 0 20 } List TimeEventLifeTime { 0 20 } } Group ParticleProperty { BillboardType 1 AttachEnable 1 List TextureFiles { flight.dds } } }";}
|
||||
for(auto& definition:visualData->attachments)definition.attach_file=effectPath.string();
|
||||
auto& effects=EffectManager::Instance();effects.DeleteAllInstances();const auto unrelated=effects.CreateEffect(effectPath.string());check(unrelated!=0,"attachment effect fixture");
|
||||
{
|
||||
FlyingInstance visual(visualData,start,spreadTarget);check(effects.GetActiveInstanceCount()==5,"only one attachment created");
|
||||
check(visual.Update(0.25f,0.25f),"visual flight died");float identity[16]={};for(int k=0;k<16;k+=5)identity[k]=1;
|
||||
float tailProjection[16]={};tailProjection[0]=tailProjection[5]=0.001f;tailProjection[10]=0.0005f;tailProjection[14]=0.5f;tailProjection[15]=1;
|
||||
std::vector<Render3DDraw> ribbons;visual.BuildDrawCommands(identity,tailProjection,0.25f,ribbons);check(ribbons.size()==4,"independent attachment tails missing");
|
||||
const float amounts[]={0,10,20,20*std::exp(-0.25f)*0.25f};
|
||||
for(int index=0;index<4;++index) {
|
||||
const auto& positions=ribbons[index].positions;check(positions.size()>=9,"attachment ribbon geometry absent");
|
||||
const float x=(positions[3]+positions[6])*0.5f,z=(positions[5]+positions[8])*0.5f;
|
||||
check(near(x,-amounts[index]*std::cos(3.14159265358979323846f/8))
|
||||
&& near(z,25+amounts[index]*std::sin(3.14159265358979323846f/8)),"LINE/MULTI/SINE/EXP offset or angular composition");
|
||||
}
|
||||
effects.Update(0.05f);const float camera[3]={0,0,100};std::vector<Render3DDraw> particles;effects.BuildDrawCommands(identity,identity,camera,particles);
|
||||
check(particles.size()==5,"multi attachment effect draws missing");
|
||||
for(int index=0;index<4;++index) {
|
||||
const float expectedX=-amounts[index]*std::cos(3.14159265358979323846f/8),expectedZ=25+amounts[index]*std::sin(3.14159265358979323846f/8);
|
||||
bool found=false;for(const auto& particle:particles) {
|
||||
if(particle.positions.size()<12)continue;float x=0,z=0;
|
||||
for(int vertex=0;vertex<4;++vertex){x+=particle.positions[vertex*3]/4;z+=particle.positions[vertex*3+2]/4;}
|
||||
if(near(x,expectedX) && near(z,expectedZ))found=true;
|
||||
}
|
||||
check(found,"attachment global matrix did not reach particle drawing");
|
||||
}
|
||||
}
|
||||
check(effects.GetActiveInstanceCount()==1 && effects.IsAliveEffect(unrelated),"attachment destruction leaked/deleted unrelated effect");
|
||||
visualData->range=1;
|
||||
{
|
||||
FlyingInstance expiringVisual(visualData,start,spreadTarget);check(effects.GetActiveInstanceCount()==5,"expiring attachments not created");
|
||||
check(!expiringVisual.Update(0.25f,0.25f) && effects.GetActiveInstanceCount()==1,"range termination did not clear owned attachments");
|
||||
float identity[16]={};for(int k=0;k<16;k+=5)identity[k]=1;std::vector<Render3DDraw> clearedTails;
|
||||
expiringVisual.BuildDrawCommands(identity,identity,0.25f,clearedTails);check(clearedTails.empty(),"terminated tails retained geometry");
|
||||
}
|
||||
effects.DeleteAllInstances();fs::remove(effectPath);fs::remove(path);
|
||||
// Original tail is a six-vertex pointed strip, not a four-vertex ribbon.
|
||||
float traceView[16]={},traceProjection[16]={};for(int k=0;k<16;k+=5)traceView[k]=traceProjection[k]=1;traceView[14]=10;traceProjection[0]=traceProjection[5]=0.001f;traceProjection[10]=0.0005f;traceProjection[14]=0.5f;
|
||||
FlyTrace trace;trace.Create(0x80402010,1,2,false);trace.UpdateNewPosition(0,0,0,0);trace.UpdateNewPosition(10,0,0,0.5f);
|
||||
std::vector<Render3DDraw> traceDraws;trace.BuildDrawCommands(traceView,traceProjection,0.5f,traceDraws);
|
||||
check(traceDraws.size()==1 && traceDraws[0].positions.size()==18 && traceDraws[0].indices.size()==12,"source pointed tail topology");
|
||||
const float expectedTrace[]={12,0,0,10,-2,0,10,2,0,0,-1,0,0,1,0,-1,0,0};
|
||||
for(int k=0;k<18;++k)check(near(traceDraws[0].positions[k],expectedTrace[k]),"source camera-eye basis or width decay");
|
||||
for(auto color:traceDraws[0].diffuse)check(color==0x80402010,"tail faded original constant alpha");
|
||||
check(traceDraws[0].alpha_test && traceDraws[0].alpha_ref==0 && traceDraws[0].blend_mode==1,"tail alpha/additive states");
|
||||
trace.Create(0xFFFFFFFF,1,2,true);trace.UpdateNewPosition(0,0,0,0);trace.UpdateNewPosition(10,0,0,0.5f);traceDraws.clear();
|
||||
trace.BuildDrawCommands(traceView,traceProjection,0.5f,traceDraws);check(near(traceDraws[0].positions[9+1],-2),"rect tail width decayed");
|
||||
trace.UpdateNewPosition(20,0,0,1);traceDraws.clear();trace.BuildDrawCommands(traceView,traceProjection,1,traceDraws);
|
||||
check(traceDraws[0].positions.size()==36,"tail expiry equality removed oldest sample");
|
||||
trace.UpdateNewPosition(30,0,0,1.001f);traceDraws.clear();trace.BuildDrawCommands(traceView,traceProjection,1.001f,traceDraws);
|
||||
check(traceDraws[0].positions.size()==36,"tail strict expiry did not remove only oldest sample");
|
||||
trace.Create(0xFFFFFFFF,0.005f,0.05f,false);trace.UpdateNewPosition(0,0,0,0);trace.UpdateNewPosition(10,0,0,0.002f);traceDraws.clear();
|
||||
trace.BuildDrawCommands(traceView,traceProjection,0.002f,traceDraws);check(near(traceDraws[0].positions[0],10.05f),"small valid tail parameters replaced with defaults");
|
||||
trace.Create(0xFFFFFFFF,0,2,false);trace.UpdateNewPosition(0,0,0,0);trace.UpdateNewPosition(10,0,0,0);traceDraws.clear();
|
||||
trace.BuildDrawCommands(traceView,traceProjection,0,traceDraws);check(traceDraws.empty(),"zero-length tail generated invalid geometry");
|
||||
trace.Create(0xFFFFFFFF,10,1,true);trace.UpdateNewPosition(0,0,0,0);trace.UpdateNewPosition(10,0,10,1);trace.UpdateNewPosition(20,0,15,2);traceDraws.clear();
|
||||
trace.BuildDrawCommands(traceView,traceProjection,2,traceDraws);
|
||||
check(traceDraws[0].positions.size()==36 && near((traceDraws[0].positions[5]+traceDraws[0].positions[8])*0.5f,10),"source depth sorting changed");
|
||||
// Six normalized D3D clip planes: external tangency is OUTSIDE.
|
||||
float clipView[16]={},clipProjection[16]={};for(int k=0;k<16;k+=5)clipView[k]=clipProjection[k]=1;
|
||||
auto visible=[&](float x,float y,float z){FlyTrace clip;clip.Create(0xFFFFFFFF,10,100,true);clip.UpdateNewPosition(x,y,z-0.1f,0);clip.UpdateNewPosition(x,y,z+0.1f,1);std::vector<Render3DDraw> draws;clip.BuildDrawCommands(clipView,clipProjection,1,draws);return !draws.empty();};
|
||||
check(visible(0,0,0.5f) && !visible(2,0,0.5f) && !visible(-2,0,0.5f)
|
||||
&& !visible(0,2,0.5f) && !visible(0,-2,0.5f) && !visible(0,0,-1) && !visible(0,0,2),"six-plane tail clipping");
|
||||
// Exact binary values avoid rounding the tangent comparison.
|
||||
auto boundaryVisible=[&](float x){FlyTrace clip;clip.Create(0xFFFFFFFF,10,100,true);clip.UpdateNewPosition(x,0,0.25f,0);clip.UpdateNewPosition(x,0,0.75f,1);std::vector<Render3DDraw> draws;clip.BuildDrawCommands(clipView,clipProjection,1,draws);return !draws.empty();};
|
||||
check(!boundaryVisible(1.25f) && boundaryVisible(1.249f),"frustum tangent/partial boundary");
|
||||
// Width 100 must not enlarge the source's segment sphere.
|
||||
check(!boundaryVisible(2),"tail width incorrectly enlarged culling sphere");
|
||||
FlyTrace mixed; mixed.Create(0xFFFFFFFF,10,1,true);mixed.UpdateNewPosition(0,0,0.5f,0);mixed.UpdateNewPosition(0.5f,0,0.5f,1);mixed.UpdateNewPosition(4,0,0.5f,2);mixed.UpdateNewPosition(5,0,0.5f,3);
|
||||
traceDraws.clear();mixed.BuildDrawCommands(clipView,clipProjection,3,traceDraws);check(traceDraws.size()==1 && traceDraws[0].positions.size()==12*3,"per-segment clipping/visible strip retained");
|
||||
clipView[12]=-2;check(!visible(4,0,0.5f),"outside sphere accepted");
|
||||
FlyTrace translated;translated.Create(0xFFFFFFFF,10,1,true);translated.UpdateNewPosition(2,0,0.4f,0);translated.UpdateNewPosition(2,0,0.6f,1);traceDraws.clear();translated.BuildDrawCommands(clipView,clipProjection,1,traceDraws);
|
||||
check(!traceDraws.empty(),"view/projection matrix product order");
|
||||
// Current client's standard perspective: near=1, far=100, 90-degree FOV.
|
||||
for(int k=0;k<16;++k)clipView[k]=(k%5==0)?1.0f:0.0f;
|
||||
std::fill(clipProjection,clipProjection+16,0);clipProjection[0]=clipProjection[5]=1;clipProjection[10]=100.0f/99;clipProjection[11]=1;clipProjection[14]=-100.0f/99;
|
||||
check(visible(0.5f,0.3f,5) && !visible(0,0,0.5f) && !visible(0,0,200) && !visible(10,0,5),"perspective tail planes/coarse sphere");
|
||||
// Original screen stores degree FOV but coarse sphere uses tan(degrees/2).
|
||||
// At 20*pi degrees its coarse sphere excludes a plane-visible far corner.
|
||||
const float historicalFov=20*3.14159265358979323846f;
|
||||
clipProjection[0]=clipProjection[5]=1/std::tan(historicalFov*3.14159265358979323846f/360);
|
||||
check(!visible(50,0,99),"source FOV unit mismatch in coarse sphere not preserved");
|
||||
// UpdateGame snapshot survives render-time camera/projection changes.
|
||||
Gr2SceneRenderer scene(32,32);scene.SetCameraLookAt(0,0,0,0,0,1,0,1,0);
|
||||
scene.SetPerspective(90,1,1,100);scene.BuildViewFrustum();
|
||||
FlyTrace cached;cached.Create(0xFFFFFFFF,10,0.1f,true);cached.UpdateNewPosition(0,0,5,0);cached.UpdateNewPosition(0,0,5.2f,1);
|
||||
scene.SetCameraLookAt(100,0,0,100,0,1,0,1,0);scene.SetOrtho3D(2,2,0,10);
|
||||
traceDraws.clear();cached.BuildDrawCommands(scene.GetViewMatrix(),scene.GetProjMatrix(),1,traceDraws,scene.GetCachedViewFrustum());
|
||||
check(!traceDraws.empty(),"render-time setters invalidated UpdateGame frustum");
|
||||
scene.BuildViewFrustum();traceDraws.clear();cached.BuildDrawCommands(scene.GetViewMatrix(),scene.GetProjMatrix(),1,traceDraws,scene.GetCachedViewFrustum());
|
||||
check(traceDraws.empty(),"next UpdateGame did not refresh cached camera");
|
||||
// Ortho planes retain the last perspective's coarse sphere, including degree FOV.
|
||||
scene.SetCameraLookAt(0,0,0,0,0,1,0,1,0);scene.SetPerspective(historicalFov,1,1,100);scene.SetOrtho3D(200,200,0,100);scene.BuildViewFrustum();
|
||||
check(scene.GetCachedViewFrustum()->Outside({50,0,99},0.1f),"ortho lost saved perspective coarse sphere");
|
||||
check(!scene.GetCachedViewFrustum()->Outside({0,0,50},0.1f),"ortho coarse sphere rejects centre");
|
||||
float offAxis[16];std::copy_n(scene.GetProjMatrix(),16,offAxis);offAxis[12]=0.2f;scene.SetProjectionMatrix(offAxis);scene.BuildViewFrustum();
|
||||
check(scene.GetCachedViewFrustum()->Outside({50,0,99},0.1f),"custom projection lost coarse sphere metadata");
|
||||
scene.SetOrtho2D(200,100,10);check(near(scene.GetProjMatrix()[12],-1) && near(scene.GetProjMatrix()[13],1) && near(scene.GetProjMatrix()[5],-0.02f),"ortho2d off-centre mapping");
|
||||
// Source restores LESS but inherits ZENABLE/ZWRITE from the enclosing pass.
|
||||
scene.SetDepthState({false,false});traceDraws.clear();cached.BuildDrawCommands(traceView,traceProjection,1,traceDraws,nullptr,scene.GetDepthState());
|
||||
check(!traceDraws.empty() && !traceDraws[0].z_enable && !traceDraws[0].z_write && traceDraws[0].depth_less,"inherited tail depth states");
|
||||
scene.SetDepthState({true,true});traceDraws.clear();cached.BuildDrawCommands(traceView,traceProjection,1,traceDraws,nullptr,scene.GetDepthState());
|
||||
check(traceDraws[0].z_enable && traceDraws[0].z_write && traceDraws[0].depth_less,"default tail depth write forced off");
|
||||
HardwareBatch le{},lt{};lt.depthLess=true;check(PipelineKey(le)!=PipelineKey(lt),"GPU pipeline key merges LESS and LESSEQUAL");
|
||||
// Render equal-depth fragments: LESS must reject; additive writes still update depth.
|
||||
scene.SetCameraLookAt(0,0,0,0,0,1,0,1,0);scene.SetOrtho3D(2,2,0,1);
|
||||
auto* surface=SDL_CreateSurface(32,32,SDL_PIXELFORMAT_ARGB8888);check(surface!=nullptr,"depth surface allocation");
|
||||
Render3DDraw triangle;triangle.positions={-0.8f,-0.8f,0.5f,0.8f,-0.8f,0.5f,0,0.8f,0.5f};triangle.indices={0,1,2};triangle.diffuse={0xFFFF0000,0xFFFF0000,0xFFFF0000};triangle.lighting=false;triangle.fog=false;triangle.cull_mode=1;
|
||||
for(int k=0;k<16;k+=5)triangle.world[k]=1;
|
||||
scene.Clear(0,1);SDL_FillSurfaceRect(surface,nullptr,0);scene.RenderDraw(surface,triangle);
|
||||
const size_t pixel=16*32+16;const auto before=static_cast<uint32_t*>(surface->pixels)[pixel];check(scene.GetDepthBuffer()[pixel]<1,"depth triangle produced no fragments");
|
||||
triangle.diffuse={0xFF00FF00,0xFF00FF00,0xFF00FF00};triangle.alpha_blend=true;triangle.blend_mode=1;triangle.depth_less=true;
|
||||
scene.RenderDraw(surface,triangle);check(static_cast<uint32_t*>(surface->pixels)[pixel]==before,"LESS accepted equal-depth fragment");
|
||||
triangle.depth_less=false;scene.RenderDraw(surface,triangle);check(static_cast<uint32_t*>(surface->pixels)[pixel]!=before,"LESSEQUAL rejected equal depth");
|
||||
scene.Clear(0,1);triangle.depth_less=true;scene.RenderDraw(surface,triangle);check(scene.GetDepthBuffer()[pixel]<1,"additive depth-write state ignored");
|
||||
scene.Clear(0,1);triangle.z_write=false;scene.RenderDraw(surface,triangle);check(scene.GetDepthBuffer()[pixel]==1,"disabled additive depth-write changed depth");
|
||||
SDL_DestroySurface(surface);
|
||||
trace.Clear();check(trace.IsEmpty(),"tail clear retained history");
|
||||
// Actor resolver weak identity must reject deletion and same-VID replacement.
|
||||
auto actor=std::make_unique<ActorInstance>();actor->SetVID(7);actor->SetPosition(20,30,40);ActorInstance* registered=actor.get();
|
||||
ActorInstance::SetActorResolver([&](uint32_t vid){return vid==7?registered:nullptr;});
|
||||
auto captured=actor->CaptureFlyTargetResolver();float center[3];check(captured(center) && center[0]==20 && center[2]==40,"actor target capture");
|
||||
actor->SetPosition(25,30,45);check(captured(center) && center[0]==25 && center[2]==45,"actor target not live");
|
||||
auto replacement=std::make_unique<ActorInstance>();replacement->SetVID(7);registered=replacement.get();
|
||||
check(!captured(center),"VID reuse inherited old flight while old actor retained");actor.reset();check(!captured(center),"deleted actor resolver dereferenced");
|
||||
registered=nullptr;ActorInstance::SetActorResolver({});
|
||||
std::cout<<"AVA2 flying target lifecycle passed\n";return 0;
|
||||
}catch(const std::exception& e){fs::remove(path);fs::remove(path.string()+".mse");ActorInstance::SetActorResolver({});std::cerr<<e.what()<<'\n';return 1;}
|
||||
}
|
||||
@@ -63,6 +63,19 @@ int main() {
|
||||
color=center({near,masked});assert(color[2]>245&&color[0]<5);
|
||||
near.depthWrite=false;color=center({near,far});assert(color[1]>245&&color[0]<5);
|
||||
near.depthWrite=true;near.cull=2;color=center({near});assert(color[0]>245);
|
||||
// Original FlyTrace uses LESS, additive blending and inherited depth write.
|
||||
auto equal=near;equal.cull=1;equal.firstIndex=3;equal.blend=equal.additive=true;equal.depthLess=true;
|
||||
for(int i=3;i<6;++i)vertices[i].position[2]=.2f;
|
||||
near.cull=1;color=center({near,equal});assert(color[0]>245 && color[1]<5);
|
||||
equal.depthLess=false;color=center({near,equal});assert(color[0]>245 && color[1]>245);
|
||||
equal.depthLess=true;equal.depthWrite=true;color=center({equal,near});assert(color[0]>245 && color[1]<5); // near defaults LESSEQUAL
|
||||
auto behind=near;behind.firstIndex=6;behind.depthLess=true;
|
||||
for(int i=6;i<9;++i){vertices[i].position[2]=.4f;vertices[i].color[3]=255;}
|
||||
color=center({equal,behind});assert(color[1]>245 && color[2]<5);
|
||||
equal.depthWrite=false;color=center({equal,behind});assert(color[2]>245 && color[1]<5);
|
||||
equal.depth=false;color=center({near,equal});assert(color[0]>245 && color[1]>245);
|
||||
for(int i=3;i<6;++i)vertices[i].position[2]=.8f;
|
||||
for(int i=6;i<9;++i){vertices[i].position[2]=.1f;vertices[i].color[3]=51;}
|
||||
// Perspective-correct color interpolation: top W=2 doubles its reciprocal denominator.
|
||||
auto saved=vertices;
|
||||
vertices[2].position[1]*=2;vertices[2].position[2]*=2;vertices[2].position[3]=2;
|
||||
|
||||
@@ -124,6 +124,12 @@ int main(int argc, char** argv) {
|
||||
runtime.execute("assert mouseModule.mouseController.isAttached(), calls\n"
|
||||
"assert mouseModule.mouseController.GetAttachedSlotNumber() == 0, 'pick slot'\n");
|
||||
assert(wm->IsAttaching());
|
||||
runtime.execute("import grpImage\nicon_positions=[]\noriginal_set_position=grpImage.SetPosition\n"
|
||||
"grpImage.SetPosition=lambda h,x,y: icon_positions.append((h,x,y))\n"
|
||||
"mouseModule.mouseController.Update(100,200)\n"
|
||||
"mc=mouseModule.mouseController\n"
|
||||
"assert icon_positions[-1][2] < 200-mc.AttachedIconHalfHeight-30,icon_positions\n"
|
||||
"grpImage.SetPosition=original_set_position\n");
|
||||
// Tap an empty cell: dropped there with the original move packet.
|
||||
Tap(router, x5, y5);
|
||||
runtime.execute("assert not mouseModule.mouseController.isAttached(), ('drop', attached(), calls)\n"
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
#include "python_runtime.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "eter_net/PythonNetworkStream.h"
|
||||
#include "eter_net/NetworkActorManager.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "eter_render/CRenderTarget.h"
|
||||
#include "eter_effect/FlyingManager.h"
|
||||
#include "eter_render/MapObjectManager.h"
|
||||
#include "test_rundir.h"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
using namespace ava2;
|
||||
namespace fs=std::filesystem;
|
||||
static uint32_t motionRandom=0,motionRandomCalls=0;
|
||||
static uint32_t RandomMotion() {++motionRandomCalls;return motionRandom;}
|
||||
static uint32_t motionClock=1000;
|
||||
static uint32_t Clock() {return motionClock;}
|
||||
static uint32_t shakeRandomCalls=0;
|
||||
static uint32_t ShakeRandom() {static const uint32_t values[]={0,3,1,4,0,5};return values[(shakeRandomCalls++)%6];}
|
||||
static void require(bool ok,const char* why) {if(!ok) throw std::runtime_error(why);}
|
||||
int main(int argc,char** argv) {
|
||||
if(argc!=2) return 2;
|
||||
const auto previous=fs::current_path();
|
||||
if(!ava2_test::EnterTestRunDir()) return ava2_test::kSkip;
|
||||
const auto stdlib=fs::absolute(argv[1]);
|
||||
const auto model=fs::absolute("ymir work/pc/warrior/warrior_assasin1.gr2");
|
||||
const auto animation=fs::absolute("ymir work/pc/warrior/general/wait.gr2");
|
||||
const std::array<fs::path,3> variantAnimations={animation,fs::absolute("ymir work/pc/warrior/general/walk.gr2"),fs::absolute("ymir work/pc/warrior/general/run.gr2")};
|
||||
if(!fs::exists(model) || !fs::exists(animation) || !fs::exists(variantAnimations[1]) || !fs::exists(variantAnimations[2])) return ava2_test::kSkip;
|
||||
const auto root=fs::temp_directory_path()/("ava2-motion-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
try {
|
||||
fs::create_directories(root);fs::current_path(root);
|
||||
auto* race=RaceManager::Instance().CreateRace(1);race->RegisterMotionMode(1);
|
||||
for(uint16_t index=1;index<=RaceData::NAME_JOY;++index) {
|
||||
const auto path=root/(std::to_string(index)+".msa");
|
||||
std::ofstream(path)<<"ScriptType MotionData\nMotionFileName \""<<animation.string()<<"\"\nMotionDuration 1\n"
|
||||
<<(index==RaceData::NAME_SKILL ? "Group LoopData\n{\nMotionLoopCount -1\nLoopCancelEnable 1\nLoopStartTime 0\nLoopEndTime 0.3\n}\n" : "");
|
||||
require(race->RegisterMotion(1,index,path.string(),100),"synthetic motion registration");
|
||||
}
|
||||
std::ofstream(root/"skillgate.txt")<<"type active\nname Gate\niconfilename icon.dds\nneedspformula 1\nmotionindex 1\n";
|
||||
std::weak_ptr<CRenderTarget> preview;
|
||||
{
|
||||
PythonRuntime python(stdlib,root);auto& net=PythonNetworkStream::Instance();auto& actors=NetworkActorManager::Instance();
|
||||
preview=CRenderTargetManager::Instance().CreateRenderTarget(12345);
|
||||
actors.Clear();net.SetPhase(PHASE_GAME);net.SetMainActorVID(10);
|
||||
SNetworkActorData main{};main.m_dwVID=10;main.m_dwRace=1;main.m_bType=6;
|
||||
SNetworkActorData target=main;target.m_dwVID=20;target.m_stName="MotionTarget";
|
||||
actors.AppendActor(main);actors.AppendActor(target);
|
||||
auto actor=actors.GetActorInstance(10);auto victim=actors.GetActorInstance(20);
|
||||
require(actor && victim && actor->SetModel(model.string()) && victim->SetModel(model.string()),"GR2 motion fixture");
|
||||
actor->SetHP(1000);victim->SetHP(1000);actor->SetPosition(0,0,0);victim->SetPosition(100,0,0);
|
||||
require(actor->SetLoopMotionIndex(RaceData::NAME_WAIT),"wait motion fixture");
|
||||
python.execute("import player,net\nclass W:\n def __init__(self): self.fail=0\n def OnFishingFailure(self): self.fail+=1\nw=W()\nnet.SetPhaseWindow(net.PHASE_WINDOW_GAME,w)\nplayer.SetGameWindow(w)\n");
|
||||
python.execute("import skill\nskill.RegisterSkill(220,'skillgate.txt')\n");SetPlayerSkill(30,220);SetPlayerSkillLevel(220,0,1);SetPlayerStatusPoint(7,100);
|
||||
require(actor->InterceptMotionIndex(RaceData::NAME_SKILL,false) && actor->CanUseSkill(),"cancel-enabled current skill fixture");
|
||||
net.ClearSendQueue();ClickSkillSlot(30);require(net.GetSendQueue().empty(),"ClickSkillSlot bypassed original second IsUsingSkill gate");
|
||||
require(actor->SetLoopMotionIndex(RaceData::NAME_WAIT),"restore wait after skill gate");
|
||||
auto motion=[&](uint32_t index) {require(uint32_t(actor->GetCurrentMotion())==index,"incorrect current motion");};
|
||||
auto next=[&]() {actor->Update(actor->GetMotionDuration()+0.01f);};
|
||||
auto fishing=[&](uint8_t subtype,uint32_t vid=10,uint8_t dir=0) {
|
||||
const uint8_t packet[]={89,subtype,uint8_t(vid),uint8_t(vid>>8),uint8_t(vid>>16),uint8_t(vid>>24),dir};
|
||||
net.PushRecvData(packet,sizeof(packet));net.ProcessRecvData();
|
||||
};
|
||||
fishing(2);next();motion(RaceData::NAME_WAIT); // React ignored outside WAIT/REACT fishing motions.
|
||||
fishing(0,10,18);require(actor->GetYaw()==90,"fishing direction is not BYTE*5");
|
||||
require(!actor->IsFishing(),"queued throw treated as fishing");next();motion(RaceData::NAME_FISHING_THROW);
|
||||
require(!actor->IsFishing(),"throw treated as fishing");
|
||||
fishing(1);next();motion(RaceData::NAME_FISHING_WAIT);require(actor->IsFishing(),"wait not fishing");
|
||||
fishing(2);next();motion(RaceData::NAME_FISHING_REACT);require(actor->IsFishing(),"react not fishing");
|
||||
next();motion(RaceData::NAME_FISHING_WAIT);
|
||||
fishing(1);motion(RaceData::NAME_FISHING_STOP);require(!actor->IsFishing(),"stop remains fishing");next();motion(RaceData::NAME_WAIT);
|
||||
fishing(0);next();next();motion(RaceData::NAME_FISHING_WAIT);
|
||||
fishing(3);motion(RaceData::NAME_FISHING_CATCH);next();motion(RaceData::NAME_WAIT);
|
||||
fishing(4);motion(RaceData::NAME_FISHING_FAIL);python.execute("assert w.fail==1\n");next();motion(RaceData::NAME_WAIT);
|
||||
fishing(4,20);python.execute("assert w.fail==1\n"); // Remote failure does not call local UI.
|
||||
fishing(0,999);motion(RaceData::NAME_WAIT);
|
||||
uint8_t dig[]={134,10,0,0,0,20,0,0,0,3};
|
||||
net.PushRecvData(dig,5);net.ProcessRecvData();next();motion(RaceData::NAME_WAIT);
|
||||
net.PushRecvData(dig+5,5);net.ProcessRecvData();require(std::abs(actor->GetYaw()-90)<0.001f,"dig target facing");
|
||||
for(int count=0;count<3;++count) {next();motion(RaceData::NAME_DIG);}
|
||||
next();motion(RaceData::NAME_WAIT); // Exactly the received count, no extra repetition.
|
||||
for(uint32_t start:{uint32_t(RaceData::NAME_KISS_START),uint32_t(RaceData::NAME_FRENCH_KISS_START)}) {
|
||||
for(uint32_t job=0;job<4;++job) {
|
||||
require(actor->InterceptMotionIndex(start+job,false),"kiss motion fixture");
|
||||
python.execute("assert player.IsActingEmotion()==1\n");
|
||||
next();python.execute("assert player.IsActingEmotion()==0\n");
|
||||
}
|
||||
}
|
||||
for(uint32_t index:{uint32_t(RaceData::NAME_CLAP),uint32_t(RaceData::NAME_DANCE_1),uint32_t(RaceData::NAME_DIG),uint32_t(RaceData::NAME_SLAP_HIT_START)}) {
|
||||
require(actor->InterceptMotionIndex(index,false),"nonkiss fixture");python.execute("assert player.IsActingEmotion()==0\n");
|
||||
}
|
||||
// Original dual-emotion scheduler: 500ms delay, 100-unit approach, high/low roles.
|
||||
auto* secondRace=RaceManager::Instance().CreateRace(2);secondRace->RegisterMotionMode(1);
|
||||
for(uint16_t index=1;index<=RaceData::NAME_JOY;++index)require(secondRace->RegisterMotion(1,index,(root/(std::to_string(index)+".msa")).string(),100),"second job motions");
|
||||
require(victim->SetRace(2) && victim->SetModel(model.string()),"second job model");
|
||||
actors.GetActorData(20)->m_dwRace=2;
|
||||
actor->SetLoopMotionIndex(RaceData::NAME_WAIT);victim->SetLoopMotionIndex(RaceData::NAME_WAIT);
|
||||
actor->SetPosition(0,0,0);victim->SetPosition(500,0,0);actor->SetSpeed(100);
|
||||
actors.SetTimeSourceForTest(Clock);motionClock=1000;
|
||||
net.ServerCommand("kiss 10 20");require(actors.IsEmotionProcessing(),"main emotion processing not started");
|
||||
require(!actors.BeginDualEmotion(10,20,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START),"overlapping pair accepted");
|
||||
SetPlayerJoystick(true,1,0);float yaw=0;require(!GetPlayerMovementYaw(0,yaw),"movement input not blocked during approach");
|
||||
actor->SetMoveTarget(999,999);require(!actor->HasMoveTarget(),"click movement bypassed emotion lock");
|
||||
actor->MoveInDirection(90,1);require(actor->GetX()==0,"direct movement bypassed lock");
|
||||
SNetworkMoveActorData move{};move.m_dwVID=10;move.m_dwFunc=0;move.m_lPosX=700;move.m_lPosY=0;
|
||||
actors.MoveActor(move);motionClock=1499;actors.Update(0);
|
||||
require(actor->GetX()==0 && victim->GetX()==500,"emotion started before deadline/network move escaped lock");
|
||||
motionClock=1500;actors.Update(0);require(actor->GetX()==0 && actor->GetCurrentMotion()==MotionType::Run,"approach not started at deadline");
|
||||
actors.Update(1);require(actor->GetX()==100 && actors.IsEmotionProcessing(),"approach teleported or unlocked early");
|
||||
for(int step=0;step<3;++step)actors.Update(1);
|
||||
require(actor->GetX()==400 && victim->GetX()==500 && !actors.IsEmotionProcessing(),"dual spacing/completion");
|
||||
require(uint32_t(actor->GetCurrentMotion())==RaceData::NAME_KISS_START+2 && uint32_t(victim->GetCurrentMotion())==RaceData::NAME_KISS_START+1,"dual job selection");
|
||||
require(std::abs(actor->GetYaw()-90)<0.001f && std::abs(victim->GetYaw()-270)<0.001f,"dual mutual facing");
|
||||
require(!GetPlayerMovementYaw(0,yaw),"movement unlocked during kiss playback");
|
||||
actors.Update(actor->GetMotionDuration()+0.01f);actors.Update(0);
|
||||
require(actor->GetCurrentMotion()==MotionType::Wait && GetPlayerMovementYaw(0,yaw),"emotion input did not recover");
|
||||
// Stop packets resume after playback instead of getting discarded.
|
||||
require(actors.GetActorData(10)->m_lDstX==700,"deferred movement was discarded");
|
||||
SetPlayerJoystick(false,0,0);
|
||||
actor->SetPosition(400,0,0);victim->SetPosition(500,0,0);motionClock=2000;
|
||||
net.ServerCommand("slap 10 20");motionClock=2500;actors.Update(0);
|
||||
require(uint32_t(actor->GetCurrentMotion())==RaceData::NAME_SLAP_HIT_START+2 && uint32_t(victim->GetCurrentMotion())==RaceData::NAME_SLAP_HURT_START+1,"MAKELONG slap roles reversed");
|
||||
actors.Update(actor->GetMotionDuration()+0.01f);
|
||||
// Clock rollover and coincident positions must remain finite.
|
||||
actor->SetPosition(0,0,0);victim->SetPosition(0,0,0);motionClock=0xffffff00;
|
||||
net.ServerCommand("french_kiss 10 20");motionClock+=499;actors.Update(0);require(actors.IsEmotionProcessing(),"rollover deadline early");
|
||||
++motionClock;actors.Update(0);require(!actors.IsEmotionProcessing() && std::isfinite(actor->GetX()) && std::isfinite(actor->GetZ()),"coincident pair/rollover invalid");
|
||||
actors.Update(actor->GetMotionDuration()+0.01f);motionClock=3000;
|
||||
net.ServerCommand("kiss 10 20");actors.RemoveActor(20);
|
||||
require(!actors.IsEmotionProcessing() && !actor->IsEmotionMovementLocked(),"deleted target left input locked");
|
||||
require(!actors.BeginDualEmotion(10,10,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START),"self pair accepted");
|
||||
SNetworkActorData third=main;third.m_dwVID=30;third.m_dwRace=2;
|
||||
actors.AppendActor(third);auto thirdActor=actors.GetActorInstance(30);
|
||||
require(thirdActor->SetModel(model.string()),"main target model");thirdActor->SetPosition(500,0,0);
|
||||
net.SetMainActorVID(30);motionClock=3500;
|
||||
require(actors.BeginDualEmotion(10,30,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START) && actors.IsEmotionProcessing(),"target main not locked");
|
||||
actors.RemoveActor(10);
|
||||
require(!actors.IsEmotionProcessing() && !thirdActor->IsEmotionMovementLocked(),"source removal left main target locked");
|
||||
actors.SetTimeSourceForTest(nullptr);
|
||||
// AVA2 GetRandomMotionKey: cumulative BYTE percentages, never normalized.
|
||||
auto* variants=RaceManager::Instance().CreateRace(779);variants->RegisterMotionMode(1);
|
||||
std::array<float,3> durations{};
|
||||
for(int index=0;index<3;++index) {
|
||||
auto parsed=gr2::File::load_path(variantAnimations[index].string(),nullptr);
|
||||
require(parsed && !parsed->file_info().animations.empty(),"original variant GR2");durations[index]=parsed->file_info().animations[0].duration;
|
||||
const auto path=root/("variant"+std::to_string(index)+".msa");
|
||||
std::ofstream(path)<<"ScriptType MotionData\nMotionFileName \""<<variantAnimations[index].string()<<"\"\nMotionDuration "<<index+1<<"\n";
|
||||
require(variants->RegisterMotion(1,RaceData::NAME_WAIT,path.string(),index==0?15:index==1?25:60),"variant registration");
|
||||
}
|
||||
require(variants->RegisterMotion(1,RaceData::NAME_DAMAGE,(root/"1.msa").string(),100),"speed motion registration");
|
||||
ActorInstance weighted;require(weighted.SetRace(779) && weighted.SetModel(model.string()),"weighted motion model");
|
||||
weighted.SetMotionRandomSourceForTest(RandomMotion);
|
||||
auto checkVariant=[&](unsigned expected) {
|
||||
require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"weighted loop");
|
||||
require(weighted.GetCurrentRaceMotionData() && weighted.GetCurrentRaceMotionData()->motionDuration==float(expected+1),"events bound to wrong variant");
|
||||
require(weighted.GetCurrentRaceMotionData()->motionFileName==variantAnimations[expected].string(),"variant metadata path");
|
||||
require(std::abs(weighted.GetMotionDuration()-std::max(0.1f,durations[expected]))<0.0001f,"GR2 differs from bound event variant");
|
||||
};
|
||||
for(motionRandom=0;motionRandom<100;++motionRandom)checkVariant(motionRandom<15?0:motionRandom<40?1:2);
|
||||
variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,0,0);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,1,20);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,2,0);
|
||||
motionRandom=19;checkVariant(1);motionRandom=20;checkVariant(0);motionRandom=99;checkVariant(0); // Uncovered probability falls back to sub-index 0.
|
||||
variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,0,80);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,1,80);
|
||||
motionRandom=79;checkVariant(0);motionRandom=80;checkVariant(1);motionRandom=99;checkVariant(1);
|
||||
// Mode resolution and variant selection happen once when a queued motion binds.
|
||||
weighted.SetLoopMotionIndex(RaceData::NAME_WAIT,2);weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"explicit loop speed ignored");
|
||||
auto calls=motionRandomCalls;require(weighted.PushMotionIndex(RaceData::NAME_DAMAGE,false,0.5f),"queued speed motion");
|
||||
require(motionRandomCalls==calls,"queued motion sampled before activation");
|
||||
weighted.Update(weighted.GetMotionDuration()/2+0.01f);require(weighted.GetCurrentMotion()==MotionType::Damage,"queued motion not activated");
|
||||
weighted.Update(0.1f);require(std::abs(weighted.GetAnimTime()-0.05f)<0.0001f,"queued speed lost");
|
||||
require(weighted.PushMotionIndex(RaceData::NAME_WAIT,true,2),"queued loop speed");
|
||||
weighted.Update(weighted.GetMotionDuration()/0.5f+0.01f);require(motionRandomCalls==calls+1,"queued loop did not sample exactly once");
|
||||
weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"queued loop speed lost");
|
||||
const auto before=weighted.GetAnimTime();require(!weighted.InterceptMotionIndex(RaceData::NAME_DAMAGE,false,0) && weighted.GetAnimTime()==before,"invalid speed changed state");
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_DAMAGE,false,2),"explicit intercept speed");weighted.Update(0.01f);
|
||||
require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"intercept speed ignored");
|
||||
for(int cancel=0;cancel<2;++cancel) {
|
||||
const auto path=root/("skillcancel"+std::to_string(cancel)+".msa");
|
||||
std::ofstream(path)<<"MotionFileName \""<<animation.string()<<"\"\nMotionDuration 1\nGroup LoopData\n{\nMotionLoopCount -1\nLoopCancelEnable "<<cancel<<"\nLoopStartTime 0\nLoopEndTime 0.3\n}\n";
|
||||
require(variants->RegisterMotion(1,RaceData::NAME_SKILL+cancel,path.string(),100),"cancel skill motion registration");
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+cancel,false),"cancel skill motion bind");
|
||||
require(weighted.CanUseSkill()==bool(cancel),"LoopCancelEnable not used for skill permission");
|
||||
}
|
||||
weighted.Stun();require(!weighted.CanUseSkill(),"stunned cancellable skill accepted");weighted.Revive();
|
||||
require(weighted.CanUseSkill(),"revived cancellable skill locked");
|
||||
// Real GR2 loop playback consumes queued actor/position flight targets,
|
||||
// then restores the original primary; no inspection-only queue assertion.
|
||||
const auto flightLoop=root/"flightloop.msa";
|
||||
std::ofstream(flightLoop)<<"MotionFileName \""<<animation.string()<<"\"\nMotionDuration 1\nGroup LoopData\n{\nMotionLoopCount 1\nLoopStartTime 0\nLoopEndTime 0.1\n}\n";
|
||||
require(variants->RegisterMotion(1,RaceData::NAME_SKILL+5,flightLoop.string(),100),"flight loop motion registration");
|
||||
SNetworkActorData flightVictim=third;flightVictim.m_dwVID=31;actors.AppendActor(flightVictim);
|
||||
weighted.ClearFlyTarget();weighted.SetFlyTarget(30);weighted.AddFlyTarget(31);weighted.AddFlyTarget(123,45,678);
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false,uint32_t(270),1),"flight loop bind");
|
||||
weighted.Update(0.11f);require(weighted.GetFlyTargetVID()==31,"first queued flight not consumed");
|
||||
weighted.Update(0.11f);float flightPosition[3];
|
||||
require(weighted.GetFlyTargetVID()==0 && weighted.GetFlyTargetPosition(flightPosition)
|
||||
&& flightPosition[0]==123 && flightPosition[1]==45 && flightPosition[2]==678,"position flight queue/order");
|
||||
weighted.Update(weighted.GetMotionDuration()+0.01f);require(weighted.GetFlyTargetVID()==30,"flight primary not restored");
|
||||
weighted.ClearFlyTarget();require(!weighted.HasFlyTarget(),"flight clear retained backup");actors.RemoveActor(31);
|
||||
require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"shoot damage wait fixture");
|
||||
const int hpBeforeShoot=weighted.GetHP();weighted.OnShootDamage();
|
||||
require(weighted.GetCurrentMotion()==MotionType::Damage && weighted.GetHP()==hpBeforeShoot,"shoot damage motion/HP mismatch");
|
||||
weighted.Update(weighted.GetMotionDuration()+0.01f);require(weighted.GetCurrentMotion()==MotionType::Wait,"shoot damage did not queue wait");
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false),"shoot locked skill fixture");
|
||||
weighted.OnShootDamage();require(uint32_t(weighted.GetCurrentMotion())==RaceData::NAME_SKILL+5,"shoot damage interrupted locked skill");
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+1,false),"shoot cancellable skill fixture");
|
||||
weighted.OnShootDamage();require(weighted.GetCurrentMotion()==MotionType::Damage,"shoot reaction ignored cancel-enabled skill");
|
||||
weighted.Stun();weighted.OnShootDamage();require(weighted.IsDead(),"shoot damage on stunned actor did not die");weighted.Revive();
|
||||
// MSA FLY event -> live object tracking -> actor damage reaction and skill callback.
|
||||
const auto flightScript=root/"tracking.msf",flightMotion=root/"tracking.msa";
|
||||
std::ofstream(flightScript)<<"InitialVelocity 1000\nRange 10000\nBombRange 5\nHomingFlag 1\nHomingMaxAngle 181\n";
|
||||
std::ofstream(flightMotion)<<"MotionFileName \""<<animation.string()<<"\"\nMotionDuration 1\nGroup MotionEventData\n{\nMotionEventDataCount 1\nGroup Event00\n{\nMotionEventType 6\nStartingTime 0.02\nAttachingEnable 0\nAttachingBoneName \"\"\nFlyFileName \""<<flightScript.string()<<"\"\nFlyPosition 0 0 0\n}\n}\n";
|
||||
require(variants->RegisterMotion(1,RaceData::NAME_SKILL+6,flightMotion.string(),100),"tracking motion registration");
|
||||
SNetworkActorData liveFlightTarget=main;liveFlightTarget.m_dwVID=31;actors.AppendActor(liveFlightTarget);
|
||||
auto liveTarget=actors.GetActorInstance(31);require(liveTarget->SetModel(model.string()) && liveTarget->SetLoopMotionIndex(RaceData::NAME_WAIT),"tracking target model");
|
||||
liveTarget->SetPosition(100,0,0);weighted.SetPosition(0,0,0);weighted.SetFlyTarget(31);
|
||||
unsigned shots=0,explosions=0;weighted.SetFlyEventHandler({{},[&](uint32_t skill){require(skill==270,"shoot skill identity");++shots;},[&](uint32_t skill){require(skill==270,"hit skill identity");++explosions;}});
|
||||
auto& flying=FlyingManager::Instance();flying.DeleteAllInstances();
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+6,false,uint32_t(270),1),"tracking FLY bind");
|
||||
weighted.Update(0.04f);require(shots==1 && flying.GetActiveInstanceCount()==1,"MSA FLY did not spawn");
|
||||
liveTarget->SetPosition(200,0,0);flying.Update(0.3f,0.3f);
|
||||
require(explosions==1 && flying.GetActiveInstanceCount()==0 && liveTarget->GetCurrentMotion()==MotionType::Damage,"FLY live target/reaction/callback chain");
|
||||
flying.Update(0.3f,0.6f);require(explosions==1,"FLY hit callback repeated");
|
||||
// Source primary CG51, like extra CG53, carries graphic Y (negative game Y).
|
||||
auto* primaryRace=RaceManager::Instance().GetRaceDataPointer(1);
|
||||
require(primaryRace->RegisterMotion(1,RaceData::NAME_SKILL+10,flightMotion.string(),100)
|
||||
&& primaryRace->SetMotionRandomWeight(1,RaceData::NAME_SKILL+10,0,0),"primary packet FLY fixture");
|
||||
auto sender=actors.GetActorInstance(30);require(sender->SetRace(1) && sender->SetModel(model.string()) && sender->SetLoopMotionIndex(RaceData::NAME_WAIT),"primary packet actor fixture");
|
||||
liveTarget->SetPosition(200,0,50);ProcessPlayerAttack(0,0,false);sender->SetFlyTarget(31);net.ClearSendQueue();
|
||||
require(sender->InterceptMotionIndex(RaceData::NAME_SKILL+10,false),"primary packet FLY bind");
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({51,31,0,0,0,200,0,0,0,206,255,255,255}),"primary fly target graphic Y wire sign");
|
||||
weighted.ClearFlyEventHandler();weighted.ClearFlyTarget();actors.RemoveActor(31);
|
||||
// Real model OBB proxy: endpoint hits, altitude, yaw and manager background callback.
|
||||
fs::copy_file(model,root/"obstacle.gr2");
|
||||
MapObjectManager obstacles;require(obstacles.AddObject("obstacle.gr2",500,50,0,30),"flight obstacle model");
|
||||
const auto& obstacle=obstacles.GetObjects().front();require(obstacle.has_collision,"model collision proxy absent");
|
||||
const auto& box=obstacle.obb;
|
||||
const float center[3]={box.centerX,box.centerY,box.centerZ};
|
||||
const float obstacleStart[3]={center[0]-5000,center[1],center[2]},after[3]={center[0]+5000,center[1],center[2]};
|
||||
const float aboveBox[3]={center[0],center[1]+box.halfExtents[1]+10,center[2]};
|
||||
require(obstacles.CheckFlyingCollision(obstacleStart,center) && !obstacles.CheckFlyingCollision(aboveBox,aboveBox),"real OBB endpoint/height check");
|
||||
require(!obstacles.CheckFlyingCollision(obstacleStart,after),"OBB changed to continuous sweep instead of source endpoints");
|
||||
auto collisionData=std::make_shared<FlyingData>();collisionData->initial_velocity=100;collisionData->range=10000;collisionData->hit_on_background=true;
|
||||
FlyingInstance obstacleFlight(collisionData,center,after);unsigned obstacleHits=0;FlyCollisionCallbacks collisionCallbacks;
|
||||
collisionCallbacks.onBackground=[&]{++obstacleHits;};obstacleFlight.SetCollisionCallbacks(collisionCallbacks);
|
||||
require(!obstacleFlight.Update(0,0,nullptr,&obstacles) && obstacleHits==1,"real model background dispatch");
|
||||
// Source shake changes the graphic matrix only; sample once per Actor.Update.
|
||||
weighted.SetPosition(0,0,0);weighted.SetShakeSourcesForTest(Clock,ShakeRandom);motionClock=1000;shakeRandomCalls=0;
|
||||
require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"shake wait fixture");weighted.OnShootDamage();
|
||||
motionClock=1100;weighted.Update(0.01f);auto shaken=weighted.BuildDrawCommands();
|
||||
require(!shaken.empty() && std::abs(shaken.front().world[12]-3)<0.001f && std::abs(shaken.front().world[13]-5)<0.001f
|
||||
&& std::abs(shaken.front().world[14]-4)<0.001f,"source shake axes/amplitude/inclusive deadline");
|
||||
require(weighted.GetX()==0 && weighted.GetY()==0 && weighted.GetZ()==0 && shakeRandomCalls==6,"shake moved logical position/wrong RNG count");
|
||||
weighted.BuildDrawCommands();require(shakeRandomCalls==6,"draw sampled shake a second time");
|
||||
motionClock=1101;weighted.Update(0.01f);auto unshaken=weighted.BuildDrawCommands();
|
||||
require(!unshaken.empty() && unshaken.front().world[12]==0 && unshaken.front().world[13]==0 && unshaken.front().world[14]==0
|
||||
&& shakeRandomCalls==6,"expired shake not cleared");
|
||||
motionClock=1200;require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false),"shake locked skill fixture");weighted.OnShootDamage();weighted.Update(0.01f);
|
||||
require(uint32_t(weighted.GetCurrentMotion())==RaceData::NAME_SKILL+5 && shakeRandomCalls==12,"locked skill did not shake");
|
||||
motionClock=1301;weighted.Update(0.01f);weighted.Stun();weighted.OnShootDamage();weighted.Update(0.01f);
|
||||
require(weighted.IsDead() && shakeRandomCalls==12,"stunned death started shake");weighted.Revive();weighted.SetShakeSourcesForTest(nullptr,nullptr);
|
||||
// AVA2 IsPoly includes TYPE_PC with a non-player race, as well as TYPE_POLY.
|
||||
weighted.SetActorType(6);require(weighted.IsPolymorph(),"PC monster race not polymorph");
|
||||
weighted.SetMotionMode(2);require(weighted.GetMotionMode()==1,"polymorph mode not GENERAL");
|
||||
const auto beforePolyCalls=motionRandomCalls;
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_WAIT,false,2),"poly intercept");
|
||||
require(motionRandomCalls==beforePolyCalls && weighted.GetCurrentRaceMotionData()->motionDuration==1,"poly intercept randomized instead of base key");
|
||||
weighted.Update(0.1f);
|
||||
require(std::abs(weighted.GetAnimTime()-weighted.GetMotionDuration()*0.2f/1.1f)<0.0001f,"poly 1.1-second scaling missing");
|
||||
require(weighted.InterceptMotionIndex(RaceData::NAME_WAIT,true),"poly loop intercept");
|
||||
weighted.Update(0.1f);
|
||||
require(std::abs(weighted.GetAnimTime()-weighted.GetMotionDuration()*0.1f/1.1f)<0.0001f,"poly loop intercept normalization missing");
|
||||
require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT,2),"poly ordinary loop");
|
||||
require(motionRandomCalls==beforePolyCalls+1,"ordinary poly loop incorrectly bypassed random selection");
|
||||
weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"ordinary poly loop incorrectly normalized");
|
||||
weighted.SetActorType(0);require(!weighted.IsPolymorph(),"ordinary monster classified as poly");
|
||||
weighted.SetActorType(7);require(weighted.IsPolymorph(),"TYPE_POLY missing");
|
||||
require(weighted.SetRace(1),"normal PC classification fixture");
|
||||
weighted.SetActorType(6);require(!weighted.IsPolymorph(),"normal PC classified as poly");
|
||||
weighted.SetActorType(7);require(weighted.IsPolymorph(),"explicit poly depends on race");
|
||||
auto* walkRace=RaceManager::Instance().CreateRace(780);walkRace->RegisterMotionMode(1);
|
||||
require(walkRace->RegisterMotion(1,RaceData::NAME_WAIT,(root/"1.msa").string(),100)
|
||||
&& walkRace->RegisterMotion(1,RaceData::NAME_RUN,(root/"1.msa").string(),100),"walking speed race");
|
||||
SNetworkActorData walker{};walker.m_dwVID=40;walker.m_dwRace=780;walker.m_bType=6;walker.m_dwMovSpd=150;walker.m_dwAtkSpd=175;
|
||||
actors.AppendActor(walker);auto walking=actors.GetActorInstance(40);
|
||||
require(walking->IsPolymorph(),"network PC monster type not propagated");
|
||||
actors.SetSash(40,123);
|
||||
require(actors.GetActorData(40)->m_dwSash==0,"polymorph PC accepted sash");
|
||||
require(walking->GetAttackSpeed()==1.75f,"creation attack speed not normalized");
|
||||
require(walking->SetModel(model.string()) && walking->PlayMotion(MotionType::Run,true),"walking model");
|
||||
walking->Update(0.1f);require(std::abs(walking->GetAnimTime()-0.15f)<0.0001f,"packet move speed not applied to animation");
|
||||
SNetworkUpdateActorData speedUpdate{};speedUpdate.m_dwVID=40;speedUpdate.m_dwMovSpd=200;
|
||||
actors.UpdateActor(speedUpdate);require(walking->GetAnimTime()==0,"speed change did not restart move loop");
|
||||
walking->Update(0.1f);require(std::abs(walking->GetAnimTime()-0.2f)<0.0001f,"live walking speed update ignored");
|
||||
speedUpdate.m_dwMovSpd=0;actors.UpdateActor(speedUpdate);walking->Update(0.1f);
|
||||
require(walking->GetMoveAnimationSpeed()==0 && walking->GetAnimTime()==0,"zero packet speed not frozen");
|
||||
SNetworkMoveActorData stoppedMove{};stoppedMove.m_dwVID=40;stoppedMove.m_dwFunc=1;stoppedMove.m_lPosX=500;
|
||||
actors.MoveActor(stoppedMove);actors.Update(0.1f);require(walking->GetX()==0,"zero speed fell back to invented movement");
|
||||
speedUpdate.m_dwMovSpd=1101;actors.UpdateActor(speedUpdate);require(walking->GetMoveAnimationSpeed()==0,"original overflow-to-zero rule lost");
|
||||
for(uint32_t speed : {0u,1u,100u,175u,1100u,1101u,0xffffffffu}) {
|
||||
speedUpdate.m_dwAtkSpd=speed;actors.UpdateActor(speedUpdate);
|
||||
require(walking->GetAttackSpeed()==(speed<=1100?float(speed)/100:0),"updated attack speed boundary");
|
||||
walker.m_dwVID=41;walker.m_dwAtkSpd=speed;walker.m_dwMountVnum=780;actors.AppendActor(walker);
|
||||
require(actors.GetActorInstance(41)->GetAttackSpeed()==walking->GetAttackSpeed(),"creation/update attack speed disagree");
|
||||
auto* mounted=actors.GetActorData(41);
|
||||
require(mounted && mounted->m_pMountInstance && mounted->m_pMountInstance->GetAttackSpeed()==walking->GetAttackSpeed(),"mount creation attack speed disagree");
|
||||
auto mountUpdate=speedUpdate;mountUpdate.m_dwVID=41;mountUpdate.m_dwMountVnum=780;mountUpdate.m_dwAtkSpd=200;
|
||||
actors.UpdateActor(mountUpdate);
|
||||
require(mounted->m_pMountInstance && mounted->m_pMountInstance->GetAttackSpeed()==2,"mount update attack speed ignored");
|
||||
actors.RemoveActor(41);
|
||||
}
|
||||
python.execute("player.SetGameWindow(0)\nnet.ClearPhaseWindow(net.PHASE_WINDOW_GAME,w)\n");
|
||||
actors.Clear();net.ResetConnection();
|
||||
}
|
||||
require(preview.expired(),"preview singleton retained runtime-owned resources after shutdown");
|
||||
require(CRenderTargetManager::Instance().GetFreeIndex(12345,12345)==12345,"preview index not released on shutdown");
|
||||
fs::current_path(previous);fs::remove_all(root);
|
||||
std::cout<<"AVA2 emotion queries, fishing transitions and digging queues passed\n";return 0;
|
||||
} catch(const std::exception& error) {
|
||||
fs::current_path(previous);fs::remove_all(root);std::cerr<<error.what()<<'\n';return 1;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
#include <bit>
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
#include <filesystem>
|
||||
|
||||
using namespace ava2;
|
||||
@@ -102,6 +103,7 @@ void TestSpeedTreeModelGeneration() {
|
||||
assert(!canopy.positions.empty() && !canopy.indices.empty() && "Canopy must have geometry");
|
||||
assert(canopy.alpha_test && canopy.alpha_ref == 84 && "Canopy must have alpha test 84");
|
||||
assert(canopy.cull_mode == 1 && "Canopy must be double sided");
|
||||
assert(!trunk.lighting && !canopy.lighting && "Original static tree colors must not receive dynamic lighting twice");
|
||||
|
||||
std::cout << " -> Oak Tree generated: Trunk verts=" << trunk.positions.size() / 3
|
||||
<< ", tris=" << trunk.indices.size() / 3
|
||||
@@ -121,8 +123,8 @@ void TestSpeedTreeModelGeneration() {
|
||||
void TestWindMotionSimulation() {
|
||||
std::cout << "[Test] Wind Motion Simulation & Anchoring..." << std::endl;
|
||||
auto tree = SpeedTreeModel::CreateProcedural("BlowingPine", 1000.0f, "bark.dds", "leaves.dds");
|
||||
auto draws_t0 = tree->BuildDrawCommands(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 25.0f);
|
||||
auto draws_t1 = tree->BuildDrawCommands(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.57f, 25.0f);
|
||||
auto draws_t0 = tree->BuildDrawCommands(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 25.0f, nullptr, nullptr, true);
|
||||
auto draws_t1 = tree->BuildDrawCommands(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.57f, 25.0f, nullptr, nullptr, true);
|
||||
|
||||
// Check base vertex (y ~ 0) stays anchored
|
||||
float base_x0 = draws_t0[0].positions[0];
|
||||
@@ -157,8 +159,10 @@ void TestSpeedTreeForestSystem() {
|
||||
// Place trees in front of camera
|
||||
forest.CreateInstance(0.0f, 0.0f, 300.0f, 1001, 0.0f, 1.0f);
|
||||
forest.CreateInstance(50.0f, 0.0f, 350.0f, 1002, 30.0f, 1.0f);
|
||||
// Place one tree behind camera (Z = -500)
|
||||
forest.CreateInstance(0.0f, 0.0f, -500.0f, 1001, 0.0f, 1.0f);
|
||||
// Place its entire bounding sphere behind the camera. An origin behind
|
||||
// the camera is insufficient when the generated canopy crosses the plane.
|
||||
const float behind=-(forest.GetMainTree(1001)->GetRadius()*2+100);
|
||||
forest.CreateInstance(0.0f, 0.0f, behind, 1001, 0.0f, 1.0f);
|
||||
|
||||
assert(forest.GetInstanceCount() == 3 && "Instance count mismatch");
|
||||
forest.UpdateSystem(0.033f);
|
||||
@@ -177,7 +181,7 @@ void TestSpeedTreeForestSystem() {
|
||||
0.0f, 0.0f, -1.0f, 0.0f
|
||||
};
|
||||
|
||||
auto culled_draws = forest.BuildDrawCommands(view, proj, 0.0f, 50.0f, 0.0f, 2000.0f);
|
||||
auto culled_draws = forest.BuildDrawCommands(view, proj, 0.0f, 50.0f, 0.0f, std::abs(behind)+2000.0f);
|
||||
assert(!culled_draws.empty() && "Visible trees must produce draw commands");
|
||||
// Front trees (1 tree = 2 draws, 1 grass = 1 draw -> 3 draws total)
|
||||
assert(culled_draws.size() == 3 && "Behind-camera tree must be culled (3 draws expected)");
|
||||
@@ -206,27 +210,23 @@ void TestBillboardRendering() {
|
||||
assert(nearDraws.size()==2 && nearDraws[0].positions.size()>12);
|
||||
camera={0,0,2000};
|
||||
auto transition=model.BuildDrawCommands(0,0,0,0,1,0,15,nullptr,&camera);
|
||||
assert(transition.size()==4 && transition[2].positions.size()==12);
|
||||
camera={0,0,4000};
|
||||
auto farDraws=model.BuildDrawCommands(0,0,0,0,1,0,15,nullptr,&camera);
|
||||
assert(farDraws.size()==2 && farDraws[0].positions.size()==12 && farDraws[1].positions.size()==12);
|
||||
assert(farDraws[0].alpha_test && farDraws[0].alpha_ref==84);
|
||||
// Windows CSpeedTreeWrapper::Advance forces SetLodLevel(1): near, overlap
|
||||
// and far cameras all draw full geometry, not atlas billboard substitutes.
|
||||
assert(transition.size()==nearDraws.size() && farDraws.size()==nearDraws.size());
|
||||
for(size_t i=0;i<nearDraws.size();++i) {
|
||||
assert(transition[i].indices==nearDraws[i].indices && farDraws[i].indices==nearDraws[i].indices);
|
||||
assert(farDraws[i].positions.size()==nearDraws[i].positions.size());
|
||||
assert(farDraws[i].uv0==nearDraws[i].uv0);
|
||||
}
|
||||
assert(farDraws[1].alpha_test && farDraws[1].alpha_ref==84);
|
||||
auto windy=model.BuildDrawCommands(0,0,0,0,1,10,30,nullptr,&camera);
|
||||
assert(farDraws[0].positions==windy[0].positions && farDraws[1].positions==windy[1].positions);
|
||||
assert(model.BuildDrawCommands(0,0,0,0,1,0).size()==2);
|
||||
// A different camera heading, tree yaw and scale must still face the camera.
|
||||
camera={4000,0,0};
|
||||
auto rotated=model.BuildDrawCommands(0,0,0,90,2,0,15,nullptr,&camera);
|
||||
float centerX=0,centerZ=0;
|
||||
for(size_t i=0;i<4;++i) {
|
||||
centerX+=rotated[0].positions[i*3]*0.25f;
|
||||
centerZ+=rotated[0].positions[i*3+2]*0.25f;
|
||||
}
|
||||
float dx=camera[0]-centerX,dz=camera[2]-centerZ,length=std::hypot(dx,dz);
|
||||
for(size_t i=0;i<4;++i) {
|
||||
assert(std::abs(rotated[0].normals[i*3]-dx/length)<0.001f);
|
||||
assert(std::abs(rotated[0].normals[i*3+2]-dz/length)<0.001f);
|
||||
}
|
||||
assert(farDraws[1].positions!=windy[1].positions); // Full foliage still receives wind at distance.
|
||||
// The SDK's independent billboard builder remains available to other consumers.
|
||||
auto billboards=impl->BuildBillboardMeshes(camera);
|
||||
assert(billboards.size()==2 && billboards[0].vertices.size()==4 && billboards[1].vertices.size()==4);
|
||||
|
||||
}
|
||||
|
||||
void TestFrondRendering() {
|
||||
@@ -242,8 +242,11 @@ void TestFrondRendering() {
|
||||
SpeedTreeModel model(impl);
|
||||
auto draws=model.BuildDrawCommands(0,0,0,0,1,0);
|
||||
assert(draws.size()==2 && impl->GetLeafMesh().vertices.empty());
|
||||
assert(draws[1].alpha_test && draws[1].alpha_ref==84 && draws[1].cull_mode==1);
|
||||
auto windy=model.BuildDrawCommands(0,0,0,0,1,2);
|
||||
assert(draws[1].alpha_test && draws[1].alpha_ref==84 && draws[1].cull_mode==1 && !draws[1].lighting);
|
||||
auto later=model.BuildDrawCommands(0,0,0,0,1,2);
|
||||
assert(later[0].positions==draws[0].positions && later[1].positions==draws[1].positions);
|
||||
assert(later[0].normals==draws[0].normals && later[1].normals==draws[1].normals);
|
||||
auto windy=model.BuildDrawCommands(0,0,0,0,1,2,15,nullptr,nullptr,true);
|
||||
bool moved=false;
|
||||
for(size_t i=0;i<draws[1].positions.size();++i) {
|
||||
assert(std::isfinite(windy[1].positions[i]));
|
||||
@@ -275,6 +278,32 @@ void TestAuthoredLeafRendering() {
|
||||
auto changed=model.BuildDrawCommands(0,0,0,90,2,0,0,nullptr,&camera);
|
||||
assert(changed[1].positions!=draws[1].positions);
|
||||
assert(changed[1].uv0==draws[1].uv0 && changed[1].indices==draws[1].indices);
|
||||
speedtree::WindParameters frame;frame.strength=0.75f;frame.legacy_leaf_rocking=true;frame.legacy_leaf_phase=1;
|
||||
frame.matrices={std::array<float,16>{1,0,0,0,0,1,0,0,0,0,1,0,10000,20000,30000,1}};
|
||||
auto first=model.BuildDrawCommands(30,40,50,90,2,0,15,&frame,&camera);
|
||||
frame.legacy_leaf_phase=3;
|
||||
auto rocking=model.BuildDrawCommands(30,40,50,90,2,0,15,&frame,&camera);
|
||||
assert(rocking[0].positions==first[0].positions && rocking[0].normals==first[0].normals);
|
||||
assert(rocking[1].positions!=first[1].positions);
|
||||
// Rotation is around the authored pivot, without translating it using wind matrices.
|
||||
const auto& vertices=impl->GetLeafMesh().vertices;
|
||||
for(size_t i=0;i<vertices.size();++i) {
|
||||
const auto& v=vertices[i];
|
||||
float localPivot[3]={v.position[0]-v.leaf_pivot_offset[0],v.position[1]-v.leaf_pivot_offset[1],v.position[2]-v.leaf_pivot_offset[2]};
|
||||
float pivot[3]={30+2*localPivot[2],40+2*localPivot[1],50-2*localPivot[0]};
|
||||
float expected=0,actual=0;
|
||||
for(size_t axis=0;axis<3;++axis) {
|
||||
expected+=4*v.leaf_pivot_offset[axis]*v.leaf_pivot_offset[axis];
|
||||
float d=rocking[1].positions[i*3+axis]-pivot[axis];actual+=d*d;
|
||||
}
|
||||
assert(std::abs(actual-expected)<0.05f);
|
||||
}
|
||||
const auto identity=std::array<float,16>{1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
|
||||
auto neutral=frame;neutral.matrices={identity};
|
||||
auto neutralDraws=model.BuildDrawCommands(30,40,50,90,2,0,15,&neutral,&camera);
|
||||
for(size_t i=0;i<rocking.size();++i)assert(rocking[i].positions==neutralDraws[i].positions);
|
||||
auto cpu=model.BuildDrawCommands(30,40,50,90,2,0,15,&frame,&camera,true);
|
||||
assert(cpu[0].positions!=rocking[0].positions && cpu[1].positions!=rocking[1].positions);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#endif
|
||||
#include "python_runtime.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "python_touch.h"
|
||||
#include "python_item.h"
|
||||
#include "eter_render/Gr2ModelRenderer.h"
|
||||
#include "app/input/touch_router.h"
|
||||
#include "eter_ui/PythonWindowManager.h"
|
||||
#include "eter_ui/PythonWindow.h"
|
||||
@@ -17,6 +20,7 @@
|
||||
#include <Python.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
@@ -28,7 +32,9 @@ namespace {
|
||||
|
||||
struct GameSink final : ava2::input::TouchSink {
|
||||
UI::CWindowManager* wm = nullptr;
|
||||
int ui_downs = 0, taps = 0;
|
||||
int ui_downs = 0, taps = 0, skill_casts=0, skill_slot=-1;
|
||||
int SkillAt(float x,float y) override {return ava2::TouchSkillAt(*wm,long(x),long(y));}
|
||||
void Skill(int slot,float,float,bool) override {++skill_casts;skill_slot=slot;}
|
||||
bool attack = false;
|
||||
bool IsUiAt(float x, float y) override {
|
||||
auto* win = wm->PickWindow(long(x), long(y));
|
||||
@@ -126,6 +132,31 @@ int main(int argc, char** argv) {
|
||||
router.FingerUp(1, 160.0f + layout.joy_radius, H - 180.0f, 220);
|
||||
assert(!sink.attack && !ava2::GetPlayerMovementYaw(0.0f, yaw));
|
||||
|
||||
runtime.execute("hud.joystick.OnUpdate()\nassert not hud.joystick.base_bar.IsShow() and not hud.joystick.knob.IsShow()\n");
|
||||
// Skill shortcut resolves the current slot through the real picked Python window, including rim.
|
||||
runtime.execute("player.GetSkillIndex=lambda n: 1\nplayer.GetLocalQuickSlot=lambda n: (player.SLOT_TYPE_SKILL, 17)\n"
|
||||
"shortcut=hud.combat_wheel.slots[0]\nshortcut_xy=shortcut.GetGlobalPosition()\n");
|
||||
auto* xy=PyDict_GetItemString(PyModule_GetDict(main),"shortcut_xy");
|
||||
const float sx=float(PyInt_AsLong(PyTuple_GetItem(xy,0)))+2,sy=float(PyInt_AsLong(PyTuple_GetItem(xy,1)))+2;
|
||||
assert(sink.SkillAt(sx,sy)==17);router.FingerDown(8,sx,sy,230);router.FingerMove(8,sx+60,sy,240);router.Update(241);
|
||||
assert(sink.skill_casts==1 && sink.skill_slot==17);
|
||||
runtime.execute("hud.combat_wheel.OnUpdate()\nassert hud.combat_wheel.aim_marker.IsShow()\n");
|
||||
router.FingerCancel(8,250);runtime.execute("hud.combat_wheel.OnUpdate()\nassert not hud.combat_wheel.aim_marker.IsShow()\n");
|
||||
// Real actor/item tap adapter: approach, completion and stale item generation.
|
||||
auto& manager=ava2::NetworkActorManager::Instance();auto& network=ava2::PythonNetworkStream::Instance();manager.Clear();
|
||||
ava2::SNetworkActorData mainData{};mainData.m_dwVID=100;mainData.m_bType=6;manager.AppendActor(mainData);network.SetMainActorVID(100);
|
||||
auto mainActor=manager.GetActorInstance(100);mainActor->SetPosition(-1000,0,0);
|
||||
ava2::SNetworkActorData npcData{};npcData.m_dwVID=101;npcData.m_bType=1;manager.AppendActor(npcData);auto npc=manager.GetActorInstance(101);npc->SetPosition(0,0,0);npc->SetHP(100);
|
||||
ava2::Gr2SceneRenderer scene(W,H);scene.SetCameraLookAt(0,100,-500,0,0,0,0,1,0);scene.SetPerspective(60,float(W)/H,1,3000);
|
||||
float px,py;assert(scene.ProjectToScreen(0,0,0,px,py));network.ClearSendQueue();
|
||||
assert(ava2::HandlePlayerTouchWorldTap(scene,px+20,py));assert(mainActor->HasMoveTarget());
|
||||
mainActor->SetPosition(-400,0,0);ava2::ProcessPlayerTouchInteraction();assert(!mainActor->HasMoveTarget());
|
||||
const auto click=network.GetSendQueue();assert(click==std::vector<uint8_t>({61,101,0,0,0,26,101,0,0,0}));
|
||||
auto& ground=ava2::CPythonItem::Instance();ground.CreateItem(102,27001,0,0,0,false);mainActor->SetPosition(-1000,0,0);network.ClearSendQueue();
|
||||
assert(ava2::HandlePlayerTouchWorldTap(scene,px,py) && mainActor->HasMoveTarget());
|
||||
ground.DeleteItem(102);ground.CreateItem(102,27001,0,0,0,false);mainActor->SetPosition(0,0,0);ava2::ProcessPlayerTouchInteraction();
|
||||
assert(network.GetSendQueue().empty() && !mainActor->HasMoveTarget());
|
||||
assert(ava2::HandlePlayerTouchWorldTap(scene,px,py));assert(!network.GetSendQueue().empty());ground.DeleteAllItems();manager.Clear();
|
||||
// HUD button taps go to the window manager, open world taps become world clicks.
|
||||
router.FingerDown(3, tb_x, tb_y, 300);
|
||||
router.FingerUp(3, tb_x, tb_y, 350);
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace {
|
||||
|
||||
struct RecordingSink : TouchSink {
|
||||
// One UI window: a 200x100 box at (500, 50).
|
||||
bool skills=false;
|
||||
struct Cast {int slot;float x,y;bool repeat;};std::vector<Cast> casts;
|
||||
int SkillAt(float x,float y) override {return skills && x>=500 && x<700 && y>=50 && y<150?7:-1;}
|
||||
void Skill(int slot,float x,float y,bool repeat) override {casts.push_back({slot,x,y,repeat});}
|
||||
bool IsUiAt(float x, float y) override { return x >= 500 && x < 700 && y >= 50 && y < 150; }
|
||||
void UiMouseMove(float x, float y) override { log("move", x, y); }
|
||||
void UiMouseDown(float x, float y) override { log("down", x, y); }
|
||||
@@ -317,6 +321,27 @@ void ui_gestures() {
|
||||
"drag");
|
||||
}
|
||||
|
||||
void floating_edges_and_skills() {
|
||||
RecordingSink sink;TouchRouter r;r.SetSink(&sink);r.SetLayout(layout());r.SetWorldEnabled(true);
|
||||
r.FingerDown(0,1,719,1000);
|
||||
expect(near(sink.joy_x,0) && near(sink.joy_y,0),"edge landing moved before dragging");
|
||||
expect(near(r.GetJoystick().base_x,100) && near(r.GetJoystick().base_y,620),"visual base not clamped");
|
||||
r.FingerMove(0,101,719,1010);expect(near(sink.joy_x,1) && near(sink.joy_y,0),"edge joystick uses visual origin");
|
||||
r.FingerCancel(0,1020);r.FingerDown(1,101,719,1040);
|
||||
expect(near(sink.joy_x,1) && near(sink.joy_y,0),"reacquire lost true touch origin");r.CancelAll();
|
||||
sink.skills=true;r.FingerDown(0,600,100,2000);r.FingerUp(0,600,100,2050);
|
||||
expect(sink.casts.size()==1 && !sink.casts[0].repeat && sink.casts[0].x==0,"skill tap not exactly once");
|
||||
r.FingerDown(0,600,100,3000);r.FingerDown(1,600,100,3001);expect(r.FingerCount()==1,"duplicate skill fingers");
|
||||
r.FingerDown(2,200,500,3002);r.FingerMove(2,300,500,3003);
|
||||
r.FingerDown(3,1180,620,3004);r.FingerDown(4,900,300,3005);r.FingerMove(4,940,300,3006);
|
||||
r.FingerMove(0,740,100,3010);r.Update(3011);
|
||||
expect(sink.casts.size()==2 && near(sink.casts.back().x,140) && sink.attack && near(sink.joy_x,1) && sink.rot_x>0,"skill/attack/joystick/camera ownership");
|
||||
r.Update(3100);expect(sink.casts.size()==2,"repeat ignores cadence");r.Update(3211);
|
||||
expect(sink.casts.size()==3 && sink.casts.back().repeat,"held skill did not repeat");
|
||||
r.FingerUp(0,740,100,3220);r.Update(3500);expect(sink.casts.size()==3,"skill lift recast");r.CancelAll();
|
||||
r.FingerDown(0,600,100,4000);r.FingerCancel(0,4050);r.Update(4500);expect(sink.casts.size()==3,"cancelled pending skill cast");
|
||||
r.FingerDown(0,600,100,5000);r.SetWorldEnabled(false);r.Update(5500);expect(sink.casts.size()==3,"phase change kept skill held");
|
||||
}
|
||||
void default_layout() {
|
||||
const TouchLayout l = TouchLayout::ForScreen(1600, 720);
|
||||
expect(l.joy_x == 0 && l.joy_w > 0 && l.joy_y + l.joy_h <= 720.5f, "default joystick area");
|
||||
@@ -335,6 +360,7 @@ int main() {
|
||||
ui_gestures();
|
||||
system_edges();
|
||||
default_layout();
|
||||
floating_edges_and_skills();
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "touch_router_test: " << e.what() << '\n';
|
||||
return 1;
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
#include "python_runtime.h"
|
||||
#include "python_app.h"
|
||||
#include "python_gameplay_modules.h"
|
||||
#include "python_native_modules.h"
|
||||
#include "python_background.h"
|
||||
#include "protocol.h"
|
||||
#include "eter_net/PythonNetworkStream.h"
|
||||
#include "eter_net/NetworkActorManager.h"
|
||||
#include "eter_net/PythonSafeBox.h"
|
||||
#include "eter_effect/EffectManager.h"
|
||||
#include "eter_render/RaceData.h"
|
||||
#include "eter_ui/PythonWindow.h"
|
||||
#include "shared/common/Singleton.h"
|
||||
#include "mount_rules.h"
|
||||
#include "eter_base/Random.h"
|
||||
#include <bit>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
|
||||
using namespace ava2;
|
||||
namespace fs=std::filesystem;
|
||||
static void require(bool ok,const char* message) {if(!ok)throw std::runtime_error(message);}
|
||||
struct SingletonPrefix {virtual ~SingletonPrefix()=default; uint64_t padding=0;};
|
||||
struct OffsetSingleton : SingletonPrefix, CSingleton<OffsetSingleton> {int value=73;};
|
||||
static void write(const fs::path& path,const std::string& text) {
|
||||
fs::create_directories(path.parent_path());std::ofstream(path,std::ios::binary)<<text;
|
||||
}
|
||||
int main(int argc,char** argv) {
|
||||
if(argc!=3) return 2;
|
||||
const auto previous=fs::current_path();
|
||||
const auto root=fs::temp_directory_path()/ ("ava2_windows_behavior_"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
try {
|
||||
require(!OffsetSingleton::InstancePtr(),"singleton initially registered");
|
||||
{
|
||||
OffsetSingleton instance;
|
||||
require(static_cast<void*>(static_cast<CSingleton<OffsetSingleton>*>(&instance))!=static_cast<void*>(&instance),"nonzero singleton base offset fixture");
|
||||
require(OffsetSingleton::InstancePtr()==&instance && OffsetSingleton::Instance().value==73 && &OffsetSingleton::instance()==&instance,"multiple-inheritance singleton adjustment");
|
||||
}
|
||||
require(!OffsetSingleton::InstancePtr(),"singleton retained destroyed instance");
|
||||
auto stdlib=fs::absolute(argv[1]);fs::create_directories(root);fs::current_path(root);
|
||||
write(root/"locale/en/atlasinfo.txt","parity_map 0 0 1 1\ntarget_map 102400 204800 1 1\n");
|
||||
write(root/"map/parity_map/setting.txt","ScriptType MapSetting\nMapSize 1 1\nBasePosition 0 0\n");
|
||||
write(root/"map/parity_map/000000/height.raw",std::string(131*131*2,0));
|
||||
write(root/"map/parity_map/000000/attr.atr",std::string(256*256,char(4)));
|
||||
const std::string texture="TextureSet\nTextureCount 4\nStart Texture004\n\"d:\\ymir work\\terrainmaps\\alternate.dds\"\n2\n3\n0.25\n0.5\n0\n0\n0\nEnd Texture004\n";
|
||||
write(root/"textureset/alternate.txt",texture);
|
||||
write(root/"skill/cooldown.txt","type\tguild\nname\tCooldown\niconfilename\ticon.dds\ncooltimeformula\t20\n");
|
||||
write(root/"map/target_map/setting.txt","ScriptType MapSetting\nMapSize 1 1\nBasePosition 102400 204800\n");
|
||||
std::vector<uint16_t> targetHeights(131*131,200);
|
||||
write(root/"map/target_map/000000/height.raw",std::string(reinterpret_cast<const char*>(targetHeights.data()),targetHeights.size()*2));
|
||||
auto effectFixture=[&](const char* name,const char* texture,int offset) {
|
||||
write(root/(std::string("ymir work/")+name),
|
||||
"Group Particle { List TimeEventPosition { 0 MOVING_TYPE_DIRECT "+std::to_string(offset)+" 0 0 } "
|
||||
"Group EmitterProperty { MaxEmissionCount 1 CycleLength 1 CycleLoopEnable 1 "
|
||||
"List TimeEventEmissionCountPerSecond { 0 20 } List TimeEventLifeTime { 0 20 } } "
|
||||
"Group ParticleProperty { BillboardType 1 AttachEnable 1 List TextureFiles { "+texture+" } } }");
|
||||
};
|
||||
effectFixture("effect/etc/direction/direction_land.mse","regular.dds",0);
|
||||
effectFixture("effect/direction/direction_land2.mse","shop.dds",0);
|
||||
const char* compassTextures[]={"detected.dds","small.dds","middle.dds","large.dds"};
|
||||
const char* compassFiles[]={"effect/etc/firecracker/find_out.mse","effect/etc/compass/appear_small.mse",
|
||||
"effect/etc/compass/appear_middle.mse","effect/etc/compass/appear_large.mse"};
|
||||
for(int distance=0;distance<4;++distance) effectFixture(compassFiles[distance],compassTextures[distance],100);
|
||||
{
|
||||
PythonRuntime python(stdlib,root);auto& net=PythonNetworkStream::Instance();
|
||||
python.execute("import net, player, app, background, skill\n"
|
||||
"class Window:\n"
|
||||
" def __init__(self): self.calls=[]\n"
|
||||
" def OnSafeBoxError(self): self.calls.append('safe')\n"
|
||||
" def OpenSafeboxWindow(self,size): self.calls.append(('open',size))\n"
|
||||
" def OpenMallWindow(self,size): self.calls.append(('mallopen',size))\n"
|
||||
" def RefreshSafebox(self): self.calls.append('box')\n"
|
||||
" def RefreshMall(self): self.calls.append('mall')\n"
|
||||
" def RefreshSafeboxMoney(self): self.calls.append('money')\n"
|
||||
" def RefreshStamina(self): self.calls.append('stamina')\n"
|
||||
" def RefreshMobile(self): self.calls.append('mobile')\n"
|
||||
" def StartCatchKing(self): self.calls.append('king')\n"
|
||||
" def OnCannotShotError(self,vid,reason): self.calls.append(('shot',vid,reason))\n"
|
||||
" def BINARY_OpenAtlasWindow(self): self.calls.append('atlas')\n"
|
||||
" def BINARY_ServerCommand_Run(self,s): return False\n"
|
||||
" def RunUseSkillEvent(self,slot,time): self.calls.append(('cooldown',slot,time))\n"
|
||||
" def OnCannotUseSkill(self,vid,reason): self.calls.append(('skill',vid,reason))\n"
|
||||
"w=Window()\nnet.SetPhaseWindow(net.PHASE_WINDOW_GAME,w)\nplayer.SetGameWindow(w)\n");
|
||||
net.SetPhase(PHASE_GAME);
|
||||
python.execute("import wndMgr\nfont_handle=wndMgr.RegisterTextLine(w,'UI')\nwndMgr.SetFontColor(font_handle,0.5,1.0,0.25)\n");
|
||||
auto* font=static_cast<UI::CTextLine*>(PyLong_AsVoidPtr(PyDict_GetItemString(PyModule_GetDict(PyImport_AddModule("__main__")),"font_handle")));
|
||||
require(font && font->GetFontColor()==0xff7fff3f,"font components changed valid Win32 truncation");
|
||||
python.execute("wndMgr.SetFontColor(font_handle,-100.0,128.0,float('nan'))\n");
|
||||
require(font->GetFontColor()==0xff00ff00,"invalid font components not bounded");
|
||||
python.execute("wndMgr.SetFontColor(font_handle,0x12345678)\n");
|
||||
require(font->GetFontColor()==0x12345678,"packed font color changed");
|
||||
python.execute("wndMgr.Destroy(font_handle)\n");
|
||||
// Original GC wrong password is a single-byte packet, no inventory refresh.
|
||||
uint8_t wrong=HEADER_GC_SAFEBOX_WRONG_PASSWORD;net.PushRecvData(&wrong,1);net.ProcessRecvData();
|
||||
python.execute("assert w.calls==['safe'],w.calls\nw.calls=[]\n");
|
||||
uint8_t size[]={88,9};net.PushRecvData(size,1);net.ProcessRecvData();
|
||||
python.execute("assert w.calls==[]\n");
|
||||
net.PushRecvData(size+1,1);net.ProcessRecvData();
|
||||
uint8_t mallSize[]={122,18};net.PushRecvData(mallSize,2);net.ProcessRecvData();
|
||||
require(CPythonSafeBox::Instance().GetCurrentSafeBoxSize()==45
|
||||
&& CPythonSafeBox::Instance().GetMallSize()==90,"warehouse rows multiplied as pages");
|
||||
const TItemData* item=nullptr;
|
||||
require(CPythonSafeBox::Instance().GetItemDataPtr(44,&item)
|
||||
&& !CPythonSafeBox::Instance().GetItemDataPtr(45,&item),"warehouse slot boundary");
|
||||
python.execute("assert w.calls==[('open',9),('mallopen',18)],w.calls\nw.calls=[]\n");
|
||||
std::vector<uint8_t> stored(144,0);stored[0]=85;stored[1]=1;stored[4]=42;stored[8]=2;
|
||||
// Literal Win32 offsets: sockets start at odd byte 21, attributes at 53.
|
||||
stored[21]=0x78;stored[22]=0x56;stored[23]=0x34;stored[24]=0x12;
|
||||
stored[53]=7;stored[54]=0xc7;stored[55]=0xcf; // signed -12345
|
||||
std::vector<uint8_t> batch=stored;batch.insert(batch.end(),stored.begin(),stored.end());
|
||||
stored[0]=128;batch.insert(batch.end(),stored.begin(),stored.end());net.PushRecvData(batch);net.ProcessRecvData();
|
||||
require(CPythonSafeBox::Instance().GetItemDataPtr(0,&item) && item->alSockets[0]==0x12345678
|
||||
&& item->aAttr[0].bType==7 && item->aAttr[0].sValue==-12345,"unaligned wire item bytes changed");
|
||||
SetPlayerItemData(1,7,*item);
|
||||
python.execute("assert player.GetItemAttribute(7,0)==(7,-12345)\n");
|
||||
python.execute("assert w.calls==['box','mall'],w.calls\nw.calls=[]\n");
|
||||
uint8_t erase[]={86,0,129,0};net.PushRecvData(erase,4);net.ProcessRecvData();
|
||||
require(CPythonSafeBox::Instance().GetItemDataPtr(0,&item) && item->vnum==0,"warehouse deletion state");
|
||||
uint8_t money[]={84,0x70,0x11,1,0};net.PushRecvData(money,5);net.ProcessRecvData();
|
||||
require(CPythonSafeBox::Instance().GetMoney()==70000,"warehouse money");
|
||||
python.execute("assert w.calls==['box','mall','money'],w.calls\nw.calls=[]\n");
|
||||
auto command=[&](const std::string& text) {
|
||||
std::vector<uint8_t> bytes(10+text.size(),0);bytes[0]=HEADER_GC_CHAT;
|
||||
bytes[1]=uint8_t(bytes.size());bytes[2]=uint8_t(bytes.size()>>8);bytes[3]=CHAT_TYPE_COMMAND;
|
||||
std::copy(text.begin(),text.end(),bytes.begin()+9);net.PushRecvData(bytes);net.ProcessRecvData();
|
||||
};
|
||||
command("StartStaminaConsume 4 100");require(GetPlayerStatusPoint(9)==100,"start stamina status");
|
||||
SetGameFrameDelta(0.125f);python.execute("app.UpdateGame()\nassert player.GetStatus(player.STAMINA)==99\n");
|
||||
python.execute("app.UpdateGame()\nassert player.GetStatus(player.STAMINA)==99\nassert w.calls==['stamina','stamina'],w.calls\n");
|
||||
command("StopStaminaConsume 42");python.execute("app.UpdateGame()\nassert player.GetStatus(player.STAMINA)==42\nassert len(w.calls)==2\n");
|
||||
command("StartStaminaConsume 4");python.execute("app.UpdateGame()\nassert player.GetStatus(player.STAMINA)==42\n");
|
||||
command("sms");command("nosms");python.execute("assert w.calls[-2:]==['mobile','mobile']\nassert player.HasMobilePhoneNumber()==0\n");
|
||||
command("StartStaminaConsume 1 9");ResetPlayerState();UpdatePlayerStamina(1);
|
||||
require(GetPlayerStatusPoint(9)==0,"reset retained stamina consumption");
|
||||
|
||||
net.SetPhase(PHASE_SELECT);net.ClearSendQueue();
|
||||
python.execute("net.SendMobileMessagePacket('Bob','hi')\n");
|
||||
std::vector<uint8_t> expected(31,0);expected[0]=107;expected[1]=31;
|
||||
expected[3]='B';expected[4]='o';expected[5]='b';expected[28]='h';expected[29]='i';
|
||||
require(net.GetSendQueue()==expected && net.GetSendPackets().size()==1,"SMS wire/sequence boundary");
|
||||
auto longName=wire::mobile_message(std::string(40,'N'),"");
|
||||
require(longName.size()==29 && longName[27]==0 && longName[26]=='N',"SMS name termination");
|
||||
require(wire::mobile_message("Bob",std::string(65506,'x')).size()==65535,"SMS WORD boundary");
|
||||
require(wire::mobile_message("Bob",std::string(65507,'x')).empty(),"SMS oversized frame");
|
||||
auto sendCheck=[&](const char* script,const std::vector<uint8_t>& expected) {
|
||||
net.ClearSendQueue();python.execute(script);require(net.GetSendQueue()==expected,"extended feature send differs from Windows");
|
||||
require(expected.empty() || net.GetSendPackets().size()==1,"extended send sequence boundary");
|
||||
};
|
||||
sendCheck("net.Send67AttrPacket(258,-1,-2,0x1234)\n",{208,2,255,254,255,0x34,0x12});
|
||||
sendCheck("net.Send67AttrClosePacket()\n",{209});
|
||||
sendCheck("net.SendMiniGameCatchKingStart(257)\n",{163,5,0,0,1});
|
||||
sendCheck("net.SendMiniGameCatchKingDeckCardClick()\n",{163,4,0,1});
|
||||
sendCheck("net.SendMiniGameCatchKingFieldCardClick(-1)\n",{163,5,0,2,255});
|
||||
sendCheck("net.SendMiniGameCatchKingReward()\n",{163,4,0,3});
|
||||
python.execute("w.calls=[]\nnet.OpenCatchKing()\nassert w.calls==['king']\nw.calls=[]\n");
|
||||
sendCheck("net.CalendarOpen()\nnet.CalendarClose()\nnet.CalendarSend(1,2,'12:34','23:45')\n",{});
|
||||
|
||||
auto& actors=NetworkActorManager::Instance();actors.Clear();net.SetMainActorVID(1);
|
||||
python.execute("assert player.IsPVPInstance(2)==0 and player.IsInSafeArea()==0\n");
|
||||
SNetworkActorData main{};main.m_dwVID=1;main.m_dwGuildID=10;main.m_lCurX=100;main.m_lCurY=200;
|
||||
SNetworkActorData target{};target.m_dwVID=2;target.m_dwGuildID=20;
|
||||
actors.AppendActor(main);actors.AppendActor(target);actors.InsertPVPKey(1,2);
|
||||
std::vector<uint8_t> opened(22,0);opened[0]=220;
|
||||
sendCheck("net.CalendarOpen()\n",opened);opened[1]=1;sendCheck("net.CalendarClose()\n",opened);
|
||||
sendCheck("net.CalendarSend(-1,0x12345678,'12:34X7','23:45')\n",
|
||||
{220,2,255,255,255,255,0x78,0x56,0x34,0x12,'1','2',':','3','4','X','2','3',':','4','5',0});
|
||||
python.execute("assert player.IsPVPInstance(2)==1 and player.IsPVPInstance(99)==0\n");
|
||||
net.SetPhase(PHASE_GAME);
|
||||
python.execute("w.calls=[]\nplayer.SetTarget(0)\nplayer.ActEmotion(999)\nassert w.calls==[('shot',1,'NEED_TARGET')],w.calls\n");
|
||||
actors.GetActorData(2)->m_stName="Target Name";
|
||||
python.execute("player.SetTarget(2)\n");net.ClearSendQueue();python.execute("player.ActEmotion(0)\n");
|
||||
auto kiss=wire::chat("/kiss Target Name",CHAT_TYPE_TALKING);
|
||||
require(net.GetSendQueue()==kiss,"emotion request must use alive target name, not supplied ID");
|
||||
actors.GetActorData(2)->m_pActorInstance->SetHP(0);net.ClearSendQueue();
|
||||
python.execute("w.calls=[]\nplayer.ActEmotion(12)\nassert w.calls==[('shot',1,'NEED_TARGET')]\n");
|
||||
require(net.GetSendQueue().empty(),"emotion sent to dead target");actors.GetActorData(2)->m_pActorInstance->SetHP(1000);
|
||||
python.execute("player.SetTarget(0)\nw.calls=[]\n");
|
||||
actors.RemovePVPKey(1,2);actors.InsertGVGKey(10,20);python.execute("assert player.IsPVPInstance(2)==1\n");
|
||||
actors.RemoveGVGKey(10,20);actors.GetActorData(1)->m_duelMode=DUEL_CANNOTATTACK;
|
||||
python.execute("assert player.IsPVPInstance(2)==1\n"); // Original GetDuelMode checks any nonzero mode.
|
||||
actors.GetActorData(1)->m_duelMode=DUEL_NONE;
|
||||
python.execute("assert player.IsPVPInstance(2)==0\n");
|
||||
auto* a=actors.GetActorData(1);auto* b=actors.GetActorData(2);a->m_bType=b->m_bType=6;
|
||||
python.execute("assert player.CanAttackInstance(2)==0 and player.CanAttackInstance(1)==0\n");
|
||||
actors.InsertPVPKey(1,2);python.execute("assert player.CanAttackInstance(2)==1\n");actors.RemovePVPKey(1,2);
|
||||
a->m_duelMode=DUEL_CANNOTATTACK;python.execute("assert player.IsPVPInstance(2)==1 and player.CanAttackInstance(2)==0\n");
|
||||
a->m_duelMode=DUEL_START;python.execute("assert player.CanAttackInstance(2)==0\n");
|
||||
actors.InsertDUELKey(1,2);python.execute("assert player.CanAttackInstance(2)==1\n");a->m_duelMode=DUEL_NONE;
|
||||
a->m_byPKMode=1;b->m_byPKMode=4;python.execute("assert player.CanAttackInstance(2)==0\n");
|
||||
b->m_byPKMode=0;python.execute("assert player.CanAttackInstance(2)==1\n");
|
||||
AppendPartyMember(10,"self");AppendPartyMember(20,"target");LinkPartyMember(10,1);LinkPartyMember(20,2);
|
||||
python.execute("assert player.CanAttackInstance(2)==0\n");
|
||||
b->m_dwEmpireID=2;python.execute("assert player.CanAttackInstance(2)==1\n");b->m_dwEmpireID=0;
|
||||
b->m_bType=2;python.execute("assert player.CanAttackInstance(2)==1\n");
|
||||
b->m_bType=4;b->m_dwRace=13000;python.execute("assert player.CanAttackInstance(2)==1\n");
|
||||
b->m_dwRace=13001;python.execute("assert player.CanAttackInstance(2)==0\n");
|
||||
net.SetPhase(PHASE_GAME);command("ObserverMode 1");b->m_bType=0;
|
||||
python.execute("assert player.CanAttackInstance(2)==0\n");command("ObserverMode 0");
|
||||
require(CPythonBackground::Instance().LoadMap("parity_map"),"fixture map load");
|
||||
python.execute("assert player.IsInSafeArea()==1\n");
|
||||
std::vector<uint8_t> clear(256*256,0);auto* terrain=CPythonBackground::Instance().GetTerrain();
|
||||
require(terrain->LoadAttrFromBuffer(clear.data(),clear.size()),"safe attr fixture");
|
||||
python.execute("assert player.IsInSafeArea()==0\nbackground.TextureChange('alternate.txt')\n");
|
||||
auto uv=terrain->GetTextureUv(4,3200,6400);
|
||||
require(std::abs(uv[0]-2.25f)<1e-6 && std::abs(uv[1]-5.5f)<1e-6,"original terrain UV matrix");
|
||||
auto draw=terrain->BuildPatchDraw(0,0);
|
||||
auto at=terrain->GetTextureUv(4,draw.positions[0],draw.positions[2]);
|
||||
require(draw.texture0=="ymir work/terrainmaps/alternate.dds" && draw.uv0[0]==at[0] && draw.uv0[1]==at[1],"texture change not reflected in draw");
|
||||
require(!terrain->LoadTextureSetFromString("Start Texture004\n\"bad.dds\"\nnan\nEnd Texture004\n"),"invalid UV set accepted");
|
||||
require(terrain->GetTextureUv(4,3200,6400)==uv,"invalid set destroyed previous transform");
|
||||
|
||||
// The real target receive dispatcher must create/follow/delete world effects,
|
||||
// not just minimap entries. Use a nonzero map origin to catch double/missing conversion.
|
||||
auto& bg=CPythonBackground::Instance();auto& effects=EffectManager::Instance();
|
||||
effects.DeleteAllInstances();require(bg.LoadMap("target_map"),"direct target map load");
|
||||
auto updateTarget=[&](uint32_t id,uint32_t x,uint32_t y,uint8_t type) {
|
||||
std::vector<uint8_t> packet(14,0);packet[0]=123;packet[13]=type;
|
||||
for(int byte=0;byte<4;++byte) {packet[1+byte]=id>>(8*byte);packet[5+byte]=x>>(8*byte);packet[9+byte]=y>>(8*byte);}
|
||||
net.PushRecvData(packet);net.ProcessRecvData();
|
||||
};
|
||||
auto deleteTarget=[&](uint32_t id) {
|
||||
uint8_t packet[]={124,uint8_t(id),uint8_t(id>>8),uint8_t(id>>16),uint8_t(id>>24)};
|
||||
net.PushRecvData(packet,sizeof(packet));net.ProcessRecvData();
|
||||
};
|
||||
auto drawCenter=[&](float x,float y,float z,const char* texture) {
|
||||
float identity[16]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};float eye[]={0,100,-200};
|
||||
std::vector<Render3DDraw> draws;effects.BuildDrawCommands(identity,identity,eye,draws);
|
||||
require(draws.size()==1 && draws[0].positions.size()==12,"target effect missing/duplicated");
|
||||
float center[3]={};for(size_t i=0;i<12;++i)center[i%3]+=draws[0].positions[i]/4;
|
||||
require(std::abs(center[0]-x)<0.01f && std::abs(center[1]-y)<0.01f && std::abs(center[2]-z)<0.01f,"target effect coordinate/follow transform");
|
||||
require(draws[0].texture0.find(texture)!=std::string::npos,"wrong target effect resource");
|
||||
};
|
||||
updateTarget(77,102500,205000,1);effects.Update(0.1f);drawCenter(100,100,200,"regular.dds");
|
||||
require(bg.Warp(102500,205000),"target map warp");require(effects.GetActiveInstanceCount()==0,"warp kept prior map target");
|
||||
updateTarget(77,102500,205000,1);effects.Update(0.1f);drawCenter(100,100,200,"regular.dds");
|
||||
updateTarget(77,102700,205300,1);drawCenter(300,100,500,"regular.dds");
|
||||
deleteTarget(77);require(effects.GetActiveInstanceCount()==0,"target delete kept instance");
|
||||
updateTarget(77,102900,205500,5);effects.Update(0.1f);drawCenter(500,100,700,"shop.dds");
|
||||
deleteTarget(77);
|
||||
auto* moving=actors.GetActorData(1);require(moving && moving->m_pActorInstance,"target actor fixture");
|
||||
moving->m_pActorInstance->SetPosition(40,60,80);
|
||||
std::vector<uint8_t> targetCreate(43,0);targetCreate[0]=125;targetCreate[1]=78;targetCreate[38]=1;targetCreate[42]=2;
|
||||
net.PushRecvData(targetCreate.data(),10);net.ProcessRecvData();require(effects.GetActiveInstanceCount()==0,"fragmented target created early");
|
||||
net.PushRecvData(targetCreate.data()+10,33);net.ProcessRecvData();bg.Update(0,0,0);effects.Update(0.1f);
|
||||
drawCenter(40,60,80,"regular.dds");
|
||||
// The first actor binding survives repeated create; coordinate updates cannot override it.
|
||||
bg.CreateTargetEffect(78,uint32_t(2));updateTarget(78,102900,205500,1);
|
||||
moving->m_pActorInstance->SetPosition(70,90,110);bg.Update(0,0,0);drawCenter(70,90,110,"regular.dds");
|
||||
deleteTarget(78);bg.Update(0,0,0);require(effects.GetActiveInstanceCount()==0,"deleted actor target recreated");
|
||||
bg.CreateTargetEffectShop(79,uint32_t(1));bg.Update(0,0,0);effects.Update(0.1f);drawCenter(70,90,110,"shop.dds");
|
||||
deleteTarget(79);bg.Update(0,0,0);require(effects.GetActiveInstanceCount()==0,"shop binding survived delete");
|
||||
auto* targetTerrain=bg.GetTerrain();std::vector<uint16_t> emptyHeight(131*131,0);
|
||||
require(targetTerrain->LoadFromBuffer(emptyHeight.data(),emptyHeight.size()),"zero-height fixture");
|
||||
updateTarget(80,102500,205000,5);bg.Update(0,0,0);require(effects.GetActiveInstanceCount()==0,"zero-height target not deferred");
|
||||
require(targetTerrain->LoadFromBuffer(targetHeights.data(),targetHeights.size()),"loaded-height fixture");
|
||||
bg.Update(0,0,0);effects.Update(0.1f);drawCenter(100,100,200,"regular.dds"); // Original shared reserve uses regular resource.
|
||||
deleteTarget(80);
|
||||
for(int distance=0;distance<4;++distance) {
|
||||
command("StoneDetect 1 "+std::to_string(distance)+" 90");effects.Update(0.1f);
|
||||
drawCenter(70,90,10,compassTextures[distance]); // fmod(540-90,360)=90; local X rotates toward -Z.
|
||||
effects.DeleteAllInstances();
|
||||
}
|
||||
command("StoneDetect 1 256 450");effects.Update(0.1f);drawCenter(70,90,10,"detected.dds");effects.DeleteAllInstances();
|
||||
command("StoneDetect 999 1 90");command("StoneDetect 1 4 90");command("StoneDetect 1 1");command("StoneDetect 1 1 nan");
|
||||
require(effects.GetActiveInstanceCount()==0,"invalid StoneDetect emitted effect");
|
||||
bg.CreateTargetEffect(81,uint32_t(1));bg.Update(0,0,0);
|
||||
effects.DeleteAllInstances();bg.Update(0,0,0);require(effects.GetActiveInstanceCount()==1,"dead target instance not recreated");
|
||||
const auto unrelated=effects.CreateEffect("d:/ymir work/effect/etc/direction/direction_land.mse");
|
||||
bg.Destroy();require(effects.GetActiveInstanceCount()==1 && effects.IsAliveEffect(unrelated),"map destroy leaked targets/deleted unrelated effects");
|
||||
effects.DeleteAllInstances();
|
||||
|
||||
actors.Clear();require(LoadSkillDescriptions("skilldesc-missing.txt")==false,"missing fixture accepted");
|
||||
python.execute("skill.RegisterSkill(200,'skill/cooldown.txt')\nw.calls=[]\n");
|
||||
SetPlayerSkill(3,200);SetPlayerStatusPoint(19,1000);SetPlayerStatusPoint(21,200);
|
||||
UseGuildSkill(3);python.execute("assert w.calls==[('cooldown',3,10.0)],w.calls\n");
|
||||
// SkillDesc's empty motion column creates real no-motion skills, so
|
||||
// permission tests assert actual packets without relying on absent GR2s.
|
||||
auto desc=[](unsigned id,const std::string& attrs,const std::string& weapons="",const std::string& motion="",const std::string& count="") {
|
||||
std::vector<std::string> columns(17);columns[0]=std::to_string(id);columns[1]="active";columns[2]="Gate";columns[10]=attrs;columns[11]=weapons;columns[13]=motion;columns[14]="0";columns[15]=count;columns[16]="0";
|
||||
std::string row;for(size_t i=0;i<columns.size();++i) {if(i)row+='\t';row+=columns[i];}return row+'\n';
|
||||
};
|
||||
write(root/"skill/gates.txt",desc(210,"")+desc(211,"HORSE_SKILL")+desc(212,"PASSIVE")+desc(213,"ATTACK_SKILL")
|
||||
+desc(3,"TOGGLE")+desc(4,"TOGGLE|STANDING_SKILL")+desc(220,"")+desc(221,"")+desc(222,"")
|
||||
+desc(223,"USE_HP")+desc(224,"CAN_USE_IF_NOT_ENOUGH")+desc(225,"NEED_EMPTY_BOTTLE|NEED_POISON_BOTTLE")
|
||||
+desc(226,"WEAPON_LIMITATION","EMPTY_HAND")+desc(227,"WEAPON_LIMITATION","BOW")+desc(131,"")+desc(228,"TOGGLE")
|
||||
+desc(229,"CHARGE_ATTACK")+desc(230,"")+desc(231,"")
|
||||
+desc(240,"NEED_TARGET")+desc(241,"NEED_TARGET|NEED_CORPSE")
|
||||
+desc(242,"NEED_TARGET|ONLY_FOR_ALLIANCE")+desc(243,"NEED_TARGET|ONLY_FOR_ALLIANCE|CAN_USE_FOR_ME")
|
||||
+desc(244,"NEED_TARGET|CAN_USE_FOR_ME")+desc(245,"SEARCH_TARGET")+desc(246,"")+desc(250,"","","1")
|
||||
+desc(260,"NEED_TARGET")+desc(261,"NEED_TARGET|ONLY_FOR_ALLIANCE")+desc(262,"NEED_TARGET|CHARGE_ATTACK")
|
||||
+desc(270,"NEED_TARGET|FAN_RANGE","","","3")+desc(271,"NEED_TARGET|CIRCLE_RANGE","","","3")
|
||||
+desc(272,"NEED_TARGET","","","3")+desc(273,"NEED_TARGET|FAN_RANGE|CIRCLE_RANGE","","","3")
|
||||
+desc(274,"NEED_TARGET|CIRCLE_RANGE","","1","2")+desc(275,"NEED_TARGET","","","0")
|
||||
+desc(276,"NEED_TARGET","","","1")+desc(277,"NEED_TARGET","","","2+k")
|
||||
+desc(278,"NEED_TARGET","","","5000")+desc(279,"NEED_TARGET|ATTACK_SKILL"));
|
||||
require(LoadSkillDescriptions("skill/gates.txt"),"skill permission fixture");
|
||||
auto table=[](unsigned id,const std::string& cost,const std::string& cooldown="0",unsigned range=0) {
|
||||
std::vector<std::string> columns(27);columns[0]=std::to_string(id);columns[8]=cost;columns[11]=cooldown;columns[25]=std::to_string(range);columns[26]="0";
|
||||
std::string row;for(size_t i=0;i<columns.size();++i) {if(i)row+='\t';row+=columns[i];}return row+'\n';
|
||||
};
|
||||
write(root/"skill/costs.txt",table(210,"1")+table(211,"1")+table(213,"1")+table(220,"20")+table(221,"0")+table(222,"-1")
|
||||
+table(223,"20")+table(224,"20")+table(225,"1")+table(226,"1")+table(227,"1")+table(131,"0")+table(228,"0")
|
||||
+table(229,"20","20")+table(230,"20","20")+table(231,"1.9")
|
||||
+table(240,"1")+table(241,"1")+table(242,"1")+table(243,"1")+table(244,"1")+table(245,"1")+table(246,"1")+table(250,"1")
|
||||
+table(260,"1","0",200)+table(261,"1","0",200)+table(262,"1","20",200)
|
||||
+table(270,"1","0",2000)+table(271,"1","0",2000)+table(272,"1","0",2000)+table(273,"1","0",2000)
|
||||
+table(274,"1","0",2000)+table(275,"1","0",2000)+table(276,"1","0",2000)+table(277,"1","0",2000)+table(278,"1","0",2000)+table(279,"1","2",2000));
|
||||
require(LoadSkillTable("skill/costs.txt"),"skill cost table fixture");
|
||||
SetPlayerSkill(10,210);SetPlayerSkill(11,211);SetPlayerSkill(12,212);SetPlayerSkill(13,213);
|
||||
for(int index : {210,211,212,213})SetPlayerSkillLevel(index,0,1);
|
||||
SetPlayerStatusPoint(5,100);SetPlayerStatusPoint(7,100);
|
||||
auto resetCalls=[&]() {net.ClearSendQueue();python.execute("w.calls=[]\n");};
|
||||
resetCalls();ClickSkillSlot(10);require(net.GetSendQueue().empty(),"skill without main actor sent packet");
|
||||
SNetworkActorData caster{};caster.m_dwVID=1;caster.m_bType=6;caster.m_dwRace=0;actors.AppendActor(caster);net.SetMainActorVID(1);
|
||||
auto* casting=actors.GetActorData(1);auto& castingActor=*casting->m_pActorInstance;
|
||||
auto reject=[&](int slot) {resetCalls();ClickSkillSlot(slot);require(net.GetSendQueue().empty(),"blocked skill sent packet");python.execute("assert w.calls==[],w.calls\n");};
|
||||
reject(12);castingActor.SetActorType(7);reject(10);castingActor.SetActorType(6);
|
||||
command("ObserverMode 1");reject(10);command("ObserverMode 0");
|
||||
casting->m_awPart[RaceData::PART_MAIN]=201;reject(10);casting->m_awPart[RaceData::PART_MAIN]=0;
|
||||
casting->m_awPart[RaceData::PART_WEAPON]=29101;reject(10);casting->m_awPart[RaceData::PART_WEAPON]=0;
|
||||
castingActor.Stun();reject(10);castingActor.SetSleep(false);castingActor.Revive();
|
||||
resetCalls();ClickSkillSlot(11);require(net.GetSendQueue().empty(),"unmounted horse skill sent");
|
||||
python.execute("assert w.calls==[('skill',1,'HAVE_TO_RIDE')],w.calls\n");
|
||||
castingActor.SetMountingHorse(true);casting->m_dwMountVnum=20107;reject(11);
|
||||
SetPlayerSkill(107,107);SetPlayerSkillLevel(107,0,19);reject(11);
|
||||
SetPlayerSkillLevel(107,0,20);casting->m_dwMountVnum=20104;reject(11);
|
||||
casting->m_dwMountVnum=20107;resetCalls();ClickSkillSlot(10);
|
||||
require(net.GetSendQueue().empty(),"mounted regular skill sent");python.execute("assert w.calls==[('skill',1,'NOT_HORSE_SKILL')],w.calls\n");
|
||||
resetCalls();ClickSkillSlot(11);require(net.GetSendQueue()==std::vector<uint8_t>({233,211,0,0,0,0,0,0,0}),"mounted skill packet differs");
|
||||
python.execute("assert w.calls==[('cooldown',11,0.0)],w.calls\n");
|
||||
castingActor.SetMountingHorse(false);casting->m_dwMountVnum=0;resetCalls();ClickSkillSlot(10);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,210,0,0,0,0,0,0,0}),"normal skill packet differs");
|
||||
SetPlayerSkill(14,3);SetPlayerSkill(15,4);SetPlayerAffect(14);SetPlayerAffect(15);
|
||||
resetCalls();ClickSkillSlot(14);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,3,0,0,0,14,0,0,0}),"ordinary toggle lost skill-slot argument");
|
||||
python.execute("assert w.calls==[],w.calls\n");
|
||||
castingActor.SetActorType(7);reject(14);resetCalls();ClickSkillSlot(15);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,4,0,0,0,0,0,0,0}),"standing toggle permission exception changed");
|
||||
python.execute("assert w.calls==[],w.calls\n");castingActor.SetActorType(6);
|
||||
require(bg.LoadMap("parity_map"),"skill safe map fixture");resetCalls();ClickSkillSlot(13);
|
||||
require(net.GetSendQueue().empty(),"safe-zone attack skill sent");python.execute("assert w.calls==[('skill',1,'IN_SAFE')],w.calls\n");
|
||||
auto failed=[&](int slot,const char* reason) {
|
||||
resetCalls();ClickSkillSlot(slot);require(net.GetSendQueue().empty(),"unusable skill sent a packet");
|
||||
python.execute(std::string("assert w.calls==[('skill',1,'")+reason+"')],w.calls\n");
|
||||
};
|
||||
auto accepted=[&](int slot,unsigned index,float cooltime=0) {
|
||||
resetCalls();ClickSkillSlot(slot);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,uint8_t(index),uint8_t(index>>8),0,0,0,0,0,0}),"resource boundary skill packet");
|
||||
python.execute("assert w.calls==[('cooldown',"+std::to_string(slot)+","+std::to_string(cooltime)+")],w.calls\n");
|
||||
};
|
||||
for(int index=220;index<=228;++index) {SetPlayerSkill(index-200,index);SetPlayerSkillLevel(index,0,1);}
|
||||
SetPlayerSkill(29,131);SetPlayerSkillLevel(131,0,1);
|
||||
SetPlayerSkillLevel(220,0,0);failed(20,"NOT_YET_LEARN");
|
||||
python.execute("assert player.ToggleLevelLimit()==0\n");accepted(20,220);
|
||||
python.execute("assert player.ToggleLevelLimit()==1\n");SetPlayerSkillLevel(220,0,1);
|
||||
SetPlayerStatusPoint(7,19);failed(20,"NOT_ENOUGH_SP");SetPlayerStatusPoint(7,20);accepted(20,220);
|
||||
require(GetPlayerStatusPoint(7)==20,"client deducted skill resources before server response");
|
||||
failed(21,"NOT_ENOUGH_SP");SetPlayerStatusPoint(7,0);accepted(22,222);accepted(29,131);accepted(28,228);
|
||||
failed(24,"NOT_ENOUGH_SP");SetPlayerStatusPoint(7,1);accepted(24,224);
|
||||
SetPlayerStatusPoint(5,19);SetPlayerStatusPoint(7,100);failed(23,"NOT_ENOUGH_HP");
|
||||
SetPlayerStatusPoint(5,20);SetPlayerStatusPoint(7,19);failed(23,"NOT_ENOUGH_SP");
|
||||
SetPlayerStatusPoint(7,20);accepted(23,223);
|
||||
failed(25,"NEED_EMPTY_BOTTLE");TItemData bottle{};bottle.vnum=27995;SetPlayerItemData(5,100,bottle);
|
||||
failed(25,"NEED_POISON_BOTTLE");bottle.vnum=27996;SetPlayerItemData(6,179,bottle);accepted(25,225);
|
||||
accepted(26,226);failed(27,"NOT_MATCHABLE_WEAPON");
|
||||
castingActor.SetMotionMode(8);failed(20,"REMOVE_FISHING_ROD");castingActor.SetMotionMode(1);
|
||||
casting->m_affectFlags[0]|=1u<<31;SetPlayerStatusPoint(5,0);SetPlayerStatusPoint(7,0);accepted(23,223);
|
||||
casting->m_affectFlags[0]&=~(1u<<31);
|
||||
for(int index=229;index<=231;++index) {SetPlayerSkill(index-198,index);SetPlayerSkillLevel(index,0,1);}
|
||||
SetPlayerStatusPoint(7,20);accepted(31,229,10);failed(31,"WAIT_COOLTIME");
|
||||
casting->m_affectFlags[0]|=1u<<31;SetPlayerStatusPoint(7,0);accepted(31,229,10);
|
||||
casting->m_affectFlags[0]&=~(1u<<31);SetPlayerStatusPoint(7,20);accepted(32,230,10);
|
||||
casting->m_affectFlags[0]|=1u<<31;SetPlayerStatusPoint(7,0);failed(32,"WAIT_COOLTIME");
|
||||
python.execute("assert player.ToggleCoolTime()==0\n");accepted(32,230,10);python.execute("assert player.ToggleCoolTime()==1\n");
|
||||
casting->m_affectFlags[0]&=~(1u<<31);failed(33,"NOT_ENOUGH_SP");SetPlayerStatusPoint(7,1);accepted(33,231);
|
||||
python.execute("player_only=Window()\nplayer.SetGameWindow(player_only)\n");
|
||||
accepted(33,231);SetPlayerStatusPoint(7,0);failed(20,"NOT_ENOUGH_SP");
|
||||
python.execute("assert player_only.calls==[],player_only.calls\nplayer.SetGameWindow(w)\n");
|
||||
for(int index=240;index<=246;++index) {SetPlayerSkill(index-200,index);SetPlayerSkillLevel(index,0,1);}
|
||||
SetPlayerStatusPoint(7,100);SetPlayerStatusPoint(5,100);castingActor.SetPosition(0,0,0);
|
||||
auto* skillTerrain=bg.GetTerrain();std::vector<uint8_t> attrs(256*256,0);
|
||||
require(skillTerrain->LoadAttrFromBuffer(attrs.data(),attrs.size()),"skill target safe fixture");
|
||||
auto select=[&](uint32_t vid) {python.execute("player.SetTarget("+std::to_string(vid)+")\n");};
|
||||
auto targetAccepted=[&](int slot,unsigned index,uint32_t vid,bool changed=false) {
|
||||
resetCalls();ClickSkillSlot(slot);std::vector<uint8_t> expected;
|
||||
if(changed) {expected={61,uint8_t(vid),uint8_t(vid>>8),uint8_t(vid>>16),uint8_t(vid>>24)};}
|
||||
std::vector<uint8_t> use={233,uint8_t(index),uint8_t(index>>8),0,0,uint8_t(vid),uint8_t(vid>>8),uint8_t(vid>>16),uint8_t(vid>>24)};
|
||||
expected.insert(expected.end(),use.begin(),use.end());require(net.GetSendQueue()==expected,"skill target wire VID mismatch");
|
||||
};
|
||||
select(99999);failed(40,"NEED_TARGET");failed(41,"ONLY_FOR_CORPSE");
|
||||
targetAccepted(44,244,1);require(castingActor.GetFlyTargetVID()==1,"self fallback fly target");
|
||||
SNetworkActorData enemy{};enemy.m_dwVID=2;enemy.m_bType=0;enemy.m_dwRace=999999;actors.AppendActor(enemy);
|
||||
auto enemyActor=actors.GetActorInstance(2);enemyActor->SetPosition(100,0,0);
|
||||
select(2);targetAccepted(40,240,2);require(castingActor.GetFlyTargetVID()==2 && std::abs(castingActor.GetYaw()-90)<0.001f,"enemy fly target/facing");
|
||||
// Mobile drag aims toward a valid hostile target and uses the original packet path.
|
||||
SetPlayerSkill(79,279);SetPlayerSkillLevel(279,0,1);select(0);resetCalls();
|
||||
UsePlayerTouchSkill(79,100,0,0,false);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({61,2,0,0,0,233,23,1,0,0,2,0,0,0}),"mobile aim target/skill packet mismatch");
|
||||
require(std::abs(castingActor.GetYaw()-90)<0.001f,"mobile screen aim yaw");
|
||||
resetCalls();UsePlayerTouchSkill(79,100,0,0,true);require(net.GetSendQueue().empty(),"mobile repeated cooling skill sent packet");
|
||||
python.execute("assert w.calls==[],w.calls\n");EndSkillCoolTime(279);UsePlayerTouchSkill(79,100,0,0,true);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,23,1,0,0,2,0,0,0}),"mobile ready skill did not repeat");
|
||||
EndSkillCoolTime(279);select(0);resetCalls();UsePlayerTouchSkill(79,0,0,0,false);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({61,2,0,0,0,233,23,1,0,0,2,0,0,0}),"mobile tap did not acquire nearby hostile");
|
||||
resetCalls();UsePlayerTouchSkill(10,0,0,0,true);require(net.GetSendQueue().empty(),"mobile utility skill repeated");
|
||||
failed(41,"ONLY_FOR_CORPSE");enemyActor->Die();failed(40,"NEED_TARGET");
|
||||
actors.SetPickedInstanceVID(2);failed(40,"NEED_TARGET");actors.ClearPickedInstance();
|
||||
targetAccepted(41,241,2);enemyActor->Revive();
|
||||
failed(42,"ONLY_FOR_ALLIANCE");targetAccepted(43,243,1);
|
||||
select(1);failed(42,"CANNOT_USE_SELF");targetAccepted(43,243,1);
|
||||
SNetworkActorData ally{};ally.m_dwVID=3;ally.m_bType=6;ally.m_dwRace=0;actors.AppendActor(ally);
|
||||
actors.GetActorInstance(3)->SetPosition(100,0,0);select(3);targetAccepted(42,242,3);failed(40,"CANNOT_ATTACK");
|
||||
select(2);targetAccepted(46,246,0);python.execute("assert player.GetTargetVID()==2\n");
|
||||
// Selected dead actor falls back to a live native picked actor, with target packet first.
|
||||
enemyActor->Die();actors.SetPickedInstanceVID(3);select(2);targetAccepted(42,242,3,true);actors.ClearPickedInstance();enemyActor->Revive();
|
||||
attrs[1]=TerrainAttr::ATTR_BANPK;require(skillTerrain->LoadAttrFromBuffer(attrs.data(),attrs.size()),"safe enemy attr");
|
||||
select(2);failed(40,"CANNOT_ATTACK_ENEMY_IN_SAFE_AREA");attrs[1]=0;
|
||||
require(skillTerrain->LoadAttrFromBuffer(attrs.data(),attrs.size()),"clear safe enemy attr");
|
||||
castingActor.SetYaw(90);select(0);targetAccepted(45,245,2,true);python.execute("assert player.GetTargetVID()==2\n");
|
||||
enemyActor->SetPosition(-100,0,0);castingActor.SetYaw(90);select(0);failed(45,"NEED_TARGET");
|
||||
select(3);actors.RemoveActor(3);failed(42,"NEED_TARGET");
|
||||
SNetworkActorData farther=enemy;farther.m_dwVID=4;actors.AppendActor(farther);
|
||||
actors.GetActorInstance(4)->SetPosition(1200,0,0);enemyActor->SetPosition(1900,0,0);
|
||||
select(0);targetAccepted(45,245,2,true); // Both keys clamp to 1000: lower VID wins.
|
||||
actors.RemoveActor(4);enemyActor->SetPosition(2000,0,0);select(0);targetAccepted(45,245,2,true);
|
||||
enemyActor->SetPosition(2001,0,0);select(0);failed(45,"NEED_TARGET");
|
||||
SetPlayerSkill(50,250);SetPlayerSkillLevel(250,0,1);reject(50); // No motion data: no move/use packet or cooldown.
|
||||
for(int index=260;index<=262;++index) {SetPlayerSkill(index-200,index);SetPlayerSkillLevel(index,0,1);}
|
||||
castingActor.SetPosition(0,0,0);castingActor.SetSpeed(100);enemyActor->SetPosition(1000,0,0);select(2);
|
||||
resetCalls();ClickSkillSlot(60);require(net.GetSendQueue().empty(),"far skill sent before approach");
|
||||
ProcessPlayerReservedSkill();require(castingActor.HasMoveTarget(),"reserved skill did not steer");
|
||||
castingActor.Update(1);require(std::abs(castingActor.GetX()-100)<0.001f,"reserved movement did not advance");
|
||||
castingActor.Stun();ProcessPlayerReservedSkill();require(!castingActor.HasMoveTarget(),"stun did not pause owned approach");
|
||||
castingActor.Update(1);require(std::abs(castingActor.GetX()-100)<0.001f,"stunned reservation kept moving");
|
||||
castingActor.Revive();ProcessPlayerReservedSkill();require(castingActor.HasMoveTarget(),"reservation did not resume after revive");
|
||||
enemyActor->SetPosition(1200,0,0);ProcessPlayerReservedSkill();float mx,mz;castingActor.GetMoveTarget(mx,mz);
|
||||
require(mx==1200 && mz==0,"reservation did not follow moving target");
|
||||
castingActor.SetPosition(1010,0,0);ProcessPlayerReservedSkill();require(net.GetSendQueue().empty(),"190-unit reserved boundary not strict");
|
||||
castingActor.SetPosition(1011,0,0);select(99999);net.ClearSendQueue();ProcessPlayerReservedSkill();
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({61,2,0,0,0,233,4,1,0,0,2,0,0,0}) && !castingActor.HasMoveTarget(),"reservation did not restore/cast/stop");
|
||||
auto sent=net.GetSendQueue();ProcessPlayerReservedSkill();require(net.GetSendQueue()==sent,"reservation cast twice");
|
||||
auto reserve=[&](uint32_t vid,int slot=60) {CancelPlayerReservedSkill();castingActor.SetPosition(0,0,0);select(vid);resetCalls();ClickSkillSlot(slot);ProcessPlayerReservedSkill();};
|
||||
reserve(2);SetPlayerJoystick(true,1,0);SetPlayerJoystick(false,0,0);require(!castingActor.HasMoveTarget(),"joystick did not cancel reservation");
|
||||
ProcessPlayerReservedSkill();require(net.GetSendQueue().empty(),"cancelled reservation sent");
|
||||
reserve(2);python.execute("player.SetSingleDIKKeyState(17,1)\nplayer.SetSingleDIKKeyState(17,0)\n");require(!castingActor.HasMoveTarget(),"keyboard did not cancel");
|
||||
reserve(2);SetPlayerAttackKey(true);SetPlayerAttackKey(false);require(!castingActor.HasMoveTarget(),"attack did not cancel");
|
||||
SNetworkActorData transient=enemy;transient.m_dwVID=5;actors.AppendActor(transient);actors.GetActorInstance(5)->SetPosition(1200,0,0);
|
||||
reserve(5);actors.RemoveActor(5);ProcessPlayerReservedSkill();require(!castingActor.HasMoveTarget() && net.GetSendQueue().empty(),"deleted skill target left movement");
|
||||
actors.AppendActor(transient);actors.GetActorInstance(5)->SetPosition(1200,0,0);reserve(5);
|
||||
auto oldTarget=actors.GetActorInstance(5);actors.RemoveActor(5);actors.AppendActor(transient);ProcessPlayerReservedSkill();
|
||||
require(!castingActor.HasMoveTarget() && net.GetSendQueue().empty(),"reused target VID inherited skill");actors.RemoveActor(5);
|
||||
SNetworkActorData friendActor{};friendActor.m_dwVID=3;friendActor.m_bType=6;actors.AppendActor(friendActor);actors.GetActorInstance(3)->SetPosition(1200,0,0);
|
||||
reserve(3,61);castingActor.SetPosition(1011,0,0);ProcessPlayerReservedSkill();
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,5,1,0,0,3,0,0,0}),"friendly reserved skill");
|
||||
reserve(2);net.SetMainActorVID(3);ProcessPlayerReservedSkill();require(!castingActor.HasMoveTarget(),"main actor change did not cancel");net.SetMainActorVID(1);
|
||||
SetPlayerStatusPoint(34,1);enemyActor->SetPosition(250,0,0);castingActor.SetPosition(0,0,0);select(2);targetAccepted(60,260,2);
|
||||
SetPlayerStatusPoint(34,0);enemyActor->SetPosition(100,0,0);attrs[1]=TerrainAttr::ATTR_BLOCK;
|
||||
require(skillTerrain->LoadAttrFromBuffer(attrs.data(),attrs.size()),"blocked skill target");failed(60,"CANNOT_APPROACH");targetAccepted(40,240,2);
|
||||
attrs[1]=0;require(skillTerrain->LoadAttrFromBuffer(attrs.data(),attrs.size()),"clear blocked skill target");
|
||||
auto* hugeRace=RaceManager::Instance().CreateRace(2493);hugeRace->RegisterMotionMode(1);require(enemyActor->SetRace(2493),"huge race fixture");
|
||||
enemyActor->SetPosition(390,0,0);targetAccepted(60,260,2);
|
||||
enemyActor->SetPosition(1000,0,0);select(2);resetCalls();ClickSkillSlot(62);
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,6,1,0,0,0,0,0,0}),"charge opening request");
|
||||
resetCalls();ClickSkillSlot(62);require(net.GetSendQueue().empty(),"charge opening repeated");
|
||||
casting->m_affectFlags[0]|=1u<<31;ProcessPlayerReservedSkill();castingActor.SetPosition(611,0,0);resetCalls();ProcessPlayerReservedSkill();
|
||||
require(net.GetSendQueue()==std::vector<uint8_t>({233,6,1,0,0,2,0,0,0}),"charge reserved completion");
|
||||
casting->m_affectFlags[0]&=~(1u<<31);CancelPlayerReservedSkill();
|
||||
// Multi-flight selection: actual MSM defending spheres, deterministic source RNG,
|
||||
// and CG53 byte ordering before the final CG233 (also before a failed motion bind).
|
||||
write(root/"skill/defend.msm","Group AttachingData\n{\nAttachingDataCount 1\nGroup AttachingData00\n{\nCollisionType 3\nIsAttaching 0\nSphereDataCount 2\nGroup SphereData00\n{\nRadius 10\nPosition 0 0 0\n}\nGroup SphereData01\n{\nRadius 20\nPosition 20 0 500\n}\n}\n}\n");
|
||||
auto* flightRace=RaceManager::Instance().CreateRace(30001);flightRace->RegisterMotionMode(1);
|
||||
require(flightRace->LoadRaceData("skill/defend.msm") && flightRace->GetDefendingSpheres().size()==2,"defending sphere positions not retained");
|
||||
auto addEnemy=[&](uint32_t vid,float x,float z) {
|
||||
SNetworkActorData data{};data.m_dwVID=vid;data.m_bType=0;data.m_dwRace=30001;actors.AppendActor(data);
|
||||
auto instance=actors.GetActorInstance(vid);require(instance->SetRace(30001),"flight race binding");instance->SetPosition(x,0,z);return instance;
|
||||
};
|
||||
for(int index=270;index<=278;++index) {SetPlayerSkill(index-200,index);SetPlayerSkillLevel(index,0,1);}
|
||||
castingActor.SetPosition(0,0,0);enemyActor->SetPosition(0,0,150);select(2);
|
||||
auto near=addEnemy(20,0,100),tie=addEnemy(21,0,100),side=addEnemy(22,100,0),dead=addEnemy(23,0,50);
|
||||
dead->Die(); // Dead targets never consume an additional slot.
|
||||
auto word=[](const std::vector<uint8_t>& bytes,size_t offset) {
|
||||
return uint32_t(bytes[offset])|(uint32_t(bytes[offset+1])<<8)|(uint32_t(bytes[offset+2])<<16)|(uint32_t(bytes[offset+3])<<24);
|
||||
};
|
||||
auto flightCast=[&](int slot,unsigned index,const std::vector<uint32_t>& extra,bool bindFails=false) {
|
||||
castingActor.ClearFlyTarget();resetCalls();ClickSkillSlot(slot);const auto& bytes=net.GetSendQueue();
|
||||
require(bytes.size()==extra.size()*13+(bindFails?0:9),"multi-flight packet length");
|
||||
for(size_t i=0;i<extra.size();++i)require(bytes[i*13]==53 && word(bytes,i*13+1)==extra[i],"multi-flight sorting/VID/header");
|
||||
if(!bindFails)require(bytes[extra.size()*13]==233 && word(bytes,extra.size()*13+1)==index && word(bytes,extra.size()*13+5)==2,"multi-flight final use target/order");
|
||||
require(castingActor.GetFlyTargetVID()==2,"additional flights replaced primary");
|
||||
};
|
||||
flightCast(70,270,{20,21}); // Equal distance: source map order, primary excluded.
|
||||
require(std::bit_cast<int32_t>(word(net.GetSendQueue(),9))==-100,"real target CG53 graphic Y sign");
|
||||
flightCast(71,271,{20,21});
|
||||
near->SetPosition(0,0,1500);tie->SetPosition(0,0,1200);side->SetPosition(100,0,0);
|
||||
flightCast(70,270,{20,21}); // Fan distance keys both clamp to 1000, unlike circle.
|
||||
flightCast(71,271,{22,21});flightCast(73,273,{20,21}); // FAN takes precedence.
|
||||
side->SetPosition(0,0,2010);near->SetPosition(0,0,3000);tie->SetPosition(0,0,3000);
|
||||
require(!castingActor.IsClickableDistanceDestInstance(*side,2000),"sphere range equality not strict");
|
||||
side->SetPosition(0,0,2009);require(castingActor.IsClickableDistanceDestInstance(*side,2000),"sphere radius not included in range");
|
||||
side->SetPosition(100,10000,0);require(!castingActor.IsClickableDistanceDestInstance(*side,2000),"sphere height ignored");
|
||||
ActorInstance noSphere;noSphere.SetPosition(0,0,0);require(!castingActor.IsClickableDistanceDestInstance(noSphere,2000),"unknown defense invented cylinder");
|
||||
near->SetPosition(0,0,100);castingActor.SetPosition(0,0,100);require(castingActor.IsClickableDistanceDestInstance(*near,150),"caster graphic Y conversion mismatch");
|
||||
castingActor.SetPosition(0,0,0);near->SetPosition(0,0,3000);
|
||||
eter::srandom(1);std::array<int32_t,4> expectedRandom{};
|
||||
for(int i=0;i<2;++i) {
|
||||
const float angle=eter::frandom(-10,10)*3.14159265358979323846f/180;
|
||||
expectedRandom[i*2]=int32_t(8000*std::sin(angle));expectedRandom[i*2+1]=int32_t(-8000*std::cos(angle));
|
||||
}
|
||||
eter::srandom(1);flightCast(72,272,{0,0});
|
||||
for(int i=0;i<2;++i)require(std::bit_cast<int32_t>(word(net.GetSendQueue(),i*13+5))==expectedRandom[i*2]
|
||||
&& std::bit_cast<int32_t>(word(net.GetSendQueue(),i*13+9))==expectedRandom[i*2+1],"random fill generator/8000 cone/coordinates");
|
||||
near->SetPosition(0,0,100);flightCast(74,274,{20},true); // Expansion precedes failed bind; no use/cooldown.
|
||||
python.execute("assert w.calls==[],w.calls\n");flightCast(75,275,{});flightCast(76,276,{});
|
||||
SetPlayerSkillLevel(277,0,20);flightCast(77,277,{0}); // DWORD truncation of 2+k.
|
||||
resetCalls();ClickSkillSlot(78);require(net.GetSendQueue().empty(),"malformed count generated unbounded packets");
|
||||
for(uint32_t vid:{20,21,22,23})actors.RemoveActor(vid);castingActor.ClearFlyTarget();
|
||||
require(MountLevel(20101)==1 && MountLevel(20104)==2 && MountLevel(20109)==3 && MountLevel(32008)==0
|
||||
&& MountLevel(20228)==3 && MountLevel(99999)==0,"original mount cases changed");
|
||||
actors.Clear();bg.Destroy();
|
||||
python.execute("player.SetGameWindow(0)\nnet.ClearPhaseWindow(net.PHASE_WINDOW_GAME,w)\n");
|
||||
net.ResetConnection();CPythonBackground::Instance().Destroy();
|
||||
}
|
||||
fs::current_path(previous);fs::remove_all(root);
|
||||
std::cout<<"AVA2 Windows network, player and terrain behavior parity passed\n";return 0;
|
||||
} catch(const std::exception& e) {fs::current_path(previous);fs::remove_all(root);std::cerr<<e.what()<<'\n';return 1;}
|
||||
}
|
||||
@@ -36,7 +36,10 @@ for project in (root/'upstream/ava2-client').rglob('*.vcxproj'):
|
||||
reference_paths=[p for p in sorted(compiled) if p.is_file() and
|
||||
re.search(r'\bPy_InitModule\s*\(',p.read_text(errors='replace'))]
|
||||
windows=modules(reference_paths,True)
|
||||
port=modules(sorted((root/'src').glob('python_*.cpp')))
|
||||
port_paths=sorted((root/'src/scripting').glob('python_*.cpp'))
|
||||
if not port_paths:
|
||||
raise SystemExit('No port translation units found; check the source layout before auditing')
|
||||
port=modules(port_paths)
|
||||
rows=[]
|
||||
for name,reference in sorted(windows.items()):
|
||||
target=port.get(name,{'methods':{}});original=set(reference['methods']);current=set(target['methods'])
|
||||
|
||||
@@ -4,12 +4,23 @@ import json,re
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
rows=[]
|
||||
for path in sorted((root/'src').glob('python_*.cpp')):
|
||||
candidates=[]
|
||||
paths=sorted((root/'src/scripting').glob('python_*.cpp'))
|
||||
if not paths:
|
||||
raise SystemExit('No scripting sources found; refusing an empty parity inventory')
|
||||
for path in paths:
|
||||
source=path.read_text()
|
||||
constant_handlers={m[1]:m.start() for m in re.finditer(
|
||||
r'PyObject\s*\*\s*(\w+)\s*\([^;{}]*\)\s*\{\s*return\s+(?:Py_BuildNone\(\)|Py_BuildValue\("[ib]",\s*[01]\)|PyInt_FromLong\([01]\))\s*;\s*\}',source)}
|
||||
for name,handler in re.findall(r'\{\s*"([^"]+)"\s*,\s*(\w+)\s*,\s*METH_',source):
|
||||
if 'dummy' in handler:
|
||||
rows.append({'file':str(path.relative_to(root)),'api':name,'handler':handler,'status':'placeholder'})
|
||||
report={'scope':'Static Python method-table inventory; excludes hidden no-ops, renderer and packet behavior. Full parity is NOT established.','placeholder_count':len(rows),'placeholders':rows}
|
||||
if handler in constant_handlers:
|
||||
candidates.append({'file':str(path.relative_to(root)),'line':source.count('\n',0,constant_handlers[handler])+1,
|
||||
'api':name,'handler':handler,'status':'constant-return candidate; compare original behavior before treating as a defect'})
|
||||
report={'scope':'Static Python method-table inventory in src/scripting. Constant returns are review candidates, not proven defects. Packet/renderer behavior still requires source comparison. Full parity is NOT established.',
|
||||
'source_count':len(paths),'placeholder_count':len(rows),'placeholders':rows,
|
||||
'constant_return_candidate_count':len(candidates),'constant_return_candidates':candidates}
|
||||
output=root/'docs/WINDOWS-PARITY-INVENTORY.json'
|
||||
output.write_text(json.dumps(report,indent=2)+'\n')
|
||||
print(f'{len(rows)} placeholder bindings; report: {output}')
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// Export analysis pseudocode and a function/call index from SpeedTreeRT.
|
||||
// Run as a Ghidra headless postScript, passing an output directory.
|
||||
// @category AVA2
|
||||
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.app.decompiler.DecompInterface;
|
||||
import ghidra.app.decompiler.DecompileResults;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.listing.FunctionIterator;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.io.BufferedWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ExportSpeedTree extends GhidraScript {
|
||||
private static String cell(String s) {
|
||||
return s.replace('\t', ' ').replace('\n', ' ').replace('\r', ' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
String[] args = getScriptArgs();
|
||||
if (args.length != 1) throw new IllegalArgumentException("Expected output directory");
|
||||
Path out = Path.of(args[0]);
|
||||
Files.createDirectories(out.resolve("functions"));
|
||||
DecompInterface dec = new DecompInterface();
|
||||
dec.toggleCCode(true);
|
||||
dec.toggleSyntaxTree(true);
|
||||
if (!dec.openProgram(currentProgram)) throw new IllegalStateException(dec.getLastMessage());
|
||||
int count = 0, success = 0, failed = 0;
|
||||
try (BufferedWriter all = Files.newBufferedWriter(out.resolve("decompiled.c"), StandardCharsets.UTF_8);
|
||||
BufferedWriter index = Files.newBufferedWriter(out.resolve("functions.tsv"), StandardCharsets.UTF_8);
|
||||
BufferedWriter calls = Files.newBufferedWriter(out.resolve("calls.tsv"), StandardCharsets.UTF_8)) {
|
||||
all.write("/* Ghidra analysis pseudocode, not original source or a compilable port. */\n");
|
||||
index.write("address\tname\tprototype\tstatus\tfile\n");
|
||||
calls.write("caller_address\tcaller\tcallee_address\tcallee\n");
|
||||
FunctionIterator it = currentProgram.getFunctionManager().getFunctions(true);
|
||||
while (it.hasNext()) {
|
||||
monitor.checkCancelled();
|
||||
Function f = it.next();
|
||||
if (f.isExternal()) continue;
|
||||
count++;
|
||||
String addr = f.getEntryPoint().toString();
|
||||
String name = f.getName(true);
|
||||
DecompileResults result = dec.decompileFunction(f, 90, monitor);
|
||||
boolean ok = result.decompileCompleted() && result.getDecompiledFunction() != null;
|
||||
String status = ok ? "ok" : "failed: " + cell(result.getErrorMessage());
|
||||
String code = "/* " + addr + " " + name + " */\n";
|
||||
code += ok ? result.getDecompiledFunction().getC() : "/* " + status + " */\n";
|
||||
if (ok) success++; else failed++;
|
||||
String file = "functions/" + addr + ".c";
|
||||
Files.writeString(out.resolve(file), code, StandardCharsets.UTF_8);
|
||||
all.write(code + "\n");
|
||||
index.write(addr + "\t" + cell(name) + "\t" + cell(f.getPrototypeString(false, false))
|
||||
+ "\t" + status + "\t" + file + "\n");
|
||||
ArrayList<Function> targets = new ArrayList<>(f.getCalledFunctions(monitor));
|
||||
targets.sort(Comparator.comparing(t -> t.getEntryPoint().toString()));
|
||||
for (Function t : targets) calls.write(addr + "\t" + cell(name) + "\t"
|
||||
+ t.getEntryPoint() + "\t" + cell(t.getName(true)) + "\n");
|
||||
if (count % 100 == 0) println("Exported " + count + " functions");
|
||||
}
|
||||
} finally {
|
||||
dec.dispose();
|
||||
}
|
||||
String summary = "Program: " + currentProgram.getName() + "\nLanguage: "
|
||||
+ currentProgram.getLanguageID() + "\nCompiler: " + currentProgram.getCompilerSpec().getCompilerSpecID()
|
||||
+ "\nFunctions: " + count + "\nDecompiled: " + success + "\nFailed: " + failed + "\n";
|
||||
Files.writeString(out.resolve("summary.txt"), summary, StandardCharsets.UTF_8);
|
||||
println(summary);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user