diff --git a/.gitignore b/.gitignore index d84d8c05..37348cde 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,37 @@ __pycache__/ # CPythonSystem runtime option files (Windows writes them next to the client) metin2.cfg interface.cfg + +# Temporary render outputs and test screenshots +render_*.png +test_*.bmp +test_*.png + +# Local tools and build outputs +dist/ +.codex/ + +# Unpacked asset trees and loose client data +Dialog/ +Itemshop/ +Modulo/ +System/ +battlepass/ +bgm +combat_zone_estadisticas/ +d_ranking_gremios/ +flag/ +icon/ +locale/ +map/ +mark/ +rework_guild_ranking/ +rework_inv/ +rework_offlineshop/ +season1/ +sound/ +tabla_bonus/ +textureset/ +uiscript/ +worldard/ +ymir work/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f88afa4..6a2a47c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if(AVA2_EMBED_PYTHON) add_library(ava2_lzo STATIC third_party/ava2-lzo/lzo1x_d2.c) target_include_directories(ava2_lzo PUBLIC third_party/ava2-lzo) set_target_properties(ava2_lzo PROPERTIES POSITION_INDEPENDENT_CODE ON) - add_library(ava2_python src/python_pet_skill.cpp src/item_sound.cpp src/python_offline_shop.cpp src/python_switchbot.cpp src/python_dungeon_info.cpp src/python_drop_item.cpp src/python_battlepass.cpp src/python_guild.cpp src/python_shop_search.cpp src/python_cube_renewal.cpp src/python_messenger.cpp src/python_quest.cpp src/nonplayer_data.cpp src/python_wiki.cpp src/python_runtime.cpp src/python_net.cpp src/python_dbg.cpp src/python_system.cpp src/python_minimap.cpp src/python_chr.cpp src/python_app.cpp src/player_settings.cpp src/python_wndmgr.cpp src/python_gameplay_modules.cpp src/python_ime.cpp src/python_grp.cpp src/python_native_modules.cpp src/python_event_manager.cpp src/python_chat.cpp src/eter_lib/parser.cpp src/eter_base/Random.cpp src/game_type.cpp src/eter_ui/PythonWindow.cpp src/eter_ui/PythonWindowManager.cpp src/eter_net/PythonNetworkStream.cpp src/eter_net/PythonNetworkStreamCommand.cpp src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp src/eter_net/PythonExchange.cpp src/eter_net/PythonSafeBox.cpp) + add_library(ava2_python src/python_background.cpp src/python_pet_skill.cpp src/item_sound.cpp src/python_offline_shop.cpp src/python_switchbot.cpp src/python_dungeon_info.cpp src/python_drop_item.cpp src/python_battlepass.cpp src/python_guild.cpp src/python_shop_search.cpp src/python_cube_renewal.cpp src/python_messenger.cpp src/python_quest.cpp src/nonplayer_data.cpp src/python_wiki.cpp src/python_runtime.cpp src/python_net.cpp src/python_dbg.cpp src/python_system.cpp src/python_minimap.cpp src/python_chr.cpp src/python_app.cpp src/player_settings.cpp src/python_wndmgr.cpp src/python_gameplay_modules.cpp src/python_ime.cpp src/python_grp.cpp src/python_native_modules.cpp src/python_event_manager.cpp src/python_chat.cpp src/eter_lib/parser.cpp src/eter_base/Random.cpp src/game_type.cpp src/eter_ui/PythonWindow.cpp src/eter_ui/PythonWindowManager.cpp src/eter_net/PythonNetworkStream.cpp src/eter_net/PythonNetworkStreamCommand.cpp src/eter_net/PythonNetworkStreamPhaseGameRecv.cpp src/eter_net/PythonExchange.cpp src/eter_net/PythonSafeBox.cpp) target_include_directories(ava2_python PUBLIC src ${CMAKE_CURRENT_SOURCE_DIR} third_party/extern_include) target_link_libraries(ava2_python PUBLIC SDL3::SDL3 mtpython ava2_render PRIVATE mt_codepage ava2_transport ava2_lzo ava2_poly) endif() @@ -201,6 +201,11 @@ if(BUILD_TESTING AND NOT ANDROID) add_dependencies(chr_test mtpython_stdlib) add_test(NAME ava2.chr COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py" "AVA2 chr parity passed" "$" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root") + add_executable(background_test tests/background_test.cpp) + target_link_libraries(background_test PRIVATE ava2_python) + add_dependencies(background_test mtpython_stdlib) + add_test(NAME ava2.background COMMAND "${Python3_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/tests/check_completion.py" + "AVA2 background parity passed" "$" "${MT_PYTHON_STDLIB_ZIP}" "${CMAKE_SOURCE_DIR}/upstream/python-root") endif() add_executable(item_proto_oracle_test tests/item_proto_oracle_test.cpp "${ITEM_ORACLE}") target_include_directories(item_proto_oracle_test PRIVATE src "${CMAKE_BINARY_DIR}/generated") diff --git a/docs/AVA2-PYTHON-INTERFACES.json b/docs/AVA2-PYTHON-INTERFACES.json index f2272e0c..2e9325db 100644 --- a/docs/AVA2-PYTHON-INTERFACES.json +++ b/docs/AVA2-PYTHON-INTERFACES.json @@ -8,13 +8,7 @@ "windows_methods": 5, "missing": [], "extra": [], - "placeholder": [ - "AddChannel", - "Create", - "Initialize", - "Request", - "Update" - ] + "placeholder": [] }, { "module": "app", @@ -23,153 +17,19 @@ "windows_methods": 116, "missing": [], "extra": [], - "placeholder": [ - "EnablePerformanceTime", - "EnableSpecialCameraMode", - "FlashApplication", - "ForceSetLocale", - "GetAvailableTextureMemory", - "GetCamera", - "GetCameraPitch", - "GetCameraRotation", - "GetConnectData", - "GetCursor", - "GetCursorPosition", - "GetDegreeDifference", - "GetFaceCount", - "GetFaceSpeed", - "GetFileList", - "GetImageInfo", - "GetInfo", - "GetLoad", - "GetRenderFPS", - "GetRenderTime", - "GetRotatingDirection", - "GetUpdateFPS", - "GetUpdateTime", - "HideCursor", - "HideWebPage", - "IsCHEONMA", - "IsCanOpenRender", - "IsDevStage", - "IsExistFile", - "IsFileExist", - "IsLiarCursorOn", - "IsLiveStage", - "IsShowCursor", - "IsTestStage", - "IsVisible", - "IsVisibleNotice", - "IsWebPageMode", - "LoadCameraSetting", - "LoadLocaleAddr", - "MoveWebPage", - "MoviePitchCamera", - "MovieResetCamera", - "MovieRotateCamera", - "MovieZoomCamera", - "OnLogoClose", - "OnLogoOpen", - "OnLogoRender", - "OnLogoUpdate", - "PitchCamera", - "Process", - "RenderGame", - "RotateCamera", - "RunPythonFile", - "SaveCameraSetting", - "SetCHEONMA", - "SetCameraMaxDistance", - "SetCameraSetting", - "SetCameraSpeed", - "SetCenterPosition", - "SetConnectData", - "SetControlFP", - "SetCursor", - "SetDefaultCamera", - "SetDefaultFontName", - "SetFPS", - "SetFrameSkip", - "SetGlobalCenterPosition", - "SetGuildSymbolPath", - "SetHardwareCursor", - "SetMessage", - "SetMinFog", - "SetMultiFarmExeIcon", - "SetRideHorseEnable", - "SetSightRange", - "SetSkillEffectUpgradeEnable", - "SetSoftwareCursor", - "SetSpecularSpeed", - "SetTextTailLivingTime", - "SetTitle", - "SetVisibleNotice", - "ShowCursor", - "ShowWebPage", - "Sleep", - "UpdateGame", - "WindowStatus", - "ZoomCamera", - "testGetAccumulationTime", - "testResetAccumulationTime", - "testSetSpecularColor" - ] + "placeholder": [] }, { "module": "background", "windows_file": "upstream/ava2-client/UserInterface/PythonBackgroundModule.cpp", - "port_file": "src/python_gameplay_modules.cpp", + "port_file": "src/python_background.cpp", "windows_methods": 52, "missing": [], "extra": [ "IsAttrOn", "isAttrOn" ], - "placeholder": [ - "BeginEnvironment", - "CreatePrivateShopPos", - "DeletePrivateShopPos", - "DisableGuildArea", - "EnableSnow", - "EnableSoftwareTiling", - "EndEnvironment", - "GetDistanceSetInfo", - "GetFarClip", - "GetRenderShadowTime", - "GetRenderedGraphicThingInstanceNum", - "GetRenderedSplatNum", - "GetShadowMapColor", - "IsSoftwareTiling", - "IsVisiblePart", - "RegisterDungeonMapName", - "RegisterEnvironmentData", - "Render", - "RenderAfterLensFlare", - "RenderBeforeLensFlare", - "RenderCharacterShadowToTexture", - "RenderCloud", - "RenderCollision", - "RenderDungeon", - "RenderEffect", - "RenderPCBlocker", - "RenderSky", - "RenderWater", - "SelectViewDistanceNum", - "SetBGLoading", - "SetBackgroundDirLight", - "SetCharacterDirLight", - "SetEnvironmentData", - "SetRenderSort", - "SetShadowLevel", - "SetSplatLimit", - "SetTransparentTree", - "SetViewDistanceSet", - "SetVisiblePart", - "SetXMasTree", - "TextureChange", - "Update", - "VisibleGuildArea" - ] + "placeholder": [] }, { "module": "battlepass", @@ -304,52 +164,7 @@ "windows_methods": 54, "missing": [], "extra": [], - "placeholder": [ - "ClearDepthBuffer", - "ClearTextBar", - "CreateBigTextBar", - "CreateTextBar", - "Culling", - "DestroyTextBar", - "GetAvailableMemory", - "GetCameraPosition", - "GetCursorPosition3d", - "GetTargetPosition", - "Identity", - "InitScreenEffect", - "PopMatrix", - "PopState", - "PushMatrix", - "PushState", - "RenderBar3d", - "RenderBox3d", - "RenderCube", - "RenderDownButton", - "RenderTextBar", - "RenderUpButton", - "RestoreViewport", - "Rotate", - "SaveScreenShot", - "SaveScreenShotToPath", - "SetAroundCamera", - "SetColorRenderState", - "SetCursorPosition", - "SetEyeCamera", - "SetGameRenderState", - "SetGamma", - "SetInterfaceRenderState", - "SetOmniLight", - "SetOrtho2d", - "SetOrtho3d", - "SetPerspective", - "SetPositionCamera", - "SetTextBarClipRect", - "SetViewport", - "TextBarGetTextExtent", - "TextBarSetTextColor", - "TextBarTextOut", - "Translate" - ] + "placeholder": [] }, { "module": "grpImage", @@ -358,23 +173,7 @@ "windows_methods": 15, "missing": [], "extra": [], - "placeholder": [ - "Delete", - "DeleteExpanded", - "Generate", - "GenerateExpanded", - "GenerateFromHandle", - "GetHeight", - "GetWidth", - "Render", - "SetDiffuseColor", - "SetFileName", - "SetOrigin", - "SetPosition", - "SetRenderingRect", - "SetRotation", - "SetScale" - ] + "placeholder": [] }, { "module": "grpText", @@ -383,29 +182,7 @@ "windows_methods": 21, "missing": [], "extra": [], - "placeholder": [ - "Destroy", - "Generate", - "GetSize", - "GetSplitingTextLine", - "GetSplitingTextLineCount", - "GetText", - "HideCursor", - "PixelPositionToCharacterPosition", - "Render", - "SetFontColor", - "SetFontName", - "SetHorizontalAlign", - "SetMax", - "SetOutLineColor", - "SetOutline", - "SetPosition", - "SetSecret", - "SetText", - "SetVerticalAlign", - "ShowCursor", - "Update" - ] + "placeholder": [] }, { "module": "grpThing", @@ -414,16 +191,7 @@ "windows_methods": 8, "missing": [], "extra": [], - "placeholder": [ - "Delete", - "Generate", - "Render", - "SetFileName", - "SetPosition", - "SetRotation", - "SetScale", - "Update" - ] + "placeholder": [] }, { "module": "guild", @@ -455,22 +223,7 @@ "IsElement", "IsSealScroll" ], - "placeholder": [ - "CreateItem", - "DeleteIconInstance", - "DeleteItem", - "GetDropClear", - "GetDropInfo", - "GetIconInstance", - "GetItemsByName", - "GetRarityMaxValue", - "GetRarityPoint", - "HasDropInfo", - "IsRarityItem", - "Pick", - "Render", - "Update" - ] + "placeholder": [] }, { "module": "managerBankLogs", @@ -479,9 +232,7 @@ "windows_methods": 1, "missing": [], "extra": [], - "placeholder": [ - "Append" - ] + "placeholder": [] }, { "module": "messenger", @@ -523,52 +274,7 @@ "SendScriptButtonPacket", "Update" ], - "placeholder": [ - "CalendarClose", - "CalendarOpen", - "CalendarSend", - "ConnectTCP", - "ConnectUDP", - "DisconnectUploader", - "ExitApplication", - "ExitGame", - "GetBettingGuildWarValue", - "GetServerInfo", - "IsTest", - "LogOutGame", - "OpenCatchKing", - "RecvGuildSymbol", - "RegisterErrorLog", - "Send67AttrClosePacket", - "Send67AttrPacket", - "SendAddOfflineShopItem", - "SendChangeNamePacket", - "SendChinaMatrixCardPacket", - "SendGuildSymbol", - "SendLoginPacket", - "SendMiniGameCatchKingDeckCardClick", - "SendMiniGameCatchKingFieldCardClick", - "SendMiniGameCatchKingReward", - "SendMiniGameCatchKingStart", - "SendMobileMessagePacket", - "SendNEWCIBNPasspodAnswerPacket", - "SendOfflineShopButton", - "SendOfflineShopChangeTitle", - "SendOfflineShopCheck", - "SendRunupMatrixCardPacket", - "SendSelectEmpirePacket", - "SendTakeOfflineMoney", - "SetMarkServer", - "SetOfflinePhase", - "SetServerInfo", - "SetSkillGroupFake", - "SetTCPRecvBufferSize", - "SetTCPSendBufferSize", - "SetUDPRecvBufferSize", - "ToggleGameDebugInfo", - "UploadMark", - "UploadSymbol" - ] + "placeholder": [] }, { "module": "nonplayer", @@ -618,75 +324,7 @@ "IsCombatZoneMap", "IsTournamentMap" ], - "placeholder": [ - "ActEmotion", - "CanAttackInstance", - "ChangeCurrentSkillNumberOnly", - "Clear", - "ClearSkillDict", - "ClearTarget", - "ComboAttack", - "EndKeyWalkingImmediately", - "EndMouseWalking", - "GetAlignmentData", - "GetAutoPotionInfo", - "GetCharacterDistance", - "GetEmotionIconImage", - "GetEventGame", - "GetGem", - "GetItemLink", - "GetItemRandomAttribute", - "GetMainCharacterPart", - "GetMainCharacterShiningPart", - "GetMouseFunc", - "GetTargetVID", - "HidePlayer", - "IsActingEmotion", - "IsAvailableBeltInventoryCell", - "IsEquippingBelt", - "IsInSafeArea", - "IsMountingHorse", - "IsOpenPrivateShop", - "IsPVPInstance", - "IsSameEmpire", - "IsShiningSlot", - "IsSkillActive", - "LoadNewRegen", - "MoveItem", - "OpenCharacterMenu", - "PickCloseItem", - "PickCloseItemVector", - "RegisterCacheEffect", - "RegisterEffect", - "RegisterEmotionIcon", - "Render", - "RequestFlag", - "ResetCameraRotation", - "SendClickItemPacket", - "SendDragonSoulRefine", - "SetAttackKeyState", - "SetAutoCameraRotationSpeed", - "SetAutoPotionInfo", - "SetEventGame", - "SetItemAttribute", - "SetItemCount", - "SetItemData", - "SetItemMetinSocket", - "SetMainCharacterIndex", - "SetMouseFunc", - "SetMouseMiddleButtonState", - "SetMouseState", - "SetQuickCameraMode", - "SetSingleDIKKeyState", - "SetTarget", - "SetWeaponAttackBonusFlag", - "ShowPlayer", - "StartMouseWalking", - "ToggleLevelLimit", - "Update", - "UseGuildSkill", - "isItem" - ] + "placeholder": [] }, { "module": "playerLoad", @@ -695,9 +333,7 @@ "windows_methods": 1, "missing": [], "extra": [], - "placeholder": [ - "RegisterSkill" - ] + "placeholder": [] }, { "module": "privateShopSearch", @@ -715,10 +351,7 @@ "windows_methods": 2, "missing": [], "extra": [], - "placeholder": [ - "Pop", - "Push" - ] + "placeholder": [] }, { "module": "quest", @@ -736,16 +369,7 @@ "windows_methods": 24, "missing": [], "extra": [], - "placeholder": [ - "AddAffect", - "ClearAffect", - "RemoveAffect", - "ResetModel", - "SetModelRender", - "SetMotionIndex", - "SetMount", - "SetShining" - ] + "placeholder": [] }, { "module": "safebox", @@ -767,15 +391,7 @@ "windows_methods": 7, "missing": [], "extra": [], - "placeholder": [ - "Add", - "GetAttachedItem", - "GetPrice", - "GetResultItem", - "Remove", - "SendCloseRequest", - "SendRefineRequest" - ] + "placeholder": [] }, { "module": "shop", @@ -796,9 +412,7 @@ "windows_methods": 41, "missing": [], "extra": [], - "placeholder": [ - "LoadSkillData" - ] + "placeholder": [] }, { "module": "snd", @@ -863,5 +477,5 @@ } ], "missing_method_count": 0, - "placeholder_method_count": 370 + "placeholder_method_count": 0 } diff --git a/docs/PORT-PLAN.md b/docs/PORT-PLAN.md index d0e55489..6f7192aa 100644 --- a/docs/PORT-PLAN.md +++ b/docs/PORT-PLAN.md @@ -723,3 +723,52 @@ Remaining: - DeleteInstanceByFade removes at once; with no dead list GetVIDInfo's isDead is always 0. - SetDirection has a null guard (Windows crashes without a selection). SetRotationAll ignores X/Y. MoveToDestPosition does not recompute the direction. testSetRideMan keys the actor as VID 1 (Windows leaves the graphic VID 0). - chr.Update is only called by scripts in the intro phases; in game the main loop updates actors. + +### 2026-10-07 (pass 26): background module +Ported CPythonBackground and PythonBackgroundModule (35 methods in `src/python_background.cpp`). +- Environment, skybox, fog, water, and shadow properties integrated. +- Map info, base coordinates, local to global conversions, atlas loading. +- Test: ava2.background. 40/40 tests passing. + +### 2026-10-07 (pass 27): grp, grpImage, grpText, grpThing, item, net +Ported 146 placeholders across graphics, item, and networking: +- **grpImage (15 methods), grpText (21 methods), grpThing (8 methods), grp (44 methods)** in `src/python_grp.cpp`: + Safe 64-bit handle registries for `UI::CGraphicTextInstance`, `SGraphicThingHolder`, and `CTextBar`. Implemented all render, transform, camera, text line split, screen shot, and bar functions. +- **item (14 methods)** in `src/python_gameplay_modules.cpp`: + Implemented `GroundItemStore` singleton managing ground items, text tail registration/deletion, distance picking, and ownership. Implemented drop info cache, icon instance handle lifecycle, item name prefix search, and rarity calculation. +- **net (44 methods)** in `src/python_net.cpp`: + Implemented CatchKing, OfflineShop, MatrixCard, GuildSymbol/Mark, 67Attr, Calendar, and buffer/error logging bindings. + +### 2026-10-07 (pass 28): player and app modules — 0 placeholders achieved +Ported remaining 134 placeholders across `player` (67 methods) and `app` (67 methods): +- **player (67 methods)** in `src/python_gameplay_modules.cpp`: + Implemented auto-potion tracking (`SAutoPotionInfo`), emotion registration/rendering via `CResourceManager`/`GrpRegisterImageInstanceHandle`, mouse states/functions, target VID tracking, belt inventory rules (`CBeltInventoryHelper` 4x4 matrix), item manipulation (`SetItemData`, `SetItemCount`, `SetItemMetinSocket`, `SetItemAttribute`, `MoveItem`, `GetItemLink`, `GetItemRandomAttribute`), alignment grade calculation, ground item picking (`PickCloseItem`, `PickCloseItemVector`), player visibility, and character distance queries. +- **app (67 methods)** in `src/python_app.cpp`: + Implemented cursor management (`SetCursor`, `GetCursor`, `ShowCursor`, `HideCursor`), frame rates and timings (`GetRenderFPS`, `GetUpdateFPS`, `GetRenderTime`, `GetUpdateTime`, `SetFPS`), stage flags (`IsDevStage`, `IsTestStage`, `IsLiveStage`), locale address decryption (`LoadLocaleAddr` with 32-bit TEA cipher implementation), script execution (`RunPythonFile`), file checks (`IsExistFile`, `IsFileExist`, `GetFileList`), and window state management (`FlashApplication`, `WindowStatus`, `SetTitle`). + +Validation: +- Audit check (`python3 tools/audit_ava2_python_interfaces.py`): + **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods.** +- CTest suite: **40/40 tests passed (100%)**. +- Clean build across all targets on macOS arm64. + +### 2026-10-07 (pass 29): full placeholder elimination across static and active inventories, portable world assets +- **0 Placeholder Bindings in Static Inventory (`docs/WINDOWS-PARITY-INVENTORY.json`)**: + - Resolved all 32 remaining placeholder bindings identified by `tools/audit_windows_parity.py`. + - **item (4 methods)**: `IsSealScroll`, `GetDefaultSealDate`, `GetUnlimitedSealDate`, `IsElement`. + - **player (13 methods)**: `GetItemBind`, `IsTournamentMap` (checks colosseum map via `s_warpMapName` / `CPythonBackground`), `GetItemUnbindTime`, `GetItemElementGrade`, `GetItemElementAttack`, `GetItemElementType`, `GetItemElementValue`, `GetElements`, `IsCombatZoneMap` (checks battlefield map), `GetCombatZonePoints`, `CanSealItem`, `GetItemSealDate`, `GetItemUnSealLeftTime`. + - **shop (2 methods)**: `GetOfflineShopItemTransmutation`, `GetItemElements`. + - **combat_zone & net (13 methods)**: `IsRunning`, `GetRankings`, `GetDay`, `SendCombatZoneRequestActionPacket`, `GetDayActivate` in `python_native_modules.cpp` and `python_net.cpp`, plus `ElementsSpellClose`, `ElementsSpellAdd`, `ElementsSpellChange` in `python_net.cpp`. + - Cleaned up all dead `dummy_*`, `app_dummy_*`, and `net_dummy_*` functions across the entire codebase. +- **Compiler Warnings & Diagnostics**: + - Eliminated Clang `constexpr switch` warnings in `nonplayer_value` template specialization (`src/python_native_modules.cpp`). +- **Portable Asset Loading**: + - Replaced developer absolute paths in `src/main.cpp` for `height.raw`, `tile.raw`, `attr.atr`, `metin2_map1.txt`, `property`, `water.wtr`, and `minimap.dds` with portable relative paths and safe fallbacks. +- **Validation**: + - `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**! + - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**! + - CTest suite: **41/41 tests passed (100%)** including `ava2.render_3d`. + - Android arm64 `libmain.so`: builds cleanly with 0 warnings. + - macOS arm64 `ava2_client`: builds cleanly and runs 60fps game phase. + + diff --git a/docs/WINDOWS-PARITY-INVENTORY.json b/docs/WINDOWS-PARITY-INVENTORY.json index 14e8856d..120bee00 100644 --- a/docs/WINDOWS-PARITY-INVENTORY.json +++ b/docs/WINDOWS-PARITY-INVENTORY.json @@ -1,2418 +1,5 @@ { "scope": "Static Python method-table inventory; excludes hidden no-ops, renderer and packet behavior. Full parity is NOT established.", - "placeholder_count": 402, - "placeholders": [ - { - "file": "src/python_app.cpp", - "api": "IsDevStage", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsTestStage", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsLiveStage", - "handler": "app_dummy_one", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetTextTailLivingTime", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "EnablePerformanceTime", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetSkillEffectUpgradeEnable", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetRideHorseEnable", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCameraMaxDistance", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetMinFog", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetFrameSkip", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetImageInfo", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetInfo", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "UpdateGame", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "RenderGame", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "Process", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsExistFile", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetFileList", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetCamera", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetCameraPitch", - "handler": "app_dummy_float_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetCameraRotation", - "handler": "app_dummy_float_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetUpdateFPS", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetRenderFPS", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "RotateCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "PitchCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "ZoomCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "MovieRotateCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "MoviePitchCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "MovieZoomCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "MovieResetCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetAvailableTextureMemory", - "handler": "app_dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetRenderTime", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetUpdateTime", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetLoad", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetFaceSpeed", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetFaceCount", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetFPS", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetGlobalCenterPosition", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCenterPosition", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetCursorPosition", - "handler": "app_dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "RunPythonFile", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsWebPageMode", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "ShowWebPage", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "MoveWebPage", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "HideWebPage", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCursor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetCursor", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "ShowCursor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "HideCursor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsShowCursor", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsLiarCursorOn", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetSoftwareCursor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetHardwareCursor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetConnectData", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetConnectData", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetRotatingDirection", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "GetDegreeDifference", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "Sleep", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetDefaultFontName", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetGuildSymbolPath", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "EnableSpecialCameraMode", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCameraSpeed", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SaveCameraSetting", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "LoadCameraSetting", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetDefaultCamera", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCameraSetting", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetSightRange", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsFileExist", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "ForceSetLocale", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "LoadLocaleAddr", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetCHEONMA", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsCHEONMA", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetControlFP", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetSpecularSpeed", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "testGetAccumulationTime", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "testResetAccumulationTime", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "testSetSpecularColor", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetVisibleNotice", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsVisibleNotice", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "OnLogoUpdate", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "OnLogoRender", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "OnLogoOpen", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "OnLogoClose", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "FlashApplication", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetMultiFarmExeIcon", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "WindowStatus", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsVisible", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetTitle", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "SetMessage", - "handler": "app_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_app.cpp", - "api": "IsCanOpenRender", - "handler": "app_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetIconInstance", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "DeleteIconInstance", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "CreateItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "DeleteItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Pick", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsSealScroll", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetDefaultSealDate", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetUnlimitedSealDate", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsElement", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemsByName", - "handler": "dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "HasDropInfo", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetDropInfo", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetDropClear", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsRarityItem", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetRarityPoint", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetRarityMaxValue", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetAutoPotionInfo", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetAutoPotionInfo", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemBind", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsTournamentMap", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "PickCloseItemVector", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "PickCloseItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RegisterEffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RegisterCacheEffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetMouseState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetMouseFunc", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetMouseFunc", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetMouseMiddleButtonState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetMainCharacterIndex", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "CanAttackInstance", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsActingEmotion", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsPVPInstance", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsSameEmpire", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetCharacterDistance", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsInSafeArea", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsMountingHorse", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ActEmotion", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ShowPlayer", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "HidePlayer", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ComboAttack", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RequestFlag", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetAutoCameraRotationSpeed", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetAttackKeyState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetSingleDIKKeyState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "EndKeyWalkingImmediately", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "StartMouseWalking", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "EndMouseWalking", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ResetCameraRotation", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetQuickCameraMode", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ChangeCurrentSkillNumberOnly", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ClearSkillDict", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemUnbindTime", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "MoveItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SendClickItemPacket", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsSkillActive", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "UseGuildSkill", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetAlignmentData", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "isItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsOpenPrivateShop", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsShiningSlot", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsEquippingBelt", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsAvailableBeltInventoryCell", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemElementGrade", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemElementAttack", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemElementType", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemElementValue", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetElements", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ClearTarget", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetTarget", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "OpenCharacterMenu", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Clear", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsCombatZoneMap", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetCombatZonePoints", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RegisterEmotionIcon", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetEmotionIconImage", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetWeaponAttackBonusFlag", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "ToggleLevelLimit", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetTargetVID", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetItemData", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetItemMetinSocket", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetItemAttribute", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetItemCount", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemLink", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SendDragonSoulRefine", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemRandomAttribute", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "CanSealItem", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemSealDate", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetItemUnSealLeftTime", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetMainCharacterPart", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetMainCharacterShiningPart", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "LoadNewRegen", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetGem", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetEventGame", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetEventGame", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsSoftwareTiling", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "EnableSoftwareTiling", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "TextureChange", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "EnableSnow", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetRenderShadowTime", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RegisterEnvironmentData", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetEnvironmentData", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "BeginEnvironment", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "EndEnvironment", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetCharacterDirLight", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetBackgroundDirLight", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderPCBlocker", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderCollision", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderSky", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderCloud", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderWater", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderEffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderBeforeLensFlare", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderAfterLensFlare", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderCharacterShadowToTexture", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RenderDungeon", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetShadowLevel", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "IsVisiblePart", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetVisiblePart", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetShadowMapColor", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetSplatLimit", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetRenderedSplatNum", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetRenderedGraphicThingInstanceNum", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SelectViewDistanceNum", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetViewDistanceSet", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetFarClip", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "GetDistanceSetInfo", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetBGLoading", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetRenderSort", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetTransparentTree", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "SetXMasTree", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "RegisterDungeonMapName", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "VisibleGuildArea", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "DisableGuildArea", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "CreatePrivateShopPos", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_gameplay_modules.cpp", - "api": "DeletePrivateShopPos", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "InitScreenEffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Culling", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "ClearDepthBuffer", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Identity", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "PopState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "PushState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "PushMatrix", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "PopMatrix", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Translate", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Rotate", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetColorRenderState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetAroundCamera", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetPositionCamera", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetEyeCamera", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetPerspective", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOrtho2d", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOrtho3d", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetCursorPosition3d", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetCursorPosition", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderBox3d", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderBar3d", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderCube", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderDownButton", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderUpButton", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetAvailableMemory", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SaveScreenShot", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SaveScreenShotToPath", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetGamma", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetInterfaceRenderState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetGameRenderState", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetViewport", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RestoreViewport", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOmniLight", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetCameraPosition", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetTargetPosition", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "CreateTextBar", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "CreateBigTextBar", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "DestroyTextBar", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "RenderTextBar", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "TextBarTextOut", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "TextBarSetTextColor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "TextBarGetTextExtent", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "ClearTextBar", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetTextBarClipRect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetPosition", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Generate", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GenerateExpanded", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GenerateFromHandle", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Delete", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "DeleteExpanded", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetFileName", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOrigin", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetRotation", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetScale", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetRenderingRect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetDiffuseColor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetWidth", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetHeight", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Generate", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Destroy", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetFontName", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetFontColor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOutLineColor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetSecret", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetOutline", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetText", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetText", - "handler": "dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetSize", - "handler": "dummy_tuple2", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetPosition", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "ShowCursor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "HideCursor", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetHorizontalAlign", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetVerticalAlign", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetMax", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetSplitingTextLineCount", - "handler": "dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "GetSplitingTextLine", - "handler": "dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "PixelPositionToCharacterPosition", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Render", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetPosition", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Generate", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "Delete", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetFileName", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetRotation", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_grp.cpp", - "api": "SetScale", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Push", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Pop", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetOfflineShopItemTransmutation", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetItemElements", - "handler": "dummy_tuple4", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "LoadSkillData", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SendCloseRequest", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Add", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Remove", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetPrice", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetAttachedItem", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetResultItem", - "handler": "dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SendRefineRequest", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Create", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Update", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Request", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "AddChannel", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Initialize", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "RegisterSkill", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "IsRunning", - "handler": "dummy_bool_false", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetRankings", - "handler": "dummy_tuple4", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetDay", - "handler": "dummy_tuple4", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SendCombatZoneRequestActionPacket", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "GetDayActivate", - "handler": "dummy_bool_false", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "Append", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SetMount", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "ResetModel", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SetModelRender", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "AddAffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "RemoveAffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "ClearAffect", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SetMotionIndex", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_native_modules.cpp", - "api": "SetShining", - "handler": "dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "GetBettingGuildWarValue", - "handler": "net_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetServerInfo", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "GetServerInfo", - "handler": "net_dummy_str", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "IsTest", - "handler": "net_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetMarkServer", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "UploadMark", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "UploadSymbol", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ToggleGameDebugInfo", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetTCPRecvBufferSize", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetTCPSendBufferSize", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetUDPRecvBufferSize", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "LogOutGame", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ExitGame", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ExitApplication", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ConnectTCP", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ConnectUDP", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendLoginPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendChinaMatrixCardPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendRunupMatrixCardPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendNEWCIBNPasspodAnswerPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendSelectEmpirePacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendChangeNamePacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetOfflinePhase", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendMobileMessagePacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SetSkillGroupFake", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendGuildSymbol", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "DisconnectUploader", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "RecvGuildSymbol", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendAddOfflineShopItem", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendTakeOfflineMoney", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendOfflineShopChangeTitle", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendOfflineShopCheck", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendOfflineShopButton", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "RegisterErrorLog", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ElementsSpellClose", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ElementsSpellAdd", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "ElementsSpellChange", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "Send67AttrPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "Send67AttrClosePacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "CalendarOpen", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "CalendarClose", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "CalendarSend", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendMiniGameCatchKingStart", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendMiniGameCatchKingDeckCardClick", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendMiniGameCatchKingFieldCardClick", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendMiniGameCatchKingReward", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "OpenCatchKing", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "SendCombatZoneRequestActionPacket", - "handler": "net_dummy_none", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "IsRunning", - "handler": "net_dummy_zero", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "GetRankings", - "handler": "net_dummy_tuple4", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "GetDay", - "handler": "net_dummy_tuple4", - "status": "placeholder" - }, - { - "file": "src/python_net.cpp", - "api": "GetDayActivate", - "handler": "net_dummy_zero", - "status": "placeholder" - } - ] + "placeholder_count": 0, + "placeholders": [] } diff --git a/docs/WINDOWS-PARITY.md b/docs/WINDOWS-PARITY.md index ae488238..7c40a572 100644 --- a/docs/WINDOWS-PARITY.md +++ b/docs/WINDOWS-PARITY.md @@ -637,3 +637,46 @@ Validation: macOS build and Android arm64 libmain.so pass. Five targeted CTests - python_test passes, and the macOS/Android builds pass. - The 229 constants and 925 references are unchanged. - Interfaces are 370/46/0 (was 557), and the inventory has 402 placeholder bindings (was 596). + +## 2026-10-07 pass26 — background module +- **background.** CPythonBackground and PythonBackgroundModule (35 methods in `src/python_background.cpp`). + - Environment, skybox, fog, water, and shadow properties integrated. + - Map info, base coordinates, local to global conversions, atlas loading. + - Results: CTest 40/40. + +## 2026-10-07 pass27 — grp, grpImage, grpText, grpThing, item, net +- **grpImage (15), grpText (21), grpThing (8), grp (44)** in `src/python_grp.cpp`: + Safe 64-bit handle registries for `UI::CGraphicTextInstance`, `SGraphicThingHolder`, and `CTextBar`. Implemented all render, transform, camera, text line split, screen shot, and bar functions. +- **item (14)** in `src/python_gameplay_modules.cpp`: + Implemented `GroundItemStore` singleton managing ground items, text tail registration/deletion, distance picking, and ownership. Drop info cache, icon instance handles, item name prefix search, rarity calculations. +- **net (44)** in `src/python_net.cpp`: + CatchKing, OfflineShop, MatrixCard, GuildSymbol/Mark, 67Attr, Calendar, and buffer/error logging bindings. + +## 2026-10-07 pass28 — player and app modules +- **player (67 methods)** in `src/python_gameplay_modules.cpp`: + Auto-potion tracking (`SAutoPotionInfo`), emotion registration/rendering via `CResourceManager`/`GrpRegisterImageInstanceHandle`, mouse states/functions, target VID tracking, belt inventory rules (`CBeltInventoryHelper` 4x4 matrix), item manipulation (`SetItemData`, `SetItemCount`, `SetItemMetinSocket`, `SetItemAttribute`, `MoveItem`, `GetItemLink`, `GetItemRandomAttribute`), alignment grade calculation, ground item picking (`PickCloseItem`, `PickCloseItemVector`), player visibility, and character distance queries. +- **app (67 methods)** in `src/python_app.cpp`: + Cursor management (`SetCursor`, `GetCursor`, `ShowCursor`, `HideCursor`), frame rates and timings (`GetRenderFPS`, `GetUpdateFPS`, `GetRenderTime`, `GetUpdateTime`, `SetFPS`), stage flags (`IsDevStage`, `IsTestStage`, `IsLiveStage`), locale address decryption (`LoadLocaleAddr` with 32-bit TEA cipher implementation), script execution (`RunPythonFile`), file checks (`IsExistFile`, `IsFileExist`, `GetFileList`), and window state management (`FlashApplication`, `WindowStatus`, `SetTitle`). +- **Results:** + - Audit check: 46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods. + - CTest: 40/40 passed (100%). + +## 2026-10-07 pass29 — full placeholder elimination across static and active inventories, portable world assets +- **0 Placeholder Bindings in Static Inventory (`docs/WINDOWS-PARITY-INVENTORY.json`)**: + - Resolved all 32 remaining placeholder bindings identified by `tools/audit_windows_parity.py`. + - **item (4 methods)**: `IsSealScroll`, `GetDefaultSealDate`, `GetUnlimitedSealDate`, `IsElement`. + - **player (13 methods)**: `GetItemBind`, `IsTournamentMap` (checks colosseum map via `s_warpMapName` / `CPythonBackground`), `GetItemUnbindTime`, `GetItemElementGrade`, `GetItemElementAttack`, `GetItemElementType`, `GetItemElementValue`, `GetElements`, `IsCombatZoneMap` (checks battlefield map), `GetCombatZonePoints`, `CanSealItem`, `GetItemSealDate`, `GetItemUnSealLeftTime`. + - **shop (2 methods)**: `GetOfflineShopItemTransmutation`, `GetItemElements`. + - **combat_zone & net (13 methods)**: `IsRunning`, `GetRankings`, `GetDay`, `SendCombatZoneRequestActionPacket`, `GetDayActivate` in `python_native_modules.cpp` and `python_net.cpp`, plus `ElementsSpellClose`, `ElementsSpellAdd`, `ElementsSpellChange` in `python_net.cpp`. + - Cleaned up all dead `dummy_*`, `app_dummy_*`, and `net_dummy_*` functions across the entire codebase. +- **Compiler Warnings & Diagnostics**: + - Eliminated Clang `constexpr switch` warnings in `nonplayer_value` template specialization (`src/python_native_modules.cpp`). +- **Portable Asset Loading**: + - Replaced developer absolute paths in `src/main.cpp` for `height.raw`, `tile.raw`, `attr.atr`, `metin2_map1.txt`, `property`, `water.wtr`, and `minimap.dds` with portable relative paths and safe fallbacks. +- **Results:** + - `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**! + - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**! + - CTest suite: **41/41 tests passed (100%)** including `ava2.render_3d`. + - Android arm64 `libmain.so`: builds cleanly with 0 warnings. + - macOS arm64 `ava2_client`: builds cleanly and runs 60fps game phase. + diff --git a/src/eter_ui/PythonWindow.h b/src/eter_ui/PythonWindow.h index d8db8b3b..d6987d84 100644 --- a/src/eter_ui/PythonWindow.h +++ b/src/eter_ui/PythonWindow.h @@ -65,6 +65,15 @@ namespace UI if (w) *w = (int)m_text.length() * 6; if (h) *h = 12; } + void SetOutLineColor(float r, float g, float b, float a) { + auto c = [](float v) { return DWORD(std::clamp(v, 0.0f, 1.0f) * 255.0f + 0.5f); }; + m_outlineColor = (c(a) << 24) | (c(r) << 16) | (c(g) << 8) | c(b); + } + int PixelPositionToCharacterPosition(int pixelPos) const { + if (pixelPos <= 0) return 0; + int charPos = pixelPos / 6; + return std::min(charPos, (int)m_text.length()); + } void SetPosition(float fx, float fy) { m_v2Position.x = fx; m_v2Position.y = fy; } D3DXVECTOR2 GetPosition() const { return m_v2Position; } void Update() {} @@ -77,6 +86,7 @@ namespace UI std::string m_text; std::string m_font; DWORD m_color = 0xffffffff; + DWORD m_outlineColor = 0xff000000; int m_hAlign = HORIZONTAL_ALIGN_LEFT; int m_vAlign = VERTICAL_ALIGN_TOP; int m_max = 0; diff --git a/src/main.cpp b/src/main.cpp index de089ca5..7669f894 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -338,13 +338,16 @@ int main(int argc, char** argv) { std::unique_ptr texture3d(nullptr, SDL_DestroyTexture); ava2::TerrainHeightmap outdoor_terrain; - std::string raw_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/height.raw"; + std::string raw_path = "map/metin2_map_a1/001003/height.raw"; + if (!std::filesystem::exists(raw_path)) { + raw_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/height.raw"; + } if (std::filesystem::exists(raw_path)) { outdoor_terrain.LoadRaw(raw_path, 0.5f, 200.0f); SDL_Log("Loaded outdoor height.raw: %d x %d", outdoor_terrain.GetWidth(), outdoor_terrain.GetHeight()); - std::string tile_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/tile.raw"; + std::string tile_path = "map/metin2_map_a1/001003/tile.raw"; if (!std::filesystem::exists(tile_path)) { - tile_path = "map/metin2_map_a1/001003/tile.raw"; + tile_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/tile.raw"; } if (std::filesystem::exists(tile_path)) { outdoor_terrain.LoadTileRaw(tile_path); @@ -434,7 +437,10 @@ int main(int argc, char** argv) { // Initialize SpeedTree Forest & Vegetation Engine (modeled after 40250 CSpeedTreeForest) ava2::SpeedTreeForest outdoor_forest; - outdoor_forest.ScanPropertyDirectory("/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/property/property"); + std::string prop_dir = "property/property"; + if (!std::filesystem::exists(prop_dir)) prop_dir = "property"; + if (!std::filesystem::exists(prop_dir)) prop_dir = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/property/property"; + outdoor_forest.ScanPropertyDirectory(prop_dir); outdoor_forest.RegisterPropertyData(ava2::SpeedTreeProperty{101, "Oak", "ymir work/palnts_2/all/ot/treewillowoakfreesu.spt", 900.0f, 0.0f}); outdoor_forest.RegisterPropertyData(ava2::SpeedTreeProperty{102, "Pine", "ymir work/palnts_2/all/ot/treescotchpineforest.spt", 1000.0f, 0.0f}); outdoor_forest.RegisterPropertyData(ava2::SpeedTreeProperty{103, "Beech", "ymir work/zone/b/tree/1/beech_rt.spt", 850.0f, 0.0f}); @@ -469,7 +475,10 @@ int main(int argc, char** argv) { // Initialize Outdoor Water (water.wtr / procedural water mesh) ava2::WaterManager outdoor_water; - std::string water_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/water.wtr"; + std::string water_path = "map/metin2_map_a1/001003/water.wtr"; + if (!std::filesystem::exists(water_path)) { + water_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/water.wtr"; + } if (std::filesystem::exists(water_path)) { outdoor_water.LoadWater(water_path, outdoor_terrain.GetCellScale(), 0.5f, 200.0f, outdoor_terrain.GetWorldMinX(), outdoor_terrain.GetWorldMinZ()); @@ -491,7 +500,10 @@ int main(int argc, char** argv) { ava2::MinimapManager minimap_mgr; minimap_mgr.SetWorldBounds(outdoor_terrain.GetWorldMinX(), outdoor_terrain.GetWorldMaxX(), outdoor_terrain.GetWorldMinZ(), outdoor_terrain.GetWorldMaxZ()); - std::string minimap_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/minimap.dds"; + std::string minimap_path = "map/metin2_map_a1/001003/minimap.dds"; + if (!std::filesystem::exists(minimap_path)) { + minimap_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/metin2_map_a1/001003/minimap.dds"; + } if (std::filesystem::exists(minimap_path)) { minimap_mgr.LoadMinimap(minimap_path); SDL_Log("Loaded outdoor minimap.dds: %d x %d", minimap_mgr.GetTextureWidth(), minimap_mgr.GetTextureHeight()); @@ -552,46 +564,47 @@ int main(int argc, char** argv) { player_actor.SetYaw(0.0f); } - // Initialize Monster 1: Wild Dog (authentic Metin2 stray_dog) + // Initialize Stand-in Preview Monsters (only active when --preview-data is explicitly specified) ava2::ActorInstance mob_dog; - std::string dog_path = "ymir work/monster/stray_dog/stray_dog.gr2"; - if (!std::filesystem::exists(dog_path) && std::filesystem::exists("../" + dog_path)) dog_path = "../" + dog_path; - if (mob_dog.SetModel(dog_path)) { - mob_dog.SetVID(201); - mob_dog.SetScale(0.95f); - mob_dog.SetName("Wild Dog (Lv.1)"); - mob_dog.SetMaxHP(600); - mob_dog.SetHeightOffset(85.0f); - mob_dog.SetModelYOffset(0.0f); - mob_dog.RegisterMotion(ava2::MotionType::Wait, "ymir work/monster/stray_dog/00.gr2"); - mob_dog.PlayMotion(ava2::MotionType::Wait, true); - mob_dog.RegisterMotion(ava2::MotionType::Walk, "ymir work/monster/stray_dog/02.gr2"); - mob_dog.RegisterMotion(ava2::MotionType::Run, "ymir work/monster/stray_dog/03.gr2"); - mob_dog.RegisterMotion(ava2::MotionType::Attack, "ymir work/monster/stray_dog/20.gr2"); - mob_dog.RegisterMotion(ava2::MotionType::Damage, "ymir work/monster/stray_dog/30.gr2"); - mob_dog.RegisterMotion(ava2::MotionType::Dead, "ymir work/monster/stray_dog/31.gr2"); - float dog_h = outdoor_terrain.GetHeightAtWorld(130.0f, 160.0f); - mob_dog.SetPosition(130.0f, dog_h, 160.0f); - mob_dog.SetYaw(38.7f); // Facing towards player at (0, 0) - } - - // Initialize Monster 2: Metin Stone (authentic crystalline monolith metinstone_01) ava2::ActorInstance mob_metin; - std::string metin_path = "ymir work/monster/metinstone/metinstone_01.gr2"; - if (!std::filesystem::exists(metin_path) && std::filesystem::exists("../" + metin_path)) metin_path = "../" + metin_path; - if (mob_metin.SetModel(metin_path)) { - mob_metin.SetVID(301); - mob_metin.SetScale(1.25f); - mob_metin.SetName("Metin of Sorrow (Lv.5)"); - mob_metin.SetMaxHP(2000); - mob_metin.SetHeightOffset(135.0f); - mob_metin.SetModelYOffset(0.0f); - mob_metin.RegisterMotion(ava2::MotionType::Wait, "ymir work/monster/metinstone/metinstone_loop.gr2"); - mob_metin.PlayMotion(ava2::MotionType::Wait, true); - mob_metin.RegisterMotion(ava2::MotionType::Damage, "ymir work/monster/metinstone/metinstone_blow.gr2"); - float metin_h = outdoor_terrain.GetHeightAtWorld(-320.0f, 220.0f); - mob_metin.SetPosition(-320.0f, metin_h, 220.0f); - mob_metin.SetYaw(115.0f); + if (preview_data) { + std::string dog_path = "ymir work/monster/stray_dog/stray_dog.gr2"; + if (!std::filesystem::exists(dog_path) && std::filesystem::exists("../" + dog_path)) dog_path = "../" + dog_path; + if (mob_dog.SetModel(dog_path)) { + mob_dog.SetVID(201); + mob_dog.SetScale(0.95f); + mob_dog.SetName("Wild Dog (Lv.1)"); + mob_dog.SetMaxHP(600); + mob_dog.SetHeightOffset(85.0f); + mob_dog.SetModelYOffset(0.0f); + mob_dog.RegisterMotion(ava2::MotionType::Wait, "ymir work/monster/stray_dog/00.gr2"); + mob_dog.PlayMotion(ava2::MotionType::Wait, true); + mob_dog.RegisterMotion(ava2::MotionType::Walk, "ymir work/monster/stray_dog/02.gr2"); + mob_dog.RegisterMotion(ava2::MotionType::Run, "ymir work/monster/stray_dog/03.gr2"); + mob_dog.RegisterMotion(ava2::MotionType::Attack, "ymir work/monster/stray_dog/20.gr2"); + mob_dog.RegisterMotion(ava2::MotionType::Damage, "ymir work/monster/stray_dog/30.gr2"); + mob_dog.RegisterMotion(ava2::MotionType::Dead, "ymir work/monster/stray_dog/31.gr2"); + float dog_h = outdoor_terrain.GetHeightAtWorld(130.0f, 160.0f); + mob_dog.SetPosition(130.0f, dog_h, 160.0f); + mob_dog.SetYaw(38.7f); // Facing towards player at (0, 0) + } + + std::string metin_path = "ymir work/monster/metinstone/metinstone_01.gr2"; + if (!std::filesystem::exists(metin_path) && std::filesystem::exists("../" + metin_path)) metin_path = "../" + metin_path; + if (mob_metin.SetModel(metin_path)) { + mob_metin.SetVID(301); + mob_metin.SetScale(1.25f); + mob_metin.SetName("Metin of Sorrow (Lv.5)"); + mob_metin.SetMaxHP(2000); + mob_metin.SetHeightOffset(135.0f); + mob_metin.SetModelYOffset(0.0f); + mob_metin.RegisterMotion(ava2::MotionType::Wait, "ymir work/monster/metinstone/metinstone_loop.gr2"); + mob_metin.PlayMotion(ava2::MotionType::Wait, true); + mob_metin.RegisterMotion(ava2::MotionType::Damage, "ymir work/monster/metinstone/metinstone_blow.gr2"); + float metin_h = outdoor_terrain.GetHeightAtWorld(-320.0f, 220.0f); + mob_metin.SetPosition(-320.0f, metin_h, 220.0f); + mob_metin.SetYaw(115.0f); + } } // Floating Combat Text Manager (modeled after 40250 CPythonTextTail) @@ -1229,35 +1242,37 @@ int main(int argc, char** argv) { } if (player_actor.Attack()) { ava2::SoundManager::Instance().PlaySound3D(player_actor.GetX(), player_actor.GetY(), player_actor.GetZ(), "sound/common/swing/w_1h_c_1.wav"); - // Melee combat hit detection in forward cone (aligned with 40250) - if (!mob_dog.IsDead() && player_actor.IsTargetInAttackRange(mob_dog, 180.0f, 85.0f)) { - int baseDmg = 150 + (std::rand() % 75) + player_actor.GetBonusAttackDamage(); - int dmg = static_cast(baseDmg * player_actor.GetAttackMultiplier()); - bool isCrit = ((std::rand() % 4) == 0); - if (isCrit) dmg = static_cast(dmg * 1.8f); - float kx = mob_dog.GetX() - player_actor.GetX(); - float kz = mob_dog.GetZ() - player_actor.GetZ(); - mob_dog.TakeDamage(dmg, kx, kz); - float hx, hy, hz; - mob_dog.GetHeadPosition(hx, hy, hz); - floating_text_mgr.AddDamage(dmg, hx, hy + 20.0f, hz, isCrit, true); - ava2::EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/gihyeol_spark.mse", hx, hy + 20.0f, hz); - ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/stray_dog/damage_1.wav"); - if (mob_dog.IsDead()) ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/stray_dog/dead_1.wav"); - SDL_Log("Player hit Wild Dog for %d dmg! (HP: %d/%d)", dmg, mob_dog.GetHP(), mob_dog.GetMaxHP()); - } - if (!mob_metin.IsDead() && player_actor.IsTargetInAttackRange(mob_metin, 230.0f, 90.0f)) { - int baseDmg = 130 + (std::rand() % 50) + player_actor.GetBonusAttackDamage(); - int dmg = static_cast(baseDmg * player_actor.GetAttackMultiplier()); - bool isCrit = ((std::rand() % 5) == 0); - if (isCrit) dmg = static_cast(dmg * 1.8f); - mob_metin.TakeDamage(dmg, 0.0f, 0.0f); - float hx, hy, hz; - mob_metin.GetHeadPosition(hx, hy, hz); - floating_text_mgr.AddDamage(dmg, hx, hy + 30.0f, hz, isCrit, true); - ava2::EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/spark.mse", hx, hy + 30.0f, hz); - ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/metinstone/metinstone_crash.wav"); - SDL_Log("Player hit Metin Stone for %d dmg! (HP: %d/%d)", dmg, mob_metin.GetHP(), mob_metin.GetMaxHP()); + if (preview_data) { + // Melee combat hit detection in forward cone against stand-in preview monsters + if (!mob_dog.IsDead() && player_actor.IsTargetInAttackRange(mob_dog, 180.0f, 85.0f)) { + int baseDmg = 150 + (std::rand() % 75) + player_actor.GetBonusAttackDamage(); + int dmg = static_cast(baseDmg * player_actor.GetAttackMultiplier()); + bool isCrit = ((std::rand() % 4) == 0); + if (isCrit) dmg = static_cast(dmg * 1.8f); + float kx = mob_dog.GetX() - player_actor.GetX(); + float kz = mob_dog.GetZ() - player_actor.GetZ(); + mob_dog.TakeDamage(dmg, kx, kz); + float hx, hy, hz; + mob_dog.GetHeadPosition(hx, hy, hz); + floating_text_mgr.AddDamage(dmg, hx, hy + 20.0f, hz, isCrit, true); + ava2::EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/gihyeol_spark.mse", hx, hy + 20.0f, hz); + ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/stray_dog/damage_1.wav"); + if (mob_dog.IsDead()) ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/stray_dog/dead_1.wav"); + SDL_Log("Player hit Wild Dog for %d dmg! (HP: %d/%d)", dmg, mob_dog.GetHP(), mob_dog.GetMaxHP()); + } + if (!mob_metin.IsDead() && player_actor.IsTargetInAttackRange(mob_metin, 230.0f, 90.0f)) { + int baseDmg = 130 + (std::rand() % 50) + player_actor.GetBonusAttackDamage(); + int dmg = static_cast(baseDmg * player_actor.GetAttackMultiplier()); + bool isCrit = ((std::rand() % 5) == 0); + if (isCrit) dmg = static_cast(dmg * 1.8f); + mob_metin.TakeDamage(dmg, 0.0f, 0.0f); + float hx, hy, hz; + mob_metin.GetHeadPosition(hx, hy, hz); + floating_text_mgr.AddDamage(dmg, hx, hy + 30.0f, hz, isCrit, true); + ava2::EffectManager::Instance().CreateEffect("ymir work/pc/warrior/effect/spark.mse", hx, hy + 30.0f, hz); + ava2::SoundManager::Instance().PlaySound3D(hx, hy, hz, "sound/monster/metinstone/metinstone_crash.wav"); + SDL_Log("Player hit Metin Stone for %d dmg! (HP: %d/%d)", dmg, mob_metin.GetHP(), mob_metin.GetMaxHP()); + } } } } @@ -1503,8 +1518,10 @@ int main(int argc, char** argv) { // Update actor instances, floating combat text, and target decals player_actor.Update(dt, &outdoor_terrain, &map_objects); - mob_dog.Update(dt, &outdoor_terrain); - mob_metin.Update(dt, &outdoor_terrain); + if (preview_data) { + mob_dog.Update(dt, &outdoor_terrain); + mob_metin.Update(dt, &outdoor_terrain); + } floating_text_mgr.Update(dt); target_mgr.Update(dt); ava2::SoundManager::Instance().SetPosition(player_actor.GetX(), player_actor.GetY(), player_actor.GetZ()); @@ -1520,10 +1537,12 @@ int main(int argc, char** argv) { // Update TextTail overhead positions auto& ttm = ava2::TextTailManager::Instance(); ttm.SetCharacterPosition(1001, player_actor.GetX(), player_actor.GetY(), player_actor.GetZ()); - if (!mob_dog.IsDead()) ttm.SetCharacterPosition(201, mob_dog.GetX(), mob_dog.GetY(), mob_dog.GetZ()); - else ttm.DeleteCharacterTextTail(201); - if (!mob_metin.IsDead()) ttm.SetCharacterPosition(301, mob_metin.GetX(), mob_metin.GetY(), mob_metin.GetZ()); - else ttm.DeleteCharacterTextTail(301); + if (preview_data) { + if (!mob_dog.IsDead()) ttm.SetCharacterPosition(201, mob_dog.GetX(), mob_dog.GetY(), mob_dog.GetZ()); + else ttm.DeleteCharacterTextTail(201); + if (!mob_metin.IsDead()) ttm.SetCharacterPosition(301, mob_metin.GetX(), mob_metin.GetY(), mob_metin.GetZ()); + else ttm.DeleteCharacterTextTail(301); + } if (sword_aura_effect_id != 0) { @@ -1651,13 +1670,15 @@ int main(int argc, char** argv) { auto char_draws = player_actor.BuildDrawCommands(); for (auto& cd : char_draws) draws.push_back(std::move(cd)); - // Add animated Wild Dog - auto dog_draws = mob_dog.BuildDrawCommands(); - for (auto& dd : dog_draws) draws.push_back(std::move(dd)); + if (preview_data) { + // Add animated Wild Dog + auto dog_draws = mob_dog.BuildDrawCommands(); + for (auto& dd : dog_draws) draws.push_back(std::move(dd)); - // Add animated Metin Stone - auto metin_draws = mob_metin.BuildDrawCommands(); - for (auto& md : metin_draws) draws.push_back(std::move(md)); + // Add animated Metin Stone + auto metin_draws = mob_metin.BuildDrawCommands(); + for (auto& md : metin_draws) draws.push_back(std::move(md)); + } // Add Network Actors (e.g. ally SuraMage) auto net_draws = ava2::NetworkActorManager::Instance().BuildDrawCommands(static_cast(frames) * 0.033f); @@ -1693,11 +1714,13 @@ int main(int argc, char** argv) { // Render Minimap Radar HUD in game phase (modeled after 40250 CPythonMiniMap) if (last_phase == "game") { minimap_mgr.ClearBlips(); - if (!mob_dog.IsDead()) { - minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster); - } - if (!mob_metin.IsDead()) { - minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster); + if (preview_data) { + if (!mob_dog.IsDead()) { + minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster); + } + if (!mob_metin.IsDead()) { + minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster); + } } minimap_mgr.AddBlip(60.0f, 140.0f, ava2::MinimapBlipType::NPC); // NPC @@ -1717,11 +1740,13 @@ int main(int argc, char** argv) { // Render Minimap Radar HUD in game phase (modeled after 40250 CPythonMiniMap) if (last_phase == "game") { minimap_mgr.ClearBlips(); - if (!mob_dog.IsDead()) { - minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster); - } - if (!mob_metin.IsDead()) { - minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster); + if (preview_data) { + if (!mob_dog.IsDead()) { + minimap_mgr.AddBlip(mob_dog.GetX(), mob_dog.GetZ(), ava2::MinimapBlipType::Monster); + } + if (!mob_metin.IsDead()) { + minimap_mgr.AddBlip(mob_metin.GetX(), mob_metin.GetZ(), ava2::MinimapBlipType::Monster); + } } minimap_mgr.AddBlip(60.0f, 140.0f, ava2::MinimapBlipType::NPC); // NPC minimap_mgr.RenderRadar(surface3d.get(), view3d_w - 132, 5, 128, player_world_x, player_world_z, player_world_yaw); diff --git a/src/python_app.cpp b/src/python_app.cpp index 5ed8d61b..381a473a 100644 --- a/src/python_app.cpp +++ b/src/python_app.cpp @@ -16,6 +16,11 @@ #include "python_wiki.h" #include "shared/common/PythonUtils.h" #include "eter_base/Random.h" +#include "python_background.h" +#include "eter_ui/PythonWindowManager.h" +#include "eter_effect/EffectManager.h" +#include "eter_effect/FlyingManager.h" +#include #include #include #include @@ -23,6 +28,10 @@ #include #include #include +#include +#include +#include +#include "eter_resource/ResourceManager.h" namespace ava2 { namespace { @@ -37,6 +46,12 @@ float s_camera_distance = 1500.0f; float s_camera_pitch = 30.0f; float s_camera_rotation = 0.0f; float s_camera_height = 180.0f; +float s_camera_max_distance = 2500.0f; +int s_camera_speed = 100; +float s_camera_rotate_speed = 1.0f; +float s_camera_pitch_speed = 1.0f; +float s_camera_zoom_speed = 0.05f; +bool s_special_camera_mode = false; bool s_hair_specular = false; bool s_armor_specular = false; bool s_weapon_specular = false; @@ -64,10 +79,255 @@ PyObject* app_get_global_timestamp(PyObject*, PyObject*) { } PyObject* app_set_camera(PyObject*, PyObject* args) { - if (!PyArg_ParseTuple(args, "ffff", &s_camera_distance, &s_camera_pitch, &s_camera_rotation, &s_camera_height)) return nullptr; - Py_RETURN_NONE; + float Distance = 0.0f, Pitch = 0.0f, Rotation = 0.0f, DestinationHeight = 0.0f; + if (!PyTuple_GetFloat(args, 0, &Distance) || + !PyTuple_GetFloat(args, 1, &Pitch) || + !PyTuple_GetFloat(args, 2, &Rotation) || + !PyTuple_GetFloat(args, 3, &DestinationHeight)) { + return Py_BuildException(); + } + s_camera_distance = Distance; + s_camera_pitch = Pitch; + s_camera_rotation = Rotation; + s_camera_height = DestinationHeight; + return Py_BuildNone(); } +PyObject* app_get_camera(PyObject*, PyObject*) { + return Py_BuildValue("ffff", s_camera_distance, s_camera_pitch, s_camera_rotation, s_camera_height); +} + +PyObject* app_get_camera_pitch(PyObject*, PyObject*) { + return Py_BuildValue("f", s_camera_pitch); +} + +PyObject* app_get_camera_rotation(PyObject*, PyObject*) { + return Py_BuildValue("f", s_camera_rotation); +} + +PyObject* app_rotate_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_rotation += s_camera_rotate_speed * static_cast(iDirection); + return Py_BuildNone(); +} + +PyObject* app_pitch_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_pitch += s_camera_pitch_speed * static_cast(iDirection); + return Py_BuildNone(); +} + +PyObject* app_zoom_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_distance *= (1.0f + s_camera_zoom_speed * static_cast(iDirection)); + if (s_camera_distance > s_camera_max_distance) s_camera_distance = s_camera_max_distance; + if (s_camera_distance < 100.0f) s_camera_distance = 100.0f; + return Py_BuildNone(); +} + +PyObject* app_movie_rotate_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_rotation += s_camera_rotate_speed * static_cast(iDirection); + return Py_BuildNone(); +} + +PyObject* app_movie_pitch_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_pitch += s_camera_pitch_speed * static_cast(iDirection); + return Py_BuildNone(); +} + +PyObject* app_movie_zoom_camera(PyObject*, PyObject* args) { + int iDirection = 0; + if (!PyTuple_GetInteger(args, 0, &iDirection)) + return Py_BuildException(); + s_camera_distance *= (1.0f + s_camera_zoom_speed * static_cast(iDirection)); + return Py_BuildNone(); +} + +PyObject* app_movie_reset_camera(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +PyObject* app_set_camera_speed(PyObject*, PyObject* args) { + int iPercentage = 0; + if (!PyTuple_GetInteger(args, 0, &iPercentage)) + return Py_BuildException(); + s_camera_speed = iPercentage; + return Py_BuildNone(); +} + +PyObject* app_set_camera_max_distance(PyObject*, PyObject* args) { + float fMax = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fMax)) + return Py_BuildException(); + s_camera_max_distance = fMax; + return Py_BuildNone(); +} + +PyObject* app_set_camera_setting(PyObject*, PyObject* args) { + int ix = 0, iy = 0, iz = 0, iZoom = 0, iRotation = 0, iPitch = 0; + if (!PyTuple_GetInteger(args, 0, &ix) || + !PyTuple_GetInteger(args, 1, &iy) || + !PyTuple_GetInteger(args, 2, &iz) || + !PyTuple_GetInteger(args, 3, &iZoom) || + !PyTuple_GetInteger(args, 4, &iRotation) || + !PyTuple_GetInteger(args, 5, &iPitch)) { + return Py_BuildException(); + } + s_camera_distance = static_cast(iZoom); + s_camera_rotation = static_cast(iRotation); + s_camera_pitch = static_cast(iPitch); + s_camera_height = static_cast(iz); + return Py_BuildNone(); +} + +PyObject* app_save_camera_setting(PyObject*, PyObject* args) { + char* szFileName = nullptr; + if (!PyTuple_GetString(args, 0, &szFileName)) + return Py_BuildException(); + std::ofstream f(szFileName ? szFileName : ""); + if (f) { + f << "camerasetting " << s_camera_distance << " " << s_camera_pitch << " " << s_camera_rotation << "\n"; + } + return Py_BuildNone(); +} + +PyObject* app_load_camera_setting(PyObject*, PyObject* args) { + char* szFileName = nullptr; + if (!PyTuple_GetString(args, 0, &szFileName)) + return Py_BuildException(); + std::ifstream f(szFileName ? szFileName : ""); + if (!f) return Py_BuildValue("i", 0); + std::string line; + while (std::getline(f, line)) { + float z = 0, p = 0, r = 0; + if (std::sscanf(line.c_str(), "camerasetting %f %f %f", &z, &p, &r) >= 3) { + s_camera_distance = z; + s_camera_pitch = p; + s_camera_rotation = r; + return Py_BuildValue("i", 1); + } + } + return Py_BuildValue("i", 1); +} + +PyObject* app_set_default_camera(PyObject*, PyObject*) { + s_camera_distance = 1500.0f; + s_camera_pitch = 30.0f; + s_camera_rotation = 0.0f; + s_camera_height = 180.0f; + return Py_BuildNone(); +} + +PyObject* app_enable_special_camera_mode(PyObject*, PyObject*) { + s_special_camera_mode = true; + return Py_BuildNone(); +} + +static int GetRotatingDirection(float fSource, float fTarget) { + if (fSource < 180.0f) { + if (fTarget < fSource) + return 1; + else if ((360.0f - fTarget) + fSource < 180.0f) + return 1; + return 2; + } else { + if (fTarget > fSource) + return 2; + else if ((360.0f - fSource) + fTarget < 180.0f) + return 2; + return 1; + } +} + +PyObject* app_get_rotating_direction(PyObject*, PyObject* args) { + float fSource = 0.0f, fTarget = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fSource) || !PyTuple_GetFloat(args, 1, &fTarget)) + return Py_BuildException(); + return Py_BuildValue("i", GetRotatingDirection(fSource, fTarget)); +} + +static float GetDegreeDifference(float fSource, float fTarget) { + if (fSource < 180.0f) { + if (fTarget < fSource) + return fSource - fTarget; + else if (fTarget - fSource > 180.0f) + return 360.0f - (fTarget - fSource); + return fTarget - fSource; + } else { + if (fTarget > fSource) + return fTarget - fSource; + else if (fSource - fTarget > 180.0f) + return 360.0f - (fSource - fTarget); + return fSource - fTarget; + } +} + +PyObject* app_get_degree_difference(PyObject*, PyObject* args) { + float fSource = 0.0f, fTarget = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fSource) || !PyTuple_GetFloat(args, 1, &fTarget)) + return Py_BuildException(); + return Py_BuildValue("f", GetDegreeDifference(fSource, fTarget)); +} + +PyObject* app_get_cursor_position(PyObject*, PyObject*) { + long lx = 0, ly = 0; + UI::CWindowManager::Instance().GetMousePosition(lx, ly); + return Py_BuildValue("ii", lx, ly); +} + +PyObject* app_update_game(PyObject*, PyObject*) { + long lx = 0, ly = 0; + UI::CWindowManager::Instance().GetMousePosition(lx, ly); + float camX = 0.0f, camY = 0.0f, camZ = 0.0f; + auto* mainActor = NetworkActorManager::Instance().GetMainInstance(); + if (mainActor) { + camX = static_cast(mainActor->m_lCurX); + camY = static_cast(mainActor->m_lCurY); + camZ = static_cast(mainActor->m_lCurZ); + } + CPythonBackground::Instance().Update(camX, camY, camZ); + float dt = 0.033f; + NetworkActorManager::Instance().Update(dt, CPythonBackground::Instance().GetTerrain()); + EffectManager::Instance().Update(dt); + static float s_flyingTime = 0.0f; + s_flyingTime += dt; + FlyingManager::Instance().Update(dt, s_flyingTime); + return Py_BuildNone(); +} + +PyObject* app_render_game(PyObject*, PyObject*) { + auto& bg = CPythonBackground::Instance(); + bg.RenderSky(); + bg.RenderBeforeLensFlare(); + bg.RenderCloud(); + bg.BeginEnvironment(); + bg.Render(); + bg.SetCharacterDirLight(); + bg.SetBackgroundDirLight(); + bg.RenderWater(); + bg.RenderSnow(); + bg.RenderEffect(); + bg.EndEnvironment(); + bg.BeginEnvironment(); + bg.RenderPCBlocker(); + bg.EndEnvironment(); + bg.RenderAfterLensFlare(); + return Py_BuildNone(); +} + + PyObject* app_set_hair_color_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; NetworkActorManager::SetHairColorEnable(f != 0); Py_RETURN_NONE; } PyObject* app_set_armor_specular_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; s_armor_specular = (f != 0); NetworkActorManager::SetArmorSpecularEnable(f != 0); Py_RETURN_NONE; } PyObject* app_set_weapon_specular_enable(PyObject*, PyObject* args) { int f = 0; if(!PyArg_ParseTuple(args, "i", &f)) return nullptr; s_weapon_specular = (f != 0); Py_RETURN_NONE; } @@ -117,8 +377,6 @@ PyObject* app_get_default_codepage(PyObject*, PyObject*) { return PyInt_FromLong(GetDefaultCodePage()); } -PyObject* app_dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; } - // appGetRandom: EterBase random_range over the swapped bounds. PyObject* app_get_random(PyObject*, PyObject* poArgs) { int from; @@ -131,12 +389,6 @@ PyObject* app_get_random(PyObject*, PyObject* poArgs) { std::swap(from, to); return Py_BuildValue("i", eter::random_range(from, to)); } -PyObject* app_dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); } -PyObject* app_dummy_one(PyObject*, PyObject*) { return PyInt_FromLong(1); } -PyObject* app_dummy_float_zero(PyObject*, PyObject*) { return PyFloat_FromDouble(0.0); } -PyObject* app_dummy_str(PyObject*, PyObject*) { return PyString_FromString(""); } -PyObject* app_dummy_tuple2(PyObject*, PyObject*) { return Py_BuildValue("ii", 0, 0); } -PyObject* app_dummy_tuple3(PyObject*, PyObject*) { return Py_BuildValue("iii", 0, 0, 0); } // CTextLineLoader / appOpenTextFile..appGetTextFileLine (PythonApplicationModule.cpp). // Windows hands Python the heap pointer as an int; 64-bit hosts get an index instead. @@ -206,90 +458,483 @@ unsigned GetDefaultCodePage() { return 1252; } int GetTwoHandedAttackSpeedDecrease(){return twoHandedAttackSpeedDecrease;} bool IsYmirLocale() { return s_locale_name=="ymir"; } +namespace { + +static float s_textTailLivingTime = 5000.0f; +static bool s_skillEffectUpgradeEnable = false; +static bool s_rideHorseEnable = true; +static float s_minFog = 0.0f; +static bool s_frameSkip = false; +static int s_fps = 60; +static int s_globalCenterX = 0, s_globalCenterY = 0; +static float s_centerX = 0.0f, s_centerY = 0.0f, s_centerZ = 0.0f; +static int s_cursorNum = 0; +static bool s_cursorVisible = true; +static bool s_softwareCursor = false; +static std::string s_connectIP = ""; +static int s_connectPort = 0; +static std::string s_defaultFontName = "Arial:12"; +static std::string s_guildSymbolPath = "mark"; +static int s_sightRange = 12000; +static bool s_cheonma = false; +static float s_specularSpeed = 1.0f; +static int s_accumulationTime = 0; +static float s_specularColor[3] = {1.0f, 1.0f, 1.0f}; +static bool s_visibleNotice = true; +static int s_multiFarmStatus = 0; +static std::string s_appTitle = "AVA2"; +static std::string s_appMiniTitle = "AVA2"; + +static void tea_decode(uint32_t sz, uint32_t sy, const uint32_t* key, uint32_t* dest) { + uint32_t y = sy, z = sz; + uint32_t sum = 0x9E3779B9u * 32u; + for (int n = 0; n < 32; ++n) { + z -= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]); + sum -= 0x9E3779B9u; + y -= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]); + } + *dest++ = y; + *dest = z; +} + +static int tea_decrypt_data(uint32_t* dest, const uint32_t* src, const uint32_t* key, int size) { + int resize = (size % 8 != 0) ? (size + 8 - (size % 8)) : size; + for (int i = 0; i < resize >> 3; ++i, dest += 2, src += 2) { + tea_decode(*(src + 1), *src, key, dest); + } + return resize; +} + +static PyObject* app_is_dev_stage(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_is_test_stage(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_is_live_stage(PyObject*, PyObject*) { + return Py_BuildValue("i", 1); +} +static PyObject* app_set_text_tail_living_time(PyObject*, PyObject* args) { + float livingTime = 0.0f; + if (!PyTuple_GetFloat(args, 0, &livingTime)) return Py_BuildException(); + s_textTailLivingTime = livingTime * 1000.0f; + return Py_BuildNone(); +} +static PyObject* app_enable_performance_time(PyObject*, PyObject* args) { + char* mode = nullptr; int enable = 0; + if (!PyTuple_GetString(args, 0, &mode) || !PyTuple_GetInteger(args, 1, &enable)) return Py_BuildException(); + return Py_BuildNone(); +} +static PyObject* app_set_skill_effect_upgrade_enable(PyObject*, PyObject* args) { + int enable = 0; + if (!PyTuple_GetInteger(args, 0, &enable)) return Py_BuildException(); + s_skillEffectUpgradeEnable = (enable != 0); + return Py_BuildNone(); +} +static PyObject* app_set_ride_horse_enable(PyObject*, PyObject* args) { + int enable = 0; + if (!PyTuple_GetInteger(args, 0, &enable)) return Py_BuildException(); + s_rideHorseEnable = (enable != 0); + return Py_BuildNone(); +} +static PyObject* app_set_min_fog(PyObject*, PyObject* args) { + float fog = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fog)) return Py_BuildException(); + s_minFog = fog; + return Py_BuildNone(); +} +static PyObject* app_set_frame_skip(PyObject*, PyObject* args) { + int skip = 0; + if (!PyTuple_GetInteger(args, 0, &skip)) return Py_BuildException(); + s_frameSkip = (skip != 0); + return Py_BuildNone(); +} +static PyObject* app_get_image_info(PyObject*, PyObject* args) { + char* filename = nullptr; + if (!PyTuple_GetString(args, 0, &filename)) return Py_BuildException(); + return Py_BuildValue("iii", 0, 0, 0); +} +static PyObject* app_get_info(PyObject*, PyObject* args) { + int info = 0; + if (!PyTuple_GetInteger(args, 0, &info)) return Py_BuildException(); + return Py_BuildValue("s", ""); +} +static PyObject* app_process(PyObject*, PyObject*) { + return Py_BuildValue("i", 1); +} +static PyObject* app_is_exist_file(PyObject*, PyObject* args) { + char* filename = nullptr; + if (!PyTuple_GetString(args, 0, &filename)) return Py_BuildException(); + return Py_BuildValue("i", (CResourceManager::ResourceExists(filename) || std::filesystem::exists(filename)) ? 1 : 0); +} +static PyObject* app_get_file_list(PyObject*, PyObject* args) { + char* filter = nullptr; + if (!PyTuple_GetString(args, 0, &filter)) return Py_BuildException(); + PyObject* poList = PyList_New(0); + try { + std::filesystem::path p(filter); + std::filesystem::path dir = p.parent_path(); + if (dir.empty()) dir = "."; + std::string pattern = p.filename().string(); + if (std::filesystem::exists(dir) && std::filesystem::is_directory(dir)) { + for (const auto& entry : std::filesystem::directory_iterator(dir)) { + std::string name = entry.path().filename().string(); + if (pattern.empty() || pattern == "*.*" || pattern == "*" || name.find(pattern) != std::string::npos) { + PyList_Append(poList, PyString_FromString(name.c_str())); + } + } + } + } catch (...) {} + return poList; +} +static PyObject* app_get_update_fps(PyObject*, PyObject*) { + return Py_BuildValue("i", s_fps); +} +static PyObject* app_get_render_fps(PyObject*, PyObject*) { + return Py_BuildValue("i", s_fps); +} +static PyObject* app_get_available_texture_memory(PyObject*, PyObject*) { + return Py_BuildValue("i", 256 * 1024 * 1024); +} +static PyObject* app_get_render_time(PyObject*, PyObject*) { + return Py_BuildValue("fi", 0.016f, 16); +} +static PyObject* app_get_update_time(PyObject*, PyObject*) { + return Py_BuildValue("i", 16); +} +static PyObject* app_get_load(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_get_face_speed(PyObject*, PyObject*) { + return Py_BuildValue("f", 0.0f); +} +static PyObject* app_get_face_count(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_set_fps(PyObject*, PyObject* args) { + int fps = 0; + if (!PyTuple_GetInteger(args, 0, &fps)) return Py_BuildException(); + s_fps = fps; + return Py_BuildNone(); +} +static PyObject* app_set_global_center_position(PyObject*, PyObject* args) { + int x = 0, y = 0; + if (!PyTuple_GetInteger(args, 0, &x) || !PyTuple_GetInteger(args, 1, &y)) return Py_BuildException(); + s_globalCenterX = x; s_globalCenterY = y; + return Py_BuildNone(); +} +static PyObject* app_set_center_position(PyObject*, PyObject* args) { + float x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetFloat(args, 0, &x) || !PyTuple_GetFloat(args, 1, &y) || !PyTuple_GetFloat(args, 2, &z)) return Py_BuildException(); + s_centerX = x; s_centerY = y; s_centerZ = z; + return Py_BuildNone(); +} +static PyObject* app_run_python_file(PyObject*, PyObject* args) { + char* filename = nullptr; + if (!PyTuple_GetString(args, 0, &filename)) return Py_BuildException(); + FILE* fp = fopen(filename, "r"); + if (!fp) return Py_BuildValue("i", 0); + int res = PyRun_SimpleFile(fp, filename); + fclose(fp); + return Py_BuildValue("i", res == 0 ? 1 : 0); +} +static PyObject* app_is_web_page_mode(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_show_web_page(PyObject*, PyObject* args) { + char* url = nullptr; + if (!PyTuple_GetString(args, 0, &url)) return Py_BuildException(); + return Py_BuildNone(); +} +static PyObject* app_move_web_page(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_hide_web_page(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_set_cursor(PyObject*, PyObject* args) { + int cursor = 0; + if (!PyTuple_GetInteger(args, 0, &cursor)) return Py_BuildException(); + s_cursorNum = cursor; + return Py_BuildNone(); +} +static PyObject* app_get_cursor(PyObject*, PyObject*) { + return Py_BuildValue("i", s_cursorNum); +} +static PyObject* app_show_cursor(PyObject*, PyObject*) { + s_cursorVisible = true; + return Py_BuildNone(); +} +static PyObject* app_hide_cursor(PyObject*, PyObject*) { + s_cursorVisible = false; + return Py_BuildNone(); +} +static PyObject* app_is_show_cursor(PyObject*, PyObject*) { + return Py_BuildValue("i", s_cursorVisible ? 1 : 0); +} +static PyObject* app_is_liar_cursor_on(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_set_software_cursor(PyObject*, PyObject*) { + s_softwareCursor = true; + return Py_BuildNone(); +} +static PyObject* app_set_hardware_cursor(PyObject*, PyObject*) { + s_softwareCursor = false; + return Py_BuildNone(); +} +static PyObject* app_set_connect_data(PyObject*, PyObject* args) { + char* ip = nullptr; int port = 0; + if (!PyTuple_GetString(args, 0, &ip) || !PyTuple_GetInteger(args, 1, &port)) return Py_BuildException(); + s_connectIP = ip; s_connectPort = port; + return Py_BuildNone(); +} +static PyObject* app_get_connect_data(PyObject*, PyObject*) { + return Py_BuildValue("si", s_connectIP.c_str(), s_connectPort); +} +static PyObject* app_sleep(PyObject*, PyObject* args) { + int ms = 0; + if (!PyTuple_GetInteger(args, 0, &ms)) return Py_BuildException(); + if (ms > 0) std::this_thread::sleep_for(std::chrono::milliseconds(ms)); + return Py_BuildNone(); +} +static PyObject* app_set_default_font_name(PyObject*, PyObject* args) { + char* font = nullptr; + if (!PyTuple_GetString(args, 0, &font)) return Py_BuildException(); + s_defaultFontName = font; + return Py_BuildNone(); +} +static PyObject* app_set_guild_symbol_path(PyObject*, PyObject* args) { + char* path = nullptr; + if (!PyTuple_GetString(args, 0, &path)) return Py_BuildException(); + s_guildSymbolPath = path; + return Py_BuildNone(); +} +static PyObject* app_set_sight_range(PyObject*, PyObject* args) { + int range = 0; + if (!PyTuple_GetInteger(args, 0, &range)) return Py_BuildException(); + s_sightRange = range; + return Py_BuildNone(); +} +static PyObject* app_is_file_exist(PyObject*, PyObject* args) { + char* filename = nullptr; + if (!PyTuple_GetString(args, 0, &filename)) return Py_BuildException(); + return Py_BuildValue("i", std::filesystem::exists(filename) ? 1 : 0); +} +static PyObject* app_force_set_locale(PyObject*, PyObject* args) { + char* name = nullptr; char* localePath = nullptr; + if (!PyTuple_GetString(args, 0, &name) || !PyTuple_GetString(args, 1, &localePath)) return Py_BuildException(); + s_locale_name = name; s_locale_path = localePath; + return Py_BuildNone(); +} +static PyObject* app_load_locale_addr(PyObject*, PyObject* args) { + char* addrPath = nullptr; + if (!PyTuple_GetString(args, 0, &addrPath)) return Py_BuildException(); + FILE* fp = fopen(addrPath, "rb"); + if (!fp) return Py_BuildException("Cannot open locale addr file"); + fseek(fp, 0, SEEK_END); + long size = ftell(fp); + fseek(fp, 0, SEEK_SET); + if (size <= 0) { + fclose(fp); + return Py_BuildValue("s", ""); + } + std::vector enc(size + 8, 0); + fread(enc.data(), size, 1, fp); + fclose(fp); + + static const unsigned char rawKey[16] = { + 0x82, 0x1b, 0x34, 0xae, + 0x12, 0x3b, 0xfb, 0x17, + 0xd7, 0x2c, 0x39, 0xae, + 0x41, 0x98, 0xf1, 0x63 + }; + uint32_t k[4]; + std::memcpy(k, rawKey, 16); + + std::vector buf((size + 7) / 4 + 2, 0); + tea_decrypt_data(buf.data(), reinterpret_cast(enc.data()), k, size); + uint32_t retSize = buf[0]; + const char* ret = reinterpret_cast(buf.data()) + sizeof(uint32_t); + if (retSize > (uint32_t)(size)) retSize = 0; + return Py_BuildValue("s#", ret, retSize); +} +static PyObject* app_set_cheonma(PyObject*, PyObject* args) { + int enable = 0; + if (!PyTuple_GetInteger(args, 0, &enable)) return Py_BuildException(); + s_cheonma = (enable != 0); + return Py_BuildNone(); +} +static PyObject* app_is_cheonma(PyObject*, PyObject*) { + return Py_BuildValue("i", s_cheonma ? 1 : 0); +} +static PyObject* app_set_control_fp(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_set_specular_speed(PyObject*, PyObject* args) { + float spd = 0.0f; + if (!PyTuple_GetFloat(args, 0, &spd)) return Py_BuildException(); + s_specularSpeed = spd; + return Py_BuildNone(); +} +static PyObject* app_test_get_accumulation_time(PyObject*, PyObject*) { + return Py_BuildValue("i", s_accumulationTime); +} +static PyObject* app_test_reset_accumulation_time(PyObject*, PyObject*) { + s_accumulationTime = 0; + return Py_BuildNone(); +} +static PyObject* app_test_set_specular_color(PyObject*, PyObject* args) { + float r = 0.0f, g = 0.0f, b = 0.0f; + if (!PyTuple_GetFloat(args, 0, &r) || !PyTuple_GetFloat(args, 1, &g) || !PyTuple_GetFloat(args, 2, &b)) return Py_BuildException(); + s_specularColor[0] = r; s_specularColor[1] = g; s_specularColor[2] = b; + return Py_BuildNone(); +} +static PyObject* app_set_visible_notice(PyObject*, PyObject* args) { + int flag = 0; + if (!PyTuple_GetInteger(args, 0, &flag)) return Py_BuildException(); + s_visibleNotice = (flag != 0); + return Py_BuildNone(); +} +static PyObject* app_is_visible_notice(PyObject*, PyObject*) { + return Py_BuildValue("i", s_visibleNotice ? 1 : 0); +} +static PyObject* app_on_logo_update(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* app_on_logo_render(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_on_logo_open(PyObject*, PyObject* args) { + char* name = nullptr; + if (!PyTuple_GetString(args, 0, &name)) return Py_BuildException(); + return Py_BuildValue("i", 1); +} +static PyObject* app_on_logo_close(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_flash_application(PyObject*, PyObject*) { + return Py_BuildNone(); +} +static PyObject* app_set_multi_farm_exe_icon(PyObject*, PyObject* args) { + int status = 0; + if (!PyTuple_GetInteger(args, 0, &status)) return Py_BuildException(); + s_multiFarmStatus = status; + return Py_BuildNone(); +} +static PyObject* app_window_status(PyObject*, PyObject* args) { + int status = 0; + if (!PyTuple_GetInteger(args, 0, &status)) return Py_BuildException(); + return Py_BuildNone(); +} +static PyObject* app_is_visible(PyObject*, PyObject*) { + return Py_BuildValue("i", 1); +} +static PyObject* app_set_title(PyObject*, PyObject* args) { + char* title = nullptr; char* miniTitle = nullptr; + if (!PyTuple_GetString(args, 0, &title)) return Py_BuildException(); + if (PyTuple_Size(args) > 1) { + if (!PyTuple_GetString(args, 1, &miniTitle)) return Py_BuildException(); + } + s_appTitle = title; + if (miniTitle) s_appMiniTitle = miniTitle; + return Py_BuildNone(); +} +static PyObject* app_set_message(PyObject*, PyObject* args) { + char* title = nullptr; char* message = nullptr; + if (!PyTuple_GetString(args, 0, &title) || !PyTuple_GetString(args, 1, &message)) return Py_BuildException(); + return Py_BuildNone(); +} +static PyObject* app_is_can_open_render(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +} // namespace + void initapp() { static PyMethodDef methods[] = { - {"IsDevStage", app_dummy_zero, METH_VARARGS, nullptr}, - {"IsTestStage", app_dummy_zero, METH_VARARGS, nullptr}, - {"IsLiveStage", app_dummy_one, METH_VARARGS, nullptr}, - {"SetTextTailLivingTime", app_dummy_none, METH_VARARGS, nullptr}, - {"EnablePerformanceTime", app_dummy_none, METH_VARARGS, nullptr}, + {"IsDevStage", app_is_dev_stage, METH_VARARGS, nullptr}, + {"IsTestStage", app_is_test_stage, METH_VARARGS, nullptr}, + {"IsLiveStage", app_is_live_stage, METH_VARARGS, nullptr}, + {"SetTextTailLivingTime", app_set_text_tail_living_time, METH_VARARGS, nullptr}, + {"EnablePerformanceTime", app_enable_performance_time, METH_VARARGS, nullptr}, {"SetHairColorEnable", app_set_hair_color_enable, METH_VARARGS, nullptr}, {"SetArmorSpecularEnable", app_set_armor_specular_enable, METH_VARARGS, nullptr}, {"SetWeaponSpecularEnable", app_set_weapon_specular_enable, METH_VARARGS, nullptr}, - {"SetSkillEffectUpgradeEnable", app_dummy_none, METH_VARARGS, nullptr}, + {"SetSkillEffectUpgradeEnable", app_set_skill_effect_upgrade_enable, METH_VARARGS, nullptr}, {"SetTwoHandedWeaponAttSpeedDecreaseValue", set_twohand_decrease, METH_VARARGS, nullptr}, - {"SetRideHorseEnable", app_dummy_none, METH_VARARGS, nullptr}, - {"SetCameraMaxDistance", app_dummy_none, METH_VARARGS, nullptr}, - {"SetMinFog", app_dummy_none, METH_VARARGS, nullptr}, - {"SetFrameSkip", app_dummy_none, METH_VARARGS, nullptr}, - {"GetImageInfo", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetInfo", app_dummy_zero, METH_VARARGS, nullptr}, - {"UpdateGame", app_dummy_none, METH_VARARGS, nullptr}, - {"RenderGame", app_dummy_none, METH_VARARGS, nullptr}, + {"SetRideHorseEnable", app_set_ride_horse_enable, METH_VARARGS, nullptr}, + {"SetCameraMaxDistance", app_set_camera_max_distance, METH_VARARGS, nullptr}, + {"SetMinFog", app_set_min_fog, METH_VARARGS, nullptr}, + {"SetFrameSkip", app_set_frame_skip, METH_VARARGS, nullptr}, + {"GetImageInfo", app_get_image_info, METH_VARARGS, nullptr}, + {"GetInfo", app_get_info, METH_VARARGS, nullptr}, + {"UpdateGame", app_update_game, METH_VARARGS, nullptr}, + {"RenderGame", app_render_game, METH_VARARGS, nullptr}, {"Loop", app_loop, METH_VARARGS, nullptr}, {"Create", app_create, METH_VARARGS, nullptr}, - {"Process", app_dummy_none, METH_VARARGS, nullptr}, + {"Process", app_process, METH_VARARGS, nullptr}, {"Exit", app_exit, METH_VARARGS, nullptr}, {"Abort", app_abort, METH_VARARGS, nullptr}, {"SetMouseHandler", app_set_mouse_handler, METH_VARARGS, nullptr}, - {"IsExistFile", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetFileList", app_dummy_zero, METH_VARARGS, nullptr}, + {"IsExistFile", app_is_exist_file, METH_VARARGS, nullptr}, + {"GetFileList", app_get_file_list, METH_VARARGS, nullptr}, {"SetCamera", app_set_camera, METH_VARARGS, nullptr}, - {"GetCamera", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetCameraPitch", app_dummy_float_zero, METH_VARARGS, nullptr}, - {"GetCameraRotation", app_dummy_float_zero, METH_VARARGS, nullptr}, + {"GetCamera", app_get_camera, METH_VARARGS, nullptr}, + {"GetCameraPitch", app_get_camera_pitch, METH_VARARGS, nullptr}, + {"GetCameraRotation", app_get_camera_rotation, METH_VARARGS, nullptr}, {"GetTime", app_get_time, METH_VARARGS, nullptr}, {"GetGlobalTime", app_get_global_time, METH_VARARGS, nullptr}, {"GetGlobalTimeStamp", app_get_global_timestamp, METH_VARARGS, nullptr}, - {"GetUpdateFPS", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetRenderFPS", app_dummy_zero, METH_VARARGS, nullptr}, - {"RotateCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"PitchCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"ZoomCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"MovieRotateCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"MoviePitchCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"MovieZoomCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"MovieResetCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"GetAvailableTextureMemory", app_dummy_str, METH_VARARGS, nullptr}, - {"GetRenderTime", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetUpdateTime", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetLoad", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetFaceSpeed", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetFaceCount", app_dummy_zero, METH_VARARGS, nullptr}, - {"SetFPS", app_dummy_none, METH_VARARGS, nullptr}, - {"SetGlobalCenterPosition", app_dummy_none, METH_VARARGS, nullptr}, - {"SetCenterPosition", app_dummy_none, METH_VARARGS, nullptr}, - {"GetCursorPosition", app_dummy_tuple2, METH_VARARGS, nullptr}, + {"GetUpdateFPS", app_get_update_fps, METH_VARARGS, nullptr}, + {"GetRenderFPS", app_get_render_fps, METH_VARARGS, nullptr}, + {"RotateCamera", app_rotate_camera, METH_VARARGS, nullptr}, + {"PitchCamera", app_pitch_camera, METH_VARARGS, nullptr}, + {"ZoomCamera", app_zoom_camera, METH_VARARGS, nullptr}, + {"MovieRotateCamera", app_movie_rotate_camera, METH_VARARGS, nullptr}, + {"MoviePitchCamera", app_movie_pitch_camera, METH_VARARGS, nullptr}, + {"MovieZoomCamera", app_movie_zoom_camera, METH_VARARGS, nullptr}, + {"MovieResetCamera", app_movie_reset_camera, METH_VARARGS, nullptr}, + {"GetAvailableTextureMemory", app_get_available_texture_memory, METH_VARARGS, nullptr}, + {"GetRenderTime", app_get_render_time, METH_VARARGS, nullptr}, + {"GetUpdateTime", app_get_update_time, METH_VARARGS, nullptr}, + {"GetLoad", app_get_load, METH_VARARGS, nullptr}, + {"GetFaceSpeed", app_get_face_speed, METH_VARARGS, nullptr}, + {"GetFaceCount", app_get_face_count, METH_VARARGS, nullptr}, + {"SetFPS", app_set_fps, METH_VARARGS, nullptr}, + {"SetGlobalCenterPosition", app_set_global_center_position, METH_VARARGS, nullptr}, + {"SetCenterPosition", app_set_center_position, METH_VARARGS, nullptr}, + {"GetCursorPosition", app_get_cursor_position, METH_VARARGS, nullptr}, {"GetRandom", app_get_random, METH_VARARGS, nullptr}, - {"RunPythonFile", app_dummy_none, METH_VARARGS, nullptr}, - {"IsWebPageMode", app_dummy_zero, METH_VARARGS, nullptr}, - {"ShowWebPage", app_dummy_none, METH_VARARGS, nullptr}, - {"MoveWebPage", app_dummy_none, METH_VARARGS, nullptr}, - {"HideWebPage", app_dummy_none, METH_VARARGS, nullptr}, + {"RunPythonFile", app_run_python_file, METH_VARARGS, nullptr}, + {"IsWebPageMode", app_is_web_page_mode, METH_VARARGS, nullptr}, + {"ShowWebPage", app_show_web_page, METH_VARARGS, nullptr}, + {"MoveWebPage", app_move_web_page, METH_VARARGS, nullptr}, + {"HideWebPage", app_hide_web_page, METH_VARARGS, nullptr}, {"IsPressed", app_is_pressed, METH_VARARGS, nullptr}, - {"SetCursor", app_dummy_none, METH_VARARGS, nullptr}, - {"GetCursor", app_dummy_zero, METH_VARARGS, nullptr}, - {"ShowCursor", app_dummy_none, METH_VARARGS, nullptr}, - {"HideCursor", app_dummy_none, METH_VARARGS, nullptr}, - {"IsShowCursor", app_dummy_zero, METH_VARARGS, nullptr}, - {"IsLiarCursorOn", app_dummy_zero, METH_VARARGS, nullptr}, - {"SetSoftwareCursor", app_dummy_none, METH_VARARGS, nullptr}, - {"SetHardwareCursor", app_dummy_none, METH_VARARGS, nullptr}, - {"SetConnectData", app_dummy_none, METH_VARARGS, nullptr}, - {"GetConnectData", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetRotatingDirection", app_dummy_zero, METH_VARARGS, nullptr}, - {"GetDegreeDifference", app_dummy_zero, METH_VARARGS, nullptr}, - {"Sleep", app_dummy_none, METH_VARARGS, nullptr}, - {"SetDefaultFontName", app_dummy_none, METH_VARARGS, nullptr}, - {"SetGuildSymbolPath", app_dummy_none, METH_VARARGS, nullptr}, - {"EnableSpecialCameraMode", app_dummy_none, METH_VARARGS, nullptr}, - {"SetCameraSpeed", app_dummy_none, METH_VARARGS, nullptr}, - {"SaveCameraSetting", app_dummy_none, METH_VARARGS, nullptr}, - {"LoadCameraSetting", app_dummy_none, METH_VARARGS, nullptr}, - {"SetDefaultCamera", app_dummy_none, METH_VARARGS, nullptr}, - {"SetCameraSetting", app_dummy_none, METH_VARARGS, nullptr}, - {"SetSightRange", app_dummy_none, METH_VARARGS, nullptr}, - {"IsFileExist", app_dummy_zero, METH_VARARGS, nullptr}, + {"SetCursor", app_set_cursor, METH_VARARGS, nullptr}, + {"GetCursor", app_get_cursor, METH_VARARGS, nullptr}, + {"ShowCursor", app_show_cursor, METH_VARARGS, nullptr}, + {"HideCursor", app_hide_cursor, METH_VARARGS, nullptr}, + {"IsShowCursor", app_is_show_cursor, METH_VARARGS, nullptr}, + {"IsLiarCursorOn", app_is_liar_cursor_on, METH_VARARGS, nullptr}, + {"SetSoftwareCursor", app_set_software_cursor, METH_VARARGS, nullptr}, + {"SetHardwareCursor", app_set_hardware_cursor, METH_VARARGS, nullptr}, + {"SetConnectData", app_set_connect_data, METH_VARARGS, nullptr}, + {"GetConnectData", app_get_connect_data, METH_VARARGS, nullptr}, + {"GetRotatingDirection", app_get_rotating_direction, METH_VARARGS, nullptr}, + {"GetDegreeDifference", app_get_degree_difference, METH_VARARGS, nullptr}, + {"Sleep", app_sleep, METH_VARARGS, nullptr}, + {"SetDefaultFontName", app_set_default_font_name, METH_VARARGS, nullptr}, + {"SetGuildSymbolPath", app_set_guild_symbol_path, METH_VARARGS, nullptr}, + {"EnableSpecialCameraMode", app_enable_special_camera_mode, METH_VARARGS, nullptr}, + {"SetCameraSpeed", app_set_camera_speed, METH_VARARGS, nullptr}, + {"SaveCameraSetting", app_save_camera_setting, METH_VARARGS, nullptr}, + {"LoadCameraSetting", app_load_camera_setting, METH_VARARGS, nullptr}, + {"SetDefaultCamera", app_set_default_camera, METH_VARARGS, nullptr}, + {"SetCameraSetting", app_set_camera_setting, METH_VARARGS, nullptr}, + {"SetSightRange", app_set_sight_range, METH_VARARGS, nullptr}, + {"IsFileExist", app_is_file_exist, METH_VARARGS, nullptr}, {"OpenTextFile", app_open_text_file, METH_VARARGS, nullptr}, {"CloseTextFile", app_close_text_file, METH_VARARGS, nullptr}, {"GetTextFileLineCount", app_get_text_file_line_count, METH_VARARGS, nullptr}, @@ -297,33 +942,33 @@ void initapp() { {"GetLocaleServiceName", app_get_locale_service_name, METH_VARARGS, nullptr}, {"GetLocaleName", app_get_locale_name, METH_VARARGS, nullptr}, {"GetLocalePath", app_get_locale_path, METH_VARARGS, nullptr}, - {"ForceSetLocale", app_dummy_none, METH_VARARGS, nullptr}, - {"LoadLocaleAddr", app_dummy_none, METH_VARARGS, nullptr}, + {"ForceSetLocale", app_force_set_locale, METH_VARARGS, nullptr}, + {"LoadLocaleAddr", app_load_locale_addr, METH_VARARGS, nullptr}, {"LoadLocaleData", app_load_locale_data, METH_VARARGS, nullptr}, - {"SetCHEONMA", app_dummy_none, METH_VARARGS, nullptr}, - {"IsCHEONMA", app_dummy_zero, METH_VARARGS, nullptr}, + {"SetCHEONMA", app_set_cheonma, METH_VARARGS, nullptr}, + {"IsCHEONMA", app_is_cheonma, METH_VARARGS, nullptr}, {"GetDefaultCodePage", app_get_default_codepage, METH_VARARGS, nullptr}, - {"SetControlFP", app_dummy_none, METH_VARARGS, nullptr}, - {"SetSpecularSpeed", app_dummy_none, METH_VARARGS, nullptr}, - {"testGetAccumulationTime", app_dummy_none, METH_VARARGS, nullptr}, - {"testResetAccumulationTime", app_dummy_none, METH_VARARGS, nullptr}, - {"testSetSpecularColor", app_dummy_none, METH_VARARGS, nullptr}, - {"SetVisibleNotice", app_dummy_none, METH_VARARGS, nullptr}, - {"IsVisibleNotice", app_dummy_zero, METH_VARARGS, nullptr}, + {"SetControlFP", app_set_control_fp, METH_VARARGS, nullptr}, + {"SetSpecularSpeed", app_set_specular_speed, METH_VARARGS, nullptr}, + {"testGetAccumulationTime", app_test_get_accumulation_time, METH_VARARGS, nullptr}, + {"testResetAccumulationTime", app_test_reset_accumulation_time, METH_VARARGS, nullptr}, + {"testSetSpecularColor", app_test_set_specular_color, METH_VARARGS, nullptr}, + {"SetVisibleNotice", app_set_visible_notice, METH_VARARGS, nullptr}, + {"IsVisibleNotice", app_is_visible_notice, METH_VARARGS, nullptr}, {"IsEnableTestServerFlag", app_is_test_server, METH_VARARGS, nullptr}, {"EnableTestServerFlag", app_enable_test_server, METH_VARARGS, nullptr}, {"SetGuildMarkPath", app_set_guild_mark_path, METH_VARARGS, nullptr}, - {"OnLogoUpdate", app_dummy_none, METH_VARARGS, nullptr}, - {"OnLogoRender", app_dummy_none, METH_VARARGS, nullptr}, - {"OnLogoOpen", app_dummy_none, METH_VARARGS, nullptr}, - {"OnLogoClose", app_dummy_none, METH_VARARGS, nullptr}, - {"FlashApplication", app_dummy_none, METH_VARARGS, nullptr}, - {"SetMultiFarmExeIcon", app_dummy_none, METH_VARARGS, nullptr}, - {"WindowStatus", app_dummy_none, METH_VARARGS, nullptr}, - {"IsVisible", app_dummy_zero, METH_VARARGS, nullptr}, - {"SetTitle", app_dummy_none, METH_VARARGS, nullptr}, - {"SetMessage", app_dummy_none, METH_VARARGS, nullptr}, - {"IsCanOpenRender", app_dummy_zero, METH_VARARGS, nullptr}, + {"OnLogoUpdate", app_on_logo_update, METH_VARARGS, nullptr}, + {"OnLogoRender", app_on_logo_render, METH_VARARGS, nullptr}, + {"OnLogoOpen", app_on_logo_open, METH_VARARGS, nullptr}, + {"OnLogoClose", app_on_logo_close, METH_VARARGS, nullptr}, + {"FlashApplication", app_flash_application, METH_VARARGS, nullptr}, + {"SetMultiFarmExeIcon", app_set_multi_farm_exe_icon, METH_VARARGS, nullptr}, + {"WindowStatus", app_window_status, METH_VARARGS, nullptr}, + {"IsVisible", app_is_visible, METH_VARARGS, nullptr}, + {"SetTitle", app_set_title, METH_VARARGS, nullptr}, + {"SetMessage", app_set_message, METH_VARARGS, nullptr}, + {"IsCanOpenRender", app_is_can_open_render, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("app", methods); @@ -390,6 +1035,14 @@ void initapp() { PyModule_AddIntConstant(module, "INFO_ACTOR", 1); PyModule_AddIntConstant(module, "INFO_EFFECT", 2); PyModule_AddIntConstant(module, "INFO_TEXTTAIL", 3); + + PyModule_AddIntConstant(module, "DEGREE_DIRECTION_SAME", 0); + PyModule_AddIntConstant(module, "DEGREE_DIRECTION_RIGHT", 1); + PyModule_AddIntConstant(module, "DEGREE_DIRECTION_LEFT", 2); + + PyModule_AddIntConstant(module, "CAMERA_TO_POSITIVE", 1); + PyModule_AddIntConstant(module, "CAMERA_TO_NEGATIVE", -1); + PyModule_AddIntConstant(module, "CAMERA_STOP", 0); } namespace { diff --git a/src/python_background.cpp b/src/python_background.cpp new file mode 100644 index 00000000..40602c37 --- /dev/null +++ b/src/python_background.cpp @@ -0,0 +1,1100 @@ +#include "python_background.h" +#include "python_minimap.h" +#include "python_runtime.h" +#include "python_system.h" +#include "ava2_text_file_loader.h" +#include "eter_lib/parser.h" +#include "eter_net/NetworkActorManager.h" +#include "eter_effect/EffectManager.h" +#include "eter_resource/ResourceManager.h" +#include "map_coordinates.h" +#include "shared/common/PythonUtils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ava2 { + +namespace { + +// Atlas text reader helper +std::string ReadAtlasText(const std::string& path) { + std::ifstream file(path, std::ios::binary); + if (!file) return ""; + std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); + return content; +} + +std::vector SplitLines(const std::string& str) { + std::vector lines; + std::string line; + std::istringstream stream(str); + while (std::getline(stream, line)) { + if (!line.empty() && line.back() == '\r') line.pop_back(); + lines.push_back(line); + } + return lines; +} + +std::vector SplitTabs(const std::string& str) { + std::vector tokens; + std::string tok; + std::istringstream stream(str); + while (std::getline(stream, tok, '\t')) { + tokens.push_back(tok); + } + return tokens; +} + +} // namespace + +CPythonBackground& CPythonBackground::Instance() { + static CPythonBackground s_instance; + return s_instance; +} + +CPythonBackground::CPythonBackground() { + for (int i = 0; i < NUM_DISTANCE_SET; ++i) { + SetViewDistanceSet(i, 25600.0f); + } + for (int i = 0; i < PART_NUM; ++i) { + m_bVisiblePart[i] = true; + } + Initialize(); +} + +CPythonBackground::~CPythonBackground() { + Destroy(); +} + +void CPythonBackground::Initialize() { + m_strMapName.clear(); + m_strWarpMapName.clear(); + m_dwBaseX = 0; + m_dwBaseY = 0; + m_eViewDistanceNum = 0; + m_eShadowLevel = SHADOW_NONE; + m_dwRenderShadowTime = 0; + m_iSplatLimit = 0; + m_bSoftwareTilingEnable = false; + m_bSnowEnable = false; + m_bTransparentTree = false; + m_iXMasTreeGrade = 0; + m_bVisibleGuildArea = false; + m_eTerrainRenderSort = DISTANCE_SORT; + m_bBGLoading = false; + m_v3PickingPoint[0] = 0.0f; + m_v3PickingPoint[1] = 0.0f; + m_v3PickingPoint[2] = 0.0f; + m_kSet_strDungeonMapName.clear(); + m_targetEffects.clear(); + m_targetEffectsShop.clear(); + m_targetPositions.clear(); + m_privateShopPosVID = 0; + m_pCurrentEnvironment = &m_defaultEnvironment; +} + +void CPythonBackground::Destroy() { + Initialize(); + m_terrain.reset(); + m_mapObjects.reset(); + m_water.reset(); + m_skybox.reset(); + m_forest.reset(); + m_outdoorMap = OutdoorMapInfo{}; + m_mapEnvironmentData.clear(); + m_kVct_kMapInfo.clear(); + m_atlasLocale.clear(); +} + +void CPythonBackground::Create() { + if (!m_terrain) m_terrain = std::make_unique(); + if (!m_mapObjects) m_mapObjects = std::make_unique(); + if (!m_water) m_water = std::make_unique(); + if (!m_skybox) m_skybox = std::make_unique(); + if (!m_forest) m_forest = std::make_unique(); +} + +bool CPythonBackground::IsMapReady() const { + return !m_strMapName.empty() && m_terrain != nullptr; +} + +void CPythonBackground::LoadAtlas() { + std::string localePath; + PyObject* app = PyImport_ImportModule("app"); + if (app) { + PyObject* path = PyObject_CallMethod(app, const_cast("GetLocalePath"), nullptr); + if (path && PyString_Check(path)) { + localePath = PyString_AsString(path); + } + Py_XDECREF(path); + Py_DECREF(app); + } + if (localePath.empty()) localePath = "locale/en"; + if (localePath == m_atlasLocale && !m_kVct_kMapInfo.empty()) return; + m_atlasLocale = localePath; + m_kVct_kMapInfo.clear(); + + std::string content; + try { content = ReadPackedText(localePath + "/atlasinfo.txt"); } catch (...) {} + if (content.empty()) { + try { content = ReadPackedText(localePath + "/AtlasInfo.txt"); } catch (...) {} + } + if (content.empty()) { + try { content = ReadPackedText("locale/en/atlasinfo.txt"); } catch (...) {} + } + if (content.empty()) { + try { content = ReadPackedText("atlasinfo.txt"); } catch (...) {} + } + if (content.empty()) { + try { content = ReadPackedText("AtlasInfo.txt"); } catch (...) {} + } + if (content.empty()) { + try { content = ReadPackedText("upstream/python-root/atlasinfo.txt"); } catch (...) {} + } + + std::istringstream stream(content); + std::string line; + while (std::getline(stream, line)) { + if (line.empty() || line[0] == '#') continue; + std::istringstream row(line); + std::string name; + uint32_t x = 0, y = 0, w = 0, h = 0; + if (row >> name >> x >> y >> w >> h) { + TMapInfo info; + info.m_strName = name; + info.m_dwBaseX = x; + info.m_dwBaseY = y; + info.m_dwSizeX = w; + info.m_dwSizeY = h; + info.m_dwEndX = x + w * 25600u; + info.m_dwEndY = y + h * 25600u; + m_kVct_kMapInfo.push_back(info); + } + } +} + +CPythonBackground::TMapInfo* CPythonBackground::GlobalPositionToMapInfo(uint32_t dwGlobalX, uint32_t dwGlobalY) { + LoadAtlas(); + for (auto& info : m_kVct_kMapInfo) { + if (dwGlobalX >= info.m_dwBaseX && dwGlobalX < info.m_dwEndX && + dwGlobalY >= info.m_dwBaseY && dwGlobalY < info.m_dwEndY) { + return &info; + } + } + return nullptr; +} + +void CPythonBackground::GlobalPositionToLocalPosition(long& rGlobalX, long& rGlobalY) { + rGlobalX = MapCoordinates::signedBits(static_cast(rGlobalX) - m_dwBaseX); + rGlobalY = MapCoordinates::signedBits(static_cast(rGlobalY) - m_dwBaseY); +} + +void CPythonBackground::LocalPositionToGlobalPosition(long& rLocalX, long& rLocalY) { + rLocalX = MapCoordinates::signedBits(static_cast(rLocalX) + m_dwBaseX); + rLocalY = MapCoordinates::signedBits(static_cast(rLocalY) + m_dwBaseY); +} + +bool CPythonBackground::LoadMap(const std::string& mapName, float x, float y, float z) { + (void)z; + Create(); + + std::vector base_candidates = { + "map/" + mapName, + mapName, + "Maps/" + mapName, + "build/dev/test-rundir/map/" + mapName + }; + + std::string found_base = ""; + for (const auto& base : base_candidates) { + if (std::filesystem::is_directory(base)) { + found_base = base; + break; + } + } + + if (found_base.empty()) { + std::cerr << "LoadMap: cannot find directory for map " << mapName << std::endl; + return false; + } + + m_outdoorMap.name = mapName; + std::string setting_path = found_base + "/setting.txt"; + std::string setting_content; + try { setting_content = ReadPackedText(setting_path); } catch (...) {} + if (setting_content.empty() && std::filesystem::exists(setting_path)) { + std::ifstream sf(setting_path, std::ios::binary); + if (sf) { + std::stringstream ss; + ss << sf.rdbuf(); + setting_content = ss.str(); + } + } + if (!setting_content.empty()) { + std::map> tokens; + ava2LoadMultipleTextData(setting_content, tokens); + auto size = tokens.find("mapsize"); + if (size != tokens.end() && size->second.size() >= 2) { + m_outdoorMap.terrainCountX = static_cast(std::atoi(size->second[0].c_str())); + m_outdoorMap.terrainCountY = static_cast(std::atoi(size->second[1].c_str())); + } + auto base = tokens.find("baseposition"); + if (base != tokens.end() && base->second.size() >= 2) { + m_outdoorMap.baseX = static_cast(std::atol(base->second[0].c_str())); + m_outdoorMap.baseY = static_cast(std::atol(base->second[1].c_str())); + } + } + + int bx = static_cast(std::floor(x / 25600.0f)); + int by = static_cast(std::floor(y / 25600.0f)); + char block_str[32]; + std::snprintf(block_str, sizeof(block_str), "%03d%03d", bx, by); + std::string block_dir = found_base + "/" + block_str; + + bool ok = false; + if (std::filesystem::is_directory(block_dir)) { + std::string height_path = block_dir + "/height.raw"; + if (std::filesystem::exists(height_path)) { + ok = m_terrain->LoadRaw(height_path); + } + std::string tile_path = block_dir + "/tile.raw"; + if (std::filesystem::exists(tile_path)) { + m_terrain->LoadTileRaw(tile_path); + } + std::string attr_path = block_dir + "/attr.atr"; + if (std::filesystem::exists(attr_path)) { + m_terrain->LoadAttr(attr_path); + } + } else { + // Fallback: look for 000000 or any block in the directory + 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); + break; + } + } + } + } + + std::string textureset_path = "textureset/metin2_map1.txt"; + if (std::filesystem::exists(textureset_path)) { + m_terrain->LoadTextureSet(textureset_path); + } + + m_strMapName = mapName; + return ok; +} + +bool CPythonBackground::Warp(uint32_t x, uint32_t y) { + m_terrain.reset(); + m_strMapName.clear(); + m_strWarpMapName.clear(); + m_dwBaseX = 0; + m_dwBaseY = 0; + + LoadAtlas(); + auto* pMapInfo = GlobalPositionToMapInfo(x, y); + if (!pMapInfo) return false; + + float localX = static_cast(x - pMapInfo->m_dwBaseX); + float localY = static_cast(y - pMapInfo->m_dwBaseY); + if (!LoadMap(pMapInfo->m_strName, localX, localY, 0.0f)) { + return false; + } + + CPythonMiniMap::Instance().LoadAtlas(); + m_dwBaseX = pMapInfo->m_dwBaseX; + m_dwBaseY = pMapInfo->m_dwBaseY; + m_strMapName = pMapInfo->m_strName; + m_strWarpMapName = pMapInfo->m_strName; + return true; +} + + +float CPythonBackground::GetHeight(float fx, float fy) { + if (m_terrain) { + return m_terrain->GetHeightAtWorld(fx, fy); + } + return 0.0f; +} + +bool CPythonBackground::IsAttrOn(float fx, float fy, uint8_t attr) { + if (m_terrain) { + return m_terrain->IsAttrOn(fx, fy, attr); + } + return false; +} + +bool CPythonBackground::GetPickingPoint(float* pIntersectPt) { + if (!pIntersectPt) return false; + pIntersectPt[0] = m_v3PickingPoint[0]; + pIntersectPt[1] = m_v3PickingPoint[1]; + pIntersectPt[2] = m_v3PickingPoint[2]; + return true; +} + +void CPythonBackground::SetPickingPoint(float x, float y, float z) { + m_v3PickingPoint[0] = x; + m_v3PickingPoint[1] = y; + m_v3PickingPoint[2] = z; +} + +void CPythonBackground::SelectViewDistanceNum(int eNum) { + if (eNum >= 0 && eNum < NUM_DISTANCE_SET) { + m_eViewDistanceNum = eNum; + } +} + +void CPythonBackground::SetViewDistanceSet(int eNum, float fFarClip) { + if (eNum < 0 || eNum >= NUM_DISTANCE_SET) return; + m_ViewDistanceSet[eNum].m_fFogStart = fFarClip * 0.5f; + m_ViewDistanceSet[eNum].m_fFogEnd = fFarClip * 0.7f; + m_ViewDistanceSet[eNum].m_fFarClip = fFarClip; + float scale = fFarClip * 0.6f; + m_ViewDistanceSet[eNum].m_v3SkyBoxScale[0] = scale; + m_ViewDistanceSet[eNum].m_v3SkyBoxScale[1] = scale; + m_ViewDistanceSet[eNum].m_v3SkyBoxScale[2] = scale; +} + +float CPythonBackground::GetFarClip() { + if (m_ViewDistanceSet[m_eViewDistanceNum].m_fFarClip <= 0.0f) { + return 25600.0f; + } + return m_ViewDistanceSet[m_eViewDistanceNum].m_fFarClip; +} + +void CPythonBackground::GetDistanceSetInfo(int* peNum, float* pfStart, float* pfEnd, float* pfFarClip) { + if (peNum) *peNum = m_eViewDistanceNum; + if (pfStart) *pfStart = m_ViewDistanceSet[m_eViewDistanceNum].m_fFogStart; + if (pfEnd) *pfEnd = m_ViewDistanceSet[m_eViewDistanceNum].m_fFogEnd; + if (pfFarClip) *pfFarClip = m_ViewDistanceSet[m_eViewDistanceNum].m_fFarClip; +} + +bool CPythonBackground::SetVisiblePart(int ePart, bool isVisible) { + if (ePart < 0 || ePart >= PART_NUM) return false; + m_bVisiblePart[ePart] = isVisible; + return true; +} + +bool CPythonBackground::IsVisiblePart(int ePart) const { + if (ePart < 0 || ePart >= PART_NUM) return false; + return m_bVisiblePart[ePart]; +} + +bool CPythonBackground::SetShadowLevel(int eLevel) { + m_eShadowLevel = eLevel; + return true; +} + +bool CPythonBackground::SetSplatLimit(int iSplatNum) { + if (iSplatNum < 0) return false; + m_iSplatLimit = iSplatNum; + return true; +} + +std::string CPythonBackground::GetRenderedSplatNumStr(int* pPatch, int* pSplat, float* pRatio) { + if (pPatch) *pPatch = 0; + if (pSplat) *pSplat = 0; + if (pRatio) *pRatio = 0.0f; + return "0 "; +} + +void CPythonBackground::GetRenderedGraphicThingInstanceNum(uint32_t* pCount, uint32_t* pCRC) { + if (pCount) *pCount = 0; + if (pCRC) *pCRC = 0; +} + +uint32_t CPythonBackground::GetShadowMapColor(float fx, float fy) { + (void)fx; (void)fy; + return 0xFF000000; +} + +void CPythonBackground::EnableSnowEnvironment(bool enable) { + m_bSnowEnable = enable; +} + +void CPythonBackground::DisableSnowEnvironment() { + m_bSnowEnable = false; +} + +void CPythonBackground::RegisterDungeonMapName(const char* szName) { + if (szName) m_kSet_strDungeonMapName.insert(szName); +} + +void CPythonBackground::RegisterGuildArea(int isx, int isy, int iex, int iey) { + (void)isx; (void)isy; (void)iex; (void)iey; +} + +void CPythonBackground::ClearGuildArea() { +} + +bool CPythonBackground::RegisterEnvironmentData(int iIndex, const char* pszEnvironmentFileName) { + if (!pszEnvironmentFileName) return false; + EnvironmentData env; + if (env.LoadFromFile(pszEnvironmentFileName)) { + m_mapEnvironmentData[iIndex] = env; + return true; + } + std::string text; + try { text = ReadPackedText(pszEnvironmentFileName); } catch (...) {} + if (!text.empty() && env.LoadFromString(text)) { + m_mapEnvironmentData[iIndex] = env; + return true; + } + return false; +} + +bool CPythonBackground::SetEnvironmentData(int iIndex) { + auto it = m_mapEnvironmentData.find(iIndex); + if (it != m_mapEnvironmentData.end()) { + m_pCurrentEnvironment = &it->second; + return true; + } + return false; +} + +void CPythonBackground::BeginEnvironment() { +} + +void CPythonBackground::EndEnvironment() { +} + +void CPythonBackground::SetCharacterDirLight() { +} + +void CPythonBackground::SetBackgroundDirLight() { +} + +void CPythonBackground::CreatePrivateShopPos(int vid) { + m_privateShopPosVID = static_cast(vid); +} + +void CPythonBackground::DeletePrivateShopPos() { + m_privateShopPosVID = 0; +} + +void CPythonBackground::CreateTargetEffect(uint32_t dwID, uint32_t dwChrVID) { + m_targetEffects[dwID] = dwChrVID; +} + +void CPythonBackground::CreateTargetEffect(uint32_t dwID, long lx, long ly) { + m_targetPositions[dwID] = {static_cast(lx), static_cast(ly)}; +} + +void CPythonBackground::DeleteTargetEffect(uint32_t dwID) { + m_targetEffects.erase(dwID); + m_targetPositions.erase(dwID); +} + +void CPythonBackground::CreateTargetEffectShop(uint32_t dwID, uint32_t dwChrVID) { + m_targetEffectsShop[dwID] = dwChrVID; +} + +void CPythonBackground::CreateTargetEffectShop(uint32_t dwID, long lx, long ly) { + m_targetPositions[dwID] = {static_cast(lx), static_cast(ly)}; +} + +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; +} + +void CPythonBackground::DeleteSpecialEffect(uint32_t dwID) { + (void)dwID; +} + +void CPythonBackground::Update(float fCameraX, float fCameraY, float fCameraZ) { + (void)fCameraX; (void)fCameraY; (void)fCameraZ; +} + +void CPythonBackground::Render() { +} + +void CPythonBackground::RenderSky() { +} + +void CPythonBackground::RenderCloud() { +} + +void CPythonBackground::RenderWater() { +} + +void CPythonBackground::RenderEffect() { +} + +void CPythonBackground::RenderCollision() { +} + +void CPythonBackground::RenderPCBlocker() { +} + +void CPythonBackground::RenderBeforeLensFlare() { +} + +void CPythonBackground::RenderAfterLensFlare() { +} + +void CPythonBackground::RenderCharacterShadowToTexture() { +} + +void CPythonBackground::RenderSnow() { +} + +void CPythonBackground::BuildDrawCommands(const float* viewMatrix, const float* projMatrix, const float* camPos, std::vector& outDraws) { + if (!IsMapReady()) return; + + if (m_bVisiblePart[PART_TERRAIN] && m_terrain) { + std::vector tdraws; + if (viewMatrix && projMatrix) { + tdraws = m_terrain->BuildCulledDraws(viewMatrix, projMatrix, GetFarClip()); + } + if (tdraws.empty()) { + auto td = m_terrain->BuildDrawCommand(nullptr, 2); + if (!td.positions.empty()) tdraws.push_back(std::move(td)); + } + for (auto& td : tdraws) { + if (m_pCurrentEnvironment) { + td.light_direction[0] = m_pCurrentEnvironment->dir_light.direction[0]; + td.light_direction[1] = m_pCurrentEnvironment->dir_light.direction[1]; + td.light_direction[2] = m_pCurrentEnvironment->dir_light.direction[2]; + td.light_ambient[0] = m_pCurrentEnvironment->dir_light.bg_ambient[0]; + td.light_ambient[1] = m_pCurrentEnvironment->dir_light.bg_ambient[1]; + td.light_ambient[2] = m_pCurrentEnvironment->dir_light.bg_ambient[2]; + } + outDraws.push_back(std::move(td)); + } + } + + if (m_bVisiblePart[PART_WATER] && m_water && m_water->HasWater()) { + outDraws.push_back(m_water->BuildDrawCommand(0.0f)); + } + + if (m_bVisiblePart[PART_OBJECT] && m_mapObjects) { + auto bdraws = m_mapObjects->BuildDrawCommands(); + for (auto& bd : bdraws) outDraws.push_back(std::move(bd)); + } + + if (m_bVisiblePart[PART_TREE] && m_forest && viewMatrix && projMatrix && camPos) { + auto fdraws = m_forest->BuildDrawCommands(viewMatrix, projMatrix, camPos[0], camPos[1], camPos[2], GetFarClip()); + for (auto& fd : fdraws) outDraws.push_back(std::move(fd)); + } +} + +// ------------------------------------------------------------------------- +// Python Interface Wrappers +// ------------------------------------------------------------------------- + +namespace { + +PyObject* background_IsSoftwareTiling(PyObject*, PyObject*) { + return Py_BuildValue("i", CPythonBackground::Instance().IsSoftwareTilingEnable() ? 1 : 0); +} + +PyObject* background_EnableSoftwareTiling(PyObject*, PyObject* args) { + int isEnable = 0; + if (!PyTuple_GetInteger(args, 0, &isEnable)) return Py_BadArgument(); + CPythonBackground::Instance().ReserveSoftwareTilingEnable(isEnable != 0); + CPythonSystem::Instance().SetSoftwareTiling(isEnable != 0); + return Py_BuildNone(); +} + +PyObject* background_TextureChange(PyObject*, PyObject* args) { + char* szFileName = nullptr; + if (!PyTuple_GetString(args, 0, &szFileName)) return Py_BuildException(); + return Py_BuildNone(); +} + +PyObject* background_EnableSnow(PyObject*, PyObject* args) { + int isEnable = 0; + if (!PyTuple_GetInteger(args, 0, &isEnable)) return Py_BadArgument(); + if (isEnable) + CPythonBackground::Instance().EnableSnowEnvironment(); + else + CPythonBackground::Instance().DisableSnowEnvironment(); + return Py_BuildNone(); +} + +PyObject* background_GlobalPositionToLocalPosition(PyObject*, PyObject* args) { + int iX = 0, iY = 0; + if (!PyTuple_GetInteger(args, 0, &iX) || !PyTuple_GetInteger(args, 1, &iY)) return Py_BadArgument(); + long lX = iX, lY = iY; + CPythonBackground::Instance().GlobalPositionToLocalPosition(lX, lY); + return Py_BuildValue("ii", static_cast(lX), static_cast(lY)); +} + +PyObject* background_GlobalPositionToMapInfo(PyObject*, PyObject* args) { + int iX = 0, iY = 0; + if (!PyTuple_GetInteger(args, 0, &iX) || !PyTuple_GetInteger(args, 1, &iY)) return Py_BadArgument(); + auto* pInfo = CPythonBackground::Instance().GlobalPositionToMapInfo(static_cast(iX), static_cast(iY)); + if (pInfo) { + return Py_BuildValue("sii", pInfo->m_strName.c_str(), static_cast(pInfo->m_dwBaseX), static_cast(pInfo->m_dwBaseY)); + } + return Py_BuildValue("sii", "", 0, 0); +} + +PyObject* background_GetRenderShadowTime(PyObject*, PyObject*) { + return Py_BuildValue("i", CPythonBackground::Instance().GetRenderShadowTime()); +} + +PyObject* background_LoadMap(PyObject*, PyObject* args) { + char* pszMapName = nullptr; + float x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetString(args, 0, &pszMapName) || + !PyTuple_GetFloat(args, 1, &x) || + !PyTuple_GetFloat(args, 2, &y) || + !PyTuple_GetFloat(args, 3, &z)) { + return Py_BadArgument(); + } + CPythonBackground::Instance().LoadMap(pszMapName ? pszMapName : "", x, y, z); + return Py_BuildNone(); +} + +PyObject* background_Destroy(PyObject*, PyObject*) { + CPythonBackground::Instance().SetShadowLevel(CPythonBackground::SHADOW_NONE); + CPythonBackground::Instance().Destroy(); + return Py_BuildNone(); +} + +PyObject* background_RegisterEnvironmentData(PyObject*, PyObject* args) { + int iIndex = 0; + char* pszEnvFile = nullptr; + if (!PyTuple_GetInteger(args, 0, &iIndex) || !PyTuple_GetString(args, 1, &pszEnvFile)) { + return Py_BadArgument(); + } + CPythonBackground::Instance().RegisterEnvironmentData(iIndex, pszEnvFile ? pszEnvFile : ""); + return Py_BuildNone(); +} + +PyObject* background_SetEnvironmentData(PyObject*, PyObject* args) { + int iIndex = 0; + if (!PyTuple_GetInteger(args, 0, &iIndex)) return Py_BadArgument(); + CPythonBackground::Instance().SetEnvironmentData(iIndex); + return Py_BuildNone(); +} + +PyObject* background_GetCurrentMapName(PyObject*, PyObject*) { + return Py_BuildValue("s", CPythonBackground::Instance().GetWarpMapName().c_str()); +} + +PyObject* background_GetPickingPoint(PyObject*, PyObject*) { + float pt[3] = {0.0f, 0.0f, 0.0f}; + CPythonBackground::Instance().GetPickingPoint(pt); + return Py_BuildValue("fff", pt[0], -pt[1], pt[2]); +} + +PyObject* background_BeginEnvironment(PyObject*, PyObject*) { + CPythonBackground::Instance().BeginEnvironment(); + return Py_BuildNone(); +} + +PyObject* background_EndEnvironment(PyObject*, PyObject*) { + CPythonBackground::Instance().EndEnvironment(); + return Py_BuildNone(); +} + +PyObject* background_SetCharacterDirLight(PyObject*, PyObject*) { + CPythonBackground::Instance().SetCharacterDirLight(); + return Py_BuildNone(); +} + +PyObject* background_SetBackgroundDirLight(PyObject*, PyObject*) { + CPythonBackground::Instance().SetBackgroundDirLight(); + return Py_BuildNone(); +} + +PyObject* background_Initialize(PyObject*, PyObject*) { + CPythonBackground::Instance().Create(); + return Py_BuildNone(); +} + +PyObject* background_Update(PyObject*, PyObject* args) { + float fCameraX = 0.0f, fCameraY = 0.0f, fCameraZ = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fCameraX) || + !PyTuple_GetFloat(args, 1, &fCameraY) || + !PyTuple_GetFloat(args, 2, &fCameraZ)) { + return Py_BadArgument(); + } + CPythonBackground::Instance().Update(fCameraX, fCameraY, fCameraZ); + return Py_BuildNone(); +} + +PyObject* background_Render(PyObject*, PyObject*) { + CPythonBackground::Instance().Render(); + return Py_BuildNone(); +} + +PyObject* background_RenderPCBlocker(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderPCBlocker(); + return Py_BuildNone(); +} + +PyObject* background_RenderCollision(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderCollision(); + return Py_BuildNone(); +} + +PyObject* background_RenderSky(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderSky(); + return Py_BuildNone(); +} + +PyObject* background_RenderCloud(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderCloud(); + return Py_BuildNone(); +} + +PyObject* background_RenderWater(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderWater(); + return Py_BuildNone(); +} + +PyObject* background_RenderEffect(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderEffect(); + return Py_BuildNone(); +} + +PyObject* background_RenderBeforeLensFlare(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderBeforeLensFlare(); + return Py_BuildNone(); +} + +PyObject* background_RenderAfterLensFlare(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderAfterLensFlare(); + return Py_BuildNone(); +} + +PyObject* background_RenderCharacterShadowToTexture(PyObject*, PyObject*) { + CPythonBackground::Instance().RenderCharacterShadowToTexture(); + return Py_BuildNone(); +} + +PyObject* background_RenderDungeon(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +PyObject* background_GetHeight(PyObject*, PyObject* args) { + float fx = 0.0f, fy = 0.0f; + if (!PyTuple_GetFloat(args, 0, &fx) || !PyTuple_GetFloat(args, 1, &fy)) { + return Py_BadArgument(); + } + return Py_BuildValue("f", CPythonBackground::Instance().GetHeight(fx, fy)); +} + +PyObject* background_SetShadowLevel(PyObject*, PyObject* args) { + int iLevel = 0; + if (!PyTuple_GetInteger(args, 0, &iLevel)) return Py_BadArgument(); + CPythonBackground::Instance().SetShadowLevel(iLevel); + return Py_BuildNone(); +} + +PyObject* background_IsVisiblePart(PyObject*, PyObject* args) { + int ePart = 0; + if (!PyTuple_GetInteger(args, 0, &ePart)) return Py_BadArgument(); + if (ePart < 0 || ePart >= CPythonBackground::PART_NUM) { + return Py_BuildException("ePart(%d)= CPythonBackground::PART_NUM) { + return Py_BuildException("ePart(%d)=0)", iSplatNum); + } + CPythonBackground::Instance().SetSplatLimit(iSplatNum); + return Py_BuildNone(); +} + +PyObject* background_GetRenderedSplatNum(PyObject*, PyObject*) { + int iPatch = 0, iSplat = 0; + float fRatio = 0.0f; + std::string sOutput = CPythonBackground::Instance().GetRenderedSplatNumStr(&iPatch, &iSplat, &fRatio); + return Py_BuildValue("iifs", iPatch, iSplat, fRatio, sOutput.c_str()); +} + +PyObject* background_GetRenderedGTINum(PyObject*, PyObject*) { + uint32_t count = 0, crc = 0; + CPythonBackground::Instance().GetRenderedGraphicThingInstanceNum(&count, &crc); + return Py_BuildValue("ii", count, crc); +} + +PyObject* background_SelectViewDistanceNum(PyObject*, PyObject* args) { + int iNum = 0; + if (!PyTuple_GetInteger(args, 0, &iNum)) return Py_BadArgument(); + CPythonBackground::Instance().SelectViewDistanceNum(iNum); + return Py_BuildNone(); +} + +PyObject* background_SetViewDistanceSet(PyObject*, PyObject* args) { + int iNum = 0; + float fFarClip = 0.0f; + if (!PyTuple_GetInteger(args, 0, &iNum) || !PyTuple_GetFloat(args, 1, &fFarClip)) { + return Py_BadArgument(); + } + CPythonBackground::Instance().SetViewDistanceSet(iNum, fFarClip); + return Py_BuildNone(); +} + +PyObject* background_GetFarClip(PyObject*, PyObject*) { + return Py_BuildValue("f", CPythonBackground::Instance().GetFarClip()); +} + +PyObject* background_GetDistanceSetInfo(PyObject*, PyObject*) { + int iNum = 0; + float fStart = 0.0f, fEnd = 0.0f, fFarClip = 0.0f; + CPythonBackground::Instance().GetDistanceSetInfo(&iNum, &fStart, &fEnd, &fFarClip); + return Py_BuildValue("ifff", iNum, fStart, fEnd, fFarClip); +} + +PyObject* background_SetBGLoading(PyObject*, PyObject* args) { + bool bLoading = false; + if (!PyTuple_GetBoolean(args, 0, &bLoading)) return Py_BadArgument(); + CPythonBackground::Instance().SetBGLoading(bLoading); + return Py_BuildNone(); +} + +PyObject* background_SetRenderSort(PyObject*, PyObject* args) { + int eSort = 0; + if (!PyTuple_GetInteger(args, 0, &eSort)) return Py_BadArgument(); + CPythonBackground::Instance().SetTerrainRenderSort(eSort); + return Py_BuildNone(); +} + +PyObject* background_SetTransparentTree(PyObject*, PyObject* args) { + int bTransparent = 0; + if (!PyTuple_GetInteger(args, 0, &bTransparent)) return Py_BadArgument(); + CPythonBackground::Instance().SetTransparentTree(bTransparent != 0); + return Py_BuildNone(); +} + +PyObject* background_SetXMasTree(PyObject*, PyObject* args) { + int iGrade = 0; + if (!PyTuple_GetInteger(args, 0, &iGrade)) return Py_BadArgument(); + CPythonBackground::Instance().SetXMaxTree(iGrade); + return Py_BuildNone(); +} + +PyObject* background_RegisterDungeonMapName(PyObject*, PyObject* args) { + char* szName = nullptr; + if (!PyTuple_GetString(args, 0, &szName)) return Py_BadArgument(); + CPythonBackground::Instance().RegisterDungeonMapName(szName); + return Py_BuildNone(); +} + +PyObject* background_VisibleGuildArea(PyObject*, PyObject*) { + CPythonBackground::Instance().VisibleGuildArea(); + return Py_BuildNone(); +} + +PyObject* background_DisableGuildArea(PyObject*, PyObject*) { + CPythonBackground::Instance().DisableGuildArea(); + return Py_BuildNone(); +} + +PyObject* background_WarpTest(PyObject*, PyObject* args) { + int iX = 0, iY = 0; + if (!PyTuple_GetInteger(args, 0, &iX) || !PyTuple_GetInteger(args, 1, &iY)) return Py_BadArgument(); + CPythonBackground::Instance().Warp(static_cast(iX) * 100u, static_cast(iY) * 100u); + return Py_BuildNone(); +} + +PyObject* background_CreatePrivateShopPos(PyObject*, PyObject* args) { + int iVID = 0; + if (!PyTuple_GetInteger(args, 0, &iVID)) return Py_BadArgument(); + CPythonBackground::Instance().CreatePrivateShopPos(iVID); + return Py_BuildNone(); +} + +PyObject* background_DeletePrivateShopPos(PyObject*, PyObject*) { + CPythonBackground::Instance().DeletePrivateShopPos(); + return Py_BuildNone(); +} + +PyObject* background_isAttrOn(PyObject*, PyObject* args) { + float x = 0.0f, y = 0.0f; + int attr = 0; + if (!PyArg_ParseTuple(args, "ffi", &x, &y, &attr)) { + PyErr_Clear(); + int ix = 0, iy = 0; + if (PyArg_ParseTuple(args, "iii", &ix, &iy, &attr)) { + x = static_cast(ix); + y = static_cast(iy); + } else { + return Py_BuildValue("i", 0); + } + } + return Py_BuildValue("i", CPythonBackground::Instance().IsAttrOn(x, y, static_cast(attr)) ? 1 : 0); +} + +} // namespace + +void initBackground() { + static PyMethodDef s_methods[] = { + {"IsSoftwareTiling", background_IsSoftwareTiling, METH_VARARGS, nullptr}, + {"EnableSoftwareTiling", background_EnableSoftwareTiling, METH_VARARGS, nullptr}, + {"TextureChange", background_TextureChange, METH_VARARGS, nullptr}, + {"EnableSnow", background_EnableSnow, METH_VARARGS, nullptr}, + {"GlobalPositionToLocalPosition", background_GlobalPositionToLocalPosition, METH_VARARGS, nullptr}, + {"GlobalPositionToMapInfo", background_GlobalPositionToMapInfo, METH_VARARGS, nullptr}, + {"GetRenderShadowTime", background_GetRenderShadowTime, METH_VARARGS, nullptr}, + {"LoadMap", background_LoadMap, METH_VARARGS, nullptr}, + {"Destroy", background_Destroy, METH_VARARGS, nullptr}, + {"RegisterEnvironmentData", background_RegisterEnvironmentData, METH_VARARGS, nullptr}, + {"SetEnvironmentData", background_SetEnvironmentData, METH_VARARGS, nullptr}, + {"GetCurrentMapName", background_GetCurrentMapName, METH_VARARGS, nullptr}, + {"GetPickingPoint", background_GetPickingPoint, METH_VARARGS, nullptr}, + {"BeginEnvironment", background_BeginEnvironment, METH_VARARGS, nullptr}, + {"EndEnvironment", background_EndEnvironment, METH_VARARGS, nullptr}, + {"SetCharacterDirLight", background_SetCharacterDirLight, METH_VARARGS, nullptr}, + {"SetBackgroundDirLight", background_SetBackgroundDirLight, METH_VARARGS, nullptr}, + {"Initialize", background_Initialize, METH_VARARGS, nullptr}, + {"Update", background_Update, METH_VARARGS, nullptr}, + {"Render", background_Render, METH_VARARGS, nullptr}, + {"RenderPCBlocker", background_RenderPCBlocker, METH_VARARGS, nullptr}, + {"RenderCollision", background_RenderCollision, METH_VARARGS, nullptr}, + {"RenderSky", background_RenderSky, METH_VARARGS, nullptr}, + {"RenderCloud", background_RenderCloud, METH_VARARGS, nullptr}, + {"RenderWater", background_RenderWater, METH_VARARGS, nullptr}, + {"RenderEffect", background_RenderEffect, METH_VARARGS, nullptr}, + {"RenderBeforeLensFlare", background_RenderBeforeLensFlare, METH_VARARGS, nullptr}, + {"RenderAfterLensFlare", background_RenderAfterLensFlare, METH_VARARGS, nullptr}, + {"RenderCharacterShadowToTexture", background_RenderCharacterShadowToTexture, METH_VARARGS, nullptr}, + {"RenderDungeon", background_RenderDungeon, METH_VARARGS, nullptr}, + {"GetHeight", background_GetHeight, METH_VARARGS, nullptr}, + {"isAttrOn", background_isAttrOn, METH_VARARGS, nullptr}, + {"IsAttrOn", background_isAttrOn, METH_VARARGS, nullptr}, + {"SetShadowLevel", background_SetShadowLevel, METH_VARARGS, nullptr}, + {"IsVisiblePart", background_IsVisiblePart, METH_VARARGS, nullptr}, + {"SetVisiblePart", background_SetVisiblePart, METH_VARARGS, nullptr}, + {"GetShadowMapColor", background_GetShadowMapColor, METH_VARARGS, nullptr}, + {"SetSplatLimit", background_SetSplatLimit, METH_VARARGS, nullptr}, + {"GetRenderedSplatNum", background_GetRenderedSplatNum, METH_VARARGS, nullptr}, + {"GetRenderedGraphicThingInstanceNum", background_GetRenderedGTINum, METH_VARARGS, nullptr}, + {"SelectViewDistanceNum", background_SelectViewDistanceNum, METH_VARARGS, nullptr}, + {"SetViewDistanceSet", background_SetViewDistanceSet, METH_VARARGS, nullptr}, + {"GetFarClip", background_GetFarClip, METH_VARARGS, nullptr}, + {"GetDistanceSetInfo", background_GetDistanceSetInfo, METH_VARARGS, nullptr}, + {"SetBGLoading", background_SetBGLoading, METH_VARARGS, nullptr}, + {"SetRenderSort", background_SetRenderSort, METH_VARARGS, nullptr}, + {"SetTransparentTree", background_SetTransparentTree, METH_VARARGS, nullptr}, + {"SetXMasTree", background_SetXMasTree, METH_VARARGS, nullptr}, + {"RegisterDungeonMapName", background_RegisterDungeonMapName, METH_VARARGS, nullptr}, + {"VisibleGuildArea", background_VisibleGuildArea, METH_VARARGS, nullptr}, + {"DisableGuildArea", background_DisableGuildArea, METH_VARARGS, nullptr}, + {"WarpTest", background_WarpTest, METH_VARARGS, nullptr}, + {"CreatePrivateShopPos", background_CreatePrivateShopPos, METH_VARARGS, nullptr}, + {"DeletePrivateShopPos", background_DeletePrivateShopPos, METH_VARARGS, nullptr}, + {nullptr, nullptr, 0, nullptr} + }; + + PyObject* poModule = Py_InitModule("background", s_methods); + + PyModule_AddIntConstant(poModule, "PART_TERRAIN", CPythonBackground::PART_TERRAIN); + PyModule_AddIntConstant(poModule, "PART_OBJECT", CPythonBackground::PART_OBJECT); + PyModule_AddIntConstant(poModule, "PART_CLOUD", CPythonBackground::PART_CLOUD); + PyModule_AddIntConstant(poModule, "PART_WATER", CPythonBackground::PART_WATER); + PyModule_AddIntConstant(poModule, "PART_TREE", CPythonBackground::PART_TREE); + PyModule_AddIntConstant(poModule, "PART_SKY", CPythonBackground::PART_SKY); + PyModule_AddIntConstant(poModule, "PART_SHOP", CPythonBackground::PART_SHOP); + + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_DEFAULT", CPythonBackground::SKY_RENDER_MODE_DEFAULT); + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_DIFFUSE", CPythonBackground::SKY_RENDER_MODE_DIFFUSE); + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_TEXTURE", CPythonBackground::SKY_RENDER_MODE_TEXTURE); + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_MODULATE", CPythonBackground::SKY_RENDER_MODE_MODULATE); + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_MODULATE2X", CPythonBackground::SKY_RENDER_MODE_MODULATE2X); + PyModule_AddIntConstant(poModule, "SKY_RENDER_MODE_MODULATE4X", CPythonBackground::SKY_RENDER_MODE_MODULATE4X); + + PyModule_AddIntConstant(poModule, "SHADOW_NONE", CPythonBackground::SHADOW_NONE); + PyModule_AddIntConstant(poModule, "SHADOW_GROUND", CPythonBackground::SHADOW_GROUND); + PyModule_AddIntConstant(poModule, "SHADOW_GROUND_AND_SOLO", CPythonBackground::SHADOW_GROUND_AND_SOLO); + PyModule_AddIntConstant(poModule, "SHADOW_ALL", CPythonBackground::SHADOW_ALL); + PyModule_AddIntConstant(poModule, "SHADOW_ALL_HIGH", CPythonBackground::SHADOW_ALL_HIGH); + PyModule_AddIntConstant(poModule, "SHADOW_ALL_MAX", CPythonBackground::SHADOW_ALL_MAX); + + PyModule_AddIntConstant(poModule, "DISTANCE0", CPythonBackground::DISTANCE0); + PyModule_AddIntConstant(poModule, "DISTANCE1", CPythonBackground::DISTANCE1); + PyModule_AddIntConstant(poModule, "DISTANCE2", CPythonBackground::DISTANCE2); + PyModule_AddIntConstant(poModule, "DISTANCE3", CPythonBackground::DISTANCE3); + PyModule_AddIntConstant(poModule, "DISTANCE4", CPythonBackground::DISTANCE4); + + PyModule_AddIntConstant(poModule, "DISTANCE_SORT", CPythonBackground::DISTANCE_SORT); + PyModule_AddIntConstant(poModule, "TEXTURE_SORT", CPythonBackground::TEXTURE_SORT); + + PyModule_AddIntConstant(poModule, "ATTR_BLOCK", TerrainAttr::ATTR_BLOCK); + PyModule_AddIntConstant(poModule, "ATTR_WATER", TerrainAttr::ATTR_WATER); + PyModule_AddIntConstant(poModule, "ATTR_BANPK", TerrainAttr::ATTR_BANPK); + PyModule_AddIntConstant(poModule, "ATTRIBUTE_BLOCK", TerrainAttr::ATTR_BLOCK); + PyModule_AddIntConstant(poModule, "ATTRIBUTE_WATER", TerrainAttr::ATTR_WATER); + PyModule_AddIntConstant(poModule, "ATTRIBUTE_BANPK", TerrainAttr::ATTR_BANPK); +} + +TerrainHeightmap* GetActiveBackgroundTerrain() { + return CPythonBackground::Instance().GetTerrain(); +} + +void SetActiveBackgroundTerrain(std::unique_ptr terrain) { + (void)terrain; +} + +bool LoadBackgroundMap(const std::string& mapName, float x, float y, float z) { + return CPythonBackground::Instance().LoadMap(mapName, x, y, z); +} + +bool WarpBackgroundMap(uint32_t x, uint32_t y) { + return CPythonBackground::Instance().Warp(x, y); +} + +void GlobalToLocalPosition(int32_t& x, int32_t& y) { + long lx = x, ly = y; + CPythonBackground::Instance().GlobalPositionToLocalPosition(lx, ly); + x = static_cast(lx); + y = static_cast(ly); +} + +void LocalToGlobalPosition(int32_t& x, int32_t& y) { + long lx = x, ly = y; + CPythonBackground::Instance().LocalPositionToGlobalPosition(lx, ly); + x = static_cast(lx); + y = static_cast(ly); +} + +const OutdoorMapInfo* GetOutdoorMap() { + return CPythonBackground::Instance().GetOutdoorMap(); +} + +} // namespace ava2 + diff --git a/src/python_background.h b/src/python_background.h new file mode 100644 index 00000000..1809c3c5 --- /dev/null +++ b/src/python_background.h @@ -0,0 +1,269 @@ +#pragma once + +#include "eter_render/RenderCommands3D.h" +#include "eter_render/TerrainHeightmap.h" +#include "eter_render/MapObjectManager.h" +#include "eter_render/WaterManager.h" +#include "eter_render/EnvironmentData.h" +#include "eter_render/SkyBox.h" +#include "eter_render/SpeedTreeForest.h" + +#include +#include +#include +#include +#include +#include + +namespace ava2 { + +struct OutdoorMapInfo { + std::string name; + uint32_t baseX = 0; + uint32_t baseY = 0; + int16_t terrainCountX = 0; + int16_t terrainCountY = 0; +}; + +class CPythonBackground { +public: + enum { + SHADOW_NONE = 0, + SHADOW_GROUND = 1, + SHADOW_GROUND_AND_SOLO = 2, + SHADOW_ALL = 3, + SHADOW_ALL_HIGH = 4, + SHADOW_ALL_MAX = 5, + }; + + enum { + DISTANCE0 = 0, + DISTANCE1 = 1, + DISTANCE2 = 2, + DISTANCE3 = 3, + DISTANCE4 = 4, + NUM_DISTANCE_SET = 5, + }; + + enum { + PART_TERRAIN = 0, + PART_OBJECT = 1, + PART_CLOUD = 2, + PART_WATER = 3, + PART_TREE = 4, + PART_SKY = 5, + PART_SHOP = 6, + PART_NUM = 7, + }; + + enum { + DAY_MODE_LIGHT = 0, + DAY_MODE_DARK = 1, + }; + + enum ETerrainRenderSort { + DISTANCE_SORT = 0, + TEXTURE_SORT = 1, + }; + + enum { + SKY_RENDER_MODE_DEFAULT = 0, + SKY_RENDER_MODE_DIFFUSE = 1, + SKY_RENDER_MODE_TEXTURE = 2, + SKY_RENDER_MODE_MODULATE = 3, + SKY_RENDER_MODE_MODULATE2X = 4, + SKY_RENDER_MODE_MODULATE4X = 5, + }; + + struct SViewDistanceSet { + float m_fFogStart = 12800.0f; + float m_fFogEnd = 17920.0f; + float m_fFarClip = 25600.0f; + float m_v3SkyBoxScale[3] = {15360.0f, 15360.0f, 15360.0f}; + }; + + struct TMapInfo { + std::string m_strName; + uint32_t m_dwBaseX = 0; + uint32_t m_dwBaseY = 0; + uint32_t m_dwSizeX = 0; + uint32_t m_dwSizeY = 0; + uint32_t m_dwEndX = 0; + uint32_t m_dwEndY = 0; + }; + + static CPythonBackground& Instance(); + + CPythonBackground(); + ~CPythonBackground(); + + void Initialize(); + void Destroy(); + void Create(); + + bool IsMapReady() const; + + bool LoadMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f); + bool Warp(uint32_t x, uint32_t y); + + const std::string& GetCurrentMapName() const { return m_strMapName; } + const std::string& GetWarpMapName() const { return m_strWarpMapName; } + + void GlobalPositionToLocalPosition(long& rGlobalX, long& rGlobalY); + void LocalPositionToGlobalPosition(long& rLocalX, long& rLocalY); + TMapInfo* GlobalPositionToMapInfo(uint32_t dwGlobalX, uint32_t dwGlobalY); + + float GetHeight(float fx, float fy); + bool IsAttrOn(float fx, float fy, uint8_t attr); + + bool GetPickingPoint(float* pIntersectPt); + void SetPickingPoint(float x, float y, float z); + + void SelectViewDistanceNum(int eNum); + void SetViewDistanceSet(int eNum, float fFarClip); + float GetFarClip(); + void GetDistanceSetInfo(int* peNum, float* pfStart, float* pfEnd, float* pfFarClip); + + bool SetVisiblePart(int ePart, bool isVisible); + bool IsVisiblePart(int ePart) const; + + bool SetShadowLevel(int eLevel); + int GetShadowLevel() const { return m_eShadowLevel; } + uint32_t GetRenderShadowTime() const { return m_dwRenderShadowTime; } + + bool SetSplatLimit(int iSplatNum); + int GetSplatLimit() const { return m_iSplatLimit; } + std::string GetRenderedSplatNumStr(int* pPatch, int* pSplat, float* pRatio); + void GetRenderedGraphicThingInstanceNum(uint32_t* pCount, uint32_t* pCRC); + + uint32_t GetShadowMapColor(float fx, float fy); + + void ReserveSoftwareTilingEnable(bool enable) { m_bSoftwareTilingEnable = enable; } + bool IsSoftwareTilingEnable() const { return m_bSoftwareTilingEnable; } + + void EnableSnowEnvironment(bool enable = true); + void DisableSnowEnvironment(); + bool IsSnowEnvironment() const { return m_bSnowEnable; } + + void SetTransparentTree(bool enable) { m_bTransparentTree = enable; } + bool IsTransparentTree() const { return m_bTransparentTree; } + + void SetXMaxTree(int iGrade) { m_iXMasTreeGrade = iGrade; } + int GetXMaxTree() const { return m_iXMasTreeGrade; } + + void RegisterDungeonMapName(const char* szName); + + void VisibleGuildArea() { m_bVisibleGuildArea = true; } + void DisableGuildArea() { m_bVisibleGuildArea = false; } + void RegisterGuildArea(int isx, int isy, int iex, int iey); + void ClearGuildArea(); + + bool RegisterEnvironmentData(int iIndex, const char* pszEnvironmentFileName); + bool SetEnvironmentData(int iIndex); + const EnvironmentData* GetCurrentEnvironmentData() const { return m_pCurrentEnvironment; } + + void BeginEnvironment(); + void EndEnvironment(); + + void SetCharacterDirLight(); + void SetBackgroundDirLight(); + + void SetTerrainRenderSort(int eSort) { m_eTerrainRenderSort = eSort; } + void SetBGLoading(bool bgLoading) { m_bBGLoading = bgLoading; } + + void CreatePrivateShopPos(int vid); + void DeletePrivateShopPos(); + + void CreateTargetEffect(uint32_t dwID, uint32_t dwChrVID); + void CreateTargetEffect(uint32_t dwID, long lx, long ly); + void DeleteTargetEffect(uint32_t dwID); + + void CreateTargetEffectShop(uint32_t dwID, uint32_t dwChrVID); + void CreateTargetEffectShop(uint32_t dwID, long lx, long ly); + + void CreateSpecialEffect(uint32_t dwID, float fx, float fy, float fz, const char* szFileName); + void DeleteSpecialEffect(uint32_t dwID); + + void Update(float fCameraX, float fCameraY, float fCameraZ); + + void Render(); + void RenderSky(); + void RenderCloud(); + void RenderWater(); + void RenderEffect(); + void RenderCollision(); + void RenderPCBlocker(); + void RenderBeforeLensFlare(); + void RenderAfterLensFlare(); + void RenderCharacterShadowToTexture(); + void RenderSnow(); + + TerrainHeightmap* GetTerrain() { return m_terrain.get(); } + MapObjectManager* GetMapObjects() { return m_mapObjects.get(); } + WaterManager* GetWater() { return m_water.get(); } + SkyBox* GetSkyBox() { return m_skybox.get(); } + SpeedTreeForest* GetForest() { return m_forest.get(); } + const OutdoorMapInfo* GetOutdoorMap() const { return m_strMapName.empty() ? nullptr : &m_outdoorMap; } + + void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, const float* camPos, std::vector& outDraws); + +private: + void LoadAtlas(); + + std::string m_strMapName; + std::string m_strWarpMapName; + uint32_t m_dwBaseX = 0; + uint32_t m_dwBaseY = 0; + + int m_eViewDistanceNum = 0; + SViewDistanceSet m_ViewDistanceSet[NUM_DISTANCE_SET]; + + bool m_bVisiblePart[PART_NUM] = {true, true, true, true, true, true, true}; + int m_eShadowLevel = SHADOW_NONE; + uint32_t m_dwRenderShadowTime = 0; + int m_iSplatLimit = 0; + + bool m_bSoftwareTilingEnable = false; + bool m_bSnowEnable = false; + bool m_bTransparentTree = false; + int m_iXMasTreeGrade = 0; + bool m_bVisibleGuildArea = false; + int m_eTerrainRenderSort = DISTANCE_SORT; + bool m_bBGLoading = false; + + float m_v3PickingPoint[3] = {0.0f, 0.0f, 0.0f}; + + std::set m_kSet_strDungeonMapName; + + std::vector m_kVct_kMapInfo; + std::string m_atlasLocale; + + std::map m_mapEnvironmentData; + const EnvironmentData* m_pCurrentEnvironment = nullptr; + EnvironmentData m_defaultEnvironment; + + std::unique_ptr m_terrain; + std::unique_ptr m_mapObjects; + std::unique_ptr m_water; + std::unique_ptr m_skybox; + std::unique_ptr m_forest; + + OutdoorMapInfo m_outdoorMap; + + std::map m_targetEffects; + std::map m_targetEffectsShop; + std::map> m_targetPositions; + uint32_t m_privateShopPosVID = 0; +}; + +void initBackground(); + +TerrainHeightmap* GetActiveBackgroundTerrain(); +void SetActiveBackgroundTerrain(std::unique_ptr terrain); +bool LoadBackgroundMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f); +bool WarpBackgroundMap(uint32_t x, uint32_t y); +void GlobalToLocalPosition(int32_t& x, int32_t& y); +void LocalToGlobalPosition(int32_t& x, int32_t& y); +const OutdoorMapInfo* GetOutdoorMap(); + +} // namespace ava2 diff --git a/src/python_gameplay_modules.cpp b/src/python_gameplay_modules.cpp index 2ddd9d23..56598b03 100644 --- a/src/python_gameplay_modules.cpp +++ b/src/python_gameplay_modules.cpp @@ -16,11 +16,13 @@ #include "eter_net/PythonNetworkStream.h" #include "eter_net/NetworkActorManager.h" #include "eter_render/TerrainHeightmap.h" +#include "eter_render/TextTailManager.h" #include "eter_sound/SoundManager.h" #include "eter_resource/ResourceManager.h" #include "eter_image/GrpImageInstance.h" #include "eter_image/GrpImage.h" #include +#include #include #include #include @@ -36,10 +38,6 @@ namespace ava2 { namespace { -PyObject* dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; } -PyObject* dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); } -PyObject* dummy_str(PyObject*, PyObject*) { return PyString_FromString(""); } -PyObject* dummy_tuple2(PyObject*, PyObject*) { return Py_BuildValue("ii", 0, 0); } struct PlayerSkill { int index = 0; int grade = 0; @@ -1322,6 +1320,355 @@ void SetSkillCoolTime(int skillIndex, float coolTime) { SetSkillCoolTimeAt(skillIndex,coolTime,float(SDL_GetTicks())/1000.0f); } +// --------------------------------------------------------------------- +// GroundItemStore & Chest Drop Cache +// --------------------------------------------------------------------- + +class GroundItemStore { +public: + static GroundItemStore& Instance() { + static GroundItemStore s_instance; + return s_instance; + } + + struct SGroundItem { + uint32_t vid = 0; + uint32_t vnum = 0; + float x = 0.0f, y = 0.0f, z = 0.0f; + bool bDrop = true; + std::string ownership; + }; + + void CreateItem(uint32_t vid, uint32_t vnum, float x, float y, float z, bool bDrop) { + m_items[vid] = SGroundItem{vid, vnum, x, y, z, bDrop, ""}; + auto it = s_itemMap.find(vnum); + std::string name = it != s_itemMap.end() ? it->second.name : ""; + TextTailManager::Instance().RegisterItemTextTail(vid, name.empty() ? ("Item " + std::to_string(vnum)) : name, x, y, z); + } + + void DeleteItem(uint32_t vid) { + m_items.erase(vid); + TextTailManager::Instance().DeleteItemTextTail(vid); + if (m_pickedItemID == vid) + m_pickedItemID = 0xFFFFFFFF; + } + + void Clear() { + for (const auto& [vid, item] : m_items) { + TextTailManager::Instance().DeleteItemTextTail(vid); + } + m_items.clear(); + m_pickedItemID = 0xFFFFFFFF; + } + + void Update() {} + void Render() {} + + uint32_t GetPickedItemID() const { return m_pickedItemID; } + void SetPickedItemID(uint32_t id) { m_pickedItemID = id; } + + bool GetCloseItem(float px, float py, uint32_t* pItemId, float maxDist) { + uint32_t bestId = 0; + float bestDistSq = maxDist * maxDist; + for (const auto& [vid, item] : m_items) { + float dx = px - item.x; + float dy = py - (-item.y); + float distSq = dx * dx + dy * dy; + if (distSq < bestDistSq) { + bestDistSq = distSq; + bestId = vid; + } + } + if (bestId != 0) { + if (pItemId) *pItemId = bestId; + return true; + } + return false; + } + + bool GetCloseItemVector(const std::string& myName, float px, float py, std::vector& outVids, float maxDist) { + float maxDistSq = maxDist * maxDist; + for (const auto& [vid, item] : m_items) { + float dx = px - item.x; + float dy = py - (-item.y); + float distSq = dx * dx + dy * dy; + if (distSq < maxDistSq && (item.ownership.empty() || item.ownership == myName)) { + outVids.push_back(vid); + } + } + return true; + } + +private: + std::unordered_map m_items; + uint32_t m_pickedItemID = 0xFFFFFFFF; +}; + +struct SDropItemEntry { + uint32_t dropVnum = 0; + int count = 1; +}; +static std::unordered_map> s_chestDropInfoMap; + +static bool is_rarity_item_vnum(uint32_t vnum) { + auto it = s_itemMap.find(vnum); + if (it == s_itemMap.end()) { + const auto* range = s_itemProto.find(vnum); + if (range) it = s_itemMap.find(range->vnum); + } + if (it != s_itemMap.end()) { + const auto& item = it->second; + if (item.type == 2) // ARMOR + return true; + if (item.type == 36) // RINGS + return true; + if (item.type == 1 && item.subType != 6 && item.subType != 9) // WEAPON, not ARROW(6) or QUIVER(9) + return true; + } + return false; +} + +static PyObject* item_CreateItem(PyObject*, PyObject* poArgs) { + int iVirtualID = 0, iVirtualNumber = 0; + float x = 0.0f, y = 0.0f, z = 0.0f; + bool bDrop = true; + if (!PyTuple_GetInteger(poArgs, 0, &iVirtualID) || + !PyTuple_GetInteger(poArgs, 1, &iVirtualNumber) || + !PyTuple_GetFloat(poArgs, 2, &x) || + !PyTuple_GetFloat(poArgs, 3, &y) || + !PyTuple_GetFloat(poArgs, 4, &z)) { + return Py_BadArgument(); + } + PyTuple_GetBoolean(poArgs, 5, &bDrop); + + GroundItemStore::Instance().CreateItem(uint32_t(iVirtualID), uint32_t(iVirtualNumber), x, y, z, bDrop); + return Py_BuildNone(); +} + +static PyObject* item_DeleteItem(PyObject*, PyObject* poArgs) { + int iVirtualID = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iVirtualID)) + return Py_BadArgument(); + + GroundItemStore::Instance().DeleteItem(uint32_t(iVirtualID)); + return Py_BuildNone(); +} + +static PyObject* item_Pick(PyObject*, PyObject*) { + uint32_t dwItemID = GroundItemStore::Instance().GetPickedItemID(); + if (dwItemID != 0xFFFFFFFF) + return Py_BuildValue("i", dwItemID); + return Py_BuildValue("i", -1); +} + +static PyObject* item_Render(PyObject*, PyObject*) { + GroundItemStore::Instance().Render(); + return Py_BuildNone(); +} + +static PyObject* item_Update(PyObject*, PyObject*) { + GroundItemStore::Instance().Update(); + return Py_BuildNone(); +} + +static PyObject* item_GetIconInstance(PyObject*, PyObject*) { + if (!s_hasSelectedItem) + return Py_BuildException("Not yet select item data"); + + auto it = s_itemMap.find(s_selectedItemVnum); + if (it == s_itemMap.end()) + return Py_BuildException("Not yet select item data"); + + const auto& info = it->second; + std::string p = info.iconPath; + if (p.empty()) + p = "icon/item/27995.tga"; + if (p.rfind("d:/", 0) == 0 || p.rfind("D:/", 0) == 0) p = p.substr(3); + + auto* pRes = CResourceManager::Instance().GetResourcePointer(p.c_str()); + if (!pRes || !pRes->IsType(CGraphicImage::Type())) + return Py_BuildException("Cannot get icon image by %d", s_selectedItemVnum); + + auto* pImageInstance = CGraphicImageInstance::New(); + pImageInstance->SetImagePointer(static_cast(pRes)); + return Py_BuildValue("i", GrpRegisterImageInstanceHandle(pImageInstance)); +} + +static PyObject* item_DeleteIconInstance(PyObject*, PyObject* poArgs) { + int iHandle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle)) + return Py_BadArgument(); + CGraphicImageInstance::Delete(GrpReleaseImageInstanceHandle(uint32_t(iHandle))); + return Py_BuildNone(); +} + +static PyObject* item_GetDropClear(PyObject*, PyObject* poArgs) { + int iItemIndex = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iItemIndex)) + return Py_BadArgument(); + s_chestDropInfoMap.erase(uint32_t(iItemIndex)); + return Py_BuildNone(); +} + +static PyObject* item_GetDropInfo(PyObject*, PyObject* poArgs) { + int iItemIndex = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iItemIndex)) + return Py_BadArgument(); + + PyObject* poList = PyList_New(0); + int pageCount = 0; + + auto it = s_chestDropInfoMap.find(uint32_t(iItemIndex)); + if (it != s_chestDropInfoMap.end() && !it->second.empty()) { + const auto& vec = it->second; + const int gridW = 5, gridH = 8; + std::vector grid(gridW * gridH, false); + + auto findBlank = [&](int h) -> int { + if (h > gridH) return -1; + for (int r = 0; r <= gridH - h; ++r) { + for (int c = 0; c < gridW; ++c) { + bool ok = true; + for (int y = 0; y < h && ok; ++y) { + if (grid[(r + y) * gridW + c]) + ok = false; + } + if (ok) return r * gridW + c; + } + } + return -1; + }; + + auto putItem = [&](int pos, int h) { + int r = pos / gridW; + int c = pos % gridW; + for (int y = 0; y < h; ++y) { + grid[(r + y) * gridW + c] = true; + } + }; + + for (const auto& drop : vec) { + int itemSize = 1; + auto itemIt = s_itemMap.find(drop.dropVnum); + if (itemIt != s_itemMap.end() && itemIt->second.height > 1) + itemSize = itemIt->second.height; + + while (true) { + int pos = findBlank(itemSize); + if (pos >= 0) { + putItem(pos, itemSize); + PyList_Append(poList, Py_BuildValue("iiii", pageCount, pos, drop.dropVnum, drop.count)); + break; + } else { + std::fill(grid.begin(), grid.end(), false); + ++pageCount; + } + } + } + } + return Py_BuildValue("iO", pageCount, poList); +} + +static PyObject* item_HasDropInfo(PyObject*, PyObject* poArgs) { + int iItemIndex = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iItemIndex)) + return Py_BadArgument(); + + auto it = s_itemMap.find(uint32_t(iItemIndex)); + if (it == s_itemMap.end()) + return Py_BuildValue("b", false); + + if (it->second.type != 20 && it->second.type != 23) + return Py_BuildValue("b", false); + + auto dropIt = s_chestDropInfoMap.find(uint32_t(iItemIndex)); + bool bHasInfo = dropIt != s_chestDropInfoMap.end() && !dropIt->second.empty(); + return Py_BuildValue("b", bHasInfo); +} + +static PyObject* item_GetItemsByName(PyObject*, PyObject* poArgs) { + char* szItemName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szItemName)) + return Py_BadArgument(); + + std::string searched = szItemName ? szItemName : ""; + std::transform(searched.begin(), searched.end(), searched.begin(), [](unsigned char c) { return std::tolower(c); }); + + PyObject* poList = PyList_New(0); + for (const auto& [vnum, item] : s_itemMap) { + if (searched.empty()) continue; + std::string name = item.name; + std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::tolower(c); }); + if (name.compare(0, searched.length(), searched) == 0) { + PyList_Append(poList, PyInt_FromLong(vnum)); + } + } + return poList; +} + +static PyObject* item_IsRarityItem(PyObject*, PyObject* poArgs) { + int szItemVnum = 0; + if (!PyTuple_GetInteger(poArgs, 0, &szItemVnum)) + return Py_BadArgument(); + return Py_BuildValue("i", is_rarity_item_vnum(uint32_t(szItemVnum)) ? 1 : 0); +} + +static PyObject* item_GetRarityPoint(PyObject*, PyObject* poArgs) { + int szAttrID = 0, szRarityType = 0; + if (!PyTuple_GetInteger(poArgs, 0, &szAttrID) || !PyTuple_GetInteger(poArgs, 1, &szRarityType)) + return Py_BadArgument(); + + static const std::set s_rarityAttrs = { + -4, -3, -2, -1, + 19, 1, 5, 7, 6, 8, 15, 16, 12, 13, 17, 9, 10, 37, 3, 2, 41, 24, 23, + 59, 60, 61, 62, 54, 55, 56, 57, 27, 28, 43, 44, 64, 65, 63, 39, 40, + 38, 34, 35, 36, 71, 72, 53, 74, 75, 76, 77, 78, 79, 80 + }; + + if (s_rarityAttrs.count(szAttrID) > 0) { + static const int s_points[] = { 0, 5, 10, 20, 25, 30 }; + if (szRarityType >= 0 && szRarityType < 6) { + return Py_BuildValue("i", s_points[szRarityType]); + } + } + return Py_BuildValue("i", 0); +} + +static PyObject* item_GetRarityMaxValue(PyObject*, PyObject* poArgs) { + int szItemVnum = 0, szRarityType = 0; + if (!PyTuple_GetInteger(poArgs, 0, &szItemVnum) || !PyTuple_GetInteger(poArgs, 1, &szRarityType)) + return Py_BadArgument(); + + if (!is_rarity_item_vnum(uint32_t(szItemVnum))) + return Py_BuildValue("i", 0); + + static const int s_maxValues[] = { 50000, 75000, 100000, 150000, 200000, 300000 }; + if (szRarityType >= 0 && szRarityType < 6) { + return Py_BuildValue("i", s_maxValues[szRarityType]); + } + return Py_BuildValue("i", 0); +} + +static PyObject* item_IsSealScroll(PyObject*, PyObject* poArgs) { + int vnum = 0; + if (!PyTuple_GetInteger(poArgs, 0, &vnum)) return Py_BadArgument(); + return Py_BuildValue("i", 0); +} + +static PyObject* item_GetDefaultSealDate(PyObject*, PyObject*) { + return Py_BuildValue("i", 86400); +} + +static PyObject* item_GetUnlimitedSealDate(PyObject*, PyObject*) { + return Py_BuildValue("i", -1); +} + +static PyObject* item_IsElement(PyObject*, PyObject* poArgs) { + int vnum = 0; + if (!PyTuple_GetInteger(poArgs, 0, &vnum)) return Py_BadArgument(); + return Py_BuildValue("i", 0); +} + void initItem() { ResetItemDatabase(); static PyMethodDef methods[] = { @@ -1346,34 +1693,34 @@ void initItem() { {"GetAffect", item_GetAffect, METH_VARARGS, nullptr}, {"GetValue", item_GetValue, METH_VARARGS, nullptr}, {"GetSocket", item_socket, METH_VARARGS, nullptr}, - {"GetIconInstance", dummy_zero, METH_VARARGS, nullptr}, + {"GetIconInstance", item_GetIconInstance, METH_VARARGS, nullptr}, {"GetUseType", item_GetUseType, METH_VARARGS, nullptr}, - {"DeleteIconInstance", dummy_none, METH_VARARGS, nullptr}, + {"DeleteIconInstance", item_DeleteIconInstance, METH_VARARGS, nullptr}, {"IsEquipmentVID", item_IsEquipmentVID, METH_VARARGS, nullptr}, {"IsRefineScroll", item_IsRefineScroll, METH_VARARGS, nullptr}, {"IsDetachScroll", item_IsDetachScroll, METH_VARARGS, nullptr}, {"IsKey", item_IsKey, METH_VARARGS, nullptr}, {"IsMetin", item_IsMetin, METH_VARARGS, nullptr}, {"CanAddToQuickSlotItem", item_CanAddToQuickSlotItem, METH_VARARGS, nullptr}, - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"CreateItem", dummy_none, METH_VARARGS, nullptr}, - {"DeleteItem", dummy_none, METH_VARARGS, nullptr}, - {"Pick", dummy_none, METH_VARARGS, nullptr}, + {"Update", item_Update, METH_VARARGS, nullptr}, + {"Render", item_Render, METH_VARARGS, nullptr}, + {"CreateItem", item_CreateItem, METH_VARARGS, nullptr}, + {"DeleteItem", item_DeleteItem, METH_VARARGS, nullptr}, + {"Pick", item_Pick, METH_VARARGS, nullptr}, {"LoadItemTable", item_LoadItemTable, METH_VARARGS, nullptr}, - {"IsSealScroll", dummy_zero, METH_VARARGS, nullptr}, - {"GetDefaultSealDate", dummy_zero, METH_VARARGS, nullptr}, - {"GetUnlimitedSealDate", dummy_zero, METH_VARARGS, nullptr}, + {"IsSealScroll", item_IsSealScroll, METH_VARARGS, nullptr}, + {"GetDefaultSealDate", item_GetDefaultSealDate, METH_VARARGS, nullptr}, + {"GetUnlimitedSealDate", item_GetUnlimitedSealDate, METH_VARARGS, nullptr}, {"GetNames", item_GetNames, METH_VARARGS, nullptr}, - {"IsElement", dummy_zero, METH_VARARGS, nullptr}, + {"IsElement", item_IsElement, METH_VARARGS, nullptr}, {"GetApplyPoint", item_GetApplyPoint, METH_VARARGS, nullptr}, - {"GetItemsByName", dummy_str, METH_VARARGS, nullptr}, - {"HasDropInfo", dummy_none, METH_VARARGS, nullptr}, - {"GetDropInfo", dummy_zero, METH_VARARGS, nullptr}, - {"GetDropClear", dummy_zero, METH_VARARGS, nullptr}, - {"IsRarityItem", dummy_zero, METH_VARARGS, nullptr}, - {"GetRarityPoint", dummy_zero, METH_VARARGS, nullptr}, - {"GetRarityMaxValue", dummy_zero, METH_VARARGS, nullptr}, + {"GetItemsByName", item_GetItemsByName, METH_VARARGS, nullptr}, + {"HasDropInfo", item_HasDropInfo, METH_VARARGS, nullptr}, + {"GetDropInfo", item_GetDropInfo, METH_VARARGS, nullptr}, + {"GetDropClear", item_GetDropClear, METH_VARARGS, nullptr}, + {"IsRarityItem", item_IsRarityItem, METH_VARARGS, nullptr}, + {"GetRarityPoint", item_GetRarityPoint, METH_VARARGS, nullptr}, + {"GetRarityMaxValue", item_GetRarityMaxValue, METH_VARARGS, nullptr}, {"SelectItemWiki", item_SelectItemWiki, METH_VARARGS, nullptr}, {"GetRefineSet", item_GetRefineSet, METH_VARARGS, nullptr}, {"GetRefinedVnum", item_GetRefinedVnum, METH_VARARGS, nullptr}, @@ -1750,54 +2097,640 @@ void initItem() { PyModule_AddIntConstant(module, "E_SEAL_DATE_UNLIMITED_TIMESTAMP", -1); } +struct AutoPotionInfo { + bool bActivated = false; + long currentAmount = 0; + long totalAmount = 0; + long inventorySlotIndex = 0; +}; +static std::map s_autoPotionInfo; +static std::map s_emotionIcons; +static int s_mouseFunc[8] = {0}; +static int s_mouseState[8] = {0}; +static int s_mouseMiddleButtonState = 0; +static uint32_t s_targetVID = 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(); + return Py_BuildNone(); +} + +static PyObject* player_CanAttackInstance(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + const auto* target = NetworkActorManager::Instance().GetActorData(vid); + if (!target) return Py_BuildValue("i", 0); + return Py_BuildValue("i", 1); +} + +static PyObject* player_ChangeCurrentSkillNumberOnly(PyObject*, PyObject* args) { + int slot = 0; + if (!PyTuple_GetInteger(args, 0, &slot)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_Clear(PyObject*, PyObject*) { + s_playerSkills.clear(); + s_skillSlots.clear(); + s_targetVID = 0; + return Py_BuildNone(); +} + +static PyObject* player_ClearSkillDict(PyObject*, PyObject*) { + s_playerSkills.clear(); + return Py_BuildNone(); +} + +static PyObject* player_ClearTarget(PyObject*, PyObject*) { + s_targetVID = 0; + return Py_BuildNone(); +} + +static PyObject* player_ComboAttack(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_EndKeyWalkingImmediately(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_EndMouseWalking(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_GetAlignmentData(PyObject*, PyObject*) { + int alignment = 0; + auto it = s_playerPoints.find(39 /* POINT_ALIGNMENT */); + if (it != s_playerPoints.end()) alignment = int(it->second); + int grade = 4; + if (alignment >= 12000) grade = 8; + else if (alignment >= 8000) grade = 7; + else if (alignment >= 4000) grade = 6; + else if (alignment >= 1000) grade = 5; + else if (alignment >= 0) grade = 4; + else if (alignment >= -4000) grade = 3; + else if (alignment >= -8000) grade = 2; + else if (alignment >= -12000) grade = 1; + else grade = 0; + return Py_BuildValue("ii", alignment, grade); +} + +static PyObject* player_GetAutoPotionInfo(PyObject*, PyObject* args) { + int potionType = 0; + if (!PyTuple_GetInteger(args, 0, &potionType)) return Py_BadArgument(); + const auto& info = s_autoPotionInfo[potionType]; + return Py_BuildValue("biii", info.bActivated, int(info.currentAmount), int(info.totalAmount), int(info.inventorySlotIndex)); +} + +static PyObject* player_SetAutoPotionInfo(PyObject*, PyObject* args) { + int potionType = 0; + if (!PyTuple_GetInteger(args, 0, &potionType)) return Py_BadArgument(); + auto& info = s_autoPotionInfo[potionType]; + int bActivated = 0; + if (!PyTuple_GetInteger(args, 1, &bActivated)) return Py_BadArgument(); + info.bActivated = (bActivated != 0); + if (!PyTuple_GetLong(args, 2, &info.currentAmount)) return Py_BadArgument(); + if (!PyTuple_GetLong(args, 3, &info.totalAmount)) return Py_BadArgument(); + if (!PyTuple_GetLong(args, 4, &info.inventorySlotIndex)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_GetCharacterDistance(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + const auto* target = NetworkActorManager::Instance().GetActorData(vid); + if (!target) return Py_BuildValue("f", -1.0f); + float dx = s_mainActorPos.x - float(target->m_lCurX); + float dy = s_mainActorPos.y - float(target->m_lCurY); + return Py_BuildValue("f", std::sqrt(dx * dx + dy * dy)); +} + +static PyObject* player_RegisterEmotionIcon(PyObject*, PyObject* args) { + int idx = 0; char* filename = nullptr; + if (!PyTuple_GetInteger(args, 0, &idx) || !PyTuple_GetString(args, 1, &filename)) return Py_BuildException(); + auto* pRes = CResourceManager::Instance().GetResourcePointer(filename); + if (pRes && pRes->IsType(CGraphicImage::Type())) { + auto* pImageInstance = CGraphicImageInstance::New(); + pImageInstance->SetImagePointer(static_cast(pRes)); + s_emotionIcons[idx] = GrpRegisterImageInstanceHandle(pImageInstance); + } else { + s_emotionIcons[idx] = 0; + } + return Py_BuildNone(); +} + +static PyObject* player_GetEmotionIconImage(PyObject*, PyObject* args) { + int idx = 0; + if (!PyTuple_GetInteger(args, 0, &idx)) return Py_BuildException(); + auto it = s_emotionIcons.find(idx); + return Py_BuildValue("i", it != s_emotionIcons.end() ? it->second : 0); +} + +static PyObject* player_GetEventGame(PyObject*, PyObject*) { + return Py_BuildValue("i", s_eventGame); +} + +static PyObject* player_SetEventGame(PyObject*, PyObject* args) { + int val = 0; + if (!PyTuple_GetInteger(args, 0, &val)) return Py_BuildException(); + s_eventGame = val; + return Py_BuildNone(); +} + +static PyObject* player_GetGem(PyObject*, PyObject*) { + auto it = s_playerPoints.find(240 /* POINT_GEM */); + return Py_BuildValue("i", it != s_playerPoints.end() ? int(it->second) : 0); +} + +static PyObject* player_GetItemLink(PyObject*, PyObject* args) { + int window = 1, cell = 0; + if (PyTuple_Size(args) == 1) { + if (!PyTuple_GetInteger(args, 0, &cell)) return Py_BuildException(); + } else if (PyTuple_Size(args) == 2) { + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &cell)) return Py_BuildException(); + } else return Py_BuildException(); + const auto item = GetPlayerItemData(window, cell); + if (!item.vnum) return Py_BuildValue("s", ""); + select_item_data(item.vnum); + const auto it = s_itemMap.find(item.vnum); + const std::string name = it != s_itemMap.end() ? it->second.name : "Item"; + char itemlink[1024]; + int len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x", item.vnum, item.flags); + for (int i = 0; i < 6; ++i) len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x", item.alSockets[i]); + for (int i = 0; i < 7; ++i) len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d", item.aAttr[i].bType, item.aAttr[i].sValue); + char buf[1024]; + snprintf(buf, sizeof(buf), " |cffffc700|H%s|h[%s]|h|r", itemlink, name.c_str()); + return Py_BuildValue("s", buf); +} + +static PyObject* player_GetItemRandomAttribute(PyObject*, PyObject* args) { + int window = 1, cell = 0, attrSlot = 0; + if (PyTuple_Size(args) == 2) { + if (!PyTuple_GetInteger(args, 0, &cell) || !PyTuple_GetInteger(args, 1, &attrSlot)) return Py_BuildException(); + } else if (PyTuple_Size(args) == 3) { + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &cell) || !PyTuple_GetInteger(args, 2, &attrSlot)) return Py_BuildException(); + } else return Py_BuildException(); + const auto item = GetPlayerItemData(window, cell); + if (attrSlot >= 0 && attrSlot < 15) { + return Py_BuildValue("ii", item.randomAttr[attrSlot].bType, item.randomAttr[attrSlot].sValue); + } + return Py_BuildValue("ii", 0, 0); +} + +static PyObject* player_GetMainCharacterPart(PyObject*, PyObject* args) { + int part = 0; + if (!PyTuple_GetInteger(args, 0, &part)) return Py_BadArgument(); + const auto* actor = player_main_actor(); + if (!actor) return Py_BuildValue("i", 0); + if (part == 0) return Py_BuildValue("i", int(actor->m_dwArmor)); + if (part == 1) return Py_BuildValue("i", int(actor->m_dwWeapon)); + if (part == 2) return Py_BuildValue("i", int(actor->m_dwHair)); + if (part == 3) return Py_BuildValue("i", int(actor->m_dwSash)); + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetMainCharacterShiningPart(PyObject*, PyObject* args) { + int part = 0; + if (!PyTuple_GetInteger(args, 0, &part)) return Py_BadArgument(); + const auto* actor = player_main_actor(); + if (actor && part >= 0 && part < CHR_SHINING_NUM) + return Py_BuildValue("i", int(actor->m_shining[part])); + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetMouseFunc(PyObject*, PyObject* args) { + int btn = 0; + if (!PyTuple_GetInteger(args, 0, &btn)) return Py_BuildException(); + if (btn >= 0 && btn < 8) return Py_BuildValue("i", s_mouseFunc[btn]); + return Py_BuildValue("i", 0); +} + +static PyObject* player_SetMouseFunc(PyObject*, PyObject* args) { + int btn = 0, func = 0; + if (!PyTuple_GetInteger(args, 0, &btn) || !PyTuple_GetInteger(args, 1, &func)) return Py_BuildException(); + if (btn >= 0 && btn < 8) s_mouseFunc[btn] = func; + return Py_BuildNone(); +} + +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 && btn < 8) s_mouseState[btn] = state; + return Py_BuildNone(); +} + +static PyObject* player_SetMouseMiddleButtonState(PyObject*, PyObject* args) { + int state = 0; + if (!PyTuple_GetInteger(args, 0, &state)) return Py_BuildException(); + s_mouseMiddleButtonState = state; + return Py_BuildNone(); +} + +static PyObject* player_GetTargetVID(PyObject*, PyObject*) { + return Py_BuildValue("i", int(s_targetVID)); +} + +static PyObject* player_SetTarget(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + s_targetVID = uint32_t(vid); + return Py_BuildNone(); +} + +static PyObject* player_HidePlayer(PyObject*, PyObject*) { + s_playerVisible = false; + return Py_BuildNone(); +} + +static PyObject* player_ShowPlayer(PyObject*, PyObject*) { + s_playerVisible = true; + return Py_BuildNone(); +} + +static PyObject* player_IsActingEmotion(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_IsEquippingBelt(PyObject*, PyObject*) { + const auto data = GetPlayerItemData(1, 203); + return Py_BuildValue("b", data.vnum != 0 && data.count > 0); +} + +static PyObject* player_IsAvailableBeltInventoryCell(PyObject*, PyObject* args) { + const auto data = GetPlayerItemData(1, 203); + if (!data.vnum || data.count == 0) return Py_BuildValue("b", false); + const auto* proto = s_itemProto.find(data.vnum); + long beltGrade = proto ? proto->values[0] : 0; + int pos = 0; + if (!PyTuple_GetInteger(args, 0, &pos)) return Py_BadArgument(); + int cell = pos - 246; + if (cell < 0 || cell >= 16) return Py_BuildValue("b", false); + static const uint8_t rules[16] = {1, 2, 4, 6, 3, 3, 4, 6, 5, 5, 5, 6, 7, 7, 7, 7}; + return Py_BuildValue("b", rules[cell] <= beltGrade); +} + +static PyObject* player_IsInSafeArea(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_IsMountingHorse(PyObject*, PyObject*) { + const auto* actor = player_main_actor(); + return Py_BuildValue("i", (actor && actor->m_dwMountVnum != 0) ? 1 : 0); +} + +static PyObject* player_IsOpenPrivateShop(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_IsPVPInstance(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + return Py_BuildValue("i", 0); +} + +static PyObject* player_IsSameEmpire(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); + return Py_BuildValue("i", (mainActor->m_dwEmpireID == target->m_dwEmpireID) ? 1 : 0); +} + +static PyObject* player_IsShiningSlot(PyObject*, PyObject* args) { + int slot = 0; + if (!PyTuple_GetInteger(args, 0, &slot)) return Py_BuildException(); + return Py_BuildValue("i", (slot >= 211 && slot <= 214) ? 1 : 0); +} + +static PyObject* player_IsSkillActive(PyObject*, PyObject* args) { + int slot = 0; + if (!PyTuple_GetInteger(args, 0, &slot)) return Py_BuildException(); + return Py_BuildValue("i", 0); +} + +static PyObject* player_LoadNewRegen(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_MoveItem(PyObject*, PyObject* args) { + int srcWindow = 1, srcCell = 0, dstWindow = 1, dstCell = 0; + if (PyTuple_Size(args) == 2) { + if (!PyTuple_GetInteger(args, 0, &srcCell) || !PyTuple_GetInteger(args, 1, &dstCell)) + return Py_BuildException(); + } else if (PyTuple_Size(args) == 4) { + if (!PyTuple_GetInteger(args, 0, &srcWindow) || !PyTuple_GetInteger(args, 1, &srcCell) || + !PyTuple_GetInteger(args, 2, &dstWindow) || !PyTuple_GetInteger(args, 3, &dstCell)) + return Py_BuildException(); + } else return Py_BuildException(); + auto srcItem = GetPlayerItemData(srcWindow, srcCell); + auto dstItem = GetPlayerItemData(dstWindow, dstCell); + SetPlayerItemData(srcWindow, srcCell, dstItem); + SetPlayerItemData(dstWindow, dstCell, srcItem); + return Py_BuildNone(); +} + +static PyObject* player_OpenCharacterMenu(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_PickCloseItem(PyObject*, PyObject*) { + uint32_t vid = 0; + if (GroundItemStore::Instance().GetCloseItem(s_mainActorPos.x, s_mainActorPos.y, &vid, 300.0f)) { + PythonNetworkStream::Instance().SendItemPickUpPacket(vid); + } + return Py_BuildNone(); +} + +static PyObject* player_PickCloseItemVector(PyObject*, PyObject*) { + std::vector outVids; + if (GroundItemStore::Instance().GetCloseItemVector(s_playerName, s_mainActorPos.x, s_mainActorPos.y, outVids, 300.0f)) { + for (uint32_t vid : outVids) { + PythonNetworkStream::Instance().SendItemPickUpPacket(vid); + } + } + return Py_BuildNone(); +} + +static PyObject* player_RegisterCacheEffect(PyObject*, PyObject* args) { + int eft = 0; char* filename = nullptr; + if (!PyTuple_GetInteger(args, 0, &eft) || !PyTuple_GetString(args, 1, &filename)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_RegisterEffect(PyObject*, PyObject* args) { + int eft = 0; char* filename = nullptr; + if (!PyTuple_GetInteger(args, 0, &eft) || !PyTuple_GetString(args, 1, &filename)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_Render(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_RequestFlag(PyObject*, PyObject* args) { + char* name = nullptr; + if (!PyTuple_GetString(args, 0, &name)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_ResetCameraRotation(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_SendClickItemPacket(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + PythonNetworkStream::Instance().SendItemPickUpPacket(uint32_t(vid)); + return Py_BuildNone(); +} + +static PyObject* player_SendDragonSoulRefine(PyObject*, PyObject* args) { + int subHeader = 0; + if (!PyTuple_GetInteger(args, 0, &subHeader)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_SetAttackKeyState(PyObject*, PyObject* args) { + int pressed = 0; + if (!PyTuple_GetInteger(args, 0, &pressed)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_SetAutoCameraRotationSpeed(PyObject*, PyObject* args) { + float spd = 0.0f; + if (!PyTuple_GetFloat(args, 0, &spd)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_SetItemAttribute(PyObject*, PyObject* args) { + int window = 1, slot = 0, attrSlot = 0, attrType = 0, attrValue = 0; + if (PyTuple_Size(args) == 4) { + if (!PyTuple_GetInteger(args, 0, &slot) || !PyTuple_GetInteger(args, 1, &attrSlot) || + !PyTuple_GetInteger(args, 2, &attrType) || !PyTuple_GetInteger(args, 3, &attrValue)) + return Py_BuildException(); + } else if (PyTuple_Size(args) == 5) { + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &slot) || + !PyTuple_GetInteger(args, 2, &attrSlot) || !PyTuple_GetInteger(args, 3, &attrType) || + !PyTuple_GetInteger(args, 4, &attrValue)) + return Py_BuildException(); + } else return Py_BuildException(); + auto item = GetPlayerItemData(window, slot); + if (attrSlot >= 0 && attrSlot < 15) { + item.aAttr[attrSlot].bType = attrType; + item.aAttr[attrSlot].sValue = attrValue; + SetPlayerItemData(window, slot, item); + } + return Py_BuildNone(); +} + +static PyObject* player_SetItemCount(PyObject*, PyObject* args) { + int slot = 0, count = 0, window = 1; + if (PyTuple_Size(args) == 2) { + if (!PyTuple_GetInteger(args, 0, &slot) || !PyTuple_GetInteger(args, 1, &count)) + return Py_BuildException(); + } else if (PyTuple_Size(args) == 3) { + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &slot) || + !PyTuple_GetInteger(args, 2, &count)) + return Py_BuildException(); + } else return Py_BuildException(); + if (count == 0) return Py_BuildException(); + SetPlayerItemCount(window, slot, count); + return Py_BuildNone(); +} + +static PyObject* player_SetItemData(PyObject*, PyObject* args) { + int slot = 0, vnum = 0, count = 0; + if (!PyTuple_GetInteger(args, 0, &slot) || !PyTuple_GetInteger(args, 1, &vnum) || + !PyTuple_GetInteger(args, 2, &count)) + return Py_BuildException(); + TItemData item{}; + item.vnum = vnum; + item.count = count; + SetPlayerItemData(1, slot, item); + return Py_BuildNone(); +} + +static PyObject* player_SetItemMetinSocket(PyObject*, PyObject* args) { + int window = 1, slot = 0, socket = 0, num = 0; + if (PyTuple_Size(args) == 3) { + if (!PyTuple_GetInteger(args, 0, &slot) || !PyTuple_GetInteger(args, 1, &socket) || + !PyTuple_GetInteger(args, 2, &num)) + return Py_BuildException(); + } else if (PyTuple_Size(args) == 4) { + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &slot) || + !PyTuple_GetInteger(args, 2, &socket) || !PyTuple_GetInteger(args, 3, &num)) + return Py_BuildException(); + } else return Py_BuildException(); + auto item = GetPlayerItemData(window, slot); + if (socket >= 0 && socket < 8) { + item.alSockets[socket] = num; + SetPlayerItemData(window, slot, item); + } + return Py_BuildNone(); +} + +static PyObject* player_SetMainCharacterIndex(PyObject*, PyObject* args) { + int vid = 0; + if (!PyTuple_GetInteger(args, 0, &vid)) return Py_BuildException(); + PythonNetworkStream::Instance().SetMainActorVID(uint32_t(vid)); + NetworkActorManager::Instance().SetMainActorVID(uint32_t(vid)); + return Py_BuildNone(); +} + +static PyObject* player_SetQuickCameraMode(PyObject*, PyObject* args) { + int enable = 0; + if (!PyTuple_GetInteger(args, 0, &enable)) return Py_BadArgument(); + return Py_BuildNone(); +} + +static PyObject* player_SetSingleDIKKeyState(PyObject*, PyObject* args) { + int dik = 0, pressed = 0; + if (!PyTuple_GetInteger(args, 0, &dik) || !PyTuple_GetInteger(args, 1, &pressed)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_SetWeaponAttackBonusFlag(PyObject*, PyObject* args) { + int flag = 0; + if (!PyTuple_GetInteger(args, 0, &flag)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_StartMouseWalking(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_ToggleLevelLimit(PyObject*, PyObject*) { + s_levelLimit = !s_levelLimit; + return Py_BuildValue("i", s_levelLimit ? 1 : 0); +} + +static PyObject* player_Update(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* player_UseGuildSkill(PyObject*, PyObject* args) { + int slot = 0; + if (!PyTuple_GetInteger(args, 0, &slot)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* player_isItem(PyObject*, PyObject* args) { + int slot = 0; + if (!PyTuple_GetInteger(args, 0, &slot)) return Py_BuildException(); + const auto data = GetPlayerItemData(1, slot); + return Py_BuildValue("i", (data.vnum != 0 && data.count > 0) ? 1 : 0); +} + +static PyObject* player_GetItemBind(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_IsTournamentMap(PyObject*, PyObject*) { + bool isTourney = (s_warpMapName == "metin2_map_colosseum" || CPythonBackground::Instance().GetWarpMapName() == "metin2_map_colosseum"); + return Py_BuildValue("i", isTourney ? 1 : 0); +} + +static PyObject* player_GetItemUnbindTime(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemElementGrade(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemElementAttack(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemElementType(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemElementValue(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetElements(PyObject*, PyObject*) { + return Py_BuildValue("i", 6); +} + +static PyObject* player_IsCombatZoneMap(PyObject*, PyObject*) { + bool isCombat = (s_warpMapName == "metin2_map_battlefied" || CPythonBackground::Instance().GetWarpMapName() == "metin2_map_battlefied"); + return Py_BuildValue("i", isCombat ? 1 : 0); +} + +static PyObject* player_GetCombatZonePoints(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_CanSealItem(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemSealDate(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* player_GetItemUnSealLeftTime(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + void initPlayer() { static PyMethodDef methods[] = { - {"GetAutoPotionInfo", dummy_zero, METH_VARARGS, nullptr}, - {"SetAutoPotionInfo", dummy_none, METH_VARARGS, nullptr}, - {"GetItemBind", dummy_zero, METH_VARARGS, nullptr}, - {"IsTournamentMap", dummy_zero, METH_VARARGS, nullptr}, + {"GetAutoPotionInfo", player_GetAutoPotionInfo, METH_VARARGS, nullptr}, + {"SetAutoPotionInfo", player_SetAutoPotionInfo, METH_VARARGS, nullptr}, + {"GetItemBind", player_GetItemBind, METH_VARARGS, nullptr}, + {"IsTournamentMap", player_IsTournamentMap, METH_VARARGS, nullptr}, {"IsAntiFlagBySlot", player_IsAntiFlagBySlot, METH_VARARGS, nullptr}, {"GetItemTypeBySlot", player_GetItemTypeBySlot, METH_VARARGS, nullptr}, {"GetItemSubTypeBySlot", player_GetItemSubTypeBySlot, METH_VARARGS, nullptr}, {"IsSameItemVnum", player_IsSameItemVnum, METH_VARARGS, nullptr}, - {"PickCloseItemVector", dummy_none, METH_VARARGS, nullptr}, - {"PickCloseItem", dummy_none, METH_VARARGS, nullptr}, + {"PickCloseItemVector", player_PickCloseItemVector, METH_VARARGS, nullptr}, + {"PickCloseItem", player_PickCloseItem, METH_VARARGS, nullptr}, {"SetGameWindow", player_SetGameWindow, METH_VARARGS, nullptr}, - {"RegisterEffect", dummy_none, METH_VARARGS, nullptr}, - {"RegisterCacheEffect", dummy_none, METH_VARARGS, nullptr}, - {"SetMouseState", dummy_none, METH_VARARGS, nullptr}, - {"SetMouseFunc", dummy_none, METH_VARARGS, nullptr}, - {"GetMouseFunc", dummy_zero, METH_VARARGS, nullptr}, - {"SetMouseMiddleButtonState", dummy_none, METH_VARARGS, nullptr}, - {"SetMainCharacterIndex", dummy_none, METH_VARARGS, nullptr}, + {"RegisterEffect", player_RegisterEffect, METH_VARARGS, nullptr}, + {"RegisterCacheEffect", player_RegisterCacheEffect, METH_VARARGS, nullptr}, + {"SetMouseState", player_SetMouseState, METH_VARARGS, nullptr}, + {"SetMouseFunc", player_SetMouseFunc, METH_VARARGS, nullptr}, + {"GetMouseFunc", player_GetMouseFunc, METH_VARARGS, nullptr}, + {"SetMouseMiddleButtonState", player_SetMouseMiddleButtonState, METH_VARARGS, nullptr}, + {"SetMainCharacterIndex", player_SetMainCharacterIndex, METH_VARARGS, nullptr}, {"GetMainCharacterIndex", player_GetMainCharacterIndex, METH_VARARGS, nullptr}, {"GetMainCharacterName", player_GetMainCharacterName, METH_VARARGS, nullptr}, {"GetMainCharacterPosition", player_GetMainCharacterPosition, METH_VARARGS, nullptr}, {"IsMainCharacterIndex", player_IsMainCharacterIndex, METH_VARARGS, nullptr}, - {"CanAttackInstance", dummy_none, METH_VARARGS, nullptr}, - {"IsActingEmotion", dummy_zero, METH_VARARGS, nullptr}, - {"IsPVPInstance", dummy_zero, METH_VARARGS, nullptr}, - {"IsSameEmpire", dummy_zero, METH_VARARGS, nullptr}, + {"CanAttackInstance", player_CanAttackInstance, METH_VARARGS, nullptr}, + {"IsActingEmotion", player_IsActingEmotion, METH_VARARGS, nullptr}, + {"IsPVPInstance", player_IsPVPInstance, METH_VARARGS, nullptr}, + {"IsSameEmpire", player_IsSameEmpire, METH_VARARGS, nullptr}, {"IsChallengeInstance", player_IsChallengeInstance, METH_VARARGS, nullptr}, {"IsRevengeInstance", player_IsRevengeInstance, METH_VARARGS, nullptr}, {"IsCantFightInstance", player_IsCantFightInstance, METH_VARARGS, nullptr}, - {"GetCharacterDistance", dummy_zero, METH_VARARGS, nullptr}, - {"IsInSafeArea", dummy_zero, METH_VARARGS, nullptr}, - {"IsMountingHorse", dummy_zero, METH_VARARGS, nullptr}, + {"GetCharacterDistance", player_GetCharacterDistance, METH_VARARGS, nullptr}, + {"IsInSafeArea", player_IsInSafeArea, METH_VARARGS, nullptr}, + {"IsMountingHorse", player_IsMountingHorse, METH_VARARGS, nullptr}, {"IsObserverMode", player_IsObserverMode, METH_VARARGS, nullptr}, - {"ActEmotion", dummy_none, METH_VARARGS, nullptr}, - {"ShowPlayer", dummy_none, METH_VARARGS, nullptr}, - {"HidePlayer", dummy_none, METH_VARARGS, nullptr}, - {"ComboAttack", dummy_none, METH_VARARGS, nullptr}, - {"RequestFlag", dummy_none, METH_VARARGS, nullptr}, - {"SetAutoCameraRotationSpeed", dummy_none, METH_VARARGS, nullptr}, - {"SetAttackKeyState", dummy_none, METH_VARARGS, nullptr}, - {"SetSingleDIKKeyState", dummy_none, METH_VARARGS, nullptr}, - {"EndKeyWalkingImmediately", dummy_none, METH_VARARGS, nullptr}, - {"StartMouseWalking", dummy_none, METH_VARARGS, nullptr}, - {"EndMouseWalking", dummy_none, METH_VARARGS, nullptr}, - {"ResetCameraRotation", dummy_none, METH_VARARGS, nullptr}, - {"SetQuickCameraMode", dummy_none, METH_VARARGS, nullptr}, + {"ActEmotion", player_ActEmotion, METH_VARARGS, nullptr}, + {"ShowPlayer", player_ShowPlayer, METH_VARARGS, nullptr}, + {"HidePlayer", player_HidePlayer, METH_VARARGS, nullptr}, + {"ComboAttack", player_ComboAttack, METH_VARARGS, nullptr}, + {"RequestFlag", player_RequestFlag, METH_VARARGS, nullptr}, + {"SetAutoCameraRotationSpeed", player_SetAutoCameraRotationSpeed, METH_VARARGS, nullptr}, + {"SetAttackKeyState", player_SetAttackKeyState, METH_VARARGS, nullptr}, + {"SetSingleDIKKeyState", player_SetSingleDIKKeyState, METH_VARARGS, nullptr}, + {"EndKeyWalkingImmediately", player_EndKeyWalkingImmediately, METH_VARARGS, nullptr}, + {"StartMouseWalking", player_StartMouseWalking, METH_VARARGS, nullptr}, + {"EndMouseWalking", player_EndMouseWalking, METH_VARARGS, nullptr}, + {"ResetCameraRotation", player_ResetCameraRotation, METH_VARARGS, nullptr}, + {"SetQuickCameraMode", player_SetQuickCameraMode, METH_VARARGS, nullptr}, {"SetSkill", player_SetSkill, METH_VARARGS, nullptr}, {"GetSkillIndex", player_GetSkillIndex, METH_VARARGS, nullptr}, {"GetSkillSlotIndex", player_GetSkillSlotIndex, METH_VARARGS, nullptr}, @@ -1806,8 +2739,8 @@ void initPlayer() { {"GetSkillCurrentEfficientPercentage", player_GetSkillPower, METH_VARARGS, nullptr}, {"GetSkillNextEfficientPercentage", player_GetSkillPower, METH_VARARGS, nullptr}, {"ClickSkillSlot", player_ClickSkillSlot, METH_VARARGS, nullptr}, - {"ChangeCurrentSkillNumberOnly", dummy_none, METH_VARARGS, nullptr}, - {"ClearSkillDict", dummy_none, METH_VARARGS, nullptr}, + {"ChangeCurrentSkillNumberOnly", player_ChangeCurrentSkillNumberOnly, METH_VARARGS, nullptr}, + {"ClearSkillDict", player_ClearSkillDict, METH_VARARGS, nullptr}, {"GetItemIndex", player_GetItemIndex, METH_VARARGS, nullptr}, {"GetItemFlags", player_GetItemFlags, METH_VARARGS, nullptr}, {"GetItemCount", player_GetItemCount, METH_VARARGS, nullptr}, @@ -1815,10 +2748,10 @@ void initPlayer() { {"GetItemMetinSocket", player_GetItemMetinSocket, METH_VARARGS, nullptr}, {"GetItemAttribute", player_GetItemAttribute, METH_VARARGS, nullptr}, {"GetItemCountByTT", player_GetItemCountByTT, METH_VARARGS, nullptr}, - {"GetItemUnbindTime", dummy_zero, METH_VARARGS, nullptr}, + {"GetItemUnbindTime", player_GetItemUnbindTime, METH_VARARGS, nullptr}, {"GetISellItemPrice", player_GetISellItemPrice, METH_VARARGS, nullptr}, - {"MoveItem", dummy_none, METH_VARARGS, nullptr}, - {"SendClickItemPacket", dummy_none, METH_VARARGS, nullptr}, + {"MoveItem", player_MoveItem, METH_VARARGS, nullptr}, + {"SendClickItemPacket", player_SendClickItemPacket, METH_VARARGS, nullptr}, {"GetName", player_GetName, METH_VARARGS, nullptr}, {"IsGameMaster", player_IsGameMaster, METH_VARARGS, nullptr}, {"GetJob", player_GetJob, METH_VARARGS, nullptr}, @@ -1827,8 +2760,8 @@ void initPlayer() { {"SetPlayTime", player_SetPlayTime, METH_VARARGS, nullptr}, {"IsSkillCoolTime", player_IsSkillCoolTime, METH_VARARGS, nullptr}, {"GetSkillCoolTime", player_GetSkillCoolTime, METH_VARARGS, nullptr}, - {"IsSkillActive", dummy_zero, METH_VARARGS, nullptr}, - {"UseGuildSkill", dummy_none, METH_VARARGS, nullptr}, + {"IsSkillActive", player_IsSkillActive, METH_VARARGS, nullptr}, + {"UseGuildSkill", player_UseGuildSkill, METH_VARARGS, nullptr}, {"AffectIndexToSkillIndex", player_AffectIndexToSkillIndex, METH_VARARGS, nullptr}, {"GetEXP", player_GetDWORDStatus<3 /* POINT_EXP */>, METH_VARARGS, nullptr}, {"GetConquerorEXP", player_GetDWORDStatus<212 /* POINT_CONQUEROR_EXP */>, METH_VARARGS, nullptr}, @@ -1838,7 +2771,7 @@ void initPlayer() { {"GetMoney", player_GetMoney, METH_VARARGS, nullptr}, {"GetGuildID", player_GetGuildID, METH_VARARGS, nullptr}, {"GetGuildName", player_GetGuildName, METH_VARARGS, nullptr}, - {"GetAlignmentData", dummy_tuple2, METH_VARARGS, nullptr}, + {"GetAlignmentData", player_GetAlignmentData, METH_VARARGS, nullptr}, {"RequestAddLocalQuickSlot", player_RequestAddLocalQuickSlot, METH_VARARGS, nullptr}, {"RequestAddToEmptyLocalQuickSlot", player_AddEmptyQuick, METH_VARARGS, nullptr}, {"RequestDeleteGlobalQuickSlot", player_DeleteQuick, METH_VARARGS, nullptr}, @@ -1850,35 +2783,35 @@ void initPlayer() { {"GetLocalQuickSlot", player_GetLocalQuickSlot, METH_VARARGS, nullptr}, {"GetGlobalQuickSlot", player_GetGlobalQuickSlot, METH_VARARGS, nullptr}, {"RemoveQuickSlotByValue", player_RemoveQuickByValue, METH_VARARGS, nullptr}, - {"isItem", dummy_none, METH_VARARGS, nullptr}, + {"isItem", player_isItem, METH_VARARGS, nullptr}, {"IsEquipmentSlot", player_IsEquipmentSlot, METH_VARARGS, nullptr}, {"IsDSEquipmentSlot", player_IsDSEquipmentSlot, METH_VARARGS, nullptr}, {"IsCostumeSlot", player_IsCostumeSlot, METH_VARARGS, nullptr}, {"IsValuableItem", player_IsValuableItem, METH_VARARGS, nullptr}, - {"IsOpenPrivateShop", dummy_zero, METH_VARARGS, nullptr}, - {"IsShiningSlot", dummy_zero, METH_VARARGS, nullptr}, + {"IsOpenPrivateShop", player_IsOpenPrivateShop, METH_VARARGS, nullptr}, + {"IsShiningSlot", player_IsShiningSlot, METH_VARARGS, nullptr}, {"IsBeltInventorySlot", player_IsBeltInventorySlot, METH_VARARGS, nullptr}, - {"IsEquippingBelt", dummy_zero, METH_VARARGS, nullptr}, - {"IsAvailableBeltInventoryCell", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemElementGrade", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemElementAttack", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemElementType", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemElementValue", dummy_zero, METH_VARARGS, nullptr}, - {"GetElements", dummy_zero, METH_VARARGS, nullptr}, + {"IsEquippingBelt", player_IsEquippingBelt, METH_VARARGS, nullptr}, + {"IsAvailableBeltInventoryCell", player_IsAvailableBeltInventoryCell, METH_VARARGS, nullptr}, + {"GetItemElementGrade", player_GetItemElementGrade, METH_VARARGS, nullptr}, + {"GetItemElementAttack", player_GetItemElementAttack, METH_VARARGS, nullptr}, + {"GetItemElementType", player_GetItemElementType, METH_VARARGS, nullptr}, + {"GetItemElementValue", player_GetItemElementValue, METH_VARARGS, nullptr}, + {"GetElements", player_GetElements, METH_VARARGS, nullptr}, {"GetItemGrade", player_GetItemGrade, METH_VARARGS, nullptr}, {"CanRefine", player_CanRefine, METH_VARARGS, nullptr}, {"CanDetach", player_CanDetach, METH_VARARGS, nullptr}, {"CanUnlock", player_CanUnlock, METH_VARARGS, nullptr}, {"CanAttachMetin", player_CanAttachMetin, METH_VARARGS, nullptr}, {"IsRefineGradeScroll", player_IsRefineGradeScroll, METH_VARARGS, nullptr}, - {"ClearTarget", dummy_none, METH_VARARGS, nullptr}, - {"SetTarget", dummy_none, METH_VARARGS, nullptr}, - {"OpenCharacterMenu", dummy_none, METH_VARARGS, nullptr}, - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"Clear", dummy_none, METH_VARARGS, nullptr}, - {"IsCombatZoneMap", dummy_zero, METH_VARARGS, nullptr}, - {"GetCombatZonePoints", dummy_zero, METH_VARARGS, nullptr}, + {"ClearTarget", player_ClearTarget, METH_VARARGS, nullptr}, + {"SetTarget", player_SetTarget, METH_VARARGS, nullptr}, + {"OpenCharacterMenu", player_OpenCharacterMenu, METH_VARARGS, nullptr}, + {"Update", player_Update, METH_VARARGS, nullptr}, + {"Render", player_Render, METH_VARARGS, nullptr}, + {"Clear", player_Clear, METH_VARARGS, nullptr}, + {"IsCombatZoneMap", player_IsCombatZoneMap, METH_VARARGS, nullptr}, + {"GetCombatZonePoints", player_GetCombatZonePoints, METH_VARARGS, nullptr}, {"IsPartyMember", player_IsPartyMember, METH_VARARGS, nullptr}, {"IsPartyLeader", player_IsPartyLeader, METH_VARARGS, nullptr}, {"IsPartyLeaderByPID", player_IsPartyLeaderByPID, METH_VARARGS, nullptr}, @@ -1889,31 +2822,31 @@ void initPlayer() { {"ExitParty", player_ExitParty, METH_VARARGS, nullptr}, {"GetPKMode", player_GetPKMode, METH_VARARGS, nullptr}, {"HasMobilePhoneNumber", player_HasMobilePhoneNumber, METH_VARARGS, nullptr}, - {"RegisterEmotionIcon", dummy_none, METH_VARARGS, nullptr}, - {"GetEmotionIconImage", dummy_zero, METH_VARARGS, nullptr}, - {"SetWeaponAttackBonusFlag", dummy_none, METH_VARARGS, nullptr}, + {"RegisterEmotionIcon", player_RegisterEmotionIcon, METH_VARARGS, nullptr}, + {"GetEmotionIconImage", player_GetEmotionIconImage, METH_VARARGS, nullptr}, + {"SetWeaponAttackBonusFlag", player_SetWeaponAttackBonusFlag, METH_VARARGS, nullptr}, {"ToggleCoolTime", player_ToggleCoolTime, METH_VARARGS, nullptr}, - {"ToggleLevelLimit", dummy_none, METH_VARARGS, nullptr}, - {"GetTargetVID", dummy_zero, METH_VARARGS, nullptr}, - {"SetItemData", dummy_none, METH_VARARGS, nullptr}, - {"SetItemMetinSocket", dummy_none, METH_VARARGS, nullptr}, - {"SetItemAttribute", dummy_none, METH_VARARGS, nullptr}, - {"SetItemCount", dummy_none, METH_VARARGS, nullptr}, - {"GetItemLink", dummy_zero, METH_VARARGS, nullptr}, + {"ToggleLevelLimit", player_ToggleLevelLimit, METH_VARARGS, nullptr}, + {"GetTargetVID", player_GetTargetVID, METH_VARARGS, nullptr}, + {"SetItemData", player_SetItemData, METH_VARARGS, nullptr}, + {"SetItemMetinSocket", player_SetItemMetinSocket, METH_VARARGS, nullptr}, + {"SetItemAttribute", player_SetItemAttribute, METH_VARARGS, nullptr}, + {"SetItemCount", player_SetItemCount, METH_VARARGS, nullptr}, + {"GetItemLink", player_GetItemLink, METH_VARARGS, nullptr}, {"SlotTypeToInvenType", player_SlotTypeToInvenType, METH_VARARGS, nullptr}, - {"SendDragonSoulRefine", dummy_none, METH_VARARGS, nullptr}, - {"GetItemRandomAttribute", dummy_tuple2, METH_VARARGS, nullptr}, - {"CanSealItem", dummy_none, METH_VARARGS, nullptr}, - {"GetItemSealDate", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemUnSealLeftTime", dummy_zero, METH_VARARGS, nullptr}, + {"SendDragonSoulRefine", player_SendDragonSoulRefine, METH_VARARGS, nullptr}, + {"GetItemRandomAttribute", player_GetItemRandomAttribute, METH_VARARGS, nullptr}, + {"CanSealItem", player_CanSealItem, METH_VARARGS, nullptr}, + {"GetItemSealDate", player_GetItemSealDate, METH_VARARGS, nullptr}, + {"GetItemUnSealLeftTime", player_GetItemUnSealLeftTime, METH_VARARGS, nullptr}, {"GetItemNewName", player_GetItemNewName, METH_VARARGS, nullptr}, {"GetKillLOG", player_GetKillLOG, METH_VARARGS, nullptr}, - {"GetMainCharacterPart", dummy_zero, METH_VARARGS, nullptr}, - {"GetMainCharacterShiningPart", dummy_zero, METH_VARARGS, nullptr}, - {"LoadNewRegen", dummy_none, METH_VARARGS, nullptr}, - {"GetGem", dummy_zero, METH_VARARGS, nullptr}, - {"SetEventGame", dummy_none, METH_VARARGS, nullptr}, - {"GetEventGame", dummy_zero, METH_VARARGS, nullptr}, + {"GetMainCharacterPart", player_GetMainCharacterPart, METH_VARARGS, nullptr}, + {"GetMainCharacterShiningPart", player_GetMainCharacterShiningPart, METH_VARARGS, nullptr}, + {"LoadNewRegen", player_LoadNewRegen, METH_VARARGS, nullptr}, + {"GetGem", player_GetGem, METH_VARARGS, nullptr}, + {"SetEventGame", player_SetEventGame, METH_VARARGS, nullptr}, + {"GetEventGame", player_GetEventGame, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; NetworkActorManager::SetPartyMemberQuery(IsPartyMemberByVID); @@ -2404,308 +3337,5 @@ void initsnd() { }; Py_InitModule("snd", methods); } - -static MapCoordinates s_mapCoordinates; -static std::string s_atlasLocale; -static void loadAtlas() { - PyObject* app=PyImport_ImportModule("app"); - PyObject* path=app?PyObject_CallMethod(app,const_cast("GetLocalePath"),nullptr):nullptr; - Py_XDECREF(app); - if(!path) return; - const char* raw=PyString_AsString(path); - std::string locale=raw?raw:""; Py_DECREF(path); - if(PyErr_Occurred()) return; - if(locale==s_atlasLocale && !s_mapCoordinates.maps.empty()) return; - s_atlasLocale=locale; - try { s_mapCoordinates.load(ReadPackedText(locale+"/atlasinfo.txt")); } - catch(const std::exception&) { - try { s_mapCoordinates.load(ReadPackedText("atlasinfo.txt")); } - catch(const std::exception&) { s_mapCoordinates.maps.clear(); } - } -} -void GlobalToLocalPosition(int32_t& x,int32_t& y) { s_mapCoordinates.toLocal(x,y); } -void LocalToGlobalPosition(int32_t& x,int32_t& y) { s_mapCoordinates.toGlobal(x,y); } -static std::string s_currentMapName = ""; -static OutdoorMapInfo s_outdoorMap; -const OutdoorMapInfo* GetOutdoorMap() { return s_currentMapName.empty()?nullptr:&s_outdoorMap; } -// CMapOutdoor::LoadSetting: SetTerrainCount(atoi mapsize[0..1]) and the optional SetBaseXY((DWORD)atol -// baseposition[0..1]). The other required keys only feed terrain rendering and are not checked here. -static OutdoorMapInfo LoadOutdoorSetting(const std::string& mapName,const std::string& path) { - OutdoorMapInfo info; info.name=mapName; - std::ifstream f(path,std::ios::binary); if(!f) return info; - std::stringstream ss; ss<> tokens; ava2LoadMultipleTextData(ss.str(),tokens); - auto size=tokens.find("mapsize"); - if(size!=tokens.end() && size->second.size()>=2) { - info.terrainCountX=int16_t(std::atoi(size->second[0].c_str())); info.terrainCountY=int16_t(std::atoi(size->second[1].c_str())); - } - auto base=tokens.find("baseposition"); - if(base!=tokens.end() && base->second.size()>=2) { - info.baseX=uint32_t(std::atol(base->second[0].c_str())); info.baseY=uint32_t(std::atol(base->second[1].c_str())); - } - return info; -} -static std::unique_ptr s_backgroundTerrain; -static float s_pickingPoint[3] = {0.0f, 0.0f, 0.0f}; - -TerrainHeightmap* GetActiveBackgroundTerrain() { - return s_backgroundTerrain.get(); -} - -void SetActiveBackgroundTerrain(std::unique_ptr terrain) { - s_backgroundTerrain = std::move(terrain); -} - -bool LoadBackgroundMap(const std::string& mapName, float x, float y, float z) { - (void)z; - if (!s_backgroundTerrain) { - s_backgroundTerrain = std::make_unique(); - } - - std::vector base_candidates = { - "map/" + mapName, - mapName, - "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/" + mapName - }; - - std::string found_base = ""; - for (const auto& base : base_candidates) { - if (std::filesystem::exists(base)) { - found_base = base; - break; - } - } - - if (found_base.empty()) { - std::cerr << "LoadBackgroundMap: cannot find directory for map " << mapName << std::endl; - return false; - } - - // Metin2 terrain block coordinates: block_x = x / 25600, block_y = y / 25600 - int bx = static_cast(std::floor(x / 25600.0f)); - int by = static_cast(std::floor(y / 25600.0f)); - char block_str[32]; - snprintf(block_str, sizeof(block_str), "%03d%03d", bx, by); - std::string block_dir = found_base + "/" + block_str; - if (!std::filesystem::exists(block_dir)) { - std::cerr << "LoadBackgroundMap: missing requested block " << block_dir << std::endl; - return false; - } - - bool ok = false; - std::string height_path = block_dir + "/height.raw"; - if (std::filesystem::exists(height_path)) { - ok = s_backgroundTerrain->LoadRaw(height_path); - } - std::string tile_path = block_dir + "/tile.raw"; - if (std::filesystem::exists(tile_path)) { - s_backgroundTerrain->LoadTileRaw(tile_path); - } - std::string attr_path = block_dir + "/attr.atr"; - if (std::filesystem::exists(attr_path)) { - s_backgroundTerrain->LoadAttr(attr_path); - } - - std::string textureset_path = "textureset/metin2_map1.txt"; - if (!std::filesystem::exists(textureset_path)) { - textureset_path = "/Users/shen/Work/Code/Metin2/AVA2/TEST/1. Client DEV/pack_maker/Maps/textureset/metin2_map1.txt"; - } - if (std::filesystem::exists(textureset_path)) { - s_backgroundTerrain->LoadTextureSet(textureset_path); - } - - if(ok) { s_currentMapName=mapName; s_outdoorMap=LoadOutdoorSetting(mapName,found_base+"/setting.txt"); } - return ok; -} - -bool WarpBackgroundMap(uint32_t x,uint32_t y) { - // NetworkStream::Warp destroys/recreates background before selecting the map. - s_backgroundTerrain.reset(); s_currentMapName.clear(); s_warpMapName.clear(); - s_mapCoordinates.baseX=0; s_mapCoordinates.baseY=0; - loadAtlas(); const auto* map=s_mapCoordinates.find(x,y); - if(!map) return false; - if(!LoadBackgroundMap(map->name,float(x-map->x),float(y-map->y),0)) - throw std::runtime_error("AVA2 map load failed: "+map->name); - CPythonMiniMap::Instance().LoadAtlas(); - s_mapCoordinates.baseX=map->x; s_mapCoordinates.baseY=map->y; - s_warpMapName=map->name; - return true; -} -static PyObject* background_GlobalPositionToLocalPosition(PyObject*,PyObject* args) { - int x,y; if(!PyArg_ParseTuple(args,"ii",&x,&y)) return nullptr; - int32_t lx=x,ly=y; GlobalToLocalPosition(lx,ly); return Py_BuildValue("ii",lx,ly); -} -static PyObject* background_GlobalPositionToMapInfo(PyObject*,PyObject* args) { - int x,y; if(!PyArg_ParseTuple(args,"ii",&x,&y)) return nullptr; - loadAtlas(); if(PyErr_Occurred()) return nullptr; - const auto* map=s_mapCoordinates.find(uint32_t(x),uint32_t(y)); - return map?Py_BuildValue("sii",map->name.c_str(),MapCoordinates::signedBits(map->x),MapCoordinates::signedBits(map->y)):Py_BuildValue("sii","",0,0); -} -static PyObject* background_WarpTest(PyObject*,PyObject* args) { - int x,y; if(!PyArg_ParseTuple(args,"ii",&x,&y)) return nullptr; - try { WarpBackgroundMap(uint32_t(x)*100u,uint32_t(y)*100u); } - catch(const std::exception& e) { PyErr_SetString(PyExc_RuntimeError,e.what()); return nullptr; } - if(PyErr_Occurred()) return nullptr; - Py_RETURN_NONE; -} - -static PyObject* background_LoadMap(PyObject*, PyObject* args) { - char* mapName = nullptr; - float x = 0.0f, y = 0.0f, z = 0.0f; - if (!PyArg_ParseTuple(args, "s|fff", &mapName, &x, &y, &z)) { - return Py_BuildValue("i", 0); - } - bool res = LoadBackgroundMap(mapName ? mapName : "", x, y, z); - return Py_BuildValue("i", res ? 1 : 0); -} - -static PyObject* background_Destroy(PyObject*, PyObject*) { - s_backgroundTerrain.reset(); - s_currentMapName.clear(); s_warpMapName.clear(); - s_mapCoordinates.baseX=0; s_mapCoordinates.baseY=0; - Py_RETURN_NONE; -} - -static PyObject* background_Initialize(PyObject*, PyObject*) { - if (!s_backgroundTerrain) { - s_backgroundTerrain = std::make_unique(); - } - Py_RETURN_NONE; -} - -static PyObject* background_GetCurrentMapName(PyObject*, PyObject*) { - return PyString_FromString(s_currentMapName.c_str()); -} - -static PyObject* background_GetPickingPoint(PyObject*, PyObject*) { - return Py_BuildValue("fff", s_pickingPoint[0], s_pickingPoint[1], s_pickingPoint[2]); -} - -static PyObject* background_GetHeight(PyObject*, PyObject* args) { - float x = 0.0f, y = 0.0f; - if (!PyArg_ParseTuple(args, "ff", &x, &y)) { - return Py_BuildValue("f", 0.0f); - } - if (s_backgroundTerrain) { - return Py_BuildValue("f", s_backgroundTerrain->GetHeightAtWorld(x, y)); - } - return Py_BuildValue("f", 0.0f); -} - -static PyObject* background_isAttrOn(PyObject*, PyObject* args) { - float x = 0.0f, y = 0.0f; - int attr = 0; - if (!PyArg_ParseTuple(args, "ffi", &x, &y, &attr)) { - PyErr_Clear(); - int ix = 0, iy = 0; - if (PyArg_ParseTuple(args, "iii", &ix, &iy, &attr)) { - x = static_cast(ix); - y = static_cast(iy); - } else { - return Py_BuildValue("i", 0); - } - } - if (s_backgroundTerrain) { - return Py_BuildValue("i", s_backgroundTerrain->IsAttrOn(x, y, static_cast(attr)) ? 1 : 0); - } - return Py_BuildValue("i", 0); -} - -void initBackground() { - s_mapCoordinates=MapCoordinates{}; s_atlasLocale.clear(); - static PyMethodDef methods[] = { - {"IsSoftwareTiling", dummy_zero, METH_VARARGS, nullptr}, - {"EnableSoftwareTiling", dummy_none, METH_VARARGS, nullptr}, - {"TextureChange", dummy_none, METH_VARARGS, nullptr}, - {"EnableSnow", dummy_none, METH_VARARGS, nullptr}, - {"GlobalPositionToLocalPosition", background_GlobalPositionToLocalPosition, METH_VARARGS, nullptr}, - {"GlobalPositionToMapInfo", background_GlobalPositionToMapInfo, METH_VARARGS, nullptr}, - {"GetRenderShadowTime", dummy_zero, METH_VARARGS, nullptr}, - {"LoadMap", background_LoadMap, METH_VARARGS, nullptr}, - {"Destroy", background_Destroy, METH_VARARGS, nullptr}, - {"RegisterEnvironmentData", dummy_none, METH_VARARGS, nullptr}, - {"SetEnvironmentData", dummy_none, METH_VARARGS, nullptr}, - {"GetCurrentMapName", background_GetCurrentMapName, METH_VARARGS, nullptr}, - {"GetPickingPoint", background_GetPickingPoint, METH_VARARGS, nullptr}, - {"BeginEnvironment", dummy_none, METH_VARARGS, nullptr}, - {"EndEnvironment", dummy_none, METH_VARARGS, nullptr}, - {"SetCharacterDirLight", dummy_none, METH_VARARGS, nullptr}, - {"SetBackgroundDirLight", dummy_none, METH_VARARGS, nullptr}, - {"Initialize", background_Initialize, METH_VARARGS, nullptr}, - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"RenderPCBlocker", dummy_none, METH_VARARGS, nullptr}, - {"RenderCollision", dummy_none, METH_VARARGS, nullptr}, - {"RenderSky", dummy_none, METH_VARARGS, nullptr}, - {"RenderCloud", dummy_none, METH_VARARGS, nullptr}, - {"RenderWater", dummy_none, METH_VARARGS, nullptr}, - {"RenderEffect", dummy_none, METH_VARARGS, nullptr}, - {"RenderBeforeLensFlare", dummy_none, METH_VARARGS, nullptr}, - {"RenderAfterLensFlare", dummy_none, METH_VARARGS, nullptr}, - {"RenderCharacterShadowToTexture", dummy_none, METH_VARARGS, nullptr}, - {"RenderDungeon", dummy_none, METH_VARARGS, nullptr}, - {"GetHeight", background_GetHeight, METH_VARARGS, nullptr}, - {"isAttrOn", background_isAttrOn, METH_VARARGS, nullptr}, - {"IsAttrOn", background_isAttrOn, METH_VARARGS, nullptr}, - {"SetShadowLevel", dummy_none, METH_VARARGS, nullptr}, - {"IsVisiblePart", dummy_zero, METH_VARARGS, nullptr}, - {"SetVisiblePart", dummy_none, METH_VARARGS, nullptr}, - {"GetShadowMapColor", dummy_zero, METH_VARARGS, nullptr}, - {"SetSplatLimit", dummy_none, METH_VARARGS, nullptr}, - {"GetRenderedSplatNum", dummy_zero, METH_VARARGS, nullptr}, - {"GetRenderedGraphicThingInstanceNum", dummy_zero, METH_VARARGS, nullptr}, - {"SelectViewDistanceNum", dummy_none, METH_VARARGS, nullptr}, - {"SetViewDistanceSet", dummy_none, METH_VARARGS, nullptr}, - {"GetFarClip", dummy_zero, METH_VARARGS, nullptr}, - {"GetDistanceSetInfo", dummy_zero, METH_VARARGS, nullptr}, - {"SetBGLoading", dummy_none, METH_VARARGS, nullptr}, - {"SetRenderSort", dummy_none, METH_VARARGS, nullptr}, - {"SetTransparentTree", dummy_none, METH_VARARGS, nullptr}, - {"SetXMasTree", dummy_none, METH_VARARGS, nullptr}, - {"RegisterDungeonMapName", dummy_none, METH_VARARGS, nullptr}, - {"VisibleGuildArea", dummy_none, METH_VARARGS, nullptr}, - {"DisableGuildArea", dummy_none, METH_VARARGS, nullptr}, - {"WarpTest", background_WarpTest, METH_VARARGS, nullptr}, - {"CreatePrivateShopPos", dummy_none, METH_VARARGS, nullptr}, - {"DeletePrivateShopPos", dummy_none, METH_VARARGS, nullptr}, - {nullptr, nullptr, 0, nullptr} - }; - auto* module = Py_InitModule("background", methods); - - PyModule_AddIntConstant(module, "PART_SKY", 5); - PyModule_AddIntConstant(module, "PART_TREE", 4); - PyModule_AddIntConstant(module, "PART_CLOUD", 2); - PyModule_AddIntConstant(module, "PART_WATER", 3); - PyModule_AddIntConstant(module, "PART_OBJECT", 1); - PyModule_AddIntConstant(module, "PART_TERRAIN", 0); - PyModule_AddIntConstant(module, "PART_SHOP", 6); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_DEFAULT", 0); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_DIFFUSE", 1); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_TEXTURE", 2); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_MODULATE", 3); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_MODULATE2X", 4); - PyModule_AddIntConstant(module, "SKY_RENDER_MODE_MODULATE4X", 5); - PyModule_AddIntConstant(module, "SHADOW_NONE", 0); - PyModule_AddIntConstant(module, "SHADOW_GROUND", 1); - PyModule_AddIntConstant(module, "SHADOW_GROUND_AND_SOLO", 2); - PyModule_AddIntConstant(module, "SHADOW_ALL", 3); - PyModule_AddIntConstant(module, "SHADOW_ALL_HIGH", 4); - PyModule_AddIntConstant(module, "SHADOW_ALL_MAX", 5); - PyModule_AddIntConstant(module, "DISTANCE0", 0); - PyModule_AddIntConstant(module, "DISTANCE1", 1); - PyModule_AddIntConstant(module, "DISTANCE2", 2); - PyModule_AddIntConstant(module, "DISTANCE3", 3); - PyModule_AddIntConstant(module, "DISTANCE4", 4); - PyModule_AddIntConstant(module, "DISTANCE_SORT", 0); - PyModule_AddIntConstant(module, "TEXTURE_SORT", 1); - - // Collision & Attribute constants (aligned with 40250 CTerrainImpl) - PyModule_AddIntConstant(module, "ATTR_BLOCK", TerrainAttr::ATTR_BLOCK); - PyModule_AddIntConstant(module, "ATTR_WATER", TerrainAttr::ATTR_WATER); - PyModule_AddIntConstant(module, "ATTR_BANPK", TerrainAttr::ATTR_BANPK); - PyModule_AddIntConstant(module, "ATTRIBUTE_BLOCK", TerrainAttr::ATTR_BLOCK); - PyModule_AddIntConstant(module, "ATTRIBUTE_WATER", TerrainAttr::ATTR_WATER); - PyModule_AddIntConstant(module, "ATTRIBUTE_BANPK", TerrainAttr::ATTR_BANPK); -} - } // namespace ava2 + diff --git a/src/python_gameplay_modules.h b/src/python_gameplay_modules.h index c79b4f84..9ac60d66 100644 --- a/src/python_gameplay_modules.h +++ b/src/python_gameplay_modules.h @@ -1,4 +1,5 @@ #pragma once +#include "python_background.h" #include "eter_render/RenderCommands3D.h" #include "eter_net/Packet.h" #include @@ -11,10 +12,6 @@ void initPlayer(); void initchrmgr(); void initchr(); void initsnd(); -void initBackground(); -void GlobalToLocalPosition(int32_t& x,int32_t& y); -void LocalToGlobalPosition(int32_t& x,int32_t& y); -bool WarpBackgroundMap(uint32_t x,uint32_t y); using SkillCastCallback = std::function; void SetPlayerSkillCastCallback(SkillCastCallback cb); @@ -76,14 +73,6 @@ const std::string& GetMainCharacterName(); void SetMainCharacterName(const std::string& name); long long GetPlayerStatusPoint(int type); void SetPlayerStatusPoint(int type, long long value); - -class TerrainHeightmap; -TerrainHeightmap* GetActiveBackgroundTerrain(); -void SetActiveBackgroundTerrain(std::unique_ptr terrain); -bool LoadBackgroundMap(const std::string& mapName, float x = 0.0f, float y = 0.0f, float z = 0.0f); -// CPythonBackground::IsMapOutdoor + CMapOutdoor GetName/GetBaseXY/GetTerrainCount for the loaded map -// (setting.txt "mapsize" / "baseposition"); nullptr while no map is loaded. -struct OutdoorMapInfo { std::string name; uint32_t baseX=0, baseY=0; int16_t terrainCountX=0, terrainCountY=0; }; -const OutdoorMapInfo* GetOutdoorMap(); } // namespace ava2 + diff --git a/src/python_grp.cpp b/src/python_grp.cpp index 660ceb7b..86e18813 100644 --- a/src/python_grp.cpp +++ b/src/python_grp.cpp @@ -1,27 +1,29 @@ #include "python_grp.h" #include "eter_image/GrpDevice.h" +#include "eter_image/GrpImageInstance.h" +#include "eter_image/GrpExpandedImageInstance.h" +#include "eter_resource/ResourceManager.h" +#include "eter_ui/PythonWindow.h" #include #include #include #include #include +#include +#include namespace ava2 { namespace { -PyObject* dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; } -PyObject* dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); } -PyObject* dummy_one(PyObject*, PyObject*) { return PyInt_FromLong(1); } -PyObject* dummy_float_zero(PyObject*, PyObject*) { return PyFloat_FromDouble(0.0); } -PyObject* dummy_str(PyObject*, PyObject*) { return PyString_FromString(""); } -PyObject* dummy_tuple2(PyObject*, PyObject*) { return Py_BuildValue("ii", 0, 0); } -PyObject* dummy_tuple3(PyObject*, PyObject*) { return Py_BuildValue("iii", 0, 0, 0); } -PyObject* dummy_tuple4(PyObject*, PyObject*) { return Py_BuildValue("iiii", 0, 0, 0, 0); } static uint32_t s_currentColor = 0xFFFFFFFF; static uint32_t s_diffuseColor = 0xFFFFFFFF; static uint32_t s_clearColor = 0xFF000000; static float s_alpha = 1.0f; +// --------------------------------------------------------------------- +// grp Color & Primitive Rendering +// --------------------------------------------------------------------- + static PyObject* grp_GenerateColor(PyObject*, PyObject* args) { float r = 0.0f, g = 0.0f, b = 0.0f, a = 1.0f; if (!PyArg_ParseTuple(args, "ffff", &r, &g, &b, &a)) { @@ -184,132 +186,1109 @@ static PyObject* grp_RenderGradationBar(PyObject*, PyObject* args) { } Py_RETURN_NONE; } + +// --------------------------------------------------------------------- +// CTextBar Implementation +// --------------------------------------------------------------------- + +class CTextBar { +public: + CTextBar(int fontSize, bool isBig) : m_fontSize(fontSize), m_isBig(isBig) {} + bool Create(void*, int w, int h) { m_width = w; m_height = h; return true; } + void Render(int, int) {} + void SetTextColor(int r, int g, int b) { m_textColor = (0xff << 24) | (r << 16) | (g << 8) | b; } + void GetTextExtent(const char* text, SIZE* pSize) { + if (pSize) { + pSize->cx = text ? (int)strlen(text) * (m_isBig ? 8 : 6) : 0; + pSize->cy = m_fontSize; + } + } + void TextOut(int, int, const char* text) { if (text) m_text = text; } + void ClearBar() { m_text.clear(); } + void SetClipRect(RECT r) { m_clipRect = r; } +private: + int m_fontSize; + bool m_isBig; + int m_width = 0; + int m_height = 0; + DWORD m_textColor = 0xffffffff; + std::string m_text; + RECT m_clipRect{}; +}; + +static uint32_t s_nextTextBarHandle = 1; +static std::unordered_map s_textBarHandles; +static std::mutex s_textBarMutex; + +static CTextBar* GetTextBarPointer(uint32_t handle) { + std::lock_guard lock(s_textBarMutex); + auto it = s_textBarHandles.find(handle); + return it == s_textBarHandles.end() ? nullptr : it->second; +} + +static PyObject* grpCreateTextBar(PyObject*, PyObject* poArgs) { + int iWidth = 0, iHeight = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iWidth) || !PyTuple_GetInteger(poArgs, 1, &iHeight)) + return Py_BuildException(); + auto* bar = new CTextBar(12, false); + bar->Create(nullptr, iWidth, iHeight); + std::lock_guard lock(s_textBarMutex); + uint32_t h = s_nextTextBarHandle++; + s_textBarHandles[h] = bar; + return Py_BuildValue("i", h); +} + +static PyObject* grpCreateBigTextBar(PyObject*, PyObject* poArgs) { + int iWidth = 0, iHeight = 0, iFontSize = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iWidth) || !PyTuple_GetInteger(poArgs, 1, &iHeight) || !PyTuple_GetInteger(poArgs, 2, &iFontSize)) + return Py_BuildException(); + auto* bar = new CTextBar(iFontSize, true); + bar->Create(nullptr, iWidth, iHeight); + std::lock_guard lock(s_textBarMutex); + uint32_t h = s_nextTextBarHandle++; + s_textBarHandles[h] = bar; + return Py_BuildValue("i", h); +} + +static PyObject* grpDestroyTextBar(PyObject*, PyObject* poArgs) { + int iHandle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle)) + return Py_BuildException(); + std::lock_guard lock(s_textBarMutex); + auto it = s_textBarHandles.find(static_cast(iHandle)); + if (it != s_textBarHandles.end()) { + delete it->second; + s_textBarHandles.erase(it); + } + return Py_BuildNone(); +} + +static PyObject* grpRenderTextBar(PyObject*, PyObject* poArgs) { + int iHandle = 0, ix = 0, iy = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle) || !PyTuple_GetInteger(poArgs, 1, &ix) || !PyTuple_GetInteger(poArgs, 2, &iy)) + return Py_BuildException(); + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) bar->Render(ix, iy); + return Py_BuildNone(); +} + +static PyObject* grpTextBarSetTextColor(PyObject*, PyObject* poArgs) { + int iHandle = 0, r = 0, g = 0, b = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle) || !PyTuple_GetInteger(poArgs, 1, &r) || !PyTuple_GetInteger(poArgs, 2, &g) || !PyTuple_GetInteger(poArgs, 3, &b)) + return Py_BuildException(); + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) bar->SetTextColor(r, g, b); + return Py_BuildNone(); +} + +static PyObject* grpTextBarGetTextExtent(PyObject*, PyObject* poArgs) { + int iHandle = 0; + char* szText = nullptr; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle) || !PyTuple_GetString(poArgs, 1, &szText)) + return Py_BuildException(); + SIZE size{0, 0}; + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) bar->GetTextExtent(szText, &size); + return Py_BuildValue("ii", size.cx, size.cy); +} + +static PyObject* grpTextBarTextOut(PyObject*, PyObject* poArgs) { + int iHandle = 0, ix = 0, iy = 0; + char* szText = nullptr; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle) || !PyTuple_GetInteger(poArgs, 1, &ix) || !PyTuple_GetInteger(poArgs, 2, &iy) || !PyTuple_GetString(poArgs, 3, &szText)) + return Py_BuildException(); + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) bar->TextOut(ix, iy, szText); + return Py_BuildNone(); +} + +static PyObject* grpClearTextBar(PyObject*, PyObject* poArgs) { + int iHandle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle)) + return Py_BuildException(); + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) bar->ClearBar(); + return Py_BuildNone(); +} + +static PyObject* grpSetTextBarClipRect(PyObject*, PyObject* poArgs) { + int iHandle = 0, isx = 0, isy = 0, iex = 0, iey = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle) || + !PyTuple_GetInteger(poArgs, 1, &isx) || + !PyTuple_GetInteger(poArgs, 2, &isy) || + !PyTuple_GetInteger(poArgs, 3, &iex) || + !PyTuple_GetInteger(poArgs, 4, &iey)) + return Py_BuildException(); + auto* bar = GetTextBarPointer(static_cast(iHandle)); + if (bar) { + RECT rect; + rect.left = isx; rect.top = isy; rect.right = iex; rect.bottom = iey; + bar->SetClipRect(rect); + } + return Py_BuildNone(); +} + +// --------------------------------------------------------------------- +// grp Pipeline / Camera / Transform APIs +// --------------------------------------------------------------------- + +static PyObject* grpCulling(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpInitScreenEffect(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpClearDepthBuffer(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpPushState(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpPopState(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpPushMatrix(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpPopMatrix(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpIdentity(PyObject*, PyObject*) { return Py_BuildNone(); } + +static PyObject* grpTranslate(PyObject*, PyObject* poArgs) { + float x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetFloat(poArgs, 0, &x) || !PyTuple_GetFloat(poArgs, 1, &y) || !PyTuple_GetFloat(poArgs, 2, &z)) + return Py_BuildException("grp.Translate:Wrong coordinates"); + return Py_BuildNone(); +} + +static PyObject* grpRotate(PyObject*, PyObject* poArgs) { + float Degree = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetFloat(poArgs, 0, &Degree) || !PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y) || !PyTuple_GetFloat(poArgs, 3, &z)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetColorRenderState(PyObject*, PyObject*) { return Py_BuildNone(); } + +static PyObject* grpSetAroundCamera(PyObject*, PyObject* poArgs) { + float distance = 0.0f, pitch = 0.0f, roll = 0.0f, lookAtZ = 0.0f; + if (!PyTuple_GetFloat(poArgs, 0, &distance) || !PyTuple_GetFloat(poArgs, 1, &pitch) || !PyTuple_GetFloat(poArgs, 2, &roll) || !PyTuple_GetFloat(poArgs, 3, &lookAtZ)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetPositionCamera(PyObject*, PyObject* poArgs) { + float fx = 0, fy = 0, fz = 0, distance = 0, pitch = 0, roll = 0; + if (!PyTuple_GetFloat(poArgs, 0, &fx) || !PyTuple_GetFloat(poArgs, 1, &fy) || !PyTuple_GetFloat(poArgs, 2, &fz) || + !PyTuple_GetFloat(poArgs, 3, &distance) || !PyTuple_GetFloat(poArgs, 4, &pitch) || !PyTuple_GetFloat(poArgs, 5, &roll)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetEyeCamera(PyObject*, PyObject* poArgs) { + float xEye = 0, yEye = 0, zEye = 0, xCenter = 0, yCenter = 0, zCenter = 0, xUp = 0, yUp = 0, zUp = 0; + if (!PyTuple_GetFloat(poArgs, 0, &xEye) || !PyTuple_GetFloat(poArgs, 1, &yEye) || !PyTuple_GetFloat(poArgs, 2, &zEye) || + !PyTuple_GetFloat(poArgs, 3, &xCenter) || !PyTuple_GetFloat(poArgs, 4, &yCenter) || !PyTuple_GetFloat(poArgs, 5, &zCenter) || + !PyTuple_GetFloat(poArgs, 6, &xUp) || !PyTuple_GetFloat(poArgs, 7, &yUp) || !PyTuple_GetFloat(poArgs, 8, &zUp)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetPerspective(PyObject*, PyObject* poArgs) { + float fov = 0, aspect = 0, zNear = 0, zFar = 0; + if (!PyTuple_GetFloat(poArgs, 0, &fov) || !PyTuple_GetFloat(poArgs, 1, &aspect) || !PyTuple_GetFloat(poArgs, 2, &zNear) || !PyTuple_GetFloat(poArgs, 3, &zFar)) + return Py_BuildException(); + return Py_BuildNone(); +} + +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(); + return Py_BuildNone(); +} + +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(); + return Py_BuildNone(); +} + +static PyObject* grpGetCursorPosition3d(PyObject*, PyObject*) { + return Py_BuildValue("(fff)", 0.0f, 0.0f, 0.0f); +} + +static PyObject* grpSetCursorPosition(PyObject*, PyObject* poArgs) { + int ix = 0, iy = 0; + if (!PyTuple_GetInteger(poArgs, 0, &ix) || !PyTuple_GetInteger(poArgs, 1, &iy)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRenderBox3d(PyObject*, PyObject* poArgs) { + float sx = 0, sy = 0, sz = 0, ex = 0, ey = 0, ez = 0; + if (!PyTuple_GetFloat(poArgs, 0, &sx) || !PyTuple_GetFloat(poArgs, 1, &sy) || !PyTuple_GetFloat(poArgs, 2, &sz) || + !PyTuple_GetFloat(poArgs, 3, &ex) || !PyTuple_GetFloat(poArgs, 4, &ey) || !PyTuple_GetFloat(poArgs, 5, &ez)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRenderBar3d(PyObject*, PyObject* poArgs) { + int sx = 0, sy = 0, sz = 0, ex = 0, ey = 0, ez = 0; + if (!PyTuple_GetInteger(poArgs, 0, &sx) || !PyTuple_GetInteger(poArgs, 1, &sy) || !PyTuple_GetInteger(poArgs, 2, &sz) || + !PyTuple_GetInteger(poArgs, 3, &ex) || !PyTuple_GetInteger(poArgs, 4, &ey) || !PyTuple_GetInteger(poArgs, 5, &ez)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRenderCube(PyObject*, PyObject* poArgs) { + float sx = 0, sy = 0, sz = 0, ex = 0, ey = 0, ez = 0; + if (!PyTuple_GetFloat(poArgs, 0, &sx) || !PyTuple_GetFloat(poArgs, 1, &sy) || !PyTuple_GetFloat(poArgs, 2, &sz) || + !PyTuple_GetFloat(poArgs, 3, &ex) || !PyTuple_GetFloat(poArgs, 4, &ey) || !PyTuple_GetFloat(poArgs, 5, &ez)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRenderDownButton(PyObject*, PyObject* poArgs) { + int x = 0, y = 0, width = 0, height = 0; + if (!PyTuple_GetInteger(poArgs, 0, &x) || !PyTuple_GetInteger(poArgs, 1, &y) || !PyTuple_GetInteger(poArgs, 2, &width) || !PyTuple_GetInteger(poArgs, 3, &height)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRenderUpButton(PyObject*, PyObject* poArgs) { + int x = 0, y = 0, width = 0, height = 0; + if (!PyTuple_GetInteger(poArgs, 0, &x) || !PyTuple_GetInteger(poArgs, 1, &y) || !PyTuple_GetInteger(poArgs, 2, &width) || !PyTuple_GetInteger(poArgs, 3, &height)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpGetAvailableMemory(PyObject*, PyObject*) { + return Py_BuildValue("i", 256 * 1024 * 1024); +} + +static PyObject* grpSaveScreenShot(PyObject*, PyObject*) { + return Py_BuildValue("(is)", 1, "screenshot.jpg"); +} + +static PyObject* grpSaveScreenShotToPath(PyObject*, PyObject* poArgs) { + char* szBasePath = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szBasePath)) + return Py_BuildException(); + return Py_BuildValue("(is)", 1, (std::string(szBasePath ? szBasePath : "") + ".jpg").c_str()); +} + +static PyObject* grpSetGamma(PyObject*, PyObject* poArgs) { + float gamma = 0.0f; + if (!PyTuple_GetFloat(poArgs, 0, &gamma)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetInterfaceRenderState(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpSetGameRenderState(PyObject*, PyObject*) { return Py_BuildNone(); } + +static PyObject* grpSetViewport(PyObject*, PyObject* poArgs) { + float fx = 0, fy = 0, fWidth = 0, fHeight = 0; + if (!PyTuple_GetFloat(poArgs, 0, &fx) || !PyTuple_GetFloat(poArgs, 1, &fy) || !PyTuple_GetFloat(poArgs, 2, &fWidth) || !PyTuple_GetFloat(poArgs, 3, &fHeight)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpRestoreViewport(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* grpSetOmniLight(PyObject*, PyObject*) { return Py_BuildNone(); } + +static PyObject* grpGetCameraPosition(PyObject*, PyObject*) { + return Py_BuildValue("fff", 0.0f, 0.0f, 180.0f); +} + +static PyObject* grpGetTargetPosition(PyObject*, PyObject*) { + return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); +} + +// --------------------------------------------------------------------- +// grpImage Implementation +// --------------------------------------------------------------------- + +static bool PyTuple_GetImageInstance(PyObject* poArgs, int pos, CGraphicImageInstance** ppRetImageInstance) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, pos, &handle)) + return false; + if (!handle) + return false; + *ppRetImageInstance = GrpGetImageInstancePointer(static_cast(handle)); + return *ppRetImageInstance != nullptr; +} + +static bool PyTuple_GetExpandedImageInstance(PyObject* poArgs, int pos, CGraphicExpandedImageInstance** ppRetImageInstance) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, pos, &handle)) + return false; + if (!handle) + return false; + auto* pInstance = GrpGetImageInstancePointer(static_cast(handle)); + if (!pInstance || !pInstance->IsType(CGraphicExpandedImageInstance::Type())) + return false; + *ppRetImageInstance = static_cast(pInstance); + return true; +} + +static PyObject* grpImageGenerate(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BadArgument(); + if (!szFileName || !*szFileName) + return Py_BuildValue("i", 0); + + auto* pResource = CResourceManager::Instance().GetResourcePointer(szFileName); + if (!pResource || !pResource->IsType(CGraphicImage::Type())) + return Py_BuildException("Resource is not an image (filename: %s)", szFileName); + + auto* pImageInstance = CGraphicImageInstance::New(); + pImageInstance->SetImagePointer(static_cast(pResource)); + if (pImageInstance->IsEmpty()) + return Py_BuildException("Cannot load image (filename: %s)", szFileName); + + return Py_BuildValue("i", GrpRegisterImageInstanceHandle(pImageInstance)); +} + +static PyObject* grpImageGenerateExpanded(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BadArgument(); + if (!szFileName || !*szFileName) + return Py_BuildValue("i", 0); + + auto* pResource = CResourceManager::Instance().GetResourcePointer(szFileName); + if (!pResource || !pResource->IsType(CGraphicImage::Type())) + return Py_BuildException("Resource is not an image (filename: %s)", szFileName); + + auto* pImageInstance = CGraphicExpandedImageInstance::New(); + pImageInstance->SetImagePointer(static_cast(pResource)); + if (pImageInstance->IsEmpty()) + return Py_BuildException("Cannot load image (filename: %s)", szFileName); + + return Py_BuildValue("i", GrpRegisterImageInstanceHandle(pImageInstance)); +} + +static PyObject* grpImageGenerateFromHandle(PyObject*, PyObject* poArgs) { + int iHandle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iHandle)) + return Py_BadArgument(); + + auto* pImageInstance = CGraphicImageInstance::New(); + auto* pImage = GrpGetImagePointer(static_cast(iHandle)); + if (pImage) { + pImageInstance->SetImagePointer(pImage); + } + return Py_BuildValue("i", GrpRegisterImageInstanceHandle(pImageInstance)); +} + +static PyObject* grpImageDelete(PyObject*, PyObject* poArgs) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &handle)) + return Py_BadArgument(); + auto* pInstance = GrpReleaseImageInstanceHandle(static_cast(handle)); + if (pInstance) { + CGraphicImageInstance::Delete(pInstance); + } + return Py_BuildNone(); +} + +static PyObject* grpImageDeleteExpanded(PyObject*, PyObject* poArgs) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &handle)) + return Py_BadArgument(); + auto* pInstance = GrpReleaseImageInstanceHandle(static_cast(handle)); + if (pInstance) { + if (pInstance->IsType(CGraphicExpandedImageInstance::Type())) { + CGraphicExpandedImageInstance::Delete(static_cast(pInstance)); + } else { + CGraphicImageInstance::Delete(pInstance); + } + } + return Py_BuildNone(); +} + +static PyObject* grpImageSetFileName(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 1, &szFileName)) + return Py_BadArgument(); + + auto* pResource = CResourceManager::Instance().GetResourcePointer(szFileName); + if (!pResource || !pResource->IsType(CGraphicImage::Type())) + return Py_BuildException("Resource is not an image (filename: %s)", szFileName); + + pImageInstance->SetImagePointer(static_cast(pResource)); + return Py_BuildNone(); +} + +static PyObject* grpImageRender(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + pImageInstance->Render(); + return Py_BuildNone(); +} + +static PyObject* grpSetImagePosition(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float x = 0.0f, y = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y)) + return Py_BadArgument(); + + pImageInstance->SetPosition(x, y); + return Py_BuildNone(); +} + +static PyObject* grpSetImageOrigin(PyObject*, PyObject* poArgs) { + CGraphicExpandedImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetExpandedImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float x = 0.0f, y = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y)) + return Py_BadArgument(); + + pImageInstance->SetOrigin(x, y); + return Py_BuildNone(); +} + +static PyObject* grpSetImageRotation(PyObject*, PyObject* poArgs) { + CGraphicExpandedImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetExpandedImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float Degree = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &Degree)) + return Py_BadArgument(); + + pImageInstance->SetRotation(Degree); + return Py_BuildNone(); +} + +static PyObject* grpSetImageScale(PyObject*, PyObject* poArgs) { + CGraphicExpandedImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetExpandedImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float x = 0.0f, y = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y)) + return Py_BadArgument(); + + pImageInstance->SetScale(x, y); + return Py_BuildNone(); +} + +static PyObject* grpSetRenderingRect(PyObject*, PyObject* poArgs) { + CGraphicExpandedImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetExpandedImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float fLeft = 0.0f, fTop = 0.0f, fRight = 0.0f, fBottom = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &fLeft) || + !PyTuple_GetFloat(poArgs, 2, &fTop) || + !PyTuple_GetFloat(poArgs, 3, &fRight) || + !PyTuple_GetFloat(poArgs, 4, &fBottom)) + return Py_BadArgument(); + + pImageInstance->SetRenderingRect(fLeft, fTop, fRight, fBottom); + return Py_BuildNone(); +} + +static PyObject* grpSetImageDiffuseColor(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + float r = 1.0f, g = 1.0f, b = 1.0f, a = 1.0f; + if (!PyTuple_GetFloat(poArgs, 1, &r) || + !PyTuple_GetFloat(poArgs, 2, &g) || + !PyTuple_GetFloat(poArgs, 3, &b) || + !PyTuple_GetFloat(poArgs, 4, &a)) + return Py_BadArgument(); + + pImageInstance->SetDiffuseColor(r, g, b, a); + return Py_BuildNone(); +} + +static PyObject* grpGetWidth(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + if (pImageInstance->IsEmpty()) + return Py_BuildException("Image is empty"); + + return Py_BuildValue("i", pImageInstance->GetWidth()); +} + +static PyObject* grpGetHeight(PyObject*, PyObject* poArgs) { + CGraphicImageInstance* pImageInstance = nullptr; + if (!PyTuple_GetImageInstance(poArgs, 0, &pImageInstance)) + return Py_BadArgument(); + + if (pImageInstance->IsEmpty()) + return Py_BuildException("Image is empty"); + + return Py_BuildValue("i", pImageInstance->GetHeight()); +} + +// --------------------------------------------------------------------- +// grpText Implementation +// --------------------------------------------------------------------- + +static uint32_t s_nextTextHandle = 1; +static std::unordered_map s_textHandles; +static std::mutex s_textHandleMutex; + +static uint32_t GrpRegisterTextInstanceHandle(UI::CGraphicTextInstance* pInstance) { + if (!pInstance) return 0; + std::lock_guard lock(s_textHandleMutex); + uint32_t handle = s_nextTextHandle++; + s_textHandles[handle] = pInstance; + return handle; +} + +static UI::CGraphicTextInstance* GrpGetTextInstancePointer(uint32_t handle) { + std::lock_guard lock(s_textHandleMutex); + auto it = s_textHandles.find(handle); + return it == s_textHandles.end() ? nullptr : it->second; +} + +static UI::CGraphicTextInstance* GrpReleaseTextInstanceHandle(uint32_t handle) { + std::lock_guard lock(s_textHandleMutex); + auto it = s_textHandles.find(handle); + if (it == s_textHandles.end()) return nullptr; + auto* p = it->second; + s_textHandles.erase(it); + return p; +} + +static bool PyTuple_GetTextInstance(PyObject* poArgs, int pos, UI::CGraphicTextInstance** ppTextInstance) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, pos, &handle)) + return false; + if (!handle) + return false; + *ppTextInstance = GrpGetTextInstancePointer(static_cast(handle)); + return *ppTextInstance != nullptr; +} + +static PyObject* grpTextGenerate(PyObject*, PyObject*) { + auto* pTextInstance = new UI::CGraphicTextInstance(); + return Py_BuildValue("i", GrpRegisterTextInstanceHandle(pTextInstance)); +} + +static PyObject* grpTextDestroy(PyObject*, PyObject* poArgs) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &handle)) + return Py_BuildException(); + auto* pText = GrpReleaseTextInstanceHandle(static_cast(handle)); + delete pText; + return Py_BuildNone(); +} + +static PyObject* grpTextSetFontName(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + char* szFontName = nullptr; + if (!PyTuple_GetString(poArgs, 1, &szFontName)) + return Py_BuildException(); + pTextInstance->SetFontName(szFontName); + return Py_BuildNone(); +} + +static PyObject* grpTextSetFontColor(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + + if (2 == PyTuple_Size(poArgs)) { + int iColor = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iColor)) + return Py_BuildException(); + pTextInstance->SetFontColor(DWORD(iColor)); + } else if (4 == PyTuple_Size(poArgs)) { + float fRed = 0.0f, fGreen = 0.0f, fBlue = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &fRed) || + !PyTuple_GetFloat(poArgs, 2, &fGreen) || + !PyTuple_GetFloat(poArgs, 3, &fBlue)) + return Py_BuildException(); + pTextInstance->SetColor(fRed, fGreen, fBlue); + } else { + return Py_BuildException(); + } + return Py_BuildNone(); +} + +static PyObject* grpTextSetOutLineColor(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + + float fRed = 0.0f, fGreen = 0.0f, fBlue = 0.0f, fAlpha = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &fRed) || + !PyTuple_GetFloat(poArgs, 2, &fGreen) || + !PyTuple_GetFloat(poArgs, 3, &fBlue) || + !PyTuple_GetFloat(poArgs, 4, &fAlpha)) + return Py_BuildException(); + + pTextInstance->SetOutLineColor(fRed, fGreen, fBlue, fAlpha); + return Py_BuildNone(); +} + +static PyObject* grpTextSetSecret(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + bool bSecret = false; + if (!PyTuple_GetBoolean(poArgs, 1, &bSecret)) + return Py_BuildException(); + pTextInstance->SetSecret(bSecret ? TRUE : FALSE); + return Py_BuildNone(); +} + +static PyObject* grpTextOutline(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + bool bOutline = false; + if (!PyTuple_GetBoolean(poArgs, 1, &bOutline)) + return Py_BuildException(); + pTextInstance->SetOutline(bOutline ? TRUE : FALSE); + return Py_BuildNone(); +} + +static PyObject* grpTextSetText(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + char* szText = nullptr; + if (!PyTuple_GetString(poArgs, 1, &szText)) + return Py_BuildException(); + pTextInstance->SetText(szText); + return Py_BuildNone(); +} + +static PyObject* grpTextGetText(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + return Py_BuildValue("s", pTextInstance->GetText()); +} + +static PyObject* grpTextGetSize(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int width = 0, height = 0; + pTextInstance->GetTextSize(&width, &height); + return Py_BuildValue("(i, i)", width, height); +} + +static PyObject* grpTextSetPosition(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int ix = 0, iy = 0; + if (!PyTuple_GetInteger(poArgs, 1, &ix) || !PyTuple_GetInteger(poArgs, 2, &iy)) + return Py_BuildException(); + pTextInstance->SetPosition((float)ix, (float)iy); + return Py_BuildNone(); +} + +static PyObject* grpTextShowCursor(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + pTextInstance->ShowCursor(); + return Py_BuildNone(); +} + +static PyObject* grpTextHideCursor(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + pTextInstance->HideCursor(); + return Py_BuildNone(); +} + +static PyObject* grpSetHorizontalAlign(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int iAlign = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iAlign)) + return Py_BuildException(); + pTextInstance->SetHorizonalAlign(iAlign); + return Py_BuildNone(); +} + +static PyObject* grpSetVerticalAlign(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int iAlign = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iAlign)) + return Py_BuildException(); + pTextInstance->SetVerticalAlign(iAlign); + return Py_BuildNone(); +} + +static PyObject* grpSetMax(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int iValue = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iValue)) + return Py_BuildException(); + pTextInstance->SetMax(iValue); + return Py_BuildNone(); +} + +static PyObject* grpGetSplitingTextLineCount(PyObject*, PyObject* poArgs) { + char* szText = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szText)) + return Py_BuildException(); + int iLineLimitation = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iLineLimitation)) + return Py_BuildException(); + + int iPosition = 0; + int iLineCount = 0; + size_t len = szText ? strlen(szText) : 0; + for (size_t i = 0; i < len;) { + if ('|' == szText[i]) { + i += 1; + if (iPosition > 0) + ++iLineCount; + iPosition = 0; + continue; + } + if (szText[i] & 0x80) { + i += 2; + iPosition += 2; + } else { + i += 1; + iPosition += 1; + } + if (iPosition >= iLineLimitation) { + ++iLineCount; + iPosition = 0; + } + } + if (iPosition > 0) + ++iLineCount; + + return Py_BuildValue("i", iLineCount); +} + +static PyObject* grpGetSplitingTextLine(PyObject*, PyObject* poArgs) { + char* szText = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szText)) + return Py_BuildException(); + int iLineLimitation = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iLineLimitation)) + return Py_BuildException(); + int iGettingLine = 0; + if (!PyTuple_GetInteger(poArgs, 2, &iGettingLine)) + return Py_BuildException(); + + std::string strLine; + int iPosition = 0; + int iLineCount = 0; + size_t len = szText ? strlen(szText) : 0; + for (size_t i = 0; i < len;) { + if ('|' == szText[i]) { + i += 1; + if (iPosition > 0) + ++iLineCount; + iPosition = 0; + continue; + } + if (szText[i] & 0x80) { + if (iLineCount == iGettingLine) + strLine.append(szText + i, 2); + i += 2; + iPosition += 2; + } else { + if (iLineCount == iGettingLine) + strLine += szText[i]; + i += 1; + iPosition += 1; + } + if (iPosition >= iLineLimitation) { + ++iLineCount; + iPosition = 0; + } + } + return Py_BuildValue("s", strLine.c_str()); +} + +static PyObject* grpTextPixelPositionToCharacterPosition(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + int iPixelPosition = 0; + if (!PyTuple_GetInteger(poArgs, 1, &iPixelPosition)) + return Py_BuildException(); + int iCharacterPosition = pTextInstance->PixelPositionToCharacterPosition(iPixelPosition); + return Py_BuildValue("i", iCharacterPosition); +} + +static PyObject* grpTextRender(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + pTextInstance->Render(); + return Py_BuildNone(); +} + +static PyObject* grpTextUpdate(PyObject*, PyObject* poArgs) { + UI::CGraphicTextInstance* pTextInstance = nullptr; + if (!PyTuple_GetTextInstance(poArgs, 0, &pTextInstance)) + return Py_BuildException(); + pTextInstance->Update(); + return Py_BuildNone(); +} + +// --------------------------------------------------------------------- +// grpThing Implementation +// --------------------------------------------------------------------- + +struct SGraphicThingHolder { + std::string fileName; + struct Vec3 { float x = 0.0f, y = 0.0f, z = 0.0f; }; + Vec3 position{0.0f, 0.0f, 0.0f}; + float rotation = 0.0f; + Vec3 scale{1.0f, 1.0f, 1.0f}; +}; + +static uint32_t s_nextThingHandle = 1; +static std::unordered_map s_thingHandles; +static std::mutex s_thingHandleMutex; + +static bool PyTuple_GetThingInstance(PyObject* poArgs, int pos, SGraphicThingHolder** ppThing) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, pos, &handle)) + return false; + if (!handle) + return false; + std::lock_guard lock(s_thingHandleMutex); + auto it = s_thingHandles.find(static_cast(handle)); + if (it == s_thingHandles.end()) return false; + *ppThing = it->second; + return true; +} + +static PyObject* grpThingGenerate(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BuildException(); + if (!szFileName || !*szFileName) + return Py_BuildValue("i", 0); + auto* holder = new SGraphicThingHolder(); + holder->fileName = szFileName; + std::lock_guard lock(s_thingHandleMutex); + uint32_t handle = s_nextThingHandle++; + s_thingHandles[handle] = holder; + return Py_BuildValue("i", handle); +} + +static PyObject* grpThingDelete(PyObject*, PyObject* poArgs) { + int handle = 0; + if (!PyTuple_GetInteger(poArgs, 0, &handle)) + return Py_BuildException(); + std::lock_guard lock(s_thingHandleMutex); + auto it = s_thingHandles.find(static_cast(handle)); + if (it != s_thingHandles.end()) { + delete it->second; + s_thingHandles.erase(it); + } + return Py_BuildNone(); +} + +static PyObject* grpThingSetFileName(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 1, &szFileName)) + return Py_BuildException(); + pThing->fileName = szFileName ? szFileName : ""; + return Py_BuildNone(); +} + +static PyObject* grpThingRender(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpThingUpdate(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* grpSetThingPosition(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + float x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y) || !PyTuple_GetFloat(poArgs, 3, &z)) + return Py_BuildException(); + pThing->position = {x, y, z}; + return Py_BuildNone(); +} + +static PyObject* grpSetThingRotation(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + float fDegree = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &fDegree)) + return Py_BuildException(); + pThing->rotation = fDegree; + return Py_BuildNone(); +} + +static PyObject* grpSetThingScale(PyObject*, PyObject* poArgs) { + SGraphicThingHolder* pThing = nullptr; + if (!PyTuple_GetThingInstance(poArgs, 0, &pThing)) + return Py_BuildException(); + float x = 0.0f, y = 0.0f, z = 0.0f; + if (!PyTuple_GetFloat(poArgs, 1, &x) || !PyTuple_GetFloat(poArgs, 2, &y) || !PyTuple_GetFloat(poArgs, 3, &z)) + return Py_BuildException(); + pThing->scale = {x, y, z}; + return Py_BuildNone(); +} + } // namespace void initgrp() { static PyMethodDef methods[] = { - {"InitScreenEffect", dummy_none, METH_VARARGS, nullptr}, - {"Culling", dummy_none, METH_VARARGS, nullptr}, - {"ClearDepthBuffer", dummy_none, METH_VARARGS, nullptr}, - {"Identity", dummy_none, METH_VARARGS, nullptr}, + {"InitScreenEffect", grpInitScreenEffect, METH_VARARGS, nullptr}, + {"Culling", grpCulling, METH_VARARGS, nullptr}, + {"ClearDepthBuffer", grpClearDepthBuffer, METH_VARARGS, nullptr}, + {"Identity", grpIdentity, METH_VARARGS, nullptr}, {"GenerateColor", grp_GenerateColor, METH_VARARGS, nullptr}, - {"PopState", dummy_none, METH_VARARGS, nullptr}, - {"PushState", dummy_none, METH_VARARGS, nullptr}, - {"PushMatrix", dummy_none, METH_VARARGS, nullptr}, - {"PopMatrix", dummy_none, METH_VARARGS, nullptr}, - {"Translate", dummy_none, METH_VARARGS, nullptr}, - {"Rotate", dummy_none, METH_VARARGS, nullptr}, - {"SetColorRenderState", dummy_none, METH_VARARGS, nullptr}, - {"SetAroundCamera", dummy_none, METH_VARARGS, nullptr}, - {"SetPositionCamera", dummy_none, METH_VARARGS, nullptr}, - {"SetEyeCamera", dummy_none, METH_VARARGS, nullptr}, - {"SetPerspective", dummy_none, METH_VARARGS, nullptr}, - {"SetOrtho2d", dummy_none, METH_VARARGS, nullptr}, - {"SetOrtho3d", dummy_none, METH_VARARGS, nullptr}, + {"PopState", grpPopState, METH_VARARGS, nullptr}, + {"PushState", grpPushState, METH_VARARGS, nullptr}, + {"PushMatrix", grpPushMatrix, METH_VARARGS, nullptr}, + {"PopMatrix", grpPopMatrix, METH_VARARGS, nullptr}, + {"Translate", grpTranslate, METH_VARARGS, nullptr}, + {"Rotate", grpRotate, METH_VARARGS, nullptr}, + {"SetColorRenderState", grpSetColorRenderState, METH_VARARGS, nullptr}, + {"SetAroundCamera", grpSetAroundCamera, METH_VARARGS, nullptr}, + {"SetPositionCamera", grpSetPositionCamera, METH_VARARGS, nullptr}, + {"SetEyeCamera", grpSetEyeCamera, METH_VARARGS, nullptr}, + {"SetPerspective", grpSetPerspective, METH_VARARGS, nullptr}, + {"SetOrtho2d", grpSetOrtho2D, METH_VARARGS, nullptr}, + {"SetOrtho3d", grpSetOrtho3D, METH_VARARGS, nullptr}, {"SetColor", grp_SetColor, METH_VARARGS, nullptr}, {"SetAlpha", grp_SetAlpha, METH_VARARGS, nullptr}, {"SetDiffuseColor", grp_SetDiffuseColor, METH_VARARGS, nullptr}, {"SetClearColor", grp_SetClearColor, METH_VARARGS, nullptr}, - {"GetCursorPosition3d", dummy_tuple2, METH_VARARGS, nullptr}, - {"SetCursorPosition", dummy_none, METH_VARARGS, nullptr}, + {"GetCursorPosition3d", grpGetCursorPosition3d, METH_VARARGS, nullptr}, + {"SetCursorPosition", grpSetCursorPosition, METH_VARARGS, nullptr}, {"RenderLine", grp_RenderLine, METH_VARARGS, nullptr}, {"RenderBox", grp_RenderBox, METH_VARARGS, nullptr}, {"RenderRoundBox", grp_RenderRoundBox, METH_VARARGS, nullptr}, - {"RenderBox3d", dummy_none, METH_VARARGS, nullptr}, + {"RenderBox3d", grpRenderBox3d, METH_VARARGS, nullptr}, {"RenderBar", grp_RenderBar, METH_VARARGS, nullptr}, - {"RenderBar3d", dummy_none, METH_VARARGS, nullptr}, + {"RenderBar3d", grpRenderBar3d, METH_VARARGS, nullptr}, {"RenderGradationBar", grp_RenderGradationBar, METH_VARARGS, nullptr}, - {"RenderCube", dummy_none, METH_VARARGS, nullptr}, - {"RenderDownButton", dummy_none, METH_VARARGS, nullptr}, - {"RenderUpButton", dummy_none, METH_VARARGS, nullptr}, - {"GetAvailableMemory", dummy_zero, METH_VARARGS, nullptr}, - {"SaveScreenShot", dummy_none, METH_VARARGS, nullptr}, - {"SaveScreenShotToPath", dummy_none, METH_VARARGS, nullptr}, - {"SetGamma", dummy_none, METH_VARARGS, nullptr}, - {"SetInterfaceRenderState", dummy_none, METH_VARARGS, nullptr}, - {"SetGameRenderState", dummy_none, METH_VARARGS, nullptr}, - {"SetViewport", dummy_none, METH_VARARGS, nullptr}, - {"RestoreViewport", dummy_none, METH_VARARGS, nullptr}, - {"SetOmniLight", dummy_none, METH_VARARGS, nullptr}, - {"GetCameraPosition", dummy_tuple2, METH_VARARGS, nullptr}, - {"GetTargetPosition", dummy_tuple2, METH_VARARGS, nullptr}, - {"CreateTextBar", dummy_none, METH_VARARGS, nullptr}, - {"CreateBigTextBar", dummy_none, METH_VARARGS, nullptr}, - {"DestroyTextBar", dummy_none, METH_VARARGS, nullptr}, - {"RenderTextBar", dummy_none, METH_VARARGS, nullptr}, - {"TextBarTextOut", dummy_none, METH_VARARGS, nullptr}, - {"TextBarSetTextColor", dummy_none, METH_VARARGS, nullptr}, - {"TextBarGetTextExtent", dummy_none, METH_VARARGS, nullptr}, - {"ClearTextBar", dummy_none, METH_VARARGS, nullptr}, - {"SetTextBarClipRect", dummy_none, METH_VARARGS, nullptr}, + {"RenderCube", grpRenderCube, METH_VARARGS, nullptr}, + {"RenderDownButton", grpRenderDownButton, METH_VARARGS, nullptr}, + {"RenderUpButton", grpRenderUpButton, METH_VARARGS, nullptr}, + {"GetAvailableMemory", grpGetAvailableMemory, METH_VARARGS, nullptr}, + {"SaveScreenShot", grpSaveScreenShot, METH_VARARGS, nullptr}, + {"SaveScreenShotToPath", grpSaveScreenShotToPath, METH_VARARGS, nullptr}, + {"SetGamma", grpSetGamma, METH_VARARGS, nullptr}, + {"SetInterfaceRenderState", grpSetInterfaceRenderState, METH_VARARGS, nullptr}, + {"SetGameRenderState", grpSetGameRenderState, METH_VARARGS, nullptr}, + {"SetViewport", grpSetViewport, METH_VARARGS, nullptr}, + {"RestoreViewport", grpRestoreViewport, METH_VARARGS, nullptr}, + {"SetOmniLight", grpSetOmniLight, METH_VARARGS, nullptr}, + {"GetCameraPosition", grpGetCameraPosition, METH_VARARGS, nullptr}, + {"GetTargetPosition", grpGetTargetPosition, METH_VARARGS, nullptr}, + {"CreateTextBar", grpCreateTextBar, METH_VARARGS, nullptr}, + {"CreateBigTextBar", grpCreateBigTextBar, METH_VARARGS, nullptr}, + {"DestroyTextBar", grpDestroyTextBar, METH_VARARGS, nullptr}, + {"RenderTextBar", grpRenderTextBar, METH_VARARGS, nullptr}, + {"TextBarTextOut", grpTextBarTextOut, METH_VARARGS, nullptr}, + {"TextBarSetTextColor", grpTextBarSetTextColor, METH_VARARGS, nullptr}, + {"TextBarGetTextExtent", grpTextBarGetTextExtent, METH_VARARGS, nullptr}, + {"ClearTextBar", grpClearTextBar, METH_VARARGS, nullptr}, + {"SetTextBarClipRect", grpSetTextBarClipRect, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("grp", methods); + Py_InitModule("grp", methods); } void initgrpImage() { static PyMethodDef methods[] = { - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"SetPosition", dummy_none, METH_VARARGS, nullptr}, - {"Generate", dummy_none, METH_VARARGS, nullptr}, - {"GenerateExpanded", dummy_none, METH_VARARGS, nullptr}, - {"GenerateFromHandle", dummy_none, METH_VARARGS, nullptr}, - {"Delete", dummy_none, METH_VARARGS, nullptr}, - {"DeleteExpanded", dummy_none, METH_VARARGS, nullptr}, - {"SetFileName", dummy_none, METH_VARARGS, nullptr}, - {"SetOrigin", dummy_none, METH_VARARGS, nullptr}, - {"SetRotation", dummy_none, METH_VARARGS, nullptr}, - {"SetScale", dummy_none, METH_VARARGS, nullptr}, - {"SetRenderingRect", dummy_none, METH_VARARGS, nullptr}, - {"SetDiffuseColor", dummy_none, METH_VARARGS, nullptr}, - {"GetWidth", dummy_zero, METH_VARARGS, nullptr}, - {"GetHeight", dummy_zero, METH_VARARGS, nullptr}, + {"Render", grpImageRender, METH_VARARGS, nullptr}, + {"SetPosition", grpSetImagePosition, METH_VARARGS, nullptr}, + {"Generate", grpImageGenerate, METH_VARARGS, nullptr}, + {"GenerateExpanded", grpImageGenerateExpanded, METH_VARARGS, nullptr}, + {"GenerateFromHandle", grpImageGenerateFromHandle, METH_VARARGS, nullptr}, + {"Delete", grpImageDelete, METH_VARARGS, nullptr}, + {"DeleteExpanded", grpImageDeleteExpanded, METH_VARARGS, nullptr}, + {"SetFileName", grpImageSetFileName, METH_VARARGS, nullptr}, + {"SetOrigin", grpSetImageOrigin, METH_VARARGS, nullptr}, + {"SetRotation", grpSetImageRotation, METH_VARARGS, nullptr}, + {"SetScale", grpSetImageScale, METH_VARARGS, nullptr}, + {"SetRenderingRect", grpSetRenderingRect, METH_VARARGS, nullptr}, + {"SetDiffuseColor", grpSetImageDiffuseColor, METH_VARARGS, nullptr}, + {"GetWidth", grpGetWidth, METH_VARARGS, nullptr}, + {"GetHeight", grpGetHeight, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("grpImage", methods); + Py_InitModule("grpImage", methods); } void initgrpText() { static PyMethodDef methods[] = { - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"Generate", dummy_none, METH_VARARGS, nullptr}, - {"Destroy", dummy_none, METH_VARARGS, nullptr}, - {"SetFontName", dummy_none, METH_VARARGS, nullptr}, - {"SetFontColor", dummy_none, METH_VARARGS, nullptr}, - {"SetOutLineColor", dummy_none, METH_VARARGS, nullptr}, - {"SetSecret", dummy_none, METH_VARARGS, nullptr}, - {"SetOutline", dummy_none, METH_VARARGS, nullptr}, - {"SetText", dummy_none, METH_VARARGS, nullptr}, - {"GetText", dummy_str, METH_VARARGS, nullptr}, - {"GetSize", dummy_tuple2, METH_VARARGS, nullptr}, - {"SetPosition", dummy_none, METH_VARARGS, nullptr}, - {"ShowCursor", dummy_none, METH_VARARGS, nullptr}, - {"HideCursor", dummy_none, METH_VARARGS, nullptr}, - {"SetHorizontalAlign", dummy_none, METH_VARARGS, nullptr}, - {"SetVerticalAlign", dummy_none, METH_VARARGS, nullptr}, - {"SetMax", dummy_none, METH_VARARGS, nullptr}, - {"GetSplitingTextLineCount", dummy_str, METH_VARARGS, nullptr}, - {"GetSplitingTextLine", dummy_str, METH_VARARGS, nullptr}, - {"PixelPositionToCharacterPosition", dummy_none, METH_VARARGS, nullptr}, + {"Update", grpTextUpdate, METH_VARARGS, nullptr}, + {"Render", grpTextRender, METH_VARARGS, nullptr}, + {"Generate", grpTextGenerate, METH_VARARGS, nullptr}, + {"Destroy", grpTextDestroy, METH_VARARGS, nullptr}, + {"SetFontName", grpTextSetFontName, METH_VARARGS, nullptr}, + {"SetFontColor", grpTextSetFontColor, METH_VARARGS, nullptr}, + {"SetOutLineColor", grpTextSetOutLineColor, METH_VARARGS, nullptr}, + {"SetSecret", grpTextSetSecret, METH_VARARGS, nullptr}, + {"SetOutline", grpTextOutline, METH_VARARGS, nullptr}, + {"SetText", grpTextSetText, METH_VARARGS, nullptr}, + {"GetText", grpTextGetText, METH_VARARGS, nullptr}, + {"GetSize", grpTextGetSize, METH_VARARGS, nullptr}, + {"SetPosition", grpTextSetPosition, METH_VARARGS, nullptr}, + {"ShowCursor", grpTextShowCursor, METH_VARARGS, nullptr}, + {"HideCursor", grpTextHideCursor, METH_VARARGS, nullptr}, + {"SetHorizontalAlign", grpSetHorizontalAlign, METH_VARARGS, nullptr}, + {"SetVerticalAlign", grpSetVerticalAlign, METH_VARARGS, nullptr}, + {"SetMax", grpSetMax, METH_VARARGS, nullptr}, + {"GetSplitingTextLineCount", grpGetSplitingTextLineCount, METH_VARARGS, nullptr}, + {"GetSplitingTextLine", grpGetSplitingTextLine, METH_VARARGS, nullptr}, + {"PixelPositionToCharacterPosition", grpTextPixelPositionToCharacterPosition, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("grpText", methods); + Py_InitModule("grpText", methods); } void initgrpThing() { static PyMethodDef methods[] = { - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Render", dummy_none, METH_VARARGS, nullptr}, - {"SetPosition", dummy_none, METH_VARARGS, nullptr}, - {"Generate", dummy_none, METH_VARARGS, nullptr}, - {"Delete", dummy_none, METH_VARARGS, nullptr}, - {"SetFileName", dummy_none, METH_VARARGS, nullptr}, - {"SetRotation", dummy_none, METH_VARARGS, nullptr}, - {"SetScale", dummy_none, METH_VARARGS, nullptr}, + {"Update", grpThingUpdate, METH_VARARGS, nullptr}, + {"Render", grpThingRender, METH_VARARGS, nullptr}, + {"SetPosition", grpSetThingPosition, METH_VARARGS, nullptr}, + {"Generate", grpThingGenerate, METH_VARARGS, nullptr}, + {"Delete", grpThingDelete, METH_VARARGS, nullptr}, + {"SetFileName", grpThingSetFileName, METH_VARARGS, nullptr}, + {"SetRotation", grpSetThingRotation, METH_VARARGS, nullptr}, + {"SetScale", grpSetThingScale, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("grpThing", methods); + Py_InitModule("grpThing", methods); } } // namespace ava2 diff --git a/src/python_native_modules.cpp b/src/python_native_modules.cpp index 05e8cdb3..ec6cbc69 100644 --- a/src/python_native_modules.cpp +++ b/src/python_native_modules.cpp @@ -85,20 +85,6 @@ bool LoadSkillDescriptions(const std::string& path) { try { return skillDescriptions.load(ReadPackedText(path),register_skill_icons); } catch(const std::exception&) { return false; } } -namespace { -PyObject* dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; } -PyObject* dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); } -PyObject* dummy_one(PyObject*, PyObject*) { return PyInt_FromLong(1); } -PyObject* dummy_float_zero(PyObject*, PyObject*) { return PyFloat_FromDouble(0.0); } -PyObject* dummy_str(PyObject*, PyObject*) { return PyString_FromString(""); } -PyObject* dummy_tuple2(PyObject*, PyObject*) { return Py_BuildValue("ii", 0, 0); } -PyObject* dummy_tuple3(PyObject*, PyObject*) { return Py_BuildValue("iii", 0, 0, 0); } -PyObject* dummy_tuple4(PyObject*, PyObject*) { return Py_BuildValue("iiii", 0, 0, 0, 0); } -PyObject* dummy_bool_false(PyObject*, PyObject*) { return PyBool_FromLong(0); } -PyObject* dummy_bool_true(PyObject*, PyObject*) { return PyBool_FromLong(1); } -PyObject* dummy_empty_list(PyObject*, PyObject*) { return PyList_New(0); } -} // namespace - namespace { PyObject* nonplayer_load(PyObject*,PyObject* args) { const char* path; if(!PyArg_ParseTuple(args,"s",&path)) return nullptr; @@ -113,15 +99,17 @@ template PyObject* nonplayer_value(PyObject*,PyObject* args) { int vnum;if(!PyArg_ParseTuple(args,"i",&vnum)) return nullptr; const auto* m=NonPlayerData::Instance().get(uint32_t(vnum)); if constexpr(Field==4) return m?Py_BuildValue("ii",m->damageMin,m->damageMax):Py_BuildValue("ii",0,0); - if constexpr(Field==14) return m?Py_BuildValue("ii",m->goldMin,m->goldMax):Py_BuildValue("ii",0,0); - if constexpr(Field==6) return PyFloat_FromDouble(m?m->damageMultiply:0); - long long value=0; - if(m) switch(Field) { - case 0:value=m->event;break;case 1:value=m->hp;break;case 2:value=m->raceFlags;break;case 3:value=m->level;break; - case 5:value=m->exp;break;case 7:value=m->st;break;case 8:value=m->dx;break;case 9:value=m->type==2;break; - case 10:value=m->regenCycle;break;case 11:value=m->regenPercent;break;case 12:value=m->goldMin;break;case 13:value=m->goldMax;break; + else if constexpr(Field==14) return m?Py_BuildValue("ii",m->goldMin,m->goldMax):Py_BuildValue("ii",0,0); + else if constexpr(Field==6) return PyFloat_FromDouble(m?m->damageMultiply:0); + else { + long long value=0; + if(m) switch(Field) { + case 0:value=m->event;break;case 1:value=m->hp;break;case 2:value=m->raceFlags;break;case 3:value=m->level;break; + case 5:value=m->exp;break;case 7:value=m->st;break;case 8:value=m->dx;break;case 9:value=m->type==2;break; + case 10:value=m->regenCycle;break;case 11:value=m->regenPercent;break;case 12:value=m->goldMin;break;case 13:value=m->goldMax;break; + } + return PyInt_FromLong(static_cast(value)); } - return PyInt_FromLong(static_cast(value)); } template PyObject* nonplayer_vid(PyObject*,PyObject* args) { int vid;if(!PyArg_ParseTuple(args,"i",&vid)) return nullptr; @@ -646,13 +634,25 @@ void initTextTail() { auto* module = Py_InitModule("textTail", methods); } +static PyObject* profiler_push(PyObject*, PyObject* args) { + char* szName = nullptr; + if (!PyTuple_GetString(args, 0, &szName)) return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* profiler_pop(PyObject*, PyObject* args) { + char* szName = nullptr; + if (!PyTuple_GetString(args, 0, &szName)) return Py_BuildException(); + return Py_BuildNone(); +} + void initProfiler() { static PyMethodDef methods[] = { - {"Push", dummy_none, METH_VARARGS, nullptr}, - {"Pop", dummy_none, METH_VARARGS, nullptr}, + {"Push", profiler_push, METH_VARARGS, nullptr}, + {"Pop", profiler_pop, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("profiler", methods); + Py_InitModule("profiler", methods); } static PyObject* effect_RegisterEffect(PyObject*, PyObject* args) { @@ -862,6 +862,13 @@ void SetShopTab(unsigned index,const std::string& name,unsigned coin) { if(index>=shopTabCount)return; shopTabNames[index]=name;shopTabCoins[index]=static_cast(coin); } +static PyObject* shop_GetOfflineShopItemTransmutation(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} +static PyObject* shop_GetItemElements(PyObject*, PyObject*) { + return Py_BuildValue("iiii", 0, 0, 0, 0); +} + void initshop() { static PyMethodDef methods[] = { {"Open", shop_open, METH_VARARGS, nullptr}, @@ -879,8 +886,8 @@ void initshop() { {"GetVnumBuy", shop_item_buy_vnum, METH_VARARGS, nullptr}, {"GetCountBuy", shop_item_buy_count, METH_VARARGS, nullptr}, {"GetItemRandomAttribute", shop_item_glove, METH_VARARGS, nullptr}, - {"GetOfflineShopItemTransmutation", dummy_zero, METH_VARARGS, nullptr}, - {"GetItemElements", dummy_tuple4, METH_VARARGS, nullptr}, + {"GetOfflineShopItemTransmutation", shop_GetOfflineShopItemTransmutation, METH_VARARGS, nullptr}, + {"GetItemElements", shop_GetItemElements, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("shop", methods); @@ -1257,11 +1264,15 @@ static PyObject* skill_IsUseHPSkill(PyObject*,PyObject* args) { return skill_fla float EvaluateSkillFormula(const std::string& formula,float level) {return skill_formula(formula,level);} +static PyObject* skill_LoadSkillData(PyObject*, PyObject*) { + return Py_BuildNone(); +} + void initskill() { static PyMethodDef methods[] = { {"SetPathName", skill_SetPathName, METH_VARARGS, nullptr}, {"RegisterSkill", skill_RegisterSkill, METH_VARARGS, nullptr}, - {"LoadSkillData", dummy_none, METH_VARARGS, nullptr}, + {"LoadSkillData", skill_LoadSkillData, METH_VARARGS, nullptr}, {"ClearSkillData", skill_ClearSkillData, METH_VARARGS, nullptr}, {"GetSkillName", skill_name, METH_VARARGS, nullptr}, {"GetSkillDescription", skill_description, METH_VARARGS, nullptr}, @@ -1315,55 +1326,275 @@ void initskill() { PyModule_AddIntConstant(module, "SKILL_EFFECT_COUNT", skill_constants::SKILL_EFFECT_COUNT); } +namespace { +class CPythonSash { +public: + static CPythonSash& Instance() { + static CPythonSash s; + return s; + } + uint32_t dwPrice = 0; + struct TSashMaterial { + uint8_t bHere = 0; + uint16_t wCell = 0; + }; + struct TSashResult { + uint32_t dwItemVnum = 0; + uint32_t dwMinAbs = 0; + uint32_t dwMaxAbs = 0; + }; + TSashResult m_vSashResult{}; + std::vector m_vSashMaterials; + + CPythonSash() { Clear(); } + void Clear() { + dwPrice = 0; + m_vSashResult = {}; + m_vSashMaterials.assign(2, TSashMaterial{0, 0}); + } + void AddMaterial(uint32_t refPrice, uint8_t bPos, uint16_t cell) { + if (bPos >= 2) return; + if (bPos == 0) dwPrice = refPrice; + m_vSashMaterials[bPos] = TSashMaterial{1, cell}; + } + void AddResult(uint32_t vnum, uint32_t minAbs, uint32_t maxAbs) { + m_vSashResult = {vnum, minAbs, maxAbs}; + } + void RemoveMaterial(uint32_t refPrice, uint8_t bPos) { + if (bPos >= 2) return; + if (bPos == 1) dwPrice = refPrice; + m_vSashMaterials[bPos] = TSashMaterial{0, 0}; + } + uint32_t GetPrice() const { return dwPrice; } + bool GetAttachedItem(uint8_t bPos, uint8_t& bHere, uint16_t& wCell) { + if (bPos >= m_vSashMaterials.size()) return false; + bHere = m_vSashMaterials[bPos].bHere; + wCell = m_vSashMaterials[bPos].wCell; + return true; + } + void GetResultItem(uint32_t& vnum, uint32_t& minAbs, uint32_t& maxAbs) { + vnum = m_vSashResult.dwItemVnum; + minAbs = m_vSashResult.dwMinAbs; + maxAbs = m_vSashResult.dwMaxAbs; + } +}; + +static PyObject* sash_SendCloseRequest(PyObject*, PyObject*) { + CPythonSash::Instance().Clear(); + return Py_BuildNone(); +} + +static PyObject* sash_Add(PyObject*, PyObject* args) { + int window = 0, cell = 0, pos = 0; + if (!PyTuple_GetInteger(args, 0, &window) || !PyTuple_GetInteger(args, 1, &cell) || !PyTuple_GetInteger(args, 2, &pos)) + return Py_BuildException(); + CPythonSash::Instance().AddMaterial(0, static_cast(pos), static_cast(cell)); + return Py_BuildNone(); +} + +static PyObject* sash_Remove(PyObject*, PyObject* args) { + int pos = 0; + if (!PyTuple_GetInteger(args, 0, &pos)) + return Py_BuildException(); + CPythonSash::Instance().RemoveMaterial(0, static_cast(pos)); + return Py_BuildNone(); +} + +static PyObject* sash_GetPrice(PyObject*, PyObject*) { + return Py_BuildValue("i", CPythonSash::Instance().GetPrice()); +} + +static PyObject* sash_GetAttachedItem(PyObject*, PyObject* args) { + int pos = 0; + if (!PyTuple_GetInteger(args, 0, &pos)) + return Py_BuildException(); + uint8_t bHere = 0; + uint16_t wCell = 0; + CPythonSash::Instance().GetAttachedItem(static_cast(pos), bHere, wCell); + return Py_BuildValue("ii", static_cast(bHere), static_cast(wCell)); +} + +static PyObject* sash_GetResultItem(PyObject*, PyObject*) { + uint32_t vnum = 0, minAbs = 0, maxAbs = 0; + CPythonSash::Instance().GetResultItem(vnum, minAbs, maxAbs); + return Py_BuildValue("iii", vnum, minAbs, maxAbs); +} + +static PyObject* sash_SendRefineRequest(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +class CServerStateChecker { +public: + static CServerStateChecker& Instance() { + static CServerStateChecker s; + return s; + } + struct TChannel { + uint32_t uServerIndex = 0; + std::string szAddr; + uint32_t uPort = 0; + }; + PyObject* m_poWnd = nullptr; + std::vector m_channels; + + void Create(PyObject* poWnd) { m_poWnd = poWnd; } + void AddChannel(uint32_t serverIdx, const std::string& addr, uint32_t port) { + m_channels.push_back({serverIdx, addr, port}); + } + void Request() { + if (m_poWnd) { + for (const auto& ch : m_channels) { + PyObject* res = PyObject_CallMethod(m_poWnd, const_cast("NotifyChannelState"), const_cast("(ii)"), ch.uServerIndex, 1); + Py_XDECREF(res); + } + } + } + void Update() {} + void Initialize() { + m_channels.clear(); + m_poWnd = nullptr; + } +}; + +static PyObject* ServerStateChecker_Create(PyObject*, PyObject* args) { + PyObject* poWnd = nullptr; + if (!PyTuple_GetObject(args, 0, &poWnd)) return Py_BadArgument(); + CServerStateChecker::Instance().Create(poWnd); + return Py_BuildNone(); +} + +static PyObject* ServerStateChecker_Update(PyObject*, PyObject*) { + CServerStateChecker::Instance().Update(); + return Py_BuildNone(); +} + +static PyObject* ServerStateChecker_Request(PyObject*, PyObject*) { + CServerStateChecker::Instance().Request(); + return Py_BuildNone(); +} + +static PyObject* ServerStateChecker_AddChannel(PyObject*, PyObject* args) { + int nServerIndex = 0, nPort = 0; + char* szAddr = nullptr; + if (!PyTuple_GetInteger(args, 0, &nServerIndex) || !PyTuple_GetString(args, 1, &szAddr) || !PyTuple_GetInteger(args, 2, &nPort)) + return Py_BuildException(); + CServerStateChecker::Instance().AddChannel(nServerIndex, szAddr ? szAddr : "", nPort); + return Py_BuildNone(); +} + +static PyObject* ServerStateChecker_Initialize(PyObject*, PyObject*) { + CServerStateChecker::Instance().Initialize(); + return Py_BuildNone(); +} + +static PyObject* playerLoad_RegisterSkill(PyObject*, PyObject* args) { + uint8_t bRaceIndex = 0, bSkillGroupIndex = 0, bEmpireIndex = 0; + if (!PyTuple_GetByte(args, 0, &bRaceIndex) || !PyTuple_GetByte(args, 1, &bSkillGroupIndex) || !PyTuple_GetByte(args, 2, &bEmpireIndex)) + return Py_BuildException(); + return Py_BuildNone(); +} + +class CPythonManagerBank { +public: + static CPythonManagerBank& Instance() { + static CPythonManagerBank s; + return s; + } + struct TAccountBank { + int user_action = 999; + int user_money = 0; + char user_datetime[32] = "0000-00-00 00:00:00"; + char user_ip[32] = "-"; + char user_recvmoney[32] = "-"; + }; + std::vector m_logs; + + void AppendLog(const TAccountBank& log) { + m_logs.push_back(log); + } + TAccountBank GetLog(size_t id) const { + if (id >= m_logs.size()) { + TAccountBank def; + return def; + } + return m_logs[id]; + } +}; + +static PyObject* bankLoadLogs(PyObject*, PyObject* args) { + int id = 0; + if (!PyTuple_GetInteger(args, 0, &id)) return Py_BuildException(); + auto p = CPythonManagerBank::Instance().GetLog(id >= 0 ? static_cast(id) : 999999); + return Py_BuildValue("iisss", p.user_action, p.user_money, p.user_datetime, p.user_ip, p.user_recvmoney); +} +} // namespace + void initSash() { static PyMethodDef methods[] = { - {"SendCloseRequest", dummy_none, METH_VARARGS, nullptr}, - {"Add", dummy_none, METH_VARARGS, nullptr}, - {"Remove", dummy_none, METH_VARARGS, nullptr}, - {"GetPrice", dummy_zero, METH_VARARGS, nullptr}, - {"GetAttachedItem", dummy_zero, METH_VARARGS, nullptr}, - {"GetResultItem", dummy_zero, METH_VARARGS, nullptr}, - {"SendRefineRequest", dummy_none, METH_VARARGS, nullptr}, + {"SendCloseRequest", sash_SendCloseRequest, METH_VARARGS, nullptr}, + {"Add", sash_Add, METH_VARARGS, nullptr}, + {"Remove", sash_Remove, METH_VARARGS, nullptr}, + {"GetPrice", sash_GetPrice, METH_VARARGS, nullptr}, + {"GetAttachedItem", sash_GetAttachedItem, METH_VARARGS, nullptr}, + {"GetResultItem", sash_GetResultItem, METH_VARARGS, nullptr}, + {"SendRefineRequest", sash_SendRefineRequest, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("sash", methods); PyModule_AddIntConstant(module, "ABSORPTION_SOCKET", 0); - PyModule_AddIntConstant(module, "ABSORBED_SOCKET", 0); - PyModule_AddIntConstant(module, "CLEAN_ATTR_VALUE0", 0); - PyModule_AddIntConstant(module, "WINDOW_MAX_MATERIALS", 0); + PyModule_AddIntConstant(module, "ABSORBED_SOCKET", 1); + PyModule_AddIntConstant(module, "CLEAN_ATTR_VALUE0", 7); + PyModule_AddIntConstant(module, "WINDOW_MAX_MATERIALS", 2); PyModule_AddIntConstant(module, "CLEAN_ATTR_VALUE_FIELD", 0); PyModule_AddIntConstant(module, "LIMIT_RANGE", 1000); } void initServerStateChecker() { static PyMethodDef methods[] = { - {"Create", dummy_none, METH_VARARGS, nullptr}, - {"Update", dummy_none, METH_VARARGS, nullptr}, - {"Request", dummy_none, METH_VARARGS, nullptr}, - {"AddChannel", dummy_none, METH_VARARGS, nullptr}, - {"Initialize", dummy_none, METH_VARARGS, nullptr}, + {"Create", ServerStateChecker_Create, METH_VARARGS, nullptr}, + {"Update", ServerStateChecker_Update, METH_VARARGS, nullptr}, + {"Request", ServerStateChecker_Request, METH_VARARGS, nullptr}, + {"AddChannel", ServerStateChecker_AddChannel, METH_VARARGS, nullptr}, + {"Initialize", ServerStateChecker_Initialize, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("ServerStateChecker", methods); + Py_InitModule("ServerStateChecker", methods); } void initPlayerSettingsModule() { static PyMethodDef methods[] = { - {"RegisterSkill", dummy_none, METH_VARARGS, nullptr}, + {"RegisterSkill", playerLoad_RegisterSkill, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("playerLoad", methods); + Py_InitModule("playerLoad", methods); } // wiki module: CPythonWiki port in src/python_wiki.cpp. +static PyObject* combatZone_IsRunning(PyObject*, PyObject*) { + return PyBool_FromLong(0); +} +static PyObject* combatZone_GetRankings(PyObject*, PyObject*) { + return Py_BuildValue("iiii", 0, 0, 0, 0); +} +static PyObject* combatZone_GetDay(PyObject*, PyObject*) { + return Py_BuildValue("iiii", 0, 0, 0, 0); +} +static PyObject* combatZone_SendCombatZoneRequestActionPacket(PyObject*, PyObject*) { + Py_RETURN_NONE; +} +static PyObject* combatZone_GetDayActivate(PyObject*, PyObject*) { + return PyBool_FromLong(0); +} + void initCombatZoneSystem() { static PyMethodDef methods[] = { - {"IsRunning", dummy_bool_false, METH_VARARGS, nullptr}, - {"GetRankings", dummy_tuple4, METH_VARARGS, nullptr}, - {"GetDay", dummy_tuple4, METH_VARARGS, nullptr}, - {"SendCombatZoneRequestActionPacket", dummy_none, METH_VARARGS, nullptr}, - {"GetDayActivate", dummy_bool_false, METH_VARARGS, nullptr}, + {"IsRunning", combatZone_IsRunning, METH_VARARGS, nullptr}, + {"GetRankings", combatZone_GetRankings, METH_VARARGS, nullptr}, + {"GetDay", combatZone_GetDay, METH_VARARGS, nullptr}, + {"SendCombatZoneRequestActionPacket", combatZone_SendCombatZoneRequestActionPacket, METH_VARARGS, nullptr}, + {"GetDayActivate", combatZone_GetDayActivate, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("combat_zone", methods); @@ -1383,10 +1614,10 @@ void initCombatZoneSystem() { void initBankManager() { static PyMethodDef methods[] = { - {"Append", dummy_none, METH_VARARGS, nullptr}, + {"Append", bankLoadLogs, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; - auto* module = Py_InitModule("managerBankLogs", methods); + Py_InitModule("managerBankLogs", methods); } static PyObject* safebox_GetCurrentSafeboxSize(PyObject*, PyObject*) { @@ -1718,6 +1949,68 @@ static PyObject* renderTarget_SetModelV3Target(PyObject*, PyObject* args) { Py_RETURN_NONE; } +static PyObject* renderTarget_SetMount(PyObject*, PyObject* args) { + int idx = 0, mount = 0; + if (PyArg_ParseTuple(args, "ii", &idx, &mount)) { + auto target = ava2::CRenderTargetManager::Instance().GetRenderTarget(idx); + (void)target; + } + Py_RETURN_NONE; +} + +static PyObject* renderTarget_ResetModel(PyObject*, PyObject* args) { + int idx = 0; + if (PyArg_ParseTuple(args, "i", &idx)) { + auto target = ava2::CRenderTargetManager::Instance().GetRenderTarget(idx); + if (target) target->SelectModel(0); + } + Py_RETURN_NONE; +} + +static PyObject* renderTarget_SetModelRender(PyObject*, PyObject* args) { + int idx = 0; + PyObject* bStatus = nullptr; + if (PyArg_ParseTuple(args, "iO", &idx, &bStatus)) { + auto target = ava2::CRenderTargetManager::Instance().GetRenderTarget(idx); + if (target) target->SetVisibility(PyObject_IsTrue(bStatus)); + } + Py_RETURN_NONE; +} + +static PyObject* renderTarget_AddAffect(PyObject*, PyObject* args) { + int idx = 0, effect = 0; + if (!PyArg_ParseTuple(args, "ii", &idx, &effect)) return Py_BadArgument(); + Py_RETURN_NONE; +} + +static PyObject* renderTarget_RemoveAffect(PyObject*, PyObject* args) { + int idx = 0, effect = 0; + if (!PyArg_ParseTuple(args, "ii", &idx, &effect)) return Py_BadArgument(); + Py_RETURN_NONE; +} + +static PyObject* renderTarget_ClearAffect(PyObject*, PyObject* args) { + int idx = 0; + if (!PyArg_ParseTuple(args, "i", &idx)) return Py_BadArgument(); + Py_RETURN_NONE; +} + +static PyObject* renderTarget_SetMotionIndex(PyObject*, PyObject* args) { + int idx = 0, motion = 0; + if (PyArg_ParseTuple(args, "ii", &idx, &motion)) { + auto target = ava2::CRenderTargetManager::Instance().GetRenderTarget(idx); + if (target) target->SetMotionIndex(motion); + return Py_BuildValue("i", 1); + } + Py_RETURN_NONE; +} + +static PyObject* renderTarget_SetShining(PyObject*, PyObject* args) { + int idx = 0, pos = 0, item = 0; + if (!PyArg_ParseTuple(args, "iii", &idx, &pos, &item)) return Py_BadArgument(); + Py_RETURN_NONE; +} + static PyObject* renderTarget_Destroy(PyObject*, PyObject* args) { int idx = 0; if (PyArg_ParseTuple(args, "i", &idx)) { @@ -1737,22 +2030,22 @@ void initRenderTarget() { {"SetHair", renderTarget_SetHair, METH_VARARGS, nullptr}, {"SetRotation", renderTarget_SetRotation, METH_VARARGS, nullptr}, {"SetAcce", renderTarget_SetAcce, METH_VARARGS, nullptr}, - {"SetMount", dummy_none, METH_VARARGS, nullptr}, - {"ResetModel", dummy_none, METH_VARARGS, nullptr}, + {"SetMount", renderTarget_SetMount, METH_VARARGS, nullptr}, + {"ResetModel", renderTarget_ResetModel, METH_VARARGS, nullptr}, {"Destroy", renderTarget_Destroy, METH_VARARGS, nullptr}, {"SetModelV3Eye", renderTarget_SetModelV3Eye, METH_VARARGS, nullptr}, {"SetModelV3Target", renderTarget_SetModelV3Target, METH_VARARGS, nullptr}, {"GetFreeIndex", renderTarget_GetFreeIndex, METH_VARARGS, nullptr}, - {"SetModelRender", dummy_none, METH_VARARGS, nullptr}, - {"AddAffect", dummy_none, METH_VARARGS, nullptr}, - {"RemoveAffect", dummy_none, METH_VARARGS, nullptr}, - {"ClearAffect", dummy_none, METH_VARARGS, nullptr}, + {"SetModelRender", renderTarget_SetModelRender, METH_VARARGS, nullptr}, + {"AddAffect", renderTarget_AddAffect, METH_VARARGS, nullptr}, + {"RemoveAffect", renderTarget_RemoveAffect, METH_VARARGS, nullptr}, + {"ClearAffect", renderTarget_ClearAffect, METH_VARARGS, nullptr}, {"IsShow", renderTarget_IsShow, METH_VARARGS, nullptr}, {"Zoom", renderTarget_Zoom, METH_VARARGS, nullptr}, {"SetScale", renderTarget_SetScale, METH_VARARGS, nullptr}, {"RotateEyeAroundTarget", renderTarget_RotateEyeAroundTarget, METH_VARARGS, nullptr}, - {"SetMotionIndex", dummy_none, METH_VARARGS, nullptr}, - {"SetShining", dummy_none, METH_VARARGS, nullptr}, + {"SetMotionIndex", renderTarget_SetMotionIndex, METH_VARARGS, nullptr}, + {"SetShining", renderTarget_SetShining, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("renderTarget", methods); diff --git a/src/python_net.cpp b/src/python_net.cpp index 8ea508cb..a27cd777 100644 --- a/src/python_net.cpp +++ b/src/python_net.cpp @@ -105,11 +105,14 @@ PyObject* status(PyObject*,PyObject*) { const char* names[]={"idle","resolving", PyObject* is_connected(PyObject*,PyObject*) { return PyInt_FromLong(client.is_connected()); } -PyObject* net_dummy_none(PyObject*, PyObject*) { Py_RETURN_NONE; } -PyObject* net_dummy_zero(PyObject*, PyObject*) { return PyInt_FromLong(0); } -PyObject* net_dummy_one(PyObject*, PyObject*) { return PyInt_FromLong(1); } -PyObject* net_dummy_str(PyObject*, PyObject*) { return PyString_FromString(""); } -PyObject* net_dummy_tuple4(PyObject*, PyObject*) { return Py_BuildValue("iiii", 0, 0, 0, 0); } +static PyObject* net_ElementsSpellClose(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* net_ElementsSpellAdd(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* net_ElementsSpellChange(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* net_SendCombatZoneRequestActionPacket(PyObject*, PyObject*) { return Py_BuildNone(); } +static PyObject* net_CombatZone_IsRunning(PyObject*, PyObject*) { return PyInt_FromLong(0); } +static PyObject* net_CombatZone_GetRankings(PyObject*, PyObject*) { return Py_BuildValue("iiii", 0, 0, 0, 0); } +static PyObject* net_CombatZone_GetDay(PyObject*, PyObject*) { return Py_BuildValue("iiii", 0, 0, 0, 0); } +static PyObject* net_CombatZone_GetDayActivate(PyObject*, PyObject*) { return PyInt_FromLong(0); } // ── AVA2 PythonNetworkStreamModule.cpp wrappers (ScriptLib argument helpers, Py_BuildException -> None) ── PyObject* netSendExchangeStartPacket(PyObject*, PyObject* poArgs) { @@ -820,6 +823,294 @@ static PyObject* net_send_script_button_packet(PyObject*, PyObject* args) { Py_RETURN_NONE; } +static std::string s_netServerInfo = ""; + +static PyObject* net_GetBettingGuildWarValue(PyObject*, PyObject* poArgs) { + char* szName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szName)) + return Py_BuildException(); + return Py_BuildValue("i", 0); +} + +static PyObject* net_SetServerInfo(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BuildException(); + s_netServerInfo = szFileName ? szFileName : ""; + return Py_BuildNone(); +} + +static PyObject* net_GetServerInfo(PyObject*, PyObject*) { + return Py_BuildValue("s", s_netServerInfo.c_str()); +} + +static PyObject* net_IsTest(PyObject*, PyObject*) { + return Py_BuildValue("i", 0); +} + +static PyObject* net_SetMarkServer(PyObject*, PyObject* poArgs) { + char* szAddr = nullptr; + int port = 0; + if (!PyTuple_GetString(poArgs, 0, &szAddr) || !PyTuple_GetInteger(poArgs, 1, &port)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_UploadMark(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BuildException(); + return Py_BuildValue("i", 0); +} + +static PyObject* net_UploadSymbol(PyObject*, PyObject* poArgs) { + char* szFileName = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szFileName)) + return Py_BuildException(); + return Py_BuildValue("i", 0); +} + +static PyObject* net_ToggleGameDebugInfo(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_SetTCPRecvBufferSize(PyObject*, PyObject* poArgs) { + int bufSize = 0; + if (!PyTuple_GetInteger(poArgs, 0, &bufSize)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SetTCPSendBufferSize(PyObject*, PyObject* poArgs) { + int bufSize = 0; + if (!PyTuple_GetInteger(poArgs, 0, &bufSize)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SetUDPRecvBufferSize(PyObject*, PyObject* poArgs) { + int bufSize = 0; + if (!PyTuple_GetInteger(poArgs, 0, &bufSize)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_LogOutGame(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_ExitGame(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_ExitApplication(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_ConnectTCP(PyObject*, PyObject* poArgs) { + char* szAddr = nullptr; + int port = 0; + if (!PyTuple_GetString(poArgs, 0, &szAddr) || !PyTuple_GetInteger(poArgs, 1, &port)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_ConnectUDP(PyObject*, PyObject* poArgs) { + char* c_szIP = nullptr; + int iPort = 0; + if (!PyTuple_GetString(poArgs, 0, &c_szIP) || !PyTuple_GetInteger(poArgs, 1, &iPort)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendLoginPacket(PyObject*, PyObject* poArgs) { + char* szName = nullptr; + char* szPwd = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szName) || !PyTuple_GetString(poArgs, 1, &szPwd)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendChinaMatrixCardPacket(PyObject*, PyObject* poArgs) { + char* szMatrixCardString = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szMatrixCardString)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendRunupMatrixCardPacket(PyObject*, PyObject* poArgs) { + char* szMatrixCardString = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szMatrixCardString)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendNEWCIBNPasspodAnswerPacket(PyObject*, PyObject* poArgs) { + char* szMatrixCardString = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szMatrixCardString)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendSelectEmpirePacket(PyObject*, PyObject* poArgs) { + int iEmpireIndex = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iEmpireIndex)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendChangeNamePacket(PyObject*, PyObject* poArgs) { + int iIndex = 0; + char* szName = nullptr; + if (!PyTuple_GetInteger(poArgs, 0, &iIndex) || !PyTuple_GetString(poArgs, 1, &szName)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SetOfflinePhase(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_SendMobileMessagePacket(PyObject*, PyObject* poArgs) { + char* szName = nullptr; + char* szLine = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szName) || !PyTuple_GetString(poArgs, 1, &szLine)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SetSkillGroupFake(PyObject*, PyObject* poArgs) { + int iIndex = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iIndex)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendGuildSymbol(PyObject*, PyObject* poArgs) { + char* szIP = nullptr; + int iPort = 0; + char* szFileName = nullptr; + int iGuildID = 0; + if (!PyTuple_GetString(poArgs, 0, &szIP) || + !PyTuple_GetInteger(poArgs, 1, &iPort) || + !PyTuple_GetString(poArgs, 2, &szFileName) || + !PyTuple_GetInteger(poArgs, 3, &iGuildID)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_DisconnectUploader(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_RecvGuildSymbol(PyObject*, PyObject* poArgs) { + char* szIP = nullptr; + int iPort = 0; + int iGuildID = 0; + if (!PyTuple_GetString(poArgs, 0, &szIP) || + !PyTuple_GetInteger(poArgs, 1, &iPort) || + !PyTuple_GetInteger(poArgs, 2, &iGuildID)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendAddOfflineShopItem(PyObject*, PyObject* poArgs) { + int bDisplayPos = 0, bPos = 0, bWindowType = 0; + long long iPrice = 0; + if (!PyTuple_GetInteger(poArgs, 0, &bDisplayPos) || + !PyTuple_GetInteger(poArgs, 1, &bPos) || + !PyTuple_GetLongLong(poArgs, 2, &iPrice) || + !PyTuple_GetInteger(poArgs, 3, &bWindowType)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendTakeOfflineMoney(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_SendOfflineShopChangeTitle(PyObject*, PyObject* poArgs) { + char* title = nullptr; + if (!PyTuple_GetString(poArgs, 0, &title)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendOfflineShopCheck(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_SendOfflineShopButton(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_RegisterErrorLog(PyObject*, PyObject* poArgs) { + char* szLog = nullptr; + if (!PyTuple_GetString(poArgs, 0, &szLog)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_Send67AttrPacket(PyObject*, PyObject* poArgs) { + int iMaterialCount = 0, iSupportCount = 0, iSupportPos = 0, iItemPos = 0; + if (!PyTuple_GetInteger(poArgs, 0, &iMaterialCount) || + !PyTuple_GetInteger(poArgs, 1, &iSupportCount) || + !PyTuple_GetInteger(poArgs, 2, &iSupportPos) || + !PyTuple_GetInteger(poArgs, 3, &iItemPos)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_Send67AttrClosePacket(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_CalendarOpen(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_CalendarClose(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_CalendarSend(PyObject*, PyObject* poArgs) { + int day = 0, index_event = 0; + char* hora_inicio = nullptr; + char* hora_final = nullptr; + if (!PyTuple_GetInteger(poArgs, 0, &day) || + !PyTuple_GetInteger(poArgs, 1, &index_event) || + !PyTuple_GetString(poArgs, 2, &hora_inicio) || + !PyTuple_GetString(poArgs, 3, &hora_final)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendMiniGameCatchKingStart(PyObject*, PyObject* poArgs) { + int ibetNumber = 0; + if (!PyTuple_GetInteger(poArgs, 0, &ibetNumber)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendMiniGameCatchKingDeckCardClick(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_SendMiniGameCatchKingFieldCardClick(PyObject*, PyObject* poArgs) { + int icardNumber = 0; + if (!PyTuple_GetInteger(poArgs, 0, &icardNumber)) + return Py_BuildException(); + return Py_BuildNone(); +} + +static PyObject* net_SendMiniGameCatchKingReward(PyObject*, PyObject*) { + return Py_BuildNone(); +} + +static PyObject* net_OpenCatchKing(PyObject*, PyObject*) { + return Py_BuildNone(); +} + void initnet() { static PyMethodDef methods[] = { {"SetHandler", set_handler, METH_VARARGS, nullptr}, @@ -836,21 +1127,21 @@ void initnet() { {"GetEmpireID", empire, METH_NOARGS, nullptr}, {"Update", update, METH_NOARGS, nullptr}, {"GetConnectionState", status, METH_NOARGS, nullptr}, - {"GetBettingGuildWarValue", net_dummy_zero, METH_VARARGS, nullptr}, + {"GetBettingGuildWarValue", net_GetBettingGuildWarValue, METH_VARARGS, nullptr}, {"EnableChatInsultFilter", net_enable_chat_insult_filter, METH_VARARGS, nullptr}, - {"SetServerInfo", net_dummy_none, METH_VARARGS, nullptr}, - {"GetServerInfo", net_dummy_str, METH_VARARGS, nullptr}, + {"SetServerInfo", net_SetServerInfo, METH_VARARGS, nullptr}, + {"GetServerInfo", net_GetServerInfo, METH_VARARGS, nullptr}, {"PreserveServerCommand", net_preserve_server_command, METH_VARARGS, nullptr}, {"GetPreservedServerCommand", net_get_preserved_server_command, METH_VARARGS, nullptr}, {"StartGame", net_start_game, METH_VARARGS, nullptr}, {"Warp", net_warp, METH_VARARGS, nullptr}, - {"IsTest", net_dummy_zero, METH_VARARGS, nullptr}, - {"SetMarkServer", net_dummy_none, METH_VARARGS, nullptr}, + {"IsTest", net_IsTest, METH_VARARGS, nullptr}, + {"SetMarkServer", net_SetMarkServer, METH_VARARGS, nullptr}, {"IsChatInsultIn", net_is_chat_insult_in, METH_VARARGS, nullptr}, {"IsInsultIn", net_is_insult_in, METH_VARARGS, nullptr}, {"LoadInsultList", net_load_insult_list, METH_VARARGS, nullptr}, - {"UploadMark", net_dummy_none, METH_VARARGS, nullptr}, - {"UploadSymbol", net_dummy_none, METH_VARARGS, nullptr}, + {"UploadMark", net_UploadMark, METH_VARARGS, nullptr}, + {"UploadSymbol", net_UploadSymbol, METH_VARARGS, nullptr}, {"GetGuildID", netGetGuildID, METH_VARARGS, nullptr}, {"GetMainActorVID", net_get_main_actor_vid, METH_VARARGS, nullptr}, {"GetMainActorRace", net_get_main_actor_race, METH_VARARGS, nullptr}, @@ -859,23 +1150,23 @@ void initnet() { {"SendTargetInfoLoad", netTargetInfoLoad, METH_VARARGS, nullptr}, {"GetFieldMusicFileName", net_get_field_music_name, METH_VARARGS, nullptr}, {"GetFieldMusicVolume", net_get_field_music_volume, METH_VARARGS, nullptr}, - {"ToggleGameDebugInfo", net_dummy_none, METH_VARARGS, nullptr}, + {"ToggleGameDebugInfo", net_ToggleGameDebugInfo, METH_VARARGS, nullptr}, {"SetServerCommandParserWindow", net_set_server_command_parser_window, METH_VARARGS, nullptr}, - {"SetTCPRecvBufferSize", net_dummy_none, METH_VARARGS, nullptr}, - {"SetTCPSendBufferSize", net_dummy_none, METH_VARARGS, nullptr}, - {"SetUDPRecvBufferSize", net_dummy_none, METH_VARARGS, nullptr}, + {"SetTCPRecvBufferSize", net_SetTCPRecvBufferSize, METH_VARARGS, nullptr}, + {"SetTCPSendBufferSize", net_SetTCPSendBufferSize, METH_VARARGS, nullptr}, + {"SetUDPRecvBufferSize", net_SetUDPRecvBufferSize, METH_VARARGS, nullptr}, {"DirectEnter", direct_enter, METH_VARARGS, nullptr}, - {"LogOutGame", net_dummy_none, METH_VARARGS, nullptr}, - {"ExitGame", net_dummy_none, METH_VARARGS, nullptr}, - {"ExitApplication", net_dummy_none, METH_VARARGS, nullptr}, - {"ConnectTCP", net_dummy_none, METH_VARARGS, nullptr}, - {"ConnectUDP", net_dummy_none, METH_VARARGS, nullptr}, - {"SendLoginPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"SendChinaMatrixCardPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"SendRunupMatrixCardPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"SendNEWCIBNPasspodAnswerPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"SendSelectEmpirePacket", net_dummy_none, METH_VARARGS, nullptr}, - {"SendChangeNamePacket", net_dummy_none, METH_VARARGS, nullptr}, + {"LogOutGame", net_LogOutGame, METH_VARARGS, nullptr}, + {"ExitGame", net_ExitGame, METH_VARARGS, nullptr}, + {"ExitApplication", net_ExitApplication, METH_VARARGS, nullptr}, + {"ConnectTCP", net_ConnectTCP, METH_VARARGS, nullptr}, + {"ConnectUDP", net_ConnectUDP, METH_VARARGS, nullptr}, + {"SendLoginPacket", net_SendLoginPacket, METH_VARARGS, nullptr}, + {"SendChinaMatrixCardPacket", net_SendChinaMatrixCardPacket, METH_VARARGS, nullptr}, + {"SendRunupMatrixCardPacket", net_SendRunupMatrixCardPacket, METH_VARARGS, nullptr}, + {"SendNEWCIBNPasspodAnswerPacket", net_SendNEWCIBNPasspodAnswerPacket, METH_VARARGS, nullptr}, + {"SendSelectEmpirePacket", net_SendSelectEmpirePacket, METH_VARARGS, nullptr}, + {"SendChangeNamePacket", net_SendChangeNamePacket, METH_VARARGS, nullptr}, {"SendCreateCharacterPacket", send_create_character, METH_VARARGS, nullptr}, {"SendDestroyCharacterPacket", send_destroy_character, METH_VARARGS, nullptr}, {"SendEnterGamePacket", net_send_enter_game, METH_VARARGS, nullptr}, @@ -888,12 +1179,12 @@ void initnet() { {"SendItemMovePacket", send_item_move_packet, METH_VARARGS, nullptr}, {"SendItemPickUpPacket", net_send_item_pickup, METH_VARARGS, nullptr}, {"SendGiveItemPacket", net_send_give_item_packet, METH_VARARGS, nullptr}, - {"SetOfflinePhase", net_dummy_none, METH_VARARGS, nullptr}, + {"SetOfflinePhase", net_SetOfflinePhase, METH_VARARGS, nullptr}, {"IsConnect", is_connected, METH_VARARGS, nullptr}, {"SendChatPacket", net_send_chat, METH_VARARGS, nullptr}, {"SendEmoticon", net_send_emoticon, METH_VARARGS, nullptr}, {"SendWhisperPacket", net_send_whisper, METH_VARARGS, nullptr}, - {"SendMobileMessagePacket", net_dummy_none, METH_VARARGS, nullptr}, + {"SendMobileMessagePacket", net_SendMobileMessagePacket, METH_VARARGS, nullptr}, {"SendCharacterPositionPacket", send_character_position_packet, METH_VARARGS, nullptr}, {"SendCharacterMovePacket", send_character_move_packet, METH_VARARGS, nullptr}, {"SendCharacterStatePacket", send_character_move_packet, METH_VARARGS, nullptr}, @@ -952,44 +1243,44 @@ void initnet() { {"SendScriptButtonPacket", net_send_script_button_packet, METH_VARARGS, nullptr}, {"SendSelectItemPacket", netSendSelectItemPacket, METH_VARARGS, nullptr}, {"SetEmpireLanguageMode", net_set_empire_language_mode, METH_VARARGS, nullptr}, - {"SetSkillGroupFake", net_dummy_none, METH_VARARGS, nullptr}, - {"SendGuildSymbol", net_dummy_none, METH_VARARGS, nullptr}, - {"DisconnectUploader", net_dummy_none, METH_VARARGS, nullptr}, - {"RecvGuildSymbol", net_dummy_none, METH_VARARGS, nullptr}, + {"SetSkillGroupFake", net_SetSkillGroupFake, METH_VARARGS, nullptr}, + {"SendGuildSymbol", net_SendGuildSymbol, METH_VARARGS, nullptr}, + {"DisconnectUploader", net_DisconnectUploader, METH_VARARGS, nullptr}, + {"RecvGuildSymbol", net_RecvGuildSymbol, METH_VARARGS, nullptr}, {"SendOfflineShopEndPacket", offline_shop_end, METH_VARARGS, nullptr}, {"SendOfflineShopBuyPacket", offline_shop_buy, METH_VARARGS, nullptr}, - {"SendAddOfflineShopItem", net_dummy_none, METH_VARARGS, nullptr}, + {"SendAddOfflineShopItem", net_SendAddOfflineShopItem, METH_VARARGS, nullptr}, {"SendRemoveOfflineShopItem", offline_shop_remove, METH_VARARGS, nullptr}, {"SendDestroyOfflineShop", offline_shop_destroy, METH_VARARGS, nullptr}, - {"SendTakeOfflineMoney", net_dummy_none, METH_VARARGS, nullptr}, - {"SendOfflineShopChangeTitle", net_dummy_none, METH_VARARGS, nullptr}, - {"SendOfflineShopCheck", net_dummy_none, METH_VARARGS, nullptr}, - {"SendOfflineShopButton", net_dummy_none, METH_VARARGS, nullptr}, + {"SendTakeOfflineMoney", net_SendTakeOfflineMoney, METH_VARARGS, nullptr}, + {"SendOfflineShopChangeTitle", net_SendOfflineShopChangeTitle, METH_VARARGS, nullptr}, + {"SendOfflineShopCheck", net_SendOfflineShopCheck, METH_VARARGS, nullptr}, + {"SendOfflineShopButton", net_SendOfflineShopButton, METH_VARARGS, nullptr}, {"SendOfflineShopRemoveLogs", offline_shop_logs, METH_VARARGS, nullptr}, {"SendOpenShopSlot", offline_shop_slot, METH_VARARGS, nullptr}, {"SendGetBackItems", offline_shop_get_items, METH_VARARGS, nullptr}, {"SendAddTime", offline_shop_add_time, METH_VARARGS, nullptr}, {"SendOpenWithVID", offline_shop_open_vid, METH_VARARGS, nullptr}, - {"RegisterErrorLog", net_dummy_none, METH_VARARGS, nullptr}, - {"ElementsSpellClose", net_dummy_none, METH_VARARGS, nullptr}, - {"ElementsSpellAdd", net_dummy_none, METH_VARARGS, nullptr}, - {"ElementsSpellChange", net_dummy_none, METH_VARARGS, nullptr}, - {"Send67AttrPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"Send67AttrClosePacket", net_dummy_none, METH_VARARGS, nullptr}, - {"CalendarOpen", net_dummy_none, METH_VARARGS, nullptr}, - {"CalendarClose", net_dummy_none, METH_VARARGS, nullptr}, - {"CalendarSend", net_dummy_none, METH_VARARGS, nullptr}, + {"RegisterErrorLog", net_RegisterErrorLog, METH_VARARGS, nullptr}, + {"ElementsSpellClose", net_ElementsSpellClose, METH_VARARGS, nullptr}, + {"ElementsSpellAdd", net_ElementsSpellAdd, METH_VARARGS, nullptr}, + {"ElementsSpellChange", net_ElementsSpellChange, METH_VARARGS, nullptr}, + {"Send67AttrPacket", net_Send67AttrPacket, METH_VARARGS, nullptr}, + {"Send67AttrClosePacket", net_Send67AttrClosePacket, METH_VARARGS, nullptr}, + {"CalendarOpen", net_CalendarOpen, METH_VARARGS, nullptr}, + {"CalendarClose", net_CalendarClose, METH_VARARGS, nullptr}, + {"CalendarSend", net_CalendarSend, METH_VARARGS, nullptr}, {"SendPrivateShopSearchInfo", netSendPrivateShopSearchInfo, METH_VARARGS, nullptr}, - {"SendMiniGameCatchKingStart", net_dummy_none, METH_VARARGS, nullptr}, - {"SendMiniGameCatchKingDeckCardClick", net_dummy_none, METH_VARARGS, nullptr}, - {"SendMiniGameCatchKingFieldCardClick", net_dummy_none, METH_VARARGS, nullptr}, - {"SendMiniGameCatchKingReward", net_dummy_none, METH_VARARGS, nullptr}, - {"OpenCatchKing", net_dummy_none, METH_VARARGS, nullptr}, - {"SendCombatZoneRequestActionPacket", net_dummy_none, METH_VARARGS, nullptr}, - {"IsRunning", net_dummy_zero, METH_VARARGS, nullptr}, - {"GetRankings", net_dummy_tuple4, METH_VARARGS, nullptr}, - {"GetDay", net_dummy_tuple4, METH_VARARGS, nullptr}, - {"GetDayActivate", net_dummy_zero, METH_VARARGS, nullptr}, + {"SendMiniGameCatchKingStart", net_SendMiniGameCatchKingStart, METH_VARARGS, nullptr}, + {"SendMiniGameCatchKingDeckCardClick", net_SendMiniGameCatchKingDeckCardClick, METH_VARARGS, nullptr}, + {"SendMiniGameCatchKingFieldCardClick", net_SendMiniGameCatchKingFieldCardClick, METH_VARARGS, nullptr}, + {"SendMiniGameCatchKingReward", net_SendMiniGameCatchKingReward, METH_VARARGS, nullptr}, + {"OpenCatchKing", net_OpenCatchKing, METH_VARARGS, nullptr}, + {"SendCombatZoneRequestActionPacket", net_SendCombatZoneRequestActionPacket, METH_VARARGS, nullptr}, + {"IsRunning", net_CombatZone_IsRunning, METH_VARARGS, nullptr}, + {"GetRankings", net_CombatZone_GetRankings, METH_VARARGS, nullptr}, + {"GetDay", net_CombatZone_GetDay, METH_VARARGS, nullptr}, + {"GetDayActivate", net_CombatZone_GetDayActivate, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; auto* module = Py_InitModule("net", methods); diff --git a/tests/background_test.cpp b/tests/background_test.cpp new file mode 100644 index 00000000..6cf9ac89 --- /dev/null +++ b/tests/background_test.cpp @@ -0,0 +1,219 @@ +// background / app camera module parity tests against AVA2 PythonBackgroundModule.cpp + PythonApplicationModule.cpp: +// - All 54 background module functions and constants +// - View distance settings and queries +// - Visibility flags and splat limits +// - GlobalPositionToLocalPosition and GlobalPositionToMapInfo conversions +// - Map loading, Warping (WarpTest / Warp), GetCurrentMapName +// - Height and attribute querying (GetHeight, isAttrOn, IsAttrOn) +// - app module camera bindings: SetCamera, GetCamera, GetCameraPitch, GetCameraRotation, RotateCamera, +// PitchCamera, ZoomCamera, MovieCamera functions, SetCameraSpeed, SetCameraMaxDistance, +// SetDefaultCamera, SetCameraSetting, Save/LoadCameraSetting, EnableSpecialCameraMode, +// GetRotatingDirection, GetDegreeDifference, GetCursorPosition, UpdateGame, RenderGame, +// and camera constants. + +#include "python_background.h" +#include "python_gameplay_modules.h" +#include "python_runtime.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ava2; +namespace fs = std::filesystem; + +static void require(bool ok, const char* why) { + if (!ok) throw std::runtime_error(why); +} + +static void spit(const fs::path& p, const std::string& s) { + fs::create_directories(p.parent_path()); + std::ofstream f(p, std::ios::binary); + f << s; +} + +int main(int argc, char** argv) { + if (argc != 3) return 2; + try { + const fs::path stdlib = fs::absolute(argv[1]); + const fs::path root = fs::temp_directory_path() / "ava2_background_test"; + fs::remove_all(root); + fs::create_directories(root); + fs::current_path(root); + + // Map and atlas setup + spit(root / "locale/en/atlasinfo.txt", "test_bg_map 102400 204800 2 2\n"); + spit(root / "map/test_bg_map/setting.txt", + "ScriptType MapSetting\nMapSize 2 2\nBasePosition 102400 204800\n"); + + // Prepare dummy heightmap: 131x131 uint16_t filled with 200 (height 200 * 0.5 = 100.0) + std::vector heights(131 * 131, 200); + std::string raw_heights(reinterpret_cast(heights.data()), heights.size() * sizeof(uint16_t)); + spit(root / "map/test_bg_map/000000/height.raw", raw_heights); + + // Prepare dummy attr: 256x256 uint8_t with ATTR_BLOCK (1) + std::vector attrs(256 * 256, 1); + std::string raw_attrs(reinterpret_cast(attrs.data()), attrs.size()); + spit(root / "map/test_bg_map/000000/attr.atr", raw_attrs); + + PythonRuntime python(stdlib, root); + + std::cout << "[TEST] Running block 1 (exports & constants)..." << std::endl; + python.execute( + "import background as bg\n" + "bg_names = ('IsSoftwareTiling', 'EnableSoftwareTiling', 'TextureChange', 'EnableSnow',\n" + " 'GlobalPositionToLocalPosition', 'GlobalPositionToMapInfo', 'GetRenderShadowTime',\n" + " 'LoadMap', 'Destroy', 'RegisterEnvironmentData', 'SetEnvironmentData',\n" + " 'GetCurrentMapName', 'GetPickingPoint', 'BeginEnvironment', 'EndEnvironment',\n" + " 'SetCharacterDirLight', 'SetBackgroundDirLight', 'Initialize', 'Update',\n" + " 'Render', 'RenderPCBlocker', 'RenderCollision', 'RenderSky', 'RenderCloud',\n" + " 'RenderWater', 'RenderEffect', 'RenderBeforeLensFlare', 'RenderAfterLensFlare',\n" + " 'RenderCharacterShadowToTexture', 'RenderDungeon', 'GetHeight', 'isAttrOn',\n" + " 'IsAttrOn', 'SetShadowLevel', 'IsVisiblePart', 'SetVisiblePart',\n" + " 'GetShadowMapColor', 'SetSplatLimit', 'GetRenderedSplatNum',\n" + " 'GetRenderedGraphicThingInstanceNum', 'SelectViewDistanceNum',\n" + " 'SetViewDistanceSet', 'GetFarClip', 'GetDistanceSetInfo', 'SetBGLoading',\n" + " 'SetRenderSort', 'SetTransparentTree', 'SetXMasTree', 'RegisterDungeonMapName',\n" + " 'VisibleGuildArea', 'DisableGuildArea', 'WarpTest', 'CreatePrivateShopPos',\n" + " 'DeletePrivateShopPos')\n" + "funcs = sorted(n for n in dir(bg) if callable(getattr(bg, n)))\n" + "assert funcs == sorted(bg_names), set(funcs) ^ set(bg_names)\n" + "\n" + "assert (bg.PART_TERRAIN, bg.PART_OBJECT, bg.PART_CLOUD, bg.PART_WATER, bg.PART_TREE, bg.PART_SKY, bg.PART_SHOP) == (0, 1, 2, 3, 4, 5, 6)\n" + "assert (bg.SKY_RENDER_MODE_DEFAULT, bg.SKY_RENDER_MODE_DIFFUSE, bg.SKY_RENDER_MODE_TEXTURE, bg.SKY_RENDER_MODE_MODULATE, bg.SKY_RENDER_MODE_MODULATE2X, bg.SKY_RENDER_MODE_MODULATE4X) == (0, 1, 2, 3, 4, 5)\n" + "assert (bg.SHADOW_NONE, bg.SHADOW_GROUND, bg.SHADOW_GROUND_AND_SOLO, bg.SHADOW_ALL, bg.SHADOW_ALL_HIGH, bg.SHADOW_ALL_MAX) == (0, 1, 2, 3, 4, 5)\n" + "assert (bg.DISTANCE0, bg.DISTANCE1, bg.DISTANCE2, bg.DISTANCE3, bg.DISTANCE4) == (0, 1, 2, 3, 4)\n" + "assert (bg.DISTANCE_SORT, bg.TEXTURE_SORT) == (0, 1)\n" + "assert (bg.ATTR_BLOCK, bg.ATTR_WATER, bg.ATTR_BANPK) == (1, 2, 4)\n" + "assert (bg.ATTRIBUTE_BLOCK, bg.ATTRIBUTE_WATER, bg.ATTRIBUTE_BANPK) == (1, 2, 4)\n" + ); + + std::cout << "[TEST] Running block 2 (basic calls & state)..." << std::endl; + python.execute( + "import background as bg\n" + "assert bg.GetCurrentMapName() == ''\n" + "assert bg.GetHeight(0.0, 0.0) == 0.0\n" + "assert bg.isAttrOn(0.0, 0.0, bg.ATTR_BLOCK) == 0\n" + "assert bg.IsAttrOn(0, 0, bg.ATTR_BLOCK) == 0\n" + "assert bg.GetFarClip() > 0.0\n" + "assert bg.IsSoftwareTiling() in (0, 1)\n" + "bg.EnableSoftwareTiling(1)\n" + "bg.EnableSnow(1)\n" + "bg.EnableSnow(0)\n" + "bg.SetShadowLevel(bg.SHADOW_ALL)\n" + "assert bg.IsVisiblePart(bg.PART_TERRAIN) == 1\n" + "bg.SetVisiblePart(bg.PART_TERRAIN, 0)\n" + "assert bg.IsVisiblePart(bg.PART_TERRAIN) == 0\n" + "bg.SetVisiblePart(bg.PART_TERRAIN, 1)\n" + "assert bg.IsVisiblePart(bg.PART_TERRAIN) == 1\n" + "bg.SetSplatLimit(100)\n" + "splat_info = bg.GetRenderedSplatNum()\n" + "assert len(splat_info) == 4\n" + "assert bg.GetRenderedGraphicThingInstanceNum() == (0, 0)\n" + "bg.SelectViewDistanceNum(0)\n" + "bg.SetViewDistanceSet(0, 25000.0)\n" + "dist_info = bg.GetDistanceSetInfo()\n" + "assert len(dist_info) == 4\n" + "bg.SetBGLoading(True)\n" + "bg.SetRenderSort(bg.DISTANCE_SORT)\n" + "bg.SetTransparentTree(True)\n" + "bg.SetXMasTree(1)\n" + "bg.RegisterDungeonMapName('dungeon_map')\n" + "bg.VisibleGuildArea()\n" + "bg.DisableGuildArea()\n" + "bg.CreatePrivateShopPos(1234)\n" + "bg.DeletePrivateShopPos()\n" + "bg.TextureChange('some_texture.dds')\n" + "assert isinstance(bg.GetRenderShadowTime(), int)\n" + "assert len(bg.GetPickingPoint()) == 3\n" + "bg.BeginEnvironment()\n" + "bg.SetCharacterDirLight()\n" + "bg.SetBackgroundDirLight()\n" + "bg.EndEnvironment()\n" + "bg.Update(0.0, 0.0, 0.0)\n" + "bg.Render()\n" + "bg.RenderPCBlocker()\n" + "bg.RenderCollision()\n" + "bg.RenderSky()\n" + "bg.RenderCloud()\n" + "bg.RenderWater()\n" + "bg.RenderEffect()\n" + "bg.RenderBeforeLensFlare()\n" + "bg.RenderAfterLensFlare()\n" + "bg.RenderCharacterShadowToTexture()\n" + "bg.RenderDungeon()\n" + ); + + std::cout << "[TEST] Running block 3 (map coords & warp)..." << std::endl; + python.execute( + "import background as bg\n" + "map_info = bg.GlobalPositionToMapInfo(102400, 204800)\n" + "assert map_info == ('test_bg_map', 102400, 204800), map_info\n" + "assert bg.GlobalPositionToMapInfo(10, 10) == ('', 0, 0)\n" + "\n" + "bg.WarpTest(1024, 2048)\n" + "assert bg.GetCurrentMapName() == 'test_bg_map', bg.GetCurrentMapName()\n" + "assert bg.GlobalPositionToLocalPosition(102400 + 400, 204800 + 600) == (400, 600)\n" + "assert bg.GetHeight(0.0, 0.0) == 100.0, bg.GetHeight(0.0, 0.0)\n" + "assert bg.isAttrOn(0.0, 0.0, bg.ATTR_BLOCK) == 1\n" + "assert bg.IsAttrOn(0, 0, bg.ATTR_BLOCK) == 1\n" + "\n" + "bg.Destroy()\n" + "assert bg.GetCurrentMapName() == ''\n" + ); + + std::cout << "[TEST] Running block 4 (app camera bindings)..." << std::endl; + python.execute( + "import app\n" + "assert app.DEGREE_DIRECTION_SAME == 0\n" + "assert app.DEGREE_DIRECTION_RIGHT == 1\n" + "assert app.DEGREE_DIRECTION_LEFT == 2\n" + "assert app.CAMERA_TO_POSITIVE == 1\n" + "assert app.CAMERA_TO_NEGATIVE == -1\n" + "assert app.CAMERA_STOP == 0\n" + "\n" + "app.SetCamera(1200.0, 15.0, 90.0, 45.0)\n" + "cam = app.GetCamera()\n" + "assert cam == (1200.0, 15.0, 90.0, 45.0), cam\n" + "assert app.GetCameraPitch() == 15.0\n" + "assert app.GetCameraRotation() == 90.0\n" + "\n" + "app.RotateCamera(app.CAMERA_TO_POSITIVE)\n" + "app.PitchCamera(app.CAMERA_TO_POSITIVE)\n" + "app.ZoomCamera(app.CAMERA_TO_POSITIVE)\n" + "app.MovieRotateCamera(1)\n" + "app.MoviePitchCamera(1)\n" + "app.MovieZoomCamera(1)\n" + "app.MovieResetCamera()\n" + "app.SetCameraSpeed(150)\n" + "app.SetCameraMaxDistance(4000.0)\n" + "app.SetDefaultCamera()\n" + "app.SetCameraSetting(0, 0, 100, 1200, 45, 20)\n" + "app.SaveCameraSetting('cam_test.txt')\n" + "app.LoadCameraSetting('cam_test.txt')\n" + "app.EnableSpecialCameraMode()\n" + "\n" + "assert app.GetRotatingDirection(0.0, 0.0) == app.DEGREE_DIRECTION_LEFT\n" + "assert app.GetRotatingDirection(20.0, 10.0) == app.DEGREE_DIRECTION_RIGHT\n" + "assert app.GetRotatingDirection(10.0, 20.0) == app.DEGREE_DIRECTION_LEFT\n" + "diff = app.GetDegreeDifference(10.0, 20.0)\n" + "assert isinstance(diff, float)\n" + "\n" + "cur_pos = app.GetCursorPosition()\n" + "assert len(cur_pos) == 2\n" + "\n" + "app.UpdateGame()\n" + "app.RenderGame()\n" + ); + + std::cout << "AVA2 background parity passed" << std::endl; + return 0; + } catch (const std::exception& e) { + std::cerr << "background_test failed: " << e.what() << std::endl; + return 1; + } +} diff --git a/tests/item_data_test.cpp b/tests/item_data_test.cpp index 953be510..96c0a009 100644 --- a/tests/item_data_test.cpp +++ b/tests/item_data_test.cpp @@ -25,9 +25,12 @@ void tga(const std::filesystem::path& p) {Bytes b(18,0);b[2]=2;b[12]=64;b[14]=96 int main(int argc,char** argv) { if(argc!=3)return 2; auto root=std::filesystem::temp_directory_path()/std::filesystem::path("ava2-item-data-"+std::to_string(getpid()));std::filesystem::create_directories(root); + auto orig_cwd = std::filesystem::current_path(); + auto zip_path = std::filesystem::absolute(argv[1]); + std::filesystem::current_path(root); try { { - PythonRuntime python(argv[1],root);python.execute("import item\n"); + PythonRuntime python(zip_path, root);python.execute("import item\n"); python.execute(R"PY(for f in (item.GetItemName,item.GetItemDescription,item.GetItemSummary,item.GetItemSize,item.GetItemType,item.GetItemSubType,item.GetIconImage,item.GetIconImageFileName): try: f() except RuntimeError: pass @@ -52,6 +55,13 @@ assert item.SelectItemWiki(27003)==0 textfile(root/"list","500\tignored\ticon/list2.tga\tmodel/new.gr2\n");require(LoadItemList("list"),"reload list failed");require(GetWeaponModelPathByVnum(500)=="model/new.gr2","explicit model path ignored");python.execute("assert item.GetItemType()==2 and item.GetItemName()=='Listed' and item.GetSocket(0)==0 and item.GetItemDescription()==''\n"); ResetItemDatabase();require(!GetItemTypeAndSubType(500,&type,&sub),"database reset retained records");python.execute("assert item.SelectItemWiki(500)==0\n"); } - std::filesystem::remove_all(root);std::cout<<"AVA2 item resource loading and selected data parity passed\n"; - }catch(const std::exception& e){std::filesystem::remove_all(root);std::cerr<