From 575a97bc44c2814bee3dd6d0f30fb535ebcaa526 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 12 Sep 2022 12:54:05 -0700 Subject: [PATCH] renamed c++ game class to logic --- .efrocachemap | 88 +++---- CHANGELOG.md | 3 +- .../ba_data/python/._bainternal_sources_hash | 2 +- assets/src/ba_data/python/ba/_bootstrap.py | 2 +- ballisticacore-cmake/CMakeLists.txt | 68 ++--- .../Generic/BallisticaCoreGeneric.vcxproj | 68 ++--- .../BallisticaCoreGeneric.vcxproj.filters | 210 +++++++-------- .../Headless/BallisticaCoreHeadless.vcxproj | 68 ++--- .../BallisticaCoreHeadless.vcxproj.filters | 210 +++++++-------- src/ballistica/app/app_flavor.cc | 6 +- src/ballistica/app/app_flavor_vr.cc | 4 +- src/ballistica/app/stress_test.cc | 2 +- src/ballistica/assets/assets.cc | 8 +- src/ballistica/audio/audio_server.cc | 7 +- src/ballistica/audio/audio_server.h | 2 +- src/ballistica/ballistica.cc | 20 +- src/ballistica/ballistica.h | 2 +- src/ballistica/core/context.cc | 2 +- src/ballistica/core/logging.cc | 6 +- src/ballistica/core/types.h | 2 +- .../dynamics/bg/bg_dynamics_server.cc | 6 +- .../material/impact_sound_material_action.cc | 2 +- .../material/material_condition_node.cc | 2 +- .../material/roll_sound_material_action.cc | 2 +- .../material/skid_sound_material_action.cc | 2 +- .../material/sound_material_action.cc | 2 +- src/ballistica/dynamics/part.h | 2 +- src/ballistica/generic/real_timer.h | 10 +- src/ballistica/graphics/graphics.cc | 26 +- src/ballistica/graphics/graphics_server.cc | 18 +- src/ballistica/graphics/vr_graphics.cc | 4 +- .../input/device/client_input_device.cc | 4 +- src/ballistica/input/device/input_device.cc | 22 +- src/ballistica/input/device/joystick.cc | 32 +-- src/ballistica/input/device/keyboard_input.cc | 4 +- src/ballistica/input/device/test_input.cc | 2 +- src/ballistica/input/device/touch_input.cc | 13 +- src/ballistica/input/input.cc | 79 +++--- src/ballistica/input/remote_app.cc | 26 +- .../client_controller_interface.h | 6 +- .../{game => logic}/connection/connection.cc | 2 +- .../{game => logic}/connection/connection.h | 8 +- .../connection/connection_set.cc | 57 ++-- .../connection/connection_set.h | 6 +- .../connection/connection_to_client.cc | 74 +++--- .../connection/connection_to_client.h | 8 +- .../connection/connection_to_client_udp.cc | 14 +- .../connection/connection_to_client_udp.h | 8 +- .../connection/connection_to_host.cc | 32 +-- .../connection/connection_to_host.h | 8 +- .../connection/connection_to_host_udp.cc | 22 +- .../connection/connection_to_host_udp.h | 8 +- .../{game => logic}/friend_score_set.h | 6 +- .../{game => logic}/host_activity.cc | 10 +- .../{game => logic}/host_activity.h | 6 +- .../{game/game.cc => logic/logic.cc} | 246 +++++++++--------- src/ballistica/{game/game.h => logic/logic.h} | 10 +- src/ballistica/{game => logic}/player.cc | 8 +- src/ballistica/{game => logic}/player.h | 6 +- src/ballistica/{game => logic}/player_spec.cc | 10 +- src/ballistica/{game => logic}/player_spec.h | 6 +- .../{game => logic}/session/client_session.cc | 4 +- .../{game => logic}/session/client_session.h | 10 +- .../{game => logic}/session/host_session.cc | 28 +- .../{game => logic}/session/host_session.h | 8 +- .../session/net_client_session.cc | 4 +- .../session/net_client_session.h | 8 +- .../session/replay_client_session.cc | 16 +- .../session/replay_client_session.h | 10 +- .../{game => logic}/session/session.cc | 6 +- .../{game => logic}/session/session.h | 6 +- src/ballistica/{game => logic}/v1_account.cc | 22 +- src/ballistica/{game => logic}/v1_account.h | 6 +- src/ballistica/networking/network_reader.cc | 14 +- src/ballistica/networking/networking.cc | 2 +- src/ballistica/networking/telnet_server.cc | 24 +- src/ballistica/platform/platform.cc | 14 +- src/ballistica/platform/sdl/sdl_app.cc | 4 +- src/ballistica/platform/stdio_console.cc | 6 +- .../platform/windows/platform_windows.cc | 8 +- .../class/python_class_activity_data.cc | 8 +- .../class/python_class_collide_model.cc | 4 +- .../python/class/python_class_context.cc | 12 +- .../python/class/python_class_context_call.cc | 4 +- .../python/class/python_class_data.cc | 4 +- .../python/class/python_class_input_device.cc | 4 +- .../python/class/python_class_material.cc | 6 +- .../python/class/python_class_model.cc | 4 +- .../python/class/python_class_node.cc | 2 +- .../python/class/python_class_session_data.cc | 6 +- .../class/python_class_session_player.cc | 8 +- .../python/class/python_class_sound.cc | 4 +- .../python/class/python_class_texture.cc | 4 +- .../python/class/python_class_timer.cc | 4 +- .../python/class/python_class_widget.cc | 4 +- .../python/methods/python_methods_app.cc | 30 +-- .../python/methods/python_methods_assets.cc | 2 +- .../python/methods/python_methods_gameplay.cc | 30 +-- .../python/methods/python_methods_graphics.cc | 20 +- .../python/methods/python_methods_input.cc | 2 +- .../methods/python_methods_networking.cc | 50 ++-- .../python/methods/python_methods_system.cc | 10 +- .../python/methods/python_methods_ui.cc | 67 ++--- src/ballistica/python/python.cc | 42 +-- src/ballistica/python/python.h | 2 +- src/ballistica/python/python_context_call.cc | 4 +- src/ballistica/scene/node/globals_node.cc | 6 +- src/ballistica/scene/node/spaz_node.h | 2 +- src/ballistica/scene/node/text_node.cc | 4 +- .../scene/node/time_display_node.cc | 8 +- src/ballistica/scene/scene.cc | 6 +- src/ballistica/scene/scene.h | 2 +- src/ballistica/scene/scene_stream.cc | 10 +- src/ballistica/scene/scene_stream.h | 2 +- src/ballistica/ui/console.cc | 8 +- src/ballistica/ui/root_ui.cc | 29 ++- src/ballistica/ui/ui.cc | 16 +- src/ballistica/ui/widget/button_widget.cc | 6 +- src/ballistica/ui/widget/check_box_widget.cc | 4 +- src/ballistica/ui/widget/container_widget.cc | 30 +-- src/ballistica/ui/widget/h_scroll_widget.cc | 2 +- src/ballistica/ui/widget/image_widget.cc | 4 +- src/ballistica/ui/widget/root_widget.cc | 12 +- src/ballistica/ui/widget/scroll_widget.cc | 2 +- src/ballistica/ui/widget/text_widget.cc | 18 +- src/ballistica/ui/widget/widget.cc | 4 +- tools/batools/project.py | 21 +- 127 files changed, 1178 insertions(+), 1154 deletions(-) rename src/ballistica/{game => logic}/client_controller_interface.h (78%) rename src/ballistica/{game => logic}/connection/connection.cc (99%) rename src/ballistica/{game => logic}/connection/connection.h (96%) rename src/ballistica/{game => logic}/connection/connection_set.cc (94%) rename src/ballistica/{game => logic}/connection/connection_set.h (96%) rename src/ballistica/{game => logic}/connection/connection_to_client.cc (92%) rename src/ballistica/{game => logic}/connection/connection_to_client.h (92%) rename src/ballistica/{game => logic}/connection/connection_to_client_udp.cc (88%) rename src/ballistica/{game => logic}/connection/connection_to_client_udp.h (81%) rename src/ballistica/{game => logic}/connection/connection_to_host.cc (94%) rename src/ballistica/{game => logic}/connection/connection_to_host.h (85%) rename src/ballistica/{game => logic}/connection/connection_to_host_udp.cc (89%) rename src/ballistica/{game => logic}/connection/connection_to_host_udp.h (83%) rename src/ballistica/{game => logic}/friend_score_set.h (81%) rename src/ballistica/{game => logic}/host_activity.cc (98%) rename src/ballistica/{game => logic}/host_activity.h (97%) rename src/ballistica/{game/game.cc => logic/logic.cc} (91%) rename src/ballistica/{game/game.h => logic/logic.h} (99%) rename src/ballistica/{game => logic}/player.cc (98%) rename src/ballistica/{game => logic}/player.h (98%) rename src/ballistica/{game => logic}/player_spec.cc (93%) rename src/ballistica/{game => logic}/player_spec.h (93%) rename src/ballistica/{game => logic}/session/client_session.cc (99%) rename src/ballistica/{game => logic}/session/client_session.h (94%) rename src/ballistica/{game => logic}/session/host_session.cc (96%) rename src/ballistica/{game => logic}/session/host_session.h (95%) rename src/ballistica/{game => logic}/session/net_client_session.cc (98%) rename src/ballistica/{game => logic}/session/net_client_session.h (88%) rename src/ballistica/{game => logic}/session/replay_client_session.cc (93%) rename src/ballistica/{game => logic}/session/replay_client_session.h (79%) rename src/ballistica/{game => logic}/session/session.cc (85%) rename src/ballistica/{game => logic}/session/session.h (90%) rename src/ballistica/{game => logic}/v1_account.cc (90%) rename src/ballistica/{game => logic}/v1_account.h (94%) diff --git a/.efrocachemap b/.efrocachemap index 754e3439..43f04760 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3995,50 +3995,50 @@ "assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e", "assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34", "ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a", - "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a1/66/39cac09bf6b06e56c530835eb181", - "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/2b/cb/6dd8bdf3a077d3aa761f9b8fbd63", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b5/e9/5c0a89d56a6e483229da89281796", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fe/f9/c33d7708c6186bfd96d5e47955a3", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/73/5b/93a06dabd24015bb45150bf9b504", - "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cb/e0/a0da487b59ded7b3906f14bfa720", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d2/fe/bace2357c3c17373a474bb4c2550", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bb/1c/8f71bc4449cd828817e7eb5e685e", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/59/c0/562d9fdf5769951cd04f4389f0b8", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0a/7d/8a7148a088f5b2c7c1fa770368a9", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d8/d3/b107c0c0564b59544af598ebb975", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/10/e29b058f51d202b47315a78e9426", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/1a/25/fd41d552ce3c4d3b6097ddf38575", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/68/35/afcdb16cb02aee02aefecda09c18", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/89/a6/ed6fb097d9f5b7bf213750399b09", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c6/e0/ac51274e398c2d4c9ca96918ff24", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/83/46/3a7a9981de261f0ade01976d5ff7", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a4/a9/0cfdc1a7499515d9ae1742a1556d", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/cd/9b/2b5530a52e1da3912f2b89f2de83", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/24/32/c583f30ff2e5f77c02e1716033b8", - "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/26/1d/c05986ea5543313a3d9ad8f87551", - "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a9/30/62c8fa6369762561e87708d625ae", - "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/32/e2/27313549815bc9201818b4db6c10", - "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/48/67/bac46275cec3dbdbee7d4c698406", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/13/37/b2a85900f3d5f518cc7e67151282", - "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7e/4f/2bc692ccdcb53a278ad9b06ddbf1", - "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/38/12/6e9a96f48a7af39f526dcd41ebce", - "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8f/f3/deee23add01a2c2d8bb4b6197366", - "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/83/4d/8bdc0827cf90d2cd09e56a1846ed", - "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4a/55/b93f1eae564c146ca60f1a23b915", - "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e7/fc/58cd588c4aecd56e1ef2bba7b11d", - "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/21/83/f5bcb13224fec91b6139b7ae83ed", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/69/1a/eb5f3c85fc8f8194cc96b19714b3", - "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/27/75/a18262f80729191921e12da1b2dc", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4e/a5/7144c121faf50b2e6cf1db40e281", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/29/08/889f9f0cbd89b692cbcdc0dad96c", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/96/8e/6da028cf907b53fa621cf0275352", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/c3/81/6591a6f11570c598e5dee0d58586", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/ee/f9/e0c13708771197ee7f41db988d19", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/a2/66/c5433ea1cbd812a532d23895379d", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/c9/21/154dae08aceb0c162c1ba9580ceb", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/74/c9/fd45708e613a27dcf3782b3d9dfe", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/e1/8e/f5a16f655ae1f2b075e80fb3a981", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/02/73/2dd954ea8a85a542ce900047ab6c", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c2/cb/1e9b2d26994e9dcd55d1df152b19", + "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/4a/ae/c8878226f4a2d507f4ff5f377859", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/18/0f/9abd66eae1925271ab132163f2e0", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/54/c0/bb411385e3aefb55ca3fb4150e60", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/3c/61/37d143c8b14fb05990c0b8bc8f52", + "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/f6/61/3958823929bcf2cdd9ca694d0ad7", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d5/73/b714b3e9a36076dee085fcdc7db2", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fc/42/8ad2896d59013850516d54f49b7d", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d1/7c/c554ffc1f8c71bc08d4b025ccf4e", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/48/a9/94778472d1c43f556fee5e93c0ab", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/aa/f1/1c36c23d4d5bd6516adddc206514", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/af/76/63cfa6cc0915d35583bcaf30a2e0", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/2f/bb/8bfbea820878f58c5cb9cc702ff0", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/4b/06/d72c7d9965890905dd3291c7f2c6", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c1/02/c9cfaf45b9003df94a2a8e277075", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/4c/47/a66e6ce399dc00ade26e761f876f", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b4/a4/6c844726fc0fb13925622b754cc9", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/4b/39/91b9746101e23fd615424b1721e5", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/31/07/5e49d34cd8bc204fb38e920f133c", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/6d/b1/6c593726c41a32066ba34ccf2ff5", + "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/81/60/37044e17e52ca125c1d48af83d03", + "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fb/47/d505c3feea40888985dd335dc8c4", + "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4f/3d/20c78e744ac26a13b7418166d675", + "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e3/77/67a1fafff2c1918b1661b71ecaa0", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9b/00/f11d8f7f79c9b692b84f6dbd54dc", + "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f8/3a/0cd5030cbe13f99bf23d05ee6cfb", + "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5b/2a/3be2a55cbd63f9c42618c4013c87", + "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/09/ef/8fbfc6032e6a6089215c3dc365a1", + "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f8/79/31ecc50de3e52c55a1569b8b9438", + "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8a/a0/3ef54e3c6c3c777f8a221da16c14", + "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ee/a8/07c5e78d027bfc1acc88a25932b4", + "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ec/f5/a161f6c194a64f371e35e31bbfca", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/56/45/b6b9259f447f19ef0643b972bc64", + "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3b/79/592c41691e94807d23a783723861", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/13/d9/36f4cf8527494f419db74ae6c78f", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ee/e5/7f0677e6fb8d7cfa169930579712", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/8c/4c/3bb058268312359ad8be98f35d9a", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/0a/09/1708ba819095ed0d708fdf4db96a", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/51/79/b0cccbb7292b56b00a9298d1a22f", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/20/2a/30500076cd30d44260a8365c02b5", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/88/a2/ca9e4011d6fa8b366159838b53a1", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/af/b2/b3a702920a14288ceb1603f1f091", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/70/57/1c725a736ebba2035fe3a3ec64df", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/ba/b8/e952aa9d40f5453db0acd4361f10", "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/7d/3e/229a581cb2454ed856f1d8b564a7", "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/98/12/571b2160d69d42580e8f31fa6a8d" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d9a38ec..8602aef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.7 (build 20825, api 7, 2022-09-12) +### 1.7.7 (build 20829, api 7, 2022-09-12) - Added `ba.app.meta.load_exported_classes()` for loading classes discovered by the meta subsystem cleanly in a background thread. - Improved logging of missing playlist game types. - Some ba.Lstr functionality can now be used in background threads. @@ -24,6 +24,7 @@ - Renamed C++ Media to Assets. - Removed 'scores to beat' list in coop which was only ever functional in limited cases on the Mac version. Perhaps that feature can reappear in a cross-platform way sometime. - Simplified C++ bootstrapping to allocate all globals in one place. +- Renamed C++ Game class to Logic. ### 1.7.6 (build 20687, api 7, 2022-08-11) - Cleaned up da MetaSubsystem code. diff --git a/assets/src/ba_data/python/._bainternal_sources_hash b/assets/src/ba_data/python/._bainternal_sources_hash index 1da66812..0321a786 100644 --- a/assets/src/ba_data/python/._bainternal_sources_hash +++ b/assets/src/ba_data/python/._bainternal_sources_hash @@ -1 +1 @@ -174884230264825984620020844009502663721 \ No newline at end of file +304827393730630459319623179535089986346 \ No newline at end of file diff --git a/assets/src/ba_data/python/ba/_bootstrap.py b/assets/src/ba_data/python/ba/_bootstrap.py index 039c0fcd..fdd14841 100644 --- a/assets/src/ba_data/python/ba/_bootstrap.py +++ b/assets/src/ba_data/python/ba/_bootstrap.py @@ -38,7 +38,7 @@ def bootstrap() -> None: # Give a soft warning if we're being used with a different binary # version than we expect. - expected_build = 20825 + expected_build = 20829 running_build: int = env['build_number'] if running_build != expected_build: print( diff --git a/ballisticacore-cmake/CMakeLists.txt b/ballisticacore-cmake/CMakeLists.txt index 1cc4586d..8311aaf2 100644 --- a/ballisticacore-cmake/CMakeLists.txt +++ b/ballisticacore-cmake/CMakeLists.txt @@ -332,40 +332,6 @@ add_executable(ballisticacore ${BA_SRC_ROOT}/ballistica/dynamics/part.h ${BA_SRC_ROOT}/ballistica/dynamics/rigid_body.cc ${BA_SRC_ROOT}/ballistica/dynamics/rigid_body.h - ${BA_SRC_ROOT}/ballistica/game/client_controller_interface.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection_set.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection_set.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_client.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_client.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_client_udp.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_client_udp.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_host.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_host.h - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_host_udp.cc - ${BA_SRC_ROOT}/ballistica/game/connection/connection_to_host_udp.h - ${BA_SRC_ROOT}/ballistica/game/friend_score_set.h - ${BA_SRC_ROOT}/ballistica/game/game.cc - ${BA_SRC_ROOT}/ballistica/game/game.h - ${BA_SRC_ROOT}/ballistica/game/host_activity.cc - ${BA_SRC_ROOT}/ballistica/game/host_activity.h - ${BA_SRC_ROOT}/ballistica/game/player.cc - ${BA_SRC_ROOT}/ballistica/game/player.h - ${BA_SRC_ROOT}/ballistica/game/player_spec.cc - ${BA_SRC_ROOT}/ballistica/game/player_spec.h - ${BA_SRC_ROOT}/ballistica/game/session/client_session.cc - ${BA_SRC_ROOT}/ballistica/game/session/client_session.h - ${BA_SRC_ROOT}/ballistica/game/session/host_session.cc - ${BA_SRC_ROOT}/ballistica/game/session/host_session.h - ${BA_SRC_ROOT}/ballistica/game/session/net_client_session.cc - ${BA_SRC_ROOT}/ballistica/game/session/net_client_session.h - ${BA_SRC_ROOT}/ballistica/game/session/replay_client_session.cc - ${BA_SRC_ROOT}/ballistica/game/session/replay_client_session.h - ${BA_SRC_ROOT}/ballistica/game/session/session.cc - ${BA_SRC_ROOT}/ballistica/game/session/session.h - ${BA_SRC_ROOT}/ballistica/game/v1_account.cc - ${BA_SRC_ROOT}/ballistica/game/v1_account.h ${BA_SRC_ROOT}/ballistica/generic/base64.cc ${BA_SRC_ROOT}/ballistica/generic/base64.h ${BA_SRC_ROOT}/ballistica/generic/buffer.h @@ -485,6 +451,40 @@ add_executable(ballisticacore ${BA_SRC_ROOT}/ballistica/input/remote_app.cc ${BA_SRC_ROOT}/ballistica/input/remote_app.h ${BA_SRC_ROOT}/ballistica/internal/app_internal.h + ${BA_SRC_ROOT}/ballistica/logic/client_controller_interface.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_set.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_set.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_client.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_client.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_client_udp.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_client_udp.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_host.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_host.h + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_host_udp.cc + ${BA_SRC_ROOT}/ballistica/logic/connection/connection_to_host_udp.h + ${BA_SRC_ROOT}/ballistica/logic/friend_score_set.h + ${BA_SRC_ROOT}/ballistica/logic/host_activity.cc + ${BA_SRC_ROOT}/ballistica/logic/host_activity.h + ${BA_SRC_ROOT}/ballistica/logic/logic.cc + ${BA_SRC_ROOT}/ballistica/logic/logic.h + ${BA_SRC_ROOT}/ballistica/logic/player.cc + ${BA_SRC_ROOT}/ballistica/logic/player.h + ${BA_SRC_ROOT}/ballistica/logic/player_spec.cc + ${BA_SRC_ROOT}/ballistica/logic/player_spec.h + ${BA_SRC_ROOT}/ballistica/logic/session/client_session.cc + ${BA_SRC_ROOT}/ballistica/logic/session/client_session.h + ${BA_SRC_ROOT}/ballistica/logic/session/host_session.cc + ${BA_SRC_ROOT}/ballistica/logic/session/host_session.h + ${BA_SRC_ROOT}/ballistica/logic/session/net_client_session.cc + ${BA_SRC_ROOT}/ballistica/logic/session/net_client_session.h + ${BA_SRC_ROOT}/ballistica/logic/session/replay_client_session.cc + ${BA_SRC_ROOT}/ballistica/logic/session/replay_client_session.h + ${BA_SRC_ROOT}/ballistica/logic/session/session.cc + ${BA_SRC_ROOT}/ballistica/logic/session/session.h + ${BA_SRC_ROOT}/ballistica/logic/v1_account.cc + ${BA_SRC_ROOT}/ballistica/logic/v1_account.h ${BA_SRC_ROOT}/ballistica/math/matrix44f.cc ${BA_SRC_ROOT}/ballistica/math/matrix44f.h ${BA_SRC_ROOT}/ballistica/math/point2d.h diff --git a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj index 504b79cc..ba959b23 100644 --- a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj +++ b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj @@ -323,40 +323,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -476,6 +442,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters index 7e1d56f9..cd16c516 100644 --- a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters +++ b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters @@ -403,108 +403,6 @@ ballistica\dynamics - - ballistica\game - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game - - - ballistica\game - ballistica\generic @@ -862,6 +760,108 @@ ballistica\internal + + ballistica\logic + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic + + + ballistica\logic + ballistica\math @@ -1652,9 +1652,6 @@ - - - @@ -1665,6 +1662,9 @@ + + + diff --git a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj index 303289b0..c6adfba9 100644 --- a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj +++ b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj @@ -318,40 +318,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -471,6 +437,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters index 7e1d56f9..cd16c516 100644 --- a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters +++ b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters @@ -403,108 +403,6 @@ ballistica\dynamics - - ballistica\game - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game\connection - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game\session - - - ballistica\game - - - ballistica\game - ballistica\generic @@ -862,6 +760,108 @@ ballistica\internal + + ballistica\logic + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic\connection + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic\session + + + ballistica\logic + + + ballistica\logic + ballistica\math @@ -1652,9 +1652,6 @@ - - - @@ -1665,6 +1662,9 @@ + + + diff --git a/src/ballistica/app/app_flavor.cc b/src/ballistica/app/app_flavor.cc index 4dfef290..3e085ae3 100644 --- a/src/ballistica/app/app_flavor.cc +++ b/src/ballistica/app/app_flavor.cc @@ -4,11 +4,11 @@ #include "ballistica/app/stress_test.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/graphics_server.h" #include "ballistica/graphics/renderer.h" #include "ballistica/input/device/touch_input.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/network_reader.h" #include "ballistica/networking/networking.h" #include "ballistica/networking/telnet_server.h" @@ -196,7 +196,7 @@ void AppFlavor::OnResume() { // Also let the Python layer do what it needs to // (starting/stopping music, etc.). g_python->PushObjCall(Python::ObjID::kHandleAppResumeCall); - g_game->PushOnAppResumeCall(); + g_logic->PushOnAppResumeCall(); g_graphics->SetGyroEnabled(true); @@ -211,7 +211,7 @@ void AppFlavor::OnResume() { // If we've been completely backgrounded, // send a menu-press command to the game; this will // bring up a pause menu if we're in the game/etc. - g_game->PushMainMenuPressCall(nullptr); + g_logic->PushMainMenuPressCall(nullptr); } } diff --git a/src/ballistica/app/app_flavor_vr.cc b/src/ballistica/app/app_flavor_vr.cc index 129d8b51..4fa5f7a6 100644 --- a/src/ballistica/app/app_flavor_vr.cc +++ b/src/ballistica/app/app_flavor_vr.cc @@ -4,9 +4,9 @@ #include "ballistica/app/app_flavor_vr.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/graphics_server.h" #include "ballistica/graphics/renderer.h" +#include "ballistica/logic/logic.h" namespace ballistica { @@ -87,7 +87,7 @@ auto AppFlavorVR::VRSetHands(const VRHandsState& state) -> void { renderer->VRSetHands(state); // ALSO ship it off to the game/ui thread to actually handle input from it. - g_game->PushVRHandsState(state); + g_logic->PushVRHandsState(state); } auto AppFlavorVR::VRDrawEye(int eye, float yaw, float pitch, float roll, diff --git a/src/ballistica/app/stress_test.cc b/src/ballistica/app/stress_test.cc index d7f22d39..dd63eb23 100644 --- a/src/ballistica/app/stress_test.cc +++ b/src/ballistica/app/stress_test.cc @@ -82,7 +82,7 @@ void StressTest::Update() { texture_count = g_assets->total_texture_count(); sound_count = g_assets->total_sound_count(); } - assert(g_game); + assert(g_logic); std::string mem_usage = g_platform->GetMemUsageInfo(); fprintf(stress_test_stats_file_, "%d,%.1f,%d,%d,%d,%d,%d,%s\n", static_cast_check_fit(GetRealTime()), avg, node_count, diff --git a/src/ballistica/assets/assets.cc b/src/ballistica/assets/assets.cc index 734e59e3..9393e7a8 100644 --- a/src/ballistica/assets/assets.cc +++ b/src/ballistica/assets/assets.cc @@ -14,10 +14,10 @@ #include "ballistica/assets/data/sound_data.h" #include "ballistica/audio/audio_server.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/generic/timer.h" #include "ballistica/graphics/graphics_server.h" #include "ballistica/graphics/text/text_packer.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python_sys.h" namespace ballistica { @@ -813,8 +813,8 @@ auto Assets::RunPendingLoadList(std::vector*>* c_list) -> bool { // if we dumped anything on the pending loads done list, shake the game thread // to tell it to kill the reference.. if (!l_finished.empty()) { - assert(g_game); - g_game->PushHavePendingLoadsDoneCall(); + assert(g_logic); + g_logic->PushHavePendingLoadsDoneCall(); } return (!l.empty()); } @@ -1186,7 +1186,7 @@ void Assets::AddPendingLoad(Object::Ref* c) { std::scoped_lock lock(pending_load_list_mutex_); pending_loads_other_.push_back(c); } - g_game->PushHavePendingLoadsCall(); + g_logic->PushHavePendingLoadsCall(); break; } } diff --git a/src/ballistica/audio/audio_server.cc b/src/ballistica/audio/audio_server.cc index e6abaca9..074ee8d4 100644 --- a/src/ballistica/audio/audio_server.cc +++ b/src/ballistica/audio/audio_server.cc @@ -11,8 +11,8 @@ #include "ballistica/audio/audio_streamer.h" #include "ballistica/audio/ogg_stream.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/generic/timer.h" +#include "ballistica/logic/logic.h" #include "ballistica/math/vector3f.h" // Need to move away from OpenAL on Apple stuff. @@ -1114,7 +1114,7 @@ void AudioServer::PushComponentUnloadCall( } // ...and then ship these pointers back to the game thread, so it can free // the references. - g_game->PushFreeAssetComponentRefsCall(components); + g_logic->PushFreeAssetComponentRefsCall(components); }); } @@ -1131,7 +1131,8 @@ void AudioServer::AddSoundRefDelete(const Object::Ref* c) { sound_ref_delete_list_.push_back(c); } // Now push a call to the game thread to do the deletes. - g_game->thread()->PushCall([] { g_audio_server->ClearSoundRefDeleteList(); }); + g_logic->thread()->PushCall( + [] { g_audio_server->ClearSoundRefDeleteList(); }); } void AudioServer::ClearSoundRefDeleteList() { diff --git a/src/ballistica/audio/audio_server.h b/src/ballistica/audio/audio_server.h index 026bda6a..4b9bad0c 100644 --- a/src/ballistica/audio/audio_server.h +++ b/src/ballistica/audio/audio_server.h @@ -40,7 +40,7 @@ class AudioServer { auto PushComponentUnloadCall( const std::vector*>& components) -> void; - /// For use by g_game_module(). + /// For use by g_logic_module(). auto ClearSoundRefDeleteList() -> void; auto paused() const -> bool { return paused_; } diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index 3d2efe3a..6e2515fe 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -16,11 +16,11 @@ #include "ballistica/core/thread.h" #include "ballistica/dynamics/bg/bg_dynamics.h" #include "ballistica/dynamics/bg/bg_dynamics_server.h" -#include "ballistica/game/v1_account.h" #include "ballistica/graphics/graphics_server.h" #include "ballistica/graphics/text/text_graphics.h" #include "ballistica/input/input.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/networking.h" #include "ballistica/platform/platform.h" @@ -32,7 +32,7 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20825; +const int kAppBuildNumber = 20829; const char* kAppVersion = "1.7.7"; // Our standalone globals. @@ -50,7 +50,7 @@ AudioServer* g_audio_server{}; BGDynamics* g_bg_dynamics{}; BGDynamicsServer* g_bg_dynamics_server{}; Context* g_context{}; -Game* g_game{}; +Logic* g_logic{}; Graphics* g_graphics{}; GraphicsServer* g_graphics_server{}; Input* g_input{}; @@ -129,7 +129,7 @@ auto BallisticaMain(int argc, char** argv) -> int { g_network_writer = new NetworkWriter(); g_input = new Input(); g_app_internal = CreateAppInternal(); - g_game = new Game(); + g_logic = new Logic(); Scene::Init(); if (!HeadlessMode()) { g_bg_dynamics = new BGDynamics(); @@ -146,7 +146,7 @@ auto BallisticaMain(int argc, char** argv) -> int { // Phase 2: Set things in motion. // ------------------------------------------------------------------------- - g_game->OnAppStart(); + g_logic->OnAppStart(); g_audio_server->OnAppStart(); g_assets_server->OnAppStart(); g_platform->OnAppStart(); @@ -156,7 +156,7 @@ auto BallisticaMain(int argc, char** argv) -> int { } // Ok; now that we're bootstrapped, tell the game thread to read and apply // the config which should kick off the real action. - g_game->PushApplyConfigCall(); + g_logic->PushApplyConfigCall(); // ------------------------------------------------------------------------- // Phase 3/4: Create a screen and/or kick off game (in other threads). @@ -263,7 +263,7 @@ auto GetAppInstanceUUID() -> const std::string& { } auto InLogicThread() -> bool { - return (g_game && g_game->thread()->IsCurrent()); + return (g_logic && g_logic->thread()->IsCurrent()); } auto InMainThread() -> bool { @@ -297,10 +297,10 @@ auto Log(const std::string& msg, bool to_stdout, bool to_server) -> void { auto IsVRMode() -> bool { return g_app->vr_mode; } void ScreenMessage(const std::string& s, const Vector3f& color) { - if (g_game) { - g_game->PushScreenMessage(s, color); + if (g_logic) { + g_logic->PushScreenMessage(s, color); } else { - Log("ScreenMessage before g_game init (will be lost): '" + s + "'"); + Log("ScreenMessage before g_logic init (will be lost): '" + s + "'"); } } diff --git a/src/ballistica/ballistica.h b/src/ballistica/ballistica.h index ddba4f1c..f68705fb 100644 --- a/src/ballistica/ballistica.h +++ b/src/ballistica/ballistica.h @@ -113,10 +113,10 @@ extern AudioServer* g_audio_server; extern BGDynamics* g_bg_dynamics; extern BGDynamicsServer* g_bg_dynamics_server; extern Context* g_context; -extern Game* g_game; extern Graphics* g_graphics; extern GraphicsServer* g_graphics_server; extern Input* g_input; +extern Logic* g_logic; extern Thread* g_main_thread; extern Assets* g_assets; extern AssetsServer* g_assets_server; diff --git a/src/ballistica/core/context.cc b/src/ballistica/core/context.cc index 6b6da3fb..632f9f1b 100644 --- a/src/ballistica/core/context.cc +++ b/src/ballistica/core/context.cc @@ -2,8 +2,8 @@ #include "ballistica/core/context.h" -#include "ballistica/game/host_activity.h" #include "ballistica/generic/runnable.h" +#include "ballistica/logic/host_activity.h" #include "ballistica/ui/ui.h" namespace ballistica { diff --git a/src/ballistica/core/logging.cc b/src/ballistica/core/logging.cc index 5635ceb4..69a892b9 100644 --- a/src/ballistica/core/logging.cc +++ b/src/ballistica/core/logging.cc @@ -5,8 +5,8 @@ #include #include "ballistica/app/app.h" -#include "ballistica/game/game.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/telnet_server.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" @@ -16,8 +16,8 @@ namespace ballistica { static void PrintCommon(const std::string& s) { // Print to in-game console. { - if (g_game != nullptr) { - g_game->PushConsolePrintCall(s); + if (g_logic != nullptr) { + g_logic->PushConsolePrintCall(s); } else { if (g_platform != nullptr) { g_platform->HandleLog( diff --git a/src/ballistica/core/types.h b/src/ballistica/core/types.h index 154bfe9a..ab64b1d2 100644 --- a/src/ballistica/core/types.h +++ b/src/ballistica/core/types.h @@ -81,7 +81,6 @@ class DataData; class Dynamics; class FrameDef; struct FriendScoreSet; -class Game; class GLContext; class GlobalsNode; class Graphics; @@ -97,6 +96,7 @@ struct JointFixedEF; class Joystick; class JsonDict; class KeyboardInput; +class Logic; class Material; class MaterialAction; class MaterialComponent; diff --git a/src/ballistica/dynamics/bg/bg_dynamics_server.cc b/src/ballistica/dynamics/bg/bg_dynamics_server.cc index 1da1bf9b..c77d3369 100644 --- a/src/ballistica/dynamics/bg/bg_dynamics_server.cc +++ b/src/ballistica/dynamics/bg/bg_dynamics_server.cc @@ -10,9 +10,9 @@ #include "ballistica/dynamics/bg/bg_dynamics_shadow_data.h" #include "ballistica/dynamics/bg/bg_dynamics_volume_light_data.h" #include "ballistica/dynamics/collision_cache.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/graphics_server.h" +#include "ballistica/logic/logic.h" namespace ballistica { @@ -87,7 +87,7 @@ class BGDynamicsServer::Terrain { // back to the main thread to get freed. if (collide_model_) { Object::Ref* ref = collide_model_; - g_game->thread()->PushCall([ref] { + g_logic->thread()->PushCall([ref] { (**ref).set_last_used_time(GetRealTime()); delete ref; }); @@ -2315,7 +2315,7 @@ void BGDynamicsServer::Step(StepData* step_data) { // Now generate a snapshot of our state and send it to the game thread, // so they can draw us. BGDynamicsDrawSnapshot* snapshot = CreateDrawSnapshot(); - g_game->thread()->PushCall([snapshot] { + g_logic->thread()->PushCall([snapshot] { snapshot->SetLogicThreadOwnership(); g_bg_dynamics->SetDrawSnapshot(snapshot); }); diff --git a/src/ballistica/dynamics/material/impact_sound_material_action.cc b/src/ballistica/dynamics/material/impact_sound_material_action.cc index b0eb9871..fd4952a4 100644 --- a/src/ballistica/dynamics/material/impact_sound_material_action.cc +++ b/src/ballistica/dynamics/material/impact_sound_material_action.cc @@ -4,9 +4,9 @@ #include "ballistica/dynamics/dynamics.h" #include "ballistica/dynamics/material/material_context.h" -#include "ballistica/game/session/client_session.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/graphics_server.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/scene/scene_stream.h" namespace ballistica { diff --git a/src/ballistica/dynamics/material/material_condition_node.cc b/src/ballistica/dynamics/material/material_condition_node.cc index 6fb5a663..6053ffbf 100644 --- a/src/ballistica/dynamics/material/material_condition_node.cc +++ b/src/ballistica/dynamics/material/material_condition_node.cc @@ -3,8 +3,8 @@ #include "ballistica/dynamics/material/material_condition_node.h" #include "ballistica/dynamics/material/material.h" -#include "ballistica/game/session/client_session.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/scene/scene_stream.h" namespace ballistica { diff --git a/src/ballistica/dynamics/material/roll_sound_material_action.cc b/src/ballistica/dynamics/material/roll_sound_material_action.cc index b9969a3b..363e9492 100644 --- a/src/ballistica/dynamics/material/roll_sound_material_action.cc +++ b/src/ballistica/dynamics/material/roll_sound_material_action.cc @@ -5,9 +5,9 @@ #include "ballistica/assets/component/sound.h" #include "ballistica/dynamics/dynamics.h" #include "ballistica/dynamics/material/material_context.h" -#include "ballistica/game/session/client_session.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/graphics_server.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/scene/scene_stream.h" namespace ballistica { diff --git a/src/ballistica/dynamics/material/skid_sound_material_action.cc b/src/ballistica/dynamics/material/skid_sound_material_action.cc index 652bfe29..838e3b7f 100644 --- a/src/ballistica/dynamics/material/skid_sound_material_action.cc +++ b/src/ballistica/dynamics/material/skid_sound_material_action.cc @@ -4,9 +4,9 @@ #include "ballistica/dynamics/dynamics.h" #include "ballistica/dynamics/material/material_context.h" -#include "ballistica/game/session/client_session.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/graphics_server.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/scene/scene_stream.h" namespace ballistica { diff --git a/src/ballistica/dynamics/material/sound_material_action.cc b/src/ballistica/dynamics/material/sound_material_action.cc index 9b9221b0..30d12696 100644 --- a/src/ballistica/dynamics/material/sound_material_action.cc +++ b/src/ballistica/dynamics/material/sound_material_action.cc @@ -3,8 +3,8 @@ #include "ballistica/dynamics/material/sound_material_action.h" #include "ballistica/dynamics/material/material_context.h" -#include "ballistica/game/session/client_session.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/scene/scene_stream.h" namespace ballistica { diff --git a/src/ballistica/dynamics/part.h b/src/ballistica/dynamics/part.h index b0bc494f..042ab6d1 100644 --- a/src/ballistica/dynamics/part.h +++ b/src/ballistica/dynamics/part.h @@ -71,7 +71,7 @@ class Part : public Object { // node/part combo. auto IsCollidingWith(int64_t node, int part) const -> bool; - // Used by g_game to inform us we're now colliding with another part + // Used by g_logic to inform us we're now colliding with another part // if colliding is false, we've stopped colliding with this part. void SetCollidingWith(int64_t node_id, int part, bool colliding, bool physical); diff --git a/src/ballistica/generic/real_timer.h b/src/ballistica/generic/real_timer.h index d59d23b4..88ce26f4 100644 --- a/src/ballistica/generic/real_timer.h +++ b/src/ballistica/generic/real_timer.h @@ -5,8 +5,8 @@ #include "ballistica/ballistica.h" #include "ballistica/core/object.h" -#include "ballistica/game/game.h" #include "ballistica/generic/runnable.h" +#include "ballistica/logic/logic.h" namespace ballistica { @@ -16,18 +16,18 @@ template class RealTimer : public Object { public: RealTimer(millisecs_t length, bool repeat, T* delegate) { - assert(g_game); + assert(g_logic); assert(InLogicThread()); - timer_id_ = g_game->NewRealTimer( + timer_id_ = g_logic->NewRealTimer( length, repeat, Object::New(delegate, this)); } void SetLength(uint32_t length) { assert(InLogicThread()); - g_game->SetRealTimerLength(timer_id_, length); + g_logic->SetRealTimerLength(timer_id_, length); } ~RealTimer() override { assert(InLogicThread()); - g_game->DeleteRealTimer(timer_id_); + g_logic->DeleteRealTimer(timer_id_); } private: diff --git a/src/ballistica/graphics/graphics.cc b/src/ballistica/graphics/graphics.cc index ca13b656..ac573e62 100644 --- a/src/ballistica/graphics/graphics.cc +++ b/src/ballistica/graphics/graphics.cc @@ -5,10 +5,6 @@ #include "ballistica/app/app.h" #include "ballistica/app/app_flavor.h" #include "ballistica/dynamics/bg/bg_dynamics.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client.h" -#include "ballistica/game/connection/connection_to_host.h" -#include "ballistica/game/session/session.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/component/empty_component.h" @@ -22,6 +18,10 @@ #include "ballistica/graphics/net_graph.h" #include "ballistica/graphics/text/text_graphics.h" #include "ballistica/input/input.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client.h" +#include "ballistica/logic/connection/connection_to_host.h" +#include "ballistica/logic/session/session.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" #include "ballistica/scene/node/globals_node.h" @@ -293,7 +293,7 @@ void Graphics::DrawMiscOverlays(RenderPass* pass) { // Add in/out data for any host connection. if (ConnectionToHost* connection_to_host = - g_game->connections()->connection_to_host()) { + g_logic->connections()->connection_to_host()) { if (connection_to_host->can_communicate()) show = true; in_size += connection_to_host->GetBytesInPerSecond(); in_size_compressed += connection_to_host->GetBytesInPerSecondCompressed(); @@ -307,7 +307,7 @@ void Graphics::DrawMiscOverlays(RenderPass* pass) { ping = connection_to_host->average_ping(); } else { int connected_count = 0; - for (auto&& i : g_game->connections()->connections_to_clients()) { + for (auto&& i : g_logic->connections()->connections_to_clients()) { ConnectionToClient* client = i.second.get(); if (client->can_communicate()) { show = true; @@ -879,7 +879,7 @@ void Graphics::FadeScreen(bool to, millisecs_t time, PyObject* endcall) { if (g_buildconfig.debug_build()) { Log("WARNING: 2 fades overlapping; running first fade-end-call early"); } - g_game->PushPythonCall(fade_end_call_); + g_logic->PushPythonCall(fade_end_call_); fade_end_call_.Clear(); } set_fade_start_on_next_draw_ = true; @@ -991,17 +991,17 @@ void Graphics::BuildAndPushFrameDef() { // We should not be building/pushing any frames until after // app-launch-commands have been run.. - BA_PRECONDITION_FATAL(g_game->ran_app_launch_commands()); + BA_PRECONDITION_FATAL(g_logic->ran_app_launch_commands()); // This should no longer be necessary.. WaitForRendererToExist(); - Session* session = g_game->GetForegroundSession(); + Session* session = g_logic->GetForegroundSession(); bool session_fills_screen = session ? session->DoesFillScreen() : false; millisecs_t real_time = GetRealTime(); // Store how much time this frame_def represents. - millisecs_t net_time = g_game->master_time(); + millisecs_t net_time = g_logic->master_time(); millisecs_t elapsed = std::min(millisecs_t{50}, net_time - last_create_frame_def_time_); last_create_frame_def_time_ = net_time; @@ -1010,7 +1010,7 @@ void Graphics::BuildAndPushFrameDef() { FrameDef* frame_def = GetEmptyFrameDef(); frame_def->set_real_time(real_time); - frame_def->set_base_time(g_game->master_time()); + frame_def->set_base_time(g_logic->master_time()); frame_def->set_base_time_elapsed(elapsed); frame_def->set_frame_number(frame_def_count_++); @@ -1238,7 +1238,7 @@ void Graphics::DrawFades(FrameDef* frame_def, millisecs_t real_time) { } else { fade_ = 0; if (!was_done && fade_end_call_.exists()) { - g_game->PushPythonCall(fade_end_call_); + g_logic->PushPythonCall(fade_end_call_); fade_end_call_.Clear(); } } @@ -1801,7 +1801,7 @@ void Graphics::ScreenResize(float virtual_width, float virtual_height, void Graphics::ScreenMessageEntry::UpdateTranslation() { if (translation_dirty) { - s_translated = g_game->CompileResourceString( + s_translated = g_logic->CompileResourceString( s_raw, "Graphics::ScreenMessageEntry::UpdateTranslation"); translation_dirty = false; mesh_dirty = true; diff --git a/src/ballistica/graphics/graphics_server.cc b/src/ballistica/graphics/graphics_server.cc index 81dcdc78..9cabd091 100644 --- a/src/ballistica/graphics/graphics_server.cc +++ b/src/ballistica/graphics/graphics_server.cc @@ -86,7 +86,7 @@ auto GraphicsServer::GetRenderFrameDef() -> FrameDef* { // Tell the game thread we're ready for the next frame_def so it can start // building it while we render this one. - g_game->PushFrameDefRequest(); + g_logic->PushFrameDefRequest(); return frame_def; } @@ -197,7 +197,7 @@ void GraphicsServer::ReloadMedia() { // Now tell the game thread to kick off loads for everything, flip on // progress bar drawing, and then tell the graphics thread to stop ignoring // frame-defs. - g_game->thread()->PushCall([this] { + g_logic->thread()->PushCall([this] { g_assets->MarkAllAssetsForLoad(); g_graphics->EnableProgressBar(false); PushRemoveRenderHoldCall(); @@ -248,7 +248,7 @@ void GraphicsServer::RebuildLostContext() { // Now tell the game thread to kick off loads for everything, flip on progress // bar drawing, and then tell the graphics thread to stop ignoring frame-defs. - g_game->thread()->PushCall([this] { + g_logic->thread()->PushCall([this] { g_assets->MarkAllAssetsForLoad(); g_graphics->EnableProgressBar(false); PushRemoveRenderHoldCall(); @@ -356,7 +356,7 @@ void GraphicsServer::SetScreen(bool fullscreen, int width, int height, // what types of textures to load, etc) if (!initial_screen_created_) { initial_screen_created_ = true; - g_game->PushInitialScreenCreatedCall(); + g_logic->PushInitialScreenCreatedCall(); } } @@ -403,8 +403,8 @@ void GraphicsServer::HandleFullContextScreenRebuild( UpdateVirtualScreenRes(); // Inform the game thread of the latest values. - g_game->PushScreenResizeCall(res_x_virtual_, res_y_virtual_, res_x_, - res_y_); + g_logic->PushScreenResizeCall(res_x_virtual_, res_y_virtual_, res_x_, + res_y_); } if (!renderer_) { @@ -462,7 +462,7 @@ void GraphicsServer::HandleFullContextScreenRebuild( // Now tell the game thread to kick off loads for everything, flip on // progress bar drawing, and then tell the graphics thread to stop ignoring // frame-defs. - g_game->thread()->PushCall([this] { + g_logic->thread()->PushCall([this] { g_assets->MarkAllAssetsForLoad(); g_graphics->set_internal_components_inited(false); g_graphics->EnableProgressBar(false); @@ -514,7 +514,7 @@ void GraphicsServer::VideoResize(float h, float v) { UpdateVirtualScreenRes(); // Inform the game thread of the latest values. - g_game->PushScreenResizeCall(res_x_virtual_, res_y_virtual_, res_x_, res_y_); + g_logic->PushScreenResizeCall(res_x_virtual_, res_y_virtual_, res_x_, res_y_); if (renderer_) { renderer_->ScreenSizeChanged(); } @@ -775,7 +775,7 @@ void GraphicsServer::PushComponentUnloadCall( } // ..and then ship these pointers back to the game thread so it can free the // references. - g_game->PushFreeAssetComponentRefsCall(components); + g_logic->PushFreeAssetComponentRefsCall(components); }); } diff --git a/src/ballistica/graphics/vr_graphics.cc b/src/ballistica/graphics/vr_graphics.cc index 8bf2a90b..30aa4514 100644 --- a/src/ballistica/graphics/vr_graphics.cc +++ b/src/ballistica/graphics/vr_graphics.cc @@ -4,13 +4,13 @@ #include "ballistica/graphics/vr_graphics.h" #include "ballistica/app/app.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/component/object_component.h" #include "ballistica/graphics/component/simple_component.h" #include "ballistica/graphics/component/special_component.h" #include "ballistica/graphics/frame_def.h" #include "ballistica/graphics/render_pass.h" +#include "ballistica/logic/logic.h" #include "ballistica/scene/node/globals_node.h" namespace ballistica { @@ -290,7 +290,7 @@ void VRGraphics::DrawVRControllers(FrameDef* frame_def) { } // test right hand - const VRHandsState& s(g_game->vr_hands_state()); + const VRHandsState& s(g_logic->vr_hands_state()); switch (s.r.type) { case VRHandType::kOculusTouchR: diff --git a/src/ballistica/input/device/client_input_device.cc b/src/ballistica/input/device/client_input_device.cc index 7cd9de43..378292d0 100644 --- a/src/ballistica/input/device/client_input_device.cc +++ b/src/ballistica/input/device/client_input_device.cc @@ -2,8 +2,8 @@ #include "ballistica/input/device/client_input_device.h" -#include "ballistica/game/connection/connection_to_client.h" -#include "ballistica/game/player.h" +#include "ballistica/logic/connection/connection_to_client.h" +#include "ballistica/logic/player.h" #include "ballistica/networking/networking.h" namespace ballistica { diff --git a/src/ballistica/input/device/input_device.cc b/src/ballistica/input/device/input_device.cc index 16926d6f..b1ff66bd 100644 --- a/src/ballistica/input/device/input_device.cc +++ b/src/ballistica/input/device/input_device.cc @@ -6,11 +6,11 @@ #include #include "ballistica/app/app.h" -#include "ballistica/game/connection/connection_to_host.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/host_session.h" -#include "ballistica/game/session/net_client_session.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/connection/connection_to_host.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/host_session.h" +#include "ballistica/logic/session/net_client_session.h" #include "ballistica/networking/networking.h" #include "ballistica/python/class/python_class_input_device.h" #include "ballistica/python/python.h" @@ -109,13 +109,13 @@ auto InputDevice::GetDefaultPlayerName() -> std::string { auto InputDevice::GetButtonName(int id) -> std::string { // By default just say 'button 1' or whatnot. // FIXME: should return this in Lstr json form. - return g_game->GetResourceString("buttonText") + " " + std::to_string(id); + return g_logic->GetResourceString("buttonText") + " " + std::to_string(id); } auto InputDevice::GetAxisName(int id) -> std::string { // By default just return 'axis 5' or whatnot. // FIXME: should return this in Lstr json form. - return g_game->GetResourceString("axisText") + " " + std::to_string(id); + return g_logic->GetResourceString("axisText") + " " + std::to_string(id); } auto InputDevice::HasMeaningfulButtonNames() -> bool { return false; } @@ -207,7 +207,7 @@ void InputDevice::RequestPlayer() { assert(InLogicThread()); // Make note that we're being used in some way. - last_input_time_ = g_game->master_time(); + last_input_time_ = g_logic->master_time(); if (player_.exists()) { Log("Error: InputDevice::RequestPlayer()" @@ -222,14 +222,14 @@ void InputDevice::RequestPlayer() { // If we have a local host-session, ask it for a player.. otherwise if we have // a client-session, ask it for a player. - assert(g_game); - if (auto* hs = dynamic_cast(g_game->GetForegroundSession())) { + assert(g_logic); + if (auto* hs = dynamic_cast(g_logic->GetForegroundSession())) { { Python::ScopedCallLabel label("requestPlayer"); hs->RequestPlayer(this); } } else if (auto* client_session = dynamic_cast( - g_game->GetForegroundSession())) { + g_logic->GetForegroundSession())) { if (ConnectionToHost* connection_to_host = client_session->connection_to_host()) { std::vector data(2); @@ -270,7 +270,7 @@ void InputDevice::Update() { void InputDevice::UpdateLastInputTime() { // Keep our own individual time, and also let // the overall input system know something happened. - last_input_time_ = g_game->master_time(); + last_input_time_ = g_logic->master_time(); g_input->mark_input_active(); } diff --git a/src/ballistica/input/device/joystick.cc b/src/ballistica/input/device/joystick.cc index 292c1c01..5ee52393 100644 --- a/src/ballistica/input/device/joystick.cc +++ b/src/ballistica/input/device/joystick.cc @@ -6,9 +6,9 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/audio/audio.h" #include "ballistica/core/thread.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/player.h" #include "ballistica/graphics/renderer.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/player.h" #include "ballistica/python/python.h" #include "ballistica/python/python_command.h" #include "ballistica/ui/root_ui.h" @@ -183,13 +183,13 @@ auto Joystick::GetButtonName(int index) -> std::string { if (strstr(GetDeviceName().c_str(), "Samsung Game Pad EI")) { switch (index) { case 101: - return g_game->CharStr(SpecialChar::kDiceButton4); // Y + return g_logic->CharStr(SpecialChar::kDiceButton4); // Y case 100: - return g_game->CharStr(SpecialChar::kDiceButton3); // X + return g_logic->CharStr(SpecialChar::kDiceButton3); // X case 98: - return g_game->CharStr(SpecialChar::kDiceButton2); // B + return g_logic->CharStr(SpecialChar::kDiceButton2); // B case 97: - return g_game->CharStr(SpecialChar::kDiceButton1); // A + return g_logic->CharStr(SpecialChar::kDiceButton1); // A default: break; } @@ -272,13 +272,13 @@ auto Joystick::GetButtonName(int index) -> std::string { case 204: return "B16"; case 90: - return g_game->CharStr(SpecialChar::kRewindButton); + return g_logic->CharStr(SpecialChar::kRewindButton); case 91: - return g_game->CharStr(SpecialChar::kFastForwardButton); + return g_logic->CharStr(SpecialChar::kFastForwardButton); case 24: - return g_game->CharStr(SpecialChar::kDpadCenterButton); + return g_logic->CharStr(SpecialChar::kDpadCenterButton); case 86: - return g_game->CharStr(SpecialChar::kPlayPauseButton); + return g_logic->CharStr(SpecialChar::kPlayPauseButton); default: break; } @@ -536,7 +536,7 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) { // If we've got a child joystick, send them any events they're set to handle. if (child_joy_stick_) { - assert(g_game); + assert(g_logic); bool send = false; switch (e->type) { @@ -762,14 +762,14 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) { } else { // If there's no menu up, // tell the game to pop it up and snag menu ownership for ourself. - g_game->PushMainMenuPressCall(this); + g_logic->PushMainMenuPressCall(this); return; } } // On our oculus build, select presses reset the orientation. if (e->jbutton.button == vr_reorient_button_ && IsVRMode()) { - ScreenMessage(g_game->GetResourceString("vrOrientationResetText"), + ScreenMessage(g_logic->GetResourceString("vrOrientationResetText"), {0, 1, 0}); g_app->reset_vr_orientation = true; return; @@ -991,8 +991,8 @@ void Joystick::HandleSDLEvent(const SDL_Event* e) { } else { // FIXME: Need a call we can make for this. bool do_party_button = false; - int party_size = g_game->GetPartySize(); - if (party_size > 1 || g_game->connections()->connection_to_host() + int party_size = g_logic->GetPartySize(); + if (party_size > 1 || g_logic->connections()->connection_to_host() || g_ui->root_ui()->always_draw_party_icon()) { do_party_button = true; } @@ -1533,7 +1533,7 @@ auto Joystick::GetPartyButtonName() const -> std::string { if (g_buildconfig.iircade_build()) { return "X"; } - return g_game->CharStr(SpecialChar::kTopButton); + return g_logic->CharStr(SpecialChar::kTopButton); } } // namespace ballistica diff --git a/src/ballistica/input/device/keyboard_input.cc b/src/ballistica/input/device/keyboard_input.cc index 415578eb..b76c5ee6 100644 --- a/src/ballistica/input/device/keyboard_input.cc +++ b/src/ballistica/input/device/keyboard_input.cc @@ -2,7 +2,7 @@ #include "ballistica/input/device/keyboard_input.h" -#include "ballistica/game/player.h" +#include "ballistica/logic/player.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" #include "ballistica/ui/ui.h" @@ -139,7 +139,7 @@ auto KeyboardInput::HandleKey(const SDL_Keysym* keysym, bool repeat, bool down) // Bring up menu if start is pressed. if (keysym->sym == start_key_ && !repeat && g_ui && g_ui->screen_root_widget() && g_ui->screen_root_widget()->GetChildCount() == 0) { - g_game->PushMainMenuPressCall(this); + g_logic->PushMainMenuPressCall(this); return true; } diff --git a/src/ballistica/input/device/test_input.cc b/src/ballistica/input/device/test_input.cc index d3ad9fc2..40272ee4 100644 --- a/src/ballistica/input/device/test_input.cc +++ b/src/ballistica/input/device/test_input.cc @@ -2,9 +2,9 @@ #include "ballistica/input/device/test_input.h" -#include "ballistica/game/game.h" #include "ballistica/input/device/joystick.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/min_sdl.h" namespace ballistica { diff --git a/src/ballistica/input/device/touch_input.cc b/src/ballistica/input/device/touch_input.cc index a75e1dd6..6ecb4dc7 100644 --- a/src/ballistica/input/device/touch_input.cc +++ b/src/ballistica/input/device/touch_input.cc @@ -4,10 +4,10 @@ #include "ballistica/app/app.h" #include "ballistica/app/app_config.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/player.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/component/simple_component.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/player.h" #include "ballistica/python/python.h" #include "ballistica/scene/node/player_node.h" #include "ballistica/ui/ui.h" @@ -504,12 +504,12 @@ void TouchInput::Draw(FrameDef* frame_def) { // to pull a node for the player we're attached to. if (HostActivity* host_activity = - g_game->GetForegroundContext().GetHostActivity()) { + g_logic->GetForegroundContext().GetHostActivity()) { if (Player* player = GetPlayer()) { player_node = host_activity->scene()->GetPlayerNode(player->id()); } } else { - if (Scene* scene = g_game->GetForegroundScene()) { + if (Scene* scene = g_logic->GetForegroundScene()) { player_node = scene->GetPlayerNode(remote_player_id()); } } @@ -944,8 +944,9 @@ auto TouchInput::HandleTouchDown(void* touch, float x, float y) -> bool { // ..so lets issue a warning to that effect if there's already // controllers active.. (only if we got a player though). if (attached_to_player() && g_input->HaveControllerWithPlayer()) { - ScreenMessage(g_game->GetResourceString("touchScreenJoinWarningText"), - {1.0f, 1.0f, 0.0f}); + ScreenMessage( + g_logic->GetResourceString("touchScreenJoinWarningText"), + {1.0f, 1.0f, 0.0f}); } } } else { diff --git a/src/ballistica/input/input.cc b/src/ballistica/input/input.cc index 5ddd187f..4cbfd4ed 100644 --- a/src/ballistica/input/input.cc +++ b/src/ballistica/input/input.cc @@ -6,12 +6,12 @@ #include "ballistica/app/app_config.h" #include "ballistica/audio/audio.h" #include "ballistica/core/thread.h" -#include "ballistica/game/player.h" #include "ballistica/graphics/camera.h" #include "ballistica/input/device/joystick.h" #include "ballistica/input/device/keyboard_input.h" #include "ballistica/input/device/test_input.h" #include "ballistica/input/device/touch_input.h" +#include "ballistica/logic/player.h" #include "ballistica/python/python.h" #include "ballistica/ui/console.h" #include "ballistica/ui/root_ui.h" @@ -321,7 +321,7 @@ static const char* const scancode_names[SDL_NUM_SCANCODES] = { Input::Input() {} void Input::PushCreateKeyboardInputDevices() { - g_game->thread()->PushCall([this] { CreateKeyboardInputDevices(); }); + g_logic->thread()->PushCall([this] { CreateKeyboardInputDevices(); }); } void Input::CreateKeyboardInputDevices() { @@ -337,7 +337,7 @@ void Input::CreateKeyboardInputDevices() { } void Input::PushDestroyKeyboardInputDevices() { - g_game->thread()->PushCall([this] { DestroyKeyboardInputDevices(); }); + g_logic->thread()->PushCall([this] { DestroyKeyboardInputDevices(); }); } void Input::DestroyKeyboardInputDevices() { @@ -460,25 +460,25 @@ void Input::AnnounceConnects() { // If there's been several connected, just give a number. if (explicit_bool(do_print)) { if (newly_connected_controllers_.size() > 1) { - std::string s = g_game->GetResourceString("controllersDetectedText"); + std::string s = g_logic->GetResourceString("controllersDetectedText"); Utils::StringReplaceOne( &s, "${COUNT}", std::to_string(newly_connected_controllers_.size())); ScreenMessage(s); } else { - ScreenMessage(g_game->GetResourceString("controllerDetectedText")); + ScreenMessage(g_logic->GetResourceString("controllerDetectedText")); } } } else { // If there's been several connected, just give a number. if (newly_connected_controllers_.size() > 1) { - std::string s = g_game->GetResourceString("controllersConnectedText"); + std::string s = g_logic->GetResourceString("controllersConnectedText"); Utils::StringReplaceOne( &s, "${COUNT}", std::to_string(newly_connected_controllers_.size())); ScreenMessage(s); } else { // If its just one, name it. - std::string s = g_game->GetResourceString("controllerConnectedText"); + std::string s = g_logic->GetResourceString("controllerConnectedText"); Utils::StringReplaceOne(&s, "${CONTROLLER}", newly_connected_controllers_.front()); ScreenMessage(s); @@ -492,13 +492,13 @@ void Input::AnnounceConnects() { void Input::AnnounceDisconnects() { // If there's been several connected, just give a number. if (newly_disconnected_controllers_.size() > 1) { - std::string s = g_game->GetResourceString("controllersDisconnectedText"); + std::string s = g_logic->GetResourceString("controllersDisconnectedText"); Utils::StringReplaceOne( &s, "${COUNT}", std::to_string(newly_disconnected_controllers_.size())); ScreenMessage(s); } else { // If its just one, name it. - std::string s = g_game->GetResourceString("controllerDisconnectedText"); + std::string s = g_logic->GetResourceString("controllerDisconnectedText"); Utils::StringReplaceOne(&s, "${CONTROLLER}", newly_disconnected_controllers_.front()); ScreenMessage(s); @@ -520,9 +520,9 @@ void Input::ShowStandardInputDeviceConnectedMessage(InputDevice* j) { // Set a timer to go off and announce the accumulated additions. if (connect_print_timer_id_ != 0) { - g_game->DeleteRealTimer(connect_print_timer_id_); + g_logic->DeleteRealTimer(connect_print_timer_id_); } - connect_print_timer_id_ = g_game->NewRealTimer( + connect_print_timer_id_ = g_logic->NewRealTimer( 250, false, NewLambdaRunnable([this] { AnnounceConnects(); })); } @@ -535,15 +535,15 @@ void Input::ShowStandardInputDeviceDisconnectedMessage(InputDevice* j) { // Set a timer to go off and announce the accumulated additions. if (disconnect_print_timer_id_ != 0) { - g_game->DeleteRealTimer(disconnect_print_timer_id_); + g_logic->DeleteRealTimer(disconnect_print_timer_id_); } - disconnect_print_timer_id_ = g_game->NewRealTimer( + disconnect_print_timer_id_ = g_logic->NewRealTimer( 250, false, NewLambdaRunnable([this] { AnnounceDisconnects(); })); } void Input::PushAddInputDeviceCall(InputDevice* input_device, bool standard_message) { - g_game->thread()->PushCall([this, input_device, standard_message] { + g_logic->thread()->PushCall([this, input_device, standard_message] { AddInputDevice(input_device, standard_message); }); } @@ -605,7 +605,7 @@ void Input::AddInputDevice(InputDevice* input, bool standard_message) { void Input::PushRemoveInputDeviceCall(InputDevice* input_device, bool standard_message) { - g_game->thread()->PushCall([this, input_device, standard_message] { + g_logic->thread()->PushCall([this, input_device, standard_message] { RemoveInputDevice(input_device, standard_message); }); } @@ -636,8 +636,8 @@ void Input::RemoveInputDevice(InputDevice* input, bool standard_message) { // a call to do it; otherwise its possible that someone tries // to access the player's inputdevice before the call goes // through which would lead to an exception. - g_game->RemovePlayer(input->GetPlayer()); - // g_game->PushRemovePlayerCall(input->GetPlayer()); + g_logic->RemovePlayer(input->GetPlayer()); + // g_logic->PushRemovePlayerCall(input->GetPlayer()); } if (input->GetRemotePlayer() != nullptr) { input->RemoveRemotePlayerFromGame(); @@ -672,7 +672,7 @@ void Input::UpdateInputDeviceCounts() { if (input_device.exists() && ((*input_device).IsTouchScreen() || (*input_device).IsKeyboard() || ((*input_device).last_input_time() != 0 - && g_game->master_time() - (*input_device).last_input_time() + && g_logic->master_time() - (*input_device).last_input_time() < 60000))) { total++; if (!(*input_device).IsTouchScreen()) { @@ -703,7 +703,7 @@ auto Input::GetLocalActiveInputDeviceCount() -> int { assert(InLogicThread()); // This can get called alot so lets cache the value. - millisecs_t current_time = g_game->master_time(); + millisecs_t current_time = g_logic->master_time(); if (current_time != last_get_local_active_input_device_count_check_time_) { last_get_local_active_input_device_count_check_time_ = current_time; @@ -715,7 +715,7 @@ auto Input::GetLocalActiveInputDeviceCount() -> int { && !input_device->IsTouchScreen() && !input_device->IsUIOnly() && input_device->IsLocal() && (input_device->last_input_time() != 0 - && g_game->master_time() - input_device->last_input_time() + && g_logic->master_time() - input_device->last_input_time() < 60000)) { count++; } @@ -1061,7 +1061,7 @@ void Input::HandleBackPress(bool from_toolbar) { // if available). if (g_ui->screen_root_widget()->GetChildCount() == 0 && g_ui->overlay_root_widget()->GetChildCount() == 0) { - g_game->PushMainMenuPressCall(touch_input_); + g_logic->PushMainMenuPressCall(touch_input_); } else { if (from_toolbar) { // NOTE - this means the toolbar back button can never apply to overlay @@ -1076,7 +1076,7 @@ void Input::HandleBackPress(bool from_toolbar) { } void Input::PushTextInputEvent(const std::string& text) { - g_game->thread()->PushCall([this, text] { + g_logic->thread()->PushCall([this, text] { mark_input_active(); // Ignore if input is locked. @@ -1093,7 +1093,7 @@ void Input::PushTextInputEvent(const std::string& text) { auto Input::PushJoystickEvent(const SDL_Event& event, InputDevice* input_device) -> void { - g_game->thread()->PushCall([this, event, input_device] { + g_logic->thread()->PushCall([this, event, input_device] { HandleJoystickEvent(event, input_device); }); } @@ -1125,11 +1125,11 @@ void Input::HandleJoystickEvent(const SDL_Event& event, } void Input::PushKeyPressEvent(const SDL_Keysym& keysym) { - g_game->thread()->PushCall([this, keysym] { HandleKeyPress(&keysym); }); + g_logic->thread()->PushCall([this, keysym] { HandleKeyPress(&keysym); }); } void Input::PushKeyReleaseEvent(const SDL_Keysym& keysym) { - g_game->thread()->PushCall([this, keysym] { HandleKeyRelease(&keysym); }); + g_logic->thread()->PushCall([this, keysym] { HandleKeyRelease(&keysym); }); } void Input::HandleKeyPress(const SDL_Keysym* keysym) { @@ -1194,7 +1194,7 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { // Command-Q or Control-Q quits. if (!repeat_press && keysym->sym == SDLK_q && ((keysym->mod & KMOD_CTRL) || (keysym->mod & KMOD_GUI))) { // NOLINT - g_game->PushConfirmQuitCall(); + g_logic->PushConfirmQuitCall(); return; } } @@ -1223,7 +1223,7 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { // If there's no dialogs/windows up, ask for a menu (owned by the // touch-screen if available). if (g_ui->screen_root_widget()->GetChildCount() == 0) { - g_game->PushMainMenuPressCall(touch_input_); + g_logic->PushMainMenuPressCall(touch_input_); } } handled = true; @@ -1237,12 +1237,12 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { case SDLK_EQUALS: case SDLK_PLUS: - g_game->ChangeGameSpeed(1); + g_logic->ChangeGameSpeed(1); handled = true; break; case SDLK_MINUS: - g_game->ChangeGameSpeed(-1); + g_logic->ChangeGameSpeed(-1); handled = true; break; @@ -1253,12 +1253,12 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { } case SDLK_F7: - g_game->PushToggleManualCameraCall(); + g_logic->PushToggleManualCameraCall(); handled = true; break; case SDLK_F8: - g_game->PushToggleDebugInfoDisplayCall(); + g_logic->PushToggleDebugInfoDisplayCall(); handled = true; break; @@ -1268,7 +1268,7 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { break; case SDLK_F10: - g_game->PushToggleCollisionGeometryDisplayCall(); + g_logic->PushToggleCollisionGeometryDisplayCall(); handled = true; break; @@ -1281,7 +1281,7 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) { if (g_ui->screen_root_widget()->GetChildCount() == 0 && g_ui->overlay_root_widget()->GetChildCount() == 0) { if (keyboard_input_) { - g_game->PushMainMenuPressCall(keyboard_input_); + g_logic->PushMainMenuPressCall(keyboard_input_); } } else { // Ok there's a UI up.. send along a cancel message. @@ -1378,7 +1378,7 @@ auto Input::UpdateModKeyStates(const SDL_Keysym* keysym, bool press) -> void { } auto Input::PushMouseScrollEvent(const Vector2f& amount) -> void { - g_game->thread()->PushCall([this, amount] { HandleMouseScroll(amount); }); + g_logic->thread()->PushCall([this, amount] { HandleMouseScroll(amount); }); } auto Input::HandleMouseScroll(const Vector2f& amount) -> void { @@ -1411,7 +1411,7 @@ auto Input::HandleMouseScroll(const Vector2f& amount) -> void { auto Input::PushSmoothMouseScrollEvent(const Vector2f& velocity, bool momentum) -> void { - g_game->thread()->PushCall([this, velocity, momentum] { + g_logic->thread()->PushCall([this, velocity, momentum] { HandleSmoothMouseScroll(velocity, momentum); }); } @@ -1446,7 +1446,8 @@ auto Input::HandleSmoothMouseScroll(const Vector2f& velocity, bool momentum) } auto Input::PushMouseMotionEvent(const Vector2f& position) -> void { - g_game->thread()->PushCall([this, position] { HandleMouseMotion(position); }); + g_logic->thread()->PushCall( + [this, position] { HandleMouseMotion(position); }); } auto Input::HandleMouseMotion(const Vector2f& position) -> void { @@ -1497,7 +1498,7 @@ auto Input::HandleMouseMotion(const Vector2f& position) -> void { } auto Input::PushMouseDownEvent(int button, const Vector2f& position) -> void { - g_game->thread()->PushCall( + g_logic->thread()->PushCall( [this, button, position] { HandleMouseDown(button, position); }); } @@ -1574,7 +1575,7 @@ auto Input::HandleMouseDown(int button, const Vector2f& position) -> void { } auto Input::PushMouseUpEvent(int button, const Vector2f& position) -> void { - g_game->thread()->PushCall( + g_logic->thread()->PushCall( [this, button, position] { HandleMouseUp(button, position); }); } @@ -1623,7 +1624,7 @@ auto Input::HandleMouseUp(int button, const Vector2f& position) -> void { } void Input::PushTouchEvent(const TouchEvent& e) { - g_game->thread()->PushCall([e, this] { HandleTouchEvent(e); }); + g_logic->thread()->PushCall([e, this] { HandleTouchEvent(e); }); } void Input::HandleTouchEvent(const TouchEvent& e) { diff --git a/src/ballistica/input/remote_app.cc b/src/ballistica/input/remote_app.cc index 28c70dfe..2bac63ec 100644 --- a/src/ballistica/input/remote_app.cc +++ b/src/ballistica/input/remote_app.cc @@ -11,9 +11,9 @@ #include "ballistica/app/app.h" #include "ballistica/assets/assets.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/network_reader.h" #include "ballistica/platform/min_sdl.h" @@ -165,10 +165,10 @@ void RemoteAppServer::HandleData(int socket, uint8_t* buffer, size_t amt, // Replace ${CONTROLLER} with it in our message. std::string s = - g_game->GetResourceString("controllerDisconnectedText"); + g_logic->GetResourceString("controllerDisconnectedText"); Utils::StringReplaceOne(&s, "${CONTROLLER}", m); - g_game->PushScreenMessage(s, Vector3f(1, 1, 1)); - g_game->PushPlaySoundCall(SystemSoundID::kCorkPop); + g_logic->PushScreenMessage(s, Vector3f(1, 1, 1)); + g_logic->PushPlaySoundCall(SystemSoundID::kCorkPop); g_input->PushRemoveInputDeviceCall(client->joystick_, false); client->joystick_ = nullptr; client->in_use = false; @@ -367,10 +367,10 @@ auto RemoteAppServer::GetClient(int request_id, struct sockaddr* addr, snprintf(m, sizeof(m), "%s", clients_[i].display_name); // Replace ${CONTROLLER} with it in our message. - std::string s = g_game->GetResourceString("controllerReconnectedText"); + std::string s = g_logic->GetResourceString("controllerReconnectedText"); Utils::StringReplaceOne(&s, "${CONTROLLER}", m); - g_game->PushScreenMessage(s, Vector3f(1, 1, 1)); - g_game->PushPlaySoundCall(SystemSoundID::kGunCock); + g_logic->PushScreenMessage(s, Vector3f(1, 1, 1)); + g_logic->PushPlaySoundCall(SystemSoundID::kGunCock); } clients_[i].in_use = true; return i; @@ -407,10 +407,10 @@ auto RemoteAppServer::GetClient(int request_id, struct sockaddr* addr, snprintf(m, sizeof(m), "%s", clients_[i].display_name); // Replace ${CONTROLLER} with it in our message. - std::string s = g_game->GetResourceString("controllerConnectedText"); + std::string s = g_logic->GetResourceString("controllerConnectedText"); Utils::StringReplaceOne(&s, "${CONTROLLER}", m); - g_game->PushScreenMessage(s, Vector3f(1, 1, 1)); - g_game->PushPlaySoundCall(SystemSoundID::kGunCock); + g_logic->PushScreenMessage(s, Vector3f(1, 1, 1)); + g_logic->PushPlaySoundCall(SystemSoundID::kGunCock); std::string utf8 = Utils::GetValidUTF8(clients_[i].display_name, "rsgc1"); clients_[i].joystick_ = Object::NewDeferred( -1, // not an sdl joystick @@ -425,7 +425,7 @@ auto RemoteAppServer::GetClient(int request_id, struct sockaddr* addr, if (Utils::UTF8StringLength(utf8.c_str()) <= 10) { clients_[i].joystick_->set_custom_default_player_name(utf8); } - assert(g_game); + assert(g_logic); g_input->PushAddInputDeviceCall(clients_[i].joystick_, false); return i; } @@ -512,7 +512,7 @@ void RemoteAppServer::HandleRemoteEvent(RemoteAppClient* client, break; } if (send) { - assert(g_game); + assert(g_logic); g_input->PushJoystickEvent(e, client->joystick_); } #pragma clang diagnostic pop @@ -542,7 +542,7 @@ void RemoteAppServer::HandleRemoteFloatEvent(RemoteAppClient* client, break; } if (send) { - assert(g_game); + assert(g_logic); g_input->PushJoystickEvent(e, client->joystick_); } #pragma clang diagnostic pop diff --git a/src/ballistica/game/client_controller_interface.h b/src/ballistica/logic/client_controller_interface.h similarity index 78% rename from src/ballistica/game/client_controller_interface.h rename to src/ballistica/logic/client_controller_interface.h index 0b686329..3f1a2cf4 100644 --- a/src/ballistica/game/client_controller_interface.h +++ b/src/ballistica/logic/client_controller_interface.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CLIENT_CONTROLLER_INTERFACE_H_ -#define BALLISTICA_GAME_CLIENT_CONTROLLER_INTERFACE_H_ +#ifndef BALLISTICA_LOGIC_CLIENT_CONTROLLER_INTERFACE_H_ +#define BALLISTICA_LOGIC_CLIENT_CONTROLLER_INTERFACE_H_ #include "ballistica/ballistica.h" @@ -19,4 +19,4 @@ class ClientControllerInterface { } // namespace ballistica -#endif // BALLISTICA_GAME_CLIENT_CONTROLLER_INTERFACE_H_ +#endif // BALLISTICA_LOGIC_CLIENT_CONTROLLER_INTERFACE_H_ diff --git a/src/ballistica/game/connection/connection.cc b/src/ballistica/logic/connection/connection.cc similarity index 99% rename from src/ballistica/game/connection/connection.cc rename to src/ballistica/logic/connection/connection.cc index 75e87f96..654602ba 100644 --- a/src/ballistica/game/connection/connection.cc +++ b/src/ballistica/logic/connection/connection.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection.h" +#include "ballistica/logic/connection/connection.h" #include "ballistica/generic/huffman.h" #include "ballistica/generic/json.h" diff --git a/src/ballistica/game/connection/connection.h b/src/ballistica/logic/connection/connection.h similarity index 96% rename from src/ballistica/game/connection/connection.h rename to src/ballistica/logic/connection/connection.h index d4565f66..b130ed21 100644 --- a/src/ballistica/game/connection/connection.h +++ b/src/ballistica/logic/connection/connection.h @@ -1,14 +1,14 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_H_ #include #include #include #include "ballistica/core/object.h" -#include "ballistica/game/player_spec.h" +#include "ballistica/logic/player_spec.h" #include "ballistica/python/python_ref.h" namespace ballistica { @@ -142,4 +142,4 @@ class Connection : public Object { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_H_ diff --git a/src/ballistica/game/connection/connection_set.cc b/src/ballistica/logic/connection/connection_set.cc similarity index 94% rename from src/ballistica/game/connection/connection_set.cc rename to src/ballistica/logic/connection/connection_set.cc index 25f9f027..1748a3b9 100644 --- a/src/ballistica/game/connection/connection_set.cc +++ b/src/ballistica/logic/connection/connection_set.cc @@ -1,14 +1,14 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection_set.h" +#include "ballistica/logic/connection/connection_set.h" #include "ballistica/core/thread.h" -#include "ballistica/game/connection/connection_to_client_udp.h" -#include "ballistica/game/connection/connection_to_host_udp.h" -#include "ballistica/game/game.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/connection/connection_to_client_udp.h" +#include "ballistica/logic/connection/connection_to_host_udp.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/sockaddr.h" #include "ballistica/python/python.h" @@ -113,7 +113,7 @@ void ConnectionSet::SendChatMessage(const std::string& message, // spec out of their name(s). std::string p_name_combined; if (auto* hs = - dynamic_cast(g_game->GetForegroundSession())) { + dynamic_cast(g_logic->GetForegroundSession())) { for (auto&& p : hs->players()) { InputDevice* input_device = p->GetInputDevice(); if (p->accepted() && p->name_is_real() && input_device != nullptr @@ -192,7 +192,7 @@ void ConnectionSet::SendChatMessage(const std::string& message, // And display locally if the message is addressed to all. if (clients == nullptr) { - g_game->LocalDisplayChatMessage(msg_out); + g_logic->LocalDisplayChatMessage(msg_out); } } } @@ -216,14 +216,14 @@ void ConnectionSet::PushUDPConnectionPacketCall( const std::vector& data, const SockAddr& addr) { // Avoid buffer-full errors if something is causing us to write too often; // these are unreliable messages so its ok to just drop them. - if (!g_game->thread()->CheckPushSafety()) { + if (!g_logic->thread()->CheckPushSafety()) { BA_LOG_ONCE( "Ignoring excessive udp-connection input packets; (could this be a " "flood attack?)."); return; } - g_game->thread()->PushCall( + g_logic->thread()->PushCall( [this, data, addr] { UDPConnectionPacket(data, addr); }); } @@ -284,7 +284,7 @@ auto ConnectionSet::PrepareForLaunchHostSession() -> void { connection_to_host_->RequestDisconnect(); connection_to_host_.Clear(); has_connection_to_host_ = false; - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); } } @@ -303,9 +303,9 @@ auto ConnectionSet::HandleClientDisconnected(int id) -> void { // gone. Also inform everyone who just left so they can announce it // (technically could consolidate these messages but whatever...). if (was_connected) { - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); for (auto&& connection : connections_to_clients_) { - if (g_game->ShouldAnnouncePartyJoinsAndLeaves()) { + if (g_logic->ShouldAnnouncePartyJoinsAndLeaves()) { connection.second->SendReliableMessage(leave_msg); } } @@ -339,7 +339,7 @@ auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool { // If this is considered a kick, add an entry to our banned list so we // know not to let them back in for a while. if (ban_seconds > 0) { - g_game->BanPlayer(i->second->peer_spec(), 1000 * ban_seconds); + g_logic->BanPlayer(i->second->peer_spec(), 1000 * ban_seconds); } i->second->RequestDisconnect(); @@ -354,24 +354,24 @@ auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool { } void ConnectionSet::PushClientDisconnectedCall(int id) { - g_game->thread()->PushCall([this, id] { HandleClientDisconnected(id); }); + g_logic->thread()->PushCall([this, id] { HandleClientDisconnected(id); }); } void ConnectionSet::PushDisconnectedFromHostCall() { - g_game->thread()->PushCall([this] { + g_logic->thread()->PushCall([this] { if (connection_to_host_.exists()) { bool was_connected = connection_to_host_->can_communicate(); connection_to_host_.Clear(); has_connection_to_host_ = false; // Clear out our party roster. - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); // Go back to main menu *if* the connection was fully connected. // Otherwise we're still probably sitting at the main menu // so no need to reset it. if (was_connected) { - g_game->RunMainMenu(); + g_logic->RunMainMenu(); } } }); @@ -379,10 +379,10 @@ void ConnectionSet::PushDisconnectedFromHostCall() { void ConnectionSet::PushHostConnectedUDPCall(const SockAddr& addr, bool print_connect_progress) { - g_game->thread()->PushCall([this, addr, print_connect_progress] { + g_logic->thread()->PushCall([this, addr, print_connect_progress] { // Attempt to disconnect any clients we have, turn off public-party // advertising, etc. - g_game->CleanUpBeforeConnectingToHost(); + g_logic->CleanUpBeforeConnectingToHost(); print_udp_connect_progress_ = print_connect_progress; connection_to_host_ = Object::New(addr); has_connection_to_host_ = true; @@ -391,7 +391,7 @@ void ConnectionSet::PushHostConnectedUDPCall(const SockAddr& addr, } void ConnectionSet::PushDisconnectFromHostCall() { - g_game->thread()->PushCall([this] { + g_logic->thread()->PushCall([this] { if (connection_to_host_.exists()) { connection_to_host_->RequestDisconnect(); } @@ -562,7 +562,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in, keep_trying = hc->SwitchProtocol(); if (!keep_trying) { if (!printed_host_disconnect_) { - ScreenMessage(g_game->GetResourceString( + ScreenMessage(g_logic->GetResourceString( "connectionFailedVersionMismatchText"), {1, 0, 0}); printed_host_disconnect_ = true; @@ -572,22 +572,23 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in, if (!printed_host_disconnect_) { if (print_udp_connect_progress_) { ScreenMessage( - g_game->GetResourceString("connectionFailedPartyFullText"), + g_logic->GetResourceString("connectionFailedPartyFullText"), {1, 0, 0}); } printed_host_disconnect_ = true; } } else if (data[0] == BA_PACKET_CLIENT_DENY_ALREADY_IN_PARTY) { if (!printed_host_disconnect_) { - ScreenMessage(g_game->GetResourceString( + ScreenMessage(g_logic->GetResourceString( "connectionFailedHostAlreadyInPartyText"), {1, 0, 0}); printed_host_disconnect_ = true; } } else { if (!printed_host_disconnect_) { - ScreenMessage(g_game->GetResourceString("connectionRejectedText"), - {1, 0, 0}); + ScreenMessage( + g_logic->GetResourceString("connectionRejectedText"), + {1, 0, 0}); printed_host_disconnect_ = true; } } @@ -615,7 +616,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in, std::string client_instance_uuid = &(client_instance_buffer[0]); if (static_cast(connections_to_clients_.size() + 1) - >= g_game->public_party_max_size()) { + >= g_logic->public_party_max_size()) { // If we've reached our party size limit (including ourself in that // count), reject. @@ -730,7 +731,7 @@ void ConnectionSet::SetClientInfoFromMasterServer( client->HandleMasterServerClientInfo(info_obj); // Roster will now include account-id... - g_game->mark_game_roster_dirty(); + g_logic->mark_game_roster_dirty(); break; } } diff --git a/src/ballistica/game/connection/connection_set.h b/src/ballistica/logic/connection/connection_set.h similarity index 96% rename from src/ballistica/game/connection/connection_set.h rename to src/ballistica/logic/connection/connection_set.h index c3b1888d..2d44e1da 100644 --- a/src/ballistica/game/connection/connection_set.h +++ b/src/ballistica/logic/connection/connection_set.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_SET_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_SET_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_SET_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_SET_H_ #include #include @@ -118,4 +118,4 @@ class ConnectionSet { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_SET_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_SET_H_ diff --git a/src/ballistica/game/connection/connection_to_client.cc b/src/ballistica/logic/connection/connection_to_client.cc similarity index 92% rename from src/ballistica/game/connection/connection_to_client.cc rename to src/ballistica/logic/connection/connection_to_client.cc index d98d0af1..402a7593 100644 --- a/src/ballistica/game/connection/connection_to_client.cc +++ b/src/ballistica/logic/connection/connection_to_client.cc @@ -1,17 +1,17 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection_to_client.h" +#include "ballistica/logic/connection/connection_to_client.h" #include "ballistica/assets/assets.h" #include "ballistica/audio/audio.h" -#include "ballistica/game/client_controller_interface.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/generic/json.h" #include "ballistica/input/device/client_input_device.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/client_controller_interface.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/networking/networking.h" #include "ballistica/python/python.h" #include "ballistica/python/python_sys.h" @@ -69,8 +69,8 @@ ConnectionToClient::~ConnectionToClient() { } // If they had been announced as connected, announce their departure. - if (can_communicate() && g_game->ShouldAnnouncePartyJoinsAndLeaves()) { - std::string s = g_game->GetResourceString("playerLeftPartyText"); + if (can_communicate() && g_logic->ShouldAnnouncePartyJoinsAndLeaves()) { + std::string s = g_logic->GetResourceString("playerLeftPartyText"); Utils::StringReplaceOne(&s, "${NAME}", peer_spec().GetDisplayString()); ScreenMessage(s, {1, 0.5f, 0.0f}); g_audio->PlaySound(g_assets->GetSound(SystemSoundID::kCorkPop)); @@ -174,7 +174,7 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { // Compare this against our blocked specs.. if there's a match, reject // them. - if (g_game->IsPlayerBanned(peer_spec())) { + if (g_logic->IsPlayerBanned(peer_spec())) { Error(""); return; } @@ -193,7 +193,7 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { // connection attempt so this will only apply to things like Google // Play invites where we probably want to be more verbose as // to why the game just died. - s = g_game->GetResourceString("incompatibleVersionPlayerText"); + s = g_logic->GetResourceString("incompatibleVersionPlayerText"); Utils::StringReplaceOne(&s, "${NAME}", peer_spec().GetDisplayString()); } @@ -210,8 +210,8 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { next_kick_vote_allow_time_ = GetRealTime() + kNewClientKickVoteDelay; // At this point we have their name, so lets announce their arrival. - if (g_game->ShouldAnnouncePartyJoinsAndLeaves()) { - std::string s = g_game->GetResourceString("playerJoinedPartyText"); + if (g_logic->ShouldAnnouncePartyJoinsAndLeaves()) { + std::string s = g_logic->GetResourceString("playerJoinedPartyText"); Utils::StringReplaceOne(&s, "${NAME}", peer_spec().GetDisplayString()); ScreenMessage(s, {0.5f, 1, 0.5f}); @@ -220,7 +220,7 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { // Also mark the time for flashing the 'someone just joined your // party' message in the corner. - g_game->set_last_connection_to_client_join_time(GetRealTime()); + g_logic->set_last_connection_to_client_join_time(GetRealTime()); // Added midway through protocol 29: // We now send a json dict of info about ourself first thing. This @@ -234,10 +234,10 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { cJSON_CreateNumber(kAppBuildNumber)); // Add a name entry if we've got a public party name set. - if (!g_game->public_party_name().empty()) { + if (!g_logic->public_party_name().empty()) { cJSON_AddItemToObject( info_dict, "n", - cJSON_CreateString(g_game->public_party_name().c_str())); + cJSON_CreateString(g_logic->public_party_name().c_str())); } std::string info = cJSON_PrintUnformatted(info_dict); cJSON_Delete(info_dict); @@ -253,23 +253,23 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { join_msg[0] = BA_MESSAGE_PARTY_MEMBER_JOINED; memcpy(&(join_msg[1]), joiner_spec.c_str(), joiner_spec.size()); - for (auto&& i : g_game->connections()->connections_to_clients()) { + for (auto&& i : g_logic->connections()->connections_to_clients()) { // Also send a 'party-member-joined' notification to all clients // *except* the new one. if (i.second.exists() && i.second.get() != this - && g_game->ShouldAnnouncePartyJoinsAndLeaves()) { + && g_logic->ShouldAnnouncePartyJoinsAndLeaves()) { i.second->SendReliableMessage(join_msg); } } // Update the game party roster and send it to all clients (including // this new one). - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); // Lastly, we hand this connection over to whoever is currently // feeding client connections. - if (g_game->connections()->client_controller()) { - SetController(g_game->connections()->client_controller()); + if (g_logic->connections()->client_controller()) { + SetController(g_logic->connections()->client_controller()); } } break; @@ -295,7 +295,7 @@ void ConnectionToClient::SendScreenMessage(const std::string& s, float r, // Older clients don't support the screen-message message, so in that case // we just send it as a chat-message from . if (build_number() < 14248) { - std::string value = g_game->CompileResourceString(s, "sendScreenMessage"); + std::string value = g_logic->CompileResourceString(s, "sendScreenMessage"); std::string our_spec_string = PlayerSpec::GetDummyPlayerSpec("").GetSpecString(); std::vector msg_out(1 + 1 + our_spec_string.size() + value.size()); @@ -347,10 +347,10 @@ void ConnectionToClient::HandleMessagePacket( case BA_MESSAGE_KICK_VOTE: { if (buffer.size() == 2) { - for (auto&& i : g_game->connections()->connections_to_clients()) { + for (auto&& i : g_logic->connections()->connections_to_clients()) { ConnectionToClient* client = i.second.get(); if (client->id() == static_cast(buffer[1])) { - g_game->StartKickVote(this, client); + g_logic->StartKickVote(this, client); break; } } @@ -409,7 +409,7 @@ void ConnectionToClient::HandleMessagePacket( // Newer type using json. // Only accept peer info if we've not gotten official info from // the master server (and if we're allowing it in general). - if (!g_game->require_client_authentication() + if (!g_logic->require_client_authentication() && !got_info_from_master_server_) { std::vector b2(buffer.size()); memcpy(&(b2[0]), &(buffer[1]), buffer.size() - 1); @@ -460,13 +460,13 @@ void ConnectionToClient::HandleMessagePacket( // If we require client-info and don't have it from this guy yet, // ignore their chat messages (prevent bots from jumping in and // spamming before we can verify their identities) - if (g_game->require_client_authentication() + if (g_logic->require_client_authentication() && !got_info_from_master_server_) { Log("Ignoring chat message from peer with no client info."); SendScreenMessage(R"({"r":"loadingTryAgainText"})", 1, 0, 0); } else if (last_chat_times_.size() >= 5) { chat_block_time_ = now + next_chat_block_seconds_ * 1000; - g_game->connections()->SendScreenMessageToAll( + g_logic->connections()->SendScreenMessageToAll( R"({"r":"internal.chatBlockedText","s":[["${NAME}",)" + Utils::GetJSONString( GetCombinedSpec().GetDisplayString().c_str()) @@ -498,7 +498,7 @@ void ConnectionToClient::HandleMessagePacket( "{\"t\":[\"serverResponses\"," "\"Message is too long.\"]}", 1, 0, 0); - } else if (g_game->kick_vote_in_progress() + } else if (g_logic->kick_vote_in_progress() && (!strcmp(b2.data(), "1") || !strcmp(b2.data(), "2"))) { // Special case - if there's a kick vote going on, take '1' or @@ -535,14 +535,14 @@ void ConnectionToClient::HandleMessagePacket( // Send it out to all clients. for (auto&& i : - g_game->connections()->connections_to_clients()) { + g_logic->connections()->connections_to_clients()) { if (i.second->can_communicate()) { i.second->SendReliableMessage(msg_out); } } // Display it locally. - g_game->LocalDisplayChatMessage(msg_out); + g_logic->LocalDisplayChatMessage(msg_out); } } } @@ -598,7 +598,7 @@ void ConnectionToClient::HandleMessagePacket( ClientInputDevice* cid = GetClientInputDevice(buffer[1]); if (auto* hs = - dynamic_cast(g_game->GetForegroundSession())) { + dynamic_cast(g_logic->GetForegroundSession())) { if (!cid->attached_to_player()) { millisecs_t seconds_since_last_left = (GetRealTime() - last_remove_player_time_) / 1000; @@ -615,7 +615,7 @@ void ConnectionToClient::HandleMessagePacket( + "\"]]}", 1, 1, 0); } else { - bool still_waiting = (g_game->require_client_authentication() + bool still_waiting = (g_logic->require_client_authentication() && !got_info_from_master_server_); // If we're not allowing peer client-info and have yet to get // master-server info for this client, delay their join (we'll @@ -652,7 +652,7 @@ void ConnectionToClient::HandleMessagePacket( SendScreenMessage(R"({"r":"errorUnknownText"})", 1, 0, 0); Log("Client data limit exceeded by '" + peer_spec().GetShortName() + "'; kicking."); - g_game->BanPlayer(peer_spec(), 1000 * 60); + g_logic->BanPlayer(peer_spec(), 1000 * 60); Error(""); return; } @@ -666,7 +666,7 @@ void ConnectionToClient::HandleMessagePacket( auto ConnectionToClient::GetCombinedSpec() -> PlayerSpec { // Look for players coming from this client-connection. // If we find any, make a spec out of their name(s). - if (auto* hs = dynamic_cast(g_game->GetForegroundSession())) { + if (auto* hs = dynamic_cast(g_logic->GetForegroundSession())) { std::string p_name_combined; for (auto&& p : hs->players()) { InputDevice* input_device = p->GetInputDevice(); @@ -733,7 +733,7 @@ void ConnectionToClient::HandleMasterServerClientInfo(PyObject* info_obj) { // If the server returned no valid account info for them // and we're not trusting peers, kick this fella right out // and ban him for a short bit (to hopefully limit rejoin spam). - if (g_game->require_client_authentication()) { + if (g_logic->require_client_authentication()) { SendScreenMessage( "{\"t\":[\"serverResponses\"," "\"Your account was rejected. Are you signed in?\"]}", @@ -744,7 +744,7 @@ void ConnectionToClient::HandleMasterServerClientInfo(PyObject* info_obj) { // Not benning anymore. People were exploiting this by impersonating // other players using their public ids to get them banned from // their own servers/etc. - // g_game->BanPlayer(peer_spec(), 1000 * 60); + // g_logic->BanPlayer(peer_spec(), 1000 * 60); Error(""); } } @@ -755,8 +755,8 @@ auto ConnectionToClient::IsAdmin() const -> bool { if (peer_public_account_id_.empty()) { return false; } - return (g_game->admin_public_ids().find(peer_public_account_id_) - != g_game->admin_public_ids().end()); + return (g_logic->admin_public_ids().find(peer_public_account_id_) + != g_logic->admin_public_ids().end()); } } // namespace ballistica diff --git a/src/ballistica/game/connection/connection_to_client.h b/src/ballistica/logic/connection/connection_to_client.h similarity index 92% rename from src/ballistica/game/connection/connection_to_client.h rename to src/ballistica/logic/connection/connection_to_client.h index 5269e1c5..be548a94 100644 --- a/src/ballistica/game/connection/connection_to_client.h +++ b/src/ballistica/logic/connection/connection_to_client.h @@ -1,13 +1,13 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_H_ #include #include #include -#include "ballistica/game/connection/connection.h" +#include "ballistica/logic/connection/connection.h" namespace ballistica { @@ -83,4 +83,4 @@ class ConnectionToClient : public Connection { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_H_ diff --git a/src/ballistica/game/connection/connection_to_client_udp.cc b/src/ballistica/logic/connection/connection_to_client_udp.cc similarity index 88% rename from src/ballistica/game/connection/connection_to_client_udp.cc rename to src/ballistica/logic/connection/connection_to_client_udp.cc index b330ba8e..09a65a34 100644 --- a/src/ballistica/game/connection/connection_to_client_udp.cc +++ b/src/ballistica/logic/connection/connection_to_client_udp.cc @@ -1,9 +1,9 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection_to_client_udp.h" +#include "ballistica/logic/connection/connection_to_client_udp.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/sockaddr.h" @@ -16,7 +16,7 @@ ConnectionToClientUDP::ConnectionToClientUDP(const SockAddr& addr, request_id_(request_id), addr_(new SockAddr(addr)), client_instance_uuid_(std::move(client_name)), - last_client_response_time_(g_game->master_time()), + last_client_response_time_(g_logic->master_time()), did_die_(false) {} ConnectionToClientUDP::~ConnectionToClientUDP() { @@ -46,7 +46,7 @@ void ConnectionToClientUDP::SendGamePacketCompressed( void ConnectionToClientUDP::Update() { ConnectionToClient::Update(); - millisecs_t current_time = g_game->master_time(); + millisecs_t current_time = g_logic->master_time(); // if its been long enough since we've heard anything from the host, error. if (current_time - last_client_response_time_ @@ -60,7 +60,7 @@ void ConnectionToClientUDP::Update() { void ConnectionToClientUDP::HandleGamePacket( const std::vector& buffer) { // keep track of when we last heard from the host for disconnect purposes - last_client_response_time_ = g_game->master_time(); + last_client_response_time_ = g_logic->master_time(); ConnectionToClient::HandleGamePacket(buffer); } @@ -70,7 +70,7 @@ void ConnectionToClientUDP::Die() { return; } // this will actually clear the object.. - g_game->connections()->PushClientDisconnectedCall(id()); + g_logic->connections()->PushClientDisconnectedCall(id()); did_die_ = true; } diff --git a/src/ballistica/game/connection/connection_to_client_udp.h b/src/ballistica/logic/connection/connection_to_client_udp.h similarity index 81% rename from src/ballistica/game/connection/connection_to_client_udp.h rename to src/ballistica/logic/connection/connection_to_client_udp.h index cac1b30a..c6a99237 100644 --- a/src/ballistica/game/connection/connection_to_client_udp.h +++ b/src/ballistica/logic/connection/connection_to_client_udp.h @@ -1,13 +1,13 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ #include #include #include -#include "ballistica/game/connection/connection_to_client.h" +#include "ballistica/logic/connection/connection_to_client.h" #include "ballistica/networking/networking.h" #include "ballistica/networking/sockaddr.h" @@ -40,4 +40,4 @@ class ConnectionToClientUDP : public ConnectionToClient { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_CLIENT_UDP_H_ diff --git a/src/ballistica/game/connection/connection_to_host.cc b/src/ballistica/logic/connection/connection_to_host.cc similarity index 94% rename from src/ballistica/game/connection/connection_to_host.cc rename to src/ballistica/logic/connection/connection_to_host.cc index 371a0a81..baede471 100644 --- a/src/ballistica/game/connection/connection_to_host.cc +++ b/src/ballistica/logic/connection/connection_to_host.cc @@ -1,15 +1,15 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection_to_host.h" +#include "ballistica/logic/connection/connection_to_host.h" #include "ballistica/assets/assets.h" #include "ballistica/audio/audio.h" -#include "ballistica/game/game.h" -#include "ballistica/game/session/net_client_session.h" #include "ballistica/generic/json.h" #include "ballistica/input/device/input_device.h" #include "ballistica/input/input.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/net_client_session.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/networking.h" #include "ballistica/platform/platform.h" @@ -32,16 +32,16 @@ ConnectionToHost::~ConnectionToHost() { // '${PEER-NAME}'s party'. std::string s; if (!party_name_.empty()) { - s = g_game->GetResourceString("leftGameText"); + s = g_logic->GetResourceString("leftGameText"); Utils::StringReplaceOne(&s, "${NAME}", party_name_); } else { - s = g_game->GetResourceString("leftPartyText"); + s = g_logic->GetResourceString("leftPartyText"); Utils::StringReplaceOne(&s, "${NAME}", peer_spec().GetDisplayString()); } ScreenMessage(s, {1, 0.5f, 0.0f}); g_audio->PlaySound(g_assets->GetSound(SystemSoundID::kCorkPop)); } else { - ScreenMessage(g_game->GetResourceString("connectionRejectedText"), + ScreenMessage(g_logic->GetResourceString("connectionRejectedText"), {1, 0, 0}); } } @@ -126,9 +126,9 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { if (!compatible) { if (their_protocol_version > kProtocolVersion) { - Error(g_game->GetResourceString("incompatibleNewerVersionHostText")); + Error(g_logic->GetResourceString("incompatibleNewerVersionHostText")); } else { - Error(g_game->GetResourceString("incompatibleVersionHostText")); + Error(g_logic->GetResourceString("incompatibleVersionHostText")); } return; } @@ -175,7 +175,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { peer_hash_ = g_app_internal->CalcV1PeerHash(peer_hash_input_); set_can_communicate(true); - g_game->LaunchClientSession(); + g_logic->LaunchClientSession(); // NOTE: // we don't actually print a 'connected' message until after @@ -185,7 +185,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { // Wire ourselves up to drive the client-session we're in. auto* cs = - dynamic_cast(g_game->GetForegroundSession()); + dynamic_cast(g_logic->GetForegroundSession()); assert(cs); assert(!cs->connection_to_host()); client_session_ = cs; @@ -321,7 +321,7 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { cJSON* new_roster = cJSON_Parse(reinterpret_cast(&(buffer[1]))); if (new_roster) { - g_game->SetGameRoster(new_roster); + g_logic->SetGameRoster(new_roster); } } break; @@ -372,7 +372,7 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { std::vector str_buffer(buffer.size()); memcpy(&(str_buffer[0]), &(buffer[1]), buffer.size() - 1); str_buffer[str_buffer.size() - 1] = 0; - std::string s = g_game->GetResourceString("playerJoinedPartyText"); + std::string s = g_logic->GetResourceString("playerJoinedPartyText"); Utils::StringReplaceOne( &s, "${NAME}", PlayerSpec(str_buffer.data()).GetDisplayString()); ScreenMessage(s, {0.5f, 1.0f, 0.5f}); @@ -387,7 +387,7 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { std::vector str_buffer(buffer.size()); memcpy(&(str_buffer[0]), &(buffer[1]), buffer.size() - 1); str_buffer[str_buffer.size() - 1] = 0; - std::string s = g_game->GetResourceString("playerLeftPartyText"); + std::string s = g_logic->GetResourceString("playerLeftPartyText"); Utils::StringReplaceOne( &s, "${NAME}", PlayerSpec(&(str_buffer[0])).GetDisplayString()); ScreenMessage(s, {1, 0.5f, 0.0f}); @@ -441,7 +441,7 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { } case BA_MESSAGE_CHAT: { - g_game->LocalDisplayChatMessage(buffer); + g_logic->LocalDisplayChatMessage(buffer); break; } @@ -479,10 +479,10 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { // If we've got a name for their party, use it; otherwise call it // '${NAME}'s party'. if (!party_name_.empty()) { - s = g_game->GetResourceString("connectedToGameText"); + s = g_logic->GetResourceString("connectedToGameText"); Utils::StringReplaceOne(&s, "${NAME}", party_name_); } else { - s = g_game->GetResourceString("connectedToPartyText"); + s = g_logic->GetResourceString("connectedToPartyText"); Utils::StringReplaceOne(&s, "${NAME}", peer_spec().GetDisplayString()); } ScreenMessage(s, {0.5f, 1, 0.5f}); diff --git a/src/ballistica/game/connection/connection_to_host.h b/src/ballistica/logic/connection/connection_to_host.h similarity index 85% rename from src/ballistica/game/connection/connection_to_host.h rename to src/ballistica/logic/connection/connection_to_host.h index 40b0e74b..0f1b5c54 100644 --- a/src/ballistica/game/connection/connection_to_host.h +++ b/src/ballistica/logic/connection/connection_to_host.h @@ -1,12 +1,12 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_H_ #include #include -#include "ballistica/game/connection/connection.h" +#include "ballistica/logic/connection/connection.h" namespace ballistica { @@ -44,4 +44,4 @@ class ConnectionToHost : public Connection { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_H_ diff --git a/src/ballistica/game/connection/connection_to_host_udp.cc b/src/ballistica/logic/connection/connection_to_host_udp.cc similarity index 89% rename from src/ballistica/game/connection/connection_to_host_udp.cc rename to src/ballistica/logic/connection/connection_to_host_udp.cc index f7dca8e8..c77a8a8d 100644 --- a/src/ballistica/game/connection/connection_to_host_udp.cc +++ b/src/ballistica/logic/connection/connection_to_host_udp.cc @@ -1,9 +1,9 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/connection/connection_to_host_udp.h" +#include "ballistica/logic/connection/connection_to_host_udp.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/sockaddr.h" @@ -28,10 +28,10 @@ ConnectionToHostUDP::ConnectionToHostUDP(const SockAddr& addr) last_client_id_request_time_(0), last_disconnect_request_time_(0), did_die_(false), - last_host_response_time_(g_game->master_time()) { + last_host_response_time_(g_logic->master_time()) { GetRequestID(); - if (g_game->connections()->GetPrintUDPConnectProgress()) { - ScreenMessage(g_game->GetResourceString("connectingToPartyText")); + if (g_logic->connections()->GetPrintUDPConnectProgress()) { + ScreenMessage(g_logic->GetResourceString("connectingToPartyText")); } } @@ -54,7 +54,7 @@ void ConnectionToHostUDP::GetRequestID() { void ConnectionToHostUDP::Update() { ConnectionToHost::Update(); - millisecs_t current_time = g_game->master_time(); + millisecs_t current_time = g_logic->master_time(); // If we've not gotten a client_id from the host yet, keep pestering it. if (!errored()) { @@ -80,7 +80,7 @@ void ConnectionToHostUDP::Update() { > (can_communicate() ? 10000u : 5000u)) { // If the connection never got established, announce it failed. if (!can_communicate()) { - ScreenMessage(g_game->GetResourceString("connectionFailedText"), + ScreenMessage(g_logic->GetResourceString("connectionFailedText"), {1, 0, 0}); } @@ -113,8 +113,8 @@ void ConnectionToHostUDP::Die() { Log("Error: posting multiple die messages; probably not good."); return; } - if (g_game->connections()->connection_to_host() == this) { - g_game->connections()->PushDisconnectedFromHostCall(); + if (g_logic->connections()->connection_to_host() == this) { + g_logic->connections()->PushDisconnectedFromHostCall(); did_die_ = true; } else { Log("Error: Running update for non-current host-connection; shouldn't " @@ -134,7 +134,7 @@ void ConnectionToHostUDP::SendDisconnectRequest() { void ConnectionToHostUDP::HandleGamePacket(const std::vector& buffer) { // Keep track of when we last heard from the host for time-out purposes. - last_host_response_time_ = g_game->master_time(); + last_host_response_time_ = g_logic->master_time(); ConnectionToHost::HandleGamePacket(buffer); } diff --git a/src/ballistica/game/connection/connection_to_host_udp.h b/src/ballistica/logic/connection/connection_to_host_udp.h similarity index 83% rename from src/ballistica/game/connection/connection_to_host_udp.h rename to src/ballistica/logic/connection/connection_to_host_udp.h index d3fe9cbe..40de91e0 100644 --- a/src/ballistica/game/connection/connection_to_host_udp.h +++ b/src/ballistica/logic/connection/connection_to_host_udp.h @@ -1,13 +1,13 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_UDP_H_ -#define BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_UDP_H_ +#ifndef BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_UDP_H_ +#define BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_UDP_H_ #include #include #include -#include "ballistica/game/connection/connection_to_host.h" +#include "ballistica/logic/connection/connection_to_host.h" #include "ballistica/networking/networking.h" namespace ballistica { @@ -46,4 +46,4 @@ class ConnectionToHostUDP : public ConnectionToHost { } // namespace ballistica -#endif // BALLISTICA_GAME_CONNECTION_CONNECTION_TO_HOST_UDP_H_ +#endif // BALLISTICA_LOGIC_CONNECTION_CONNECTION_TO_HOST_UDP_H_ diff --git a/src/ballistica/game/friend_score_set.h b/src/ballistica/logic/friend_score_set.h similarity index 81% rename from src/ballistica/game/friend_score_set.h rename to src/ballistica/logic/friend_score_set.h index a4108c8d..e90dd619 100644 --- a/src/ballistica/game/friend_score_set.h +++ b/src/ballistica/logic/friend_score_set.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_FRIEND_SCORE_SET_H_ -#define BALLISTICA_GAME_FRIEND_SCORE_SET_H_ +#ifndef BALLISTICA_LOGIC_FRIEND_SCORE_SET_H_ +#define BALLISTICA_LOGIC_FRIEND_SCORE_SET_H_ #include #include @@ -27,4 +27,4 @@ struct FriendScoreSet { } // namespace ballistica -#endif // BALLISTICA_GAME_FRIEND_SCORE_SET_H_ +#endif // BALLISTICA_LOGIC_FRIEND_SCORE_SET_H_ diff --git a/src/ballistica/game/host_activity.cc b/src/ballistica/logic/host_activity.cc similarity index 98% rename from src/ballistica/game/host_activity.cc rename to src/ballistica/logic/host_activity.cc index 850a5886..9685cadd 100644 --- a/src/ballistica/game/host_activity.cc +++ b/src/ballistica/logic/host_activity.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/host_activity.h" +#include "ballistica/logic/host_activity.h" #include "ballistica/assets/component/collide_model.h" #include "ballistica/assets/component/data.h" @@ -8,11 +8,11 @@ #include "ballistica/assets/component/sound.h" #include "ballistica/assets/component/texture.h" #include "ballistica/dynamics/material/material.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/generic/lambda_runnable.h" #include "ballistica/generic/timer.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" #include "ballistica/python/python_sys.h" @@ -239,7 +239,7 @@ void HostActivity::UpdateStepTimerLength() { step_scene_timer_->SetLength( std::max(1, static_cast( round(static_cast(kGameStepMilliseconds) - / (game_speed_ * g_game->debug_speed_mult())))), + / (game_speed_ * g_logic->debug_speed_mult())))), true, base_time_); } } @@ -311,7 +311,7 @@ void HostActivity::SetIsForeground(bool val) { Scene* sg = scene(); if (val && sg) { // Set it locally. - g_game->SetForegroundScene(sg); + g_logic->SetForegroundScene(sg); // Also push it to clients. if (SceneStream* out = GetSceneStream()) { diff --git a/src/ballistica/game/host_activity.h b/src/ballistica/logic/host_activity.h similarity index 97% rename from src/ballistica/game/host_activity.h rename to src/ballistica/logic/host_activity.h index d87ad6c1..f9dfca16 100644 --- a/src/ballistica/game/host_activity.h +++ b/src/ballistica/logic/host_activity.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_HOST_ACTIVITY_H_ -#define BALLISTICA_GAME_HOST_ACTIVITY_H_ +#ifndef BALLISTICA_LOGIC_HOST_ACTIVITY_H_ +#define BALLISTICA_LOGIC_HOST_ACTIVITY_H_ #include #include @@ -120,4 +120,4 @@ class HostActivity : public ContextTarget { } // namespace ballistica -#endif // BALLISTICA_GAME_HOST_ACTIVITY_H_ +#endif // BALLISTICA_LOGIC_HOST_ACTIVITY_H_ diff --git a/src/ballistica/game/game.cc b/src/ballistica/logic/logic.cc similarity index 91% rename from src/ballistica/game/game.cc rename to src/ballistica/logic/logic.cc index c5efd18c..4a54876f 100644 --- a/src/ballistica/game/game.cc +++ b/src/ballistica/logic/logic.cc @@ -1,23 +1,12 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/app/app_config.h" #include "ballistica/app/app_flavor.h" #include "ballistica/audio/audio.h" #include "ballistica/core/thread.h" #include "ballistica/dynamics/bg/bg_dynamics.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client_udp.h" -#include "ballistica/game/connection/connection_to_host_udp.h" -#include "ballistica/game/friend_score_set.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/client_session.h" -#include "ballistica/game/session/host_session.h" -#include "ballistica/game/session/net_client_session.h" -#include "ballistica/game/session/replay_client_session.h" -#include "ballistica/game/v1_account.h" #include "ballistica/generic/json.h" #include "ballistica/generic/timer.h" #include "ballistica/graphics/graphics.h" @@ -27,6 +16,17 @@ #include "ballistica/input/device/keyboard_input.h" #include "ballistica/input/device/touch_input.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client_udp.h" +#include "ballistica/logic/connection/connection_to_host_udp.h" +#include "ballistica/logic/friend_score_set.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/client_session.h" +#include "ballistica/logic/session/host_session.h" +#include "ballistica/logic/session/net_client_session.h" +#include "ballistica/logic/session/replay_client_session.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/sockaddr.h" #include "ballistica/networking/telnet_server.h" @@ -64,12 +64,12 @@ const int kMaxChatMessages = 40; // Go with 5 minute ban. const int kKickBanSeconds = 5 * 60; -Game::Game() +Logic::Logic() : game_roster_(cJSON_CreateArray()), realtimers_(new TimerList()), connections_(std::make_unique()) { // We're a singleton; make sure we don't already exist. - assert(g_game == nullptr); + assert(g_logic == nullptr); InitSpecialChars(); @@ -82,11 +82,11 @@ Game::Game() // bits of C++ logic. thread_->SetAcquiresPythonGIL(); } -auto Game::OnAppStart() -> void { +auto Logic::OnAppStart() -> void { thread_->PushCallSynchronous([this] { StartInThread(); }); } -auto Game::StartInThread() -> void { +auto Logic::StartInThread() -> void { try { // We want to be informed when our thread is pausing. thread()->AddPauseCallback( @@ -112,7 +112,7 @@ auto Game::StartInThread() -> void { } } -auto Game::OnThreadPause() -> void { +auto Logic::OnThreadPause() -> void { ScopedSetContext cp(GetUIContextTarget()); // Let Python and internal layers do their thing. @@ -120,7 +120,7 @@ auto Game::OnThreadPause() -> void { g_app_internal->OnLogicThreadPause(); } -void Game::InitSpecialChars() { +void Logic::InitSpecialChars() { std::scoped_lock lock(special_char_mutex_); special_char_strings_[SpecialChar::kDownArrow] = "\xee\x80\x84"; @@ -224,37 +224,37 @@ void Game::InitSpecialChars() { special_char_strings_[SpecialChar::kV2Logo] = "\xee\x81\xA3"; } -void Game::SetGameRoster(cJSON* r) { +void Logic::SetGameRoster(cJSON* r) { if (game_roster_ != nullptr) { cJSON_Delete(game_roster_); } game_roster_ = r; } -void Game::ResetActivityTracking() { +void Logic::ResetActivityTracking() { largest_draw_time_increment_since_last_reset_ = 0; first_draw_real_time_ = last_draw_real_time_ = g_platform->GetTicks(); } #if BA_VR_BUILD -void Game::PushVRHandsState(const VRHandsState& state) { +void Logic::PushVRHandsState(const VRHandsState& state) { thread()->PushCall([this, state] { vr_hands_state_ = state; }); } #endif // BA_VR_BUILD -void Game::PushMediaPruneCall(int level) { +void Logic::PushMediaPruneCall(int level) { thread()->PushCall([level] { assert(InLogicThread()); g_assets->Prune(level); }); } -void Game::PushSetV1LoginCall(V1AccountType account_type, - V1LoginState account_state, - const std::string& account_name, - const std::string& account_id) { +void Logic::PushSetV1LoginCall(V1AccountType account_type, + V1LoginState account_state, + const std::string& account_name, + const std::string& account_id) { thread()->PushCall( [this, account_type, account_state, account_name, account_id] { g_v1_account->SetLogin(account_type, account_state, account_name, @@ -262,11 +262,11 @@ void Game::PushSetV1LoginCall(V1AccountType account_type, }); } -void Game::PushInitialScreenCreatedCall() { +void Logic::PushInitialScreenCreatedCall() { thread()->PushCall([this] { InitialScreenCreated(); }); } -void Game::InitialScreenCreated() { +void Logic::InitialScreenCreated() { assert(InLogicThread()); // Ok; graphics-server is telling us we've got a screen. @@ -300,10 +300,10 @@ void Game::InitialScreenCreated() { RunAppLaunchCommands(); } -void Game::PruneMedia() { g_assets->Prune(); } +void Logic::PruneMedia() { g_assets->Prune(); } // Launch into main menu or whatever else. -void Game::RunAppLaunchCommands() { +void Logic::RunAppLaunchCommands() { assert(InLogicThread()); assert(!ran_app_launch_commands_); @@ -332,7 +332,7 @@ void Game::RunAppLaunchCommands() { } // Set up our sleeping based on what we're doing. -void Game::UpdateProcessTimer() { +void Logic::UpdateProcessTimer() { assert(InLogicThread()); // This might get called before we set up our timer in some cases. (such as @@ -353,7 +353,7 @@ void Game::UpdateProcessTimer() { } } -void Game::PruneSessions() { +void Logic::PruneSessions() { bool have_dead_session = false; for (auto&& i : sessions_) { if (i.exists()) { @@ -381,7 +381,7 @@ void Game::PruneSessions() { } } -void Game::UpdateKickVote() { +void Logic::UpdateKickVote() { if (!kick_vote_in_progress_) { return; } @@ -486,7 +486,7 @@ void Game::UpdateKickVote() { } } -void Game::HandleQuitOnIdle() { +void Logic::HandleQuitOnIdle() { if (idle_exit_minutes_) { float idle_seconds{g_input->input_idle_time() * 0.001f}; if (!idle_exiting_ && idle_seconds > (idle_exit_minutes_.value() * 60.0f)) { @@ -504,7 +504,7 @@ void Game::HandleQuitOnIdle() { } // Bring our scenes, real-time timers, etc up to date. -void Game::Update() { +void Logic::Update() { auto startms{Platform::GetCurrentMilliseconds()}; assert(InLogicThread()); millisecs_t real_time = GetRealTime(); @@ -662,7 +662,7 @@ void Game::Update() { } // Reset the game to a blank slate. -void Game::Reset() { +void Logic::Reset() { assert(InLogicThread()); // Tear down any existing setup. @@ -676,7 +676,7 @@ void Game::Reset() { // If all is well our sessions should all be dead. if (g_app->session_count != 0) { Log("Error: session-count is non-zero (" - + std::to_string(g_app->session_count) + ") on Game::Reset."); + + std::to_string(g_app->session_count) + ") on Logic::Reset."); } // Note: we don't clear real-time timers anymore. Should we?.. @@ -697,11 +697,11 @@ void Game::Reset() { } } -auto Game::IsInUIContext() const -> bool { +auto Logic::IsInUIContext() const -> bool { return (g_ui && Context::current().target.get() == g_ui); } -void Game::PushShowURLCall(const std::string& url) { +void Logic::PushShowURLCall(const std::string& url) { thread()->PushCall([url] { assert(InLogicThread()); assert(g_python); @@ -709,7 +709,7 @@ void Game::PushShowURLCall(const std::string& url) { }); } -auto Game::GetForegroundContext() -> Context { +auto Logic::GetForegroundContext() -> Context { Session* s = GetForegroundSession(); if (s) { return s->GetForegroundContext(); @@ -718,7 +718,7 @@ auto Game::GetForegroundContext() -> Context { } } -void Game::PushBackButtonCall(InputDevice* input_device) { +void Logic::PushBackButtonCall(InputDevice* input_device) { thread()->PushCall([this, input_device] { assert(InLogicThread()); @@ -740,7 +740,7 @@ void Game::PushBackButtonCall(InputDevice* input_device) { }); } -void Game::PushStringEditSetCall(const std::string& value) { +void Logic::PushStringEditSetCall(const std::string& value) { thread()->PushCall([value] { if (!g_ui) { Log("Error: No ui on StringEditSetEvent."); @@ -757,7 +757,7 @@ void Game::PushStringEditSetCall(const std::string& value) { }); } -void Game::PushStringEditCancelCall() { +void Logic::PushStringEditCancelCall() { thread()->PushCall([] { if (!g_ui) { Log("Error: No ui in PushStringEditCancelCall."); @@ -768,12 +768,12 @@ void Game::PushStringEditCancelCall() { // Called by a newly made Session instance to set itself as the current // session. -void Game::SetForegroundSession(Session* s) { +void Logic::SetForegroundSession(Session* s) { assert(InLogicThread()); foreground_session_ = s; } -void Game::SetForegroundScene(Scene* sg) { +void Logic::SetForegroundScene(Scene* sg) { assert(InLogicThread()); if (foreground_scene_.get() != sg) { foreground_scene_ = sg; @@ -785,7 +785,7 @@ void Game::SetForegroundScene(Scene* sg) { } } -void Game::LaunchClientSession() { +void Logic::LaunchClientSession() { if (in_update_) { throw Exception( "can't launch a session from within a session update; use " @@ -814,7 +814,7 @@ void Game::LaunchClientSession() { } } -void Game::LaunchReplaySession(const std::string& file_name) { +void Logic::LaunchReplaySession(const std::string& file_name) { if (in_update_) throw Exception( "can't launch a session from within a session update; use " @@ -844,8 +844,8 @@ void Game::LaunchReplaySession(const std::string& file_name) { } } -void Game::LaunchHostSession(PyObject* session_type_obj, - BenchmarkType benchmark_type) { +void Logic::LaunchHostSession(PyObject* session_type_obj, + BenchmarkType benchmark_type) { if (in_update_) { throw Exception( "can't call host_session() from within session update; use " @@ -879,7 +879,7 @@ void Game::LaunchHostSession(PyObject* session_type_obj, } } -void Game::RunMainMenu() { +void Logic::RunMainMenu() { assert(InLogicThread()); if (g_app->shutting_down) { return; @@ -896,7 +896,7 @@ void Game::RunMainMenu() { // Commands run via the in-game console. These are a bit more 'casual' and run // in the current visible context. -void Game::PushInGameConsoleScriptCommand(const std::string& command) { +void Logic::PushInGameConsoleScriptCommand(const std::string& command) { thread()->PushCall([this, command] { // These are always run in whichever context is 'visible'. ScopedSetContext cp(GetForegroundContext()); @@ -925,7 +925,7 @@ void Game::PushInGameConsoleScriptCommand(const std::string& command) { } // Commands run via stdin. -void Game::PushStdinScriptCommand(const std::string& command) { +void Logic::PushStdinScriptCommand(const std::string& command) { thread()->PushCall([this, command] { // These are always run in whichever context is 'visible'. ScopedSetContext cp(GetForegroundContext()); @@ -959,7 +959,7 @@ void Game::PushStdinScriptCommand(const std::string& command) { }); } -void Game::PushInterruptSignalCall() { +void Logic::PushInterruptSignalCall() { thread()->PushCall([this] { assert(InLogicThread()); @@ -974,7 +974,7 @@ void Game::PushInterruptSignalCall() { }); } -void Game::PushAskUserForTelnetAccessCall() { +void Logic::PushAskUserForTelnetAccessCall() { thread()->PushCall([this] { assert(InLogicThread()); ScopedSetContext cp(GetUIContext()); @@ -982,7 +982,7 @@ void Game::PushAskUserForTelnetAccessCall() { }); } -void Game::PushPythonCall(const Object::Ref& call) { +void Logic::PushPythonCall(const Object::Ref& call) { // Since we're mucking with refs, need to limit to game thread. BA_PRECONDITION(InLogicThread()); BA_PRECONDITION(call->object_strong_ref_count() > 0); @@ -992,8 +992,8 @@ void Game::PushPythonCall(const Object::Ref& call) { }); } -void Game::PushPythonCallArgs(const Object::Ref& call, - const PythonRef& args) { +void Logic::PushPythonCallArgs(const Object::Ref& call, + const PythonRef& args) { // Since we're mucking with refs, need to limit to game thread. BA_PRECONDITION(InLogicThread()); BA_PRECONDITION(call->object_strong_ref_count() > 0); @@ -1003,7 +1003,7 @@ void Game::PushPythonCallArgs(const Object::Ref& call, }); } -void Game::PushPythonWeakCall(const Object::WeakRef& call) { +void Logic::PushPythonWeakCall(const Object::WeakRef& call) { // Since we're mucking with refs, need to limit to game thread. BA_PRECONDITION(InLogicThread()); @@ -1019,7 +1019,7 @@ void Game::PushPythonWeakCall(const Object::WeakRef& call) { }); } -void Game::PushPythonWeakCallArgs( +void Logic::PushPythonWeakCallArgs( const Object::WeakRef& call, const PythonRef& args) { // Since we're mucking with refs, need to limit to game thread. BA_PRECONDITION(InLogicThread()); @@ -1033,7 +1033,7 @@ void Game::PushPythonWeakCallArgs( }); } -void Game::PushPythonRawCallable(PyObject* callable) { +void Logic::PushPythonRawCallable(PyObject* callable) { thread()->PushCall([this, callable] { assert(InLogicThread()); @@ -1049,18 +1049,18 @@ void Game::PushPythonRawCallable(PyObject* callable) { }); } -void Game::PushScreenMessage(const std::string& message, - const Vector3f& color) { +void Logic::PushScreenMessage(const std::string& message, + const Vector3f& color) { thread()->PushCall( [message, color] { g_graphics->AddScreenMessage(message, color); }); } -void Game::SetReplaySpeedExponent(int val) { +void Logic::SetReplaySpeedExponent(int val) { replay_speed_exponent_ = std::min(3, std::max(-3, val)); replay_speed_mult_ = powf(2.0f, static_cast(replay_speed_exponent_)); } -void Game::SetDebugSpeedExponent(int val) { +void Logic::SetDebugSpeedExponent(int val) { debug_speed_exponent_ = val; debug_speed_mult_ = powf(2.0f, static_cast(debug_speed_exponent_)); @@ -1068,7 +1068,7 @@ void Game::SetDebugSpeedExponent(int val) { if (s) s->DebugSpeedMultChanged(); } -void Game::ChangeGameSpeed(int offs) { +void Logic::ChangeGameSpeed(int offs) { assert(InLogicThread()); // If we're in a replay session, adjust playback speed there. @@ -1095,40 +1095,40 @@ void Game::ChangeGameSpeed(int offs) { } } -auto Game::GetUIContext() const -> Context { +auto Logic::GetUIContext() const -> Context { return Context(GetUIContextTarget()); } -void Game::PushToggleManualCameraCall() { +void Logic::PushToggleManualCameraCall() { thread()->PushCall([] { g_graphics->ToggleManualCamera(); }); } -void Game::PushToggleDebugInfoDisplayCall() { +void Logic::PushToggleDebugInfoDisplayCall() { thread()->PushCall([] { g_graphics->ToggleNetworkDebugDisplay(); }); } -void Game::PushToggleCollisionGeometryDisplayCall() { +void Logic::PushToggleCollisionGeometryDisplayCall() { thread()->PushCall([] { g_graphics->ToggleDebugDraw(); }); } -void Game::PushMainMenuPressCall(InputDevice* device) { +void Logic::PushMainMenuPressCall(InputDevice* device) { thread()->PushCall([this, device] { MainMenuPress(device); }); } -void Game::MainMenuPress(InputDevice* device) { +void Logic::MainMenuPress(InputDevice* device) { assert(InLogicThread()); g_python->HandleDeviceMenuPress(device); } -void Game::PushScreenResizeCall(float virtual_width, float virtual_height, - float pixel_width, float pixel_height) { +void Logic::PushScreenResizeCall(float virtual_width, float virtual_height, + float pixel_width, float pixel_height) { thread()->PushCall([=] { ScreenResize(virtual_width, virtual_height, pixel_width, pixel_height); }); } -void Game::ScreenResize(float virtual_width, float virtual_height, - float pixel_width, float pixel_height) { +void Logic::ScreenResize(float virtual_width, float virtual_height, + float pixel_width, float pixel_height) { assert(InLogicThread()); assert(g_graphics != nullptr); if (g_graphics) { @@ -1143,30 +1143,30 @@ void Game::ScreenResize(float virtual_width, float virtual_height, } } -void Game::PushGameServiceAchievementListCall( +void Logic::PushGameServiceAchievementListCall( const std::set& achievements) { thread()->PushCall( [this, achievements] { GameServiceAchievementList(achievements); }); } -void Game::GameServiceAchievementList( +void Logic::GameServiceAchievementList( const std::set& achievements) { assert(g_python); assert(InLogicThread()); g_app_internal->DispatchRemoteAchievementList(achievements); } -void Game::PushPlaySoundCall(SystemSoundID sound) { +void Logic::PushPlaySoundCall(SystemSoundID sound) { thread()->PushCall( [sound] { g_audio->PlaySound(g_assets->GetSound(sound)); }); } -void Game::PushFriendScoreSetCall(const FriendScoreSet& score_set) { +void Logic::PushFriendScoreSetCall(const FriendScoreSet& score_set) { thread()->PushCall( [score_set] { g_python->HandleFriendScoresCB(score_set); }); } -void Game::PushConfirmQuitCall() { +void Logic::PushConfirmQuitCall() { thread()->PushCall([this] { assert(InLogicThread()); if (HeadlessMode()) { @@ -1197,7 +1197,7 @@ void Game::PushConfirmQuitCall() { }); } -void Game::Draw() { +void Logic::Draw() { g_graphics->BuildAndPushFrameDef(); // Now bring the game up to date. @@ -1228,11 +1228,11 @@ void Game::Draw() { } } -void Game::PushFrameDefRequest() { +void Logic::PushFrameDefRequest() { thread()->PushCall([this] { Draw(); }); } -void Game::PushOnAppResumeCall() { +void Logic::PushOnAppResumeCall() { thread()->PushCall([] { // Wipe out whatever input device was in control of the UI. assert(g_ui); @@ -1241,7 +1241,7 @@ void Game::PushOnAppResumeCall() { } // Look through everything in our config dict and act on it. -void Game::ApplyConfig() { +void Logic::ApplyConfig() { assert(InLogicThread()); // Not relevant for fullscreen anymore @@ -1399,11 +1399,11 @@ void Game::ApplyConfig() { g_platform->ApplyConfig(); } -void Game::PushApplyConfigCall() { +void Logic::PushApplyConfigCall() { thread()->PushCall([this] { ApplyConfig(); }); } -void Game::PushRemoveGraphicsServerRenderHoldCall() { +void Logic::PushRemoveGraphicsServerRenderHoldCall() { thread()->PushCall([] { // This call acts as a flush of sorts; when it goes through, // we push a call to the graphics server saying its ok for it @@ -1413,7 +1413,7 @@ void Game::PushRemoveGraphicsServerRenderHoldCall() { }); } -void Game::PushFreeAssetComponentRefsCall( +void Logic::PushFreeAssetComponentRefsCall( const std::vector*>& components) { thread()->PushCall([components] { for (auto&& i : components) { @@ -1422,18 +1422,18 @@ void Game::PushFreeAssetComponentRefsCall( }); } -void Game::PushHavePendingLoadsDoneCall() { +void Logic::PushHavePendingLoadsDoneCall() { thread()->PushCall([] { g_assets->ClearPendingLoadsDoneList(); }); } -void Game::ToggleConsole() { +void Logic::ToggleConsole() { assert(InLogicThread()); if (auto console = g_app->console) { console->ToggleState(); } } -void Game::PushConsolePrintCall(const std::string& msg) { +void Logic::PushConsolePrintCall(const std::string& msg) { thread()->PushCall([msg] { // Send them to the console if its been created or store them // for when it is (unless we're headless in which case it never will). @@ -1445,18 +1445,18 @@ void Game::PushConsolePrintCall(const std::string& msg) { }); } -void Game::PushHavePendingLoadsCall() { +void Logic::PushHavePendingLoadsCall() { thread()->PushCall([this] { have_pending_loads_ = true; UpdateProcessTimer(); }); } -void Game::PushShutdownCall(bool soft) { +void Logic::PushShutdownCall(bool soft) { thread()->PushCall([this, soft] { Shutdown(soft); }); } -void Game::Shutdown(bool soft) { +void Logic::Shutdown(bool soft) { assert(InLogicThread()); if (!g_app->shutting_down) { @@ -1483,13 +1483,13 @@ void Game::Shutdown(bool soft) { } } -void Game::ResetInput() { +void Logic::ResetInput() { assert(InLogicThread()); g_input->ResetKeyboardHeldKeys(); g_input->ResetJoyStickHeldButtons(); } -auto Game::RemovePlayer(Player* player) -> void { +auto Logic::RemovePlayer(Player* player) -> void { assert(InLogicThread()); if (HostSession* host_session = player->GetHostSession()) { host_session->RemovePlayer(player); @@ -1498,31 +1498,33 @@ auto Game::RemovePlayer(Player* player) -> void { } } -auto Game::NewRealTimer(millisecs_t length, bool repeat, - const Object::Ref& runnable) -> int { +auto Logic::NewRealTimer(millisecs_t length, bool repeat, + const Object::Ref& runnable) -> int { int offset = 0; Timer* t = realtimers_->NewTimer(GetRealTime(), length, offset, repeat ? -1 : 0, runnable); return t->id(); } -void Game::DeleteRealTimer(int timer_id) { realtimers_->DeleteTimer(timer_id); } +void Logic::DeleteRealTimer(int timer_id) { + realtimers_->DeleteTimer(timer_id); +} -void Game::SetRealTimerLength(int timer_id, millisecs_t length) { +void Logic::SetRealTimerLength(int timer_id, millisecs_t length) { Timer* t = realtimers_->GetTimer(timer_id); if (t) { t->SetLength(length); } else { - Log("Error: Game::SetRealTimerLength() called on nonexistent timer."); + Log("Error: Logic::SetRealTimerLength() called on nonexistent timer."); } } -void Game::Process() { +void Logic::Process() { have_pending_loads_ = g_assets->RunPendingLoadsLogicThread(); UpdateProcessTimer(); } -void Game::SetLanguageKeys( +void Logic::SetLanguageKeys( const std::unordered_map& language) { assert(InLogicThread()); { @@ -1730,8 +1732,8 @@ auto DoCompileResourceString(cJSON* obj) -> std::string { return result; } -auto Game::CompileResourceString(const std::string& s, const std::string& loc, - bool* valid) -> std::string { +auto Logic::CompileResourceString(const std::string& s, const std::string& loc, + bool* valid) -> std::string { assert(g_python != nullptr); bool dummyvalid; @@ -1767,7 +1769,7 @@ auto Game::CompileResourceString(const std::string& s, const std::string& loc, return result; } -auto Game::GetResourceString(const std::string& key) -> std::string { +auto Logic::GetResourceString(const std::string& key) -> std::string { std::string val; { std::scoped_lock lock(language_mutex_); @@ -1779,7 +1781,7 @@ auto Game::GetResourceString(const std::string& key) -> std::string { return val; } -auto Game::CharStr(SpecialChar id) -> std::string { +auto Logic::CharStr(SpecialChar id) -> std::string { std::scoped_lock lock(special_char_mutex_); std::string val; auto i = special_char_strings_.find(id); @@ -1793,7 +1795,7 @@ auto Game::CharStr(SpecialChar id) -> std::string { return val; } -auto Game::ShouldAnnouncePartyJoinsAndLeaves() -> bool { +auto Logic::ShouldAnnouncePartyJoinsAndLeaves() -> bool { assert(InLogicThread()); // At the moment we don't announce these for public internet parties.. (too @@ -1801,7 +1803,7 @@ auto Game::ShouldAnnouncePartyJoinsAndLeaves() -> bool { return !public_party_enabled(); } -void Game::CleanUpBeforeConnectingToHost() { +void Logic::CleanUpBeforeConnectingToHost() { // We can't have connected clients and a host-connection at the same time. // Make a minimal attempt to disconnect any client connections we have, but // get them off the list immediately. @@ -1815,13 +1817,13 @@ void Game::CleanUpBeforeConnectingToHost() { SetPublicPartyEnabled(false); } -auto Game::GetPartySize() const -> int { +auto Logic::GetPartySize() const -> int { assert(InLogicThread()); assert(game_roster_ != nullptr); return cJSON_GetArraySize(game_roster_); } -void Game::LocalDisplayChatMessage(const std::vector& buffer) { +void Logic::LocalDisplayChatMessage(const std::vector& buffer) { // 1 type byte, 1 spec-len byte, 1 or more spec chars, 0 or more msg chars. if (buffer.size() > 3) { size_t spec_len = buffer[1]; @@ -1862,7 +1864,7 @@ void Game::LocalDisplayChatMessage(const std::vector& buffer) { } } -auto Game::GetGameRosterMessage() -> std::vector { +auto Logic::GetGameRosterMessage() -> std::vector { // This message is simply a flattened json string of our roster (including // terminating char). char* s = cJSON_PrintUnformatted(game_roster_); @@ -1875,7 +1877,7 @@ auto Game::GetGameRosterMessage() -> std::vector { return msg; } -auto Game::IsPlayerBanned(const PlayerSpec& spec) -> bool { +auto Logic::IsPlayerBanned(const PlayerSpec& spec) -> bool { millisecs_t current_time = GetRealTime(); // Now is a good time to prune no-longer-banned specs. @@ -1892,8 +1894,8 @@ auto Game::IsPlayerBanned(const PlayerSpec& spec) -> bool { return false; } -void Game::StartKickVote(ConnectionToClient* starter, - ConnectionToClient* target) { +void Logic::StartKickVote(ConnectionToClient* starter, + ConnectionToClient* target) { // Restrict votes per client. millisecs_t current_time = GetRealTime(); @@ -1991,11 +1993,11 @@ void Game::StartKickVote(ConnectionToClient* starter, } } -void Game::BanPlayer(const PlayerSpec& spec, millisecs_t duration) { +void Logic::BanPlayer(const PlayerSpec& spec, millisecs_t duration) { banned_players_.emplace_back(GetRealTime() + duration, spec); } -void Game::UpdateGameRoster() { +void Logic::UpdateGameRoster() { assert(InLogicThread()); assert(game_roster_ != nullptr); @@ -2106,7 +2108,7 @@ void Game::UpdateGameRoster() { game_roster_dirty_ = true; } -void Game::SetPublicPartyEnabled(bool val) { +void Logic::SetPublicPartyEnabled(bool val) { assert(InLogicThread()); if (val == public_party_enabled_) { return; @@ -2115,7 +2117,7 @@ void Game::SetPublicPartyEnabled(bool val) { g_app_internal->PushPublicPartyState(); } -void Game::SetPublicPartySize(int count) { +void Logic::SetPublicPartySize(int count) { assert(InLogicThread()); if (count == public_party_size_) { return; @@ -2129,7 +2131,7 @@ void Game::SetPublicPartySize(int count) { } } -void Game::SetPublicPartyMaxSize(int count) { +void Logic::SetPublicPartyMaxSize(int count) { assert(InLogicThread()); if (count == public_party_max_size_) { return; @@ -2143,7 +2145,7 @@ void Game::SetPublicPartyMaxSize(int count) { } } -void Game::SetPublicPartyName(const std::string& name) { +void Logic::SetPublicPartyName(const std::string& name) { assert(InLogicThread()); if (name == public_party_name_) { return; @@ -2157,7 +2159,7 @@ void Game::SetPublicPartyName(const std::string& name) { } } -void Game::SetPublicPartyStatsURL(const std::string& url) { +void Logic::SetPublicPartyStatsURL(const std::string& url) { assert(InLogicThread()); if (url == public_party_stats_url_) { return; @@ -2171,7 +2173,7 @@ void Game::SetPublicPartyStatsURL(const std::string& url) { } } -void Game::SetPublicPartyPlayerCount(int count) { +void Logic::SetPublicPartyPlayerCount(int count) { assert(InLogicThread()); if (count == public_party_player_count_) { return; diff --git a/src/ballistica/game/game.h b/src/ballistica/logic/logic.h similarity index 99% rename from src/ballistica/game/game.h rename to src/ballistica/logic/logic.h index 9685e5bf..def5a310 100644 --- a/src/ballistica/game/game.h +++ b/src/ballistica/logic/logic.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_GAME_H_ -#define BALLISTICA_GAME_GAME_H_ +#ifndef BALLISTICA_LOGIC_LOGIC_H_ +#define BALLISTICA_LOGIC_LOGIC_H_ #include #include @@ -22,9 +22,9 @@ const int kMaxPartyNameCombinedSize = 25; /// The Game Module generally runs on a dedicated thread; it manages /// all game logic, builds frame_defs to send to the graphics-server for /// rendering, etc. -class Game { +class Logic { public: - Game(); + Logic(); auto OnAppStart() -> void; auto LaunchHostSession(PyObject* session_type_obj, @@ -338,4 +338,4 @@ class Game { } // namespace ballistica -#endif // BALLISTICA_GAME_GAME_H_ +#endif // BALLISTICA_LOGIC_LOGIC_H_ diff --git a/src/ballistica/game/player.cc b/src/ballistica/logic/player.cc similarity index 98% rename from src/ballistica/game/player.cc rename to src/ballistica/logic/player.cc index 198d4ad1..78589270 100644 --- a/src/ballistica/game/player.cc +++ b/src/ballistica/logic/player.cc @@ -1,11 +1,11 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/player.h" +#include "ballistica/logic/player.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/generic/utils.h" #include "ballistica/input/device/joystick.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/class/python_class_session_player.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" @@ -367,7 +367,7 @@ void Player::SetName(const std::string& name, const std::string& full_name, // If we're already in the game and our name is changing, we need to update // the roster. if (accepted_) { - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); } } diff --git a/src/ballistica/game/player.h b/src/ballistica/logic/player.h similarity index 98% rename from src/ballistica/game/player.h rename to src/ballistica/logic/player.h index d501cda2..e9d6682c 100644 --- a/src/ballistica/game/player.h +++ b/src/ballistica/logic/player.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_PLAYER_H_ -#define BALLISTICA_GAME_PLAYER_H_ +#ifndef BALLISTICA_LOGIC_PLAYER_H_ +#define BALLISTICA_LOGIC_PLAYER_H_ #include #include @@ -164,4 +164,4 @@ class Player : public Object { } // namespace ballistica -#endif // BALLISTICA_GAME_PLAYER_H_ +#endif // BALLISTICA_LOGIC_PLAYER_H_ diff --git a/src/ballistica/game/player_spec.cc b/src/ballistica/logic/player_spec.cc similarity index 93% rename from src/ballistica/game/player_spec.cc rename to src/ballistica/logic/player_spec.cc index fc5b4502..71b6f515 100644 --- a/src/ballistica/game/player_spec.cc +++ b/src/ballistica/logic/player_spec.cc @@ -1,12 +1,12 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/player_spec.h" +#include "ballistica/logic/player_spec.h" #include "ballistica/app/app.h" -#include "ballistica/game/game.h" -#include "ballistica/game/v1_account.h" #include "ballistica/generic/json.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/platform/platform.h" namespace ballistica { @@ -84,9 +84,9 @@ auto PlayerSpec::GetAccountPlayerSpec() -> PlayerSpec { } else { // Headless builds fall back to V1 public-party name if that's available. if (g_buildconfig.headless_build() - && !g_game->public_party_name().empty()) { + && !g_logic->public_party_name().empty()) { spec.name_ = - Utils::GetValidUTF8(g_game->public_party_name().c_str(), "bsgp3r"); + Utils::GetValidUTF8(g_logic->public_party_name().c_str(), "bsgp3r"); } else { // Or lastly fall back to device name. spec.name_ = diff --git a/src/ballistica/game/player_spec.h b/src/ballistica/logic/player_spec.h similarity index 93% rename from src/ballistica/game/player_spec.h rename to src/ballistica/logic/player_spec.h index c9d5d225..8d1bbc49 100644 --- a/src/ballistica/game/player_spec.h +++ b/src/ballistica/logic/player_spec.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_PLAYER_SPEC_H_ -#define BALLISTICA_GAME_PLAYER_SPEC_H_ +#ifndef BALLISTICA_LOGIC_PLAYER_SPEC_H_ +#define BALLISTICA_LOGIC_PLAYER_SPEC_H_ #include @@ -56,4 +56,4 @@ class PlayerSpec { } // namespace ballistica -#endif // BALLISTICA_GAME_PLAYER_SPEC_H_ +#endif // BALLISTICA_LOGIC_PLAYER_SPEC_H_ diff --git a/src/ballistica/game/session/client_session.cc b/src/ballistica/logic/session/client_session.cc similarity index 99% rename from src/ballistica/game/session/client_session.cc rename to src/ballistica/logic/session/client_session.cc index b1b4994c..d9b72a57 100644 --- a/src/ballistica/game/session/client_session.cc +++ b/src/ballistica/logic/session/client_session.cc @@ -1,6 +1,6 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/session/client_session.h" +#include "ballistica/logic/session/client_session.h" #include "ballistica/app/app.h" #include "ballistica/assets/component/collide_model.h" @@ -360,7 +360,7 @@ void ClientSession::Update(int time_advance) { } case SessionCommand::kSetForegroundSceneGraph: { Scene* scene = GetScene(ReadInt32()); - g_game->SetForegroundScene(scene); + g_logic->SetForegroundScene(scene); break; } case SessionCommand::kNodeMessage: { diff --git a/src/ballistica/game/session/client_session.h b/src/ballistica/logic/session/client_session.h similarity index 94% rename from src/ballistica/game/session/client_session.h rename to src/ballistica/logic/session/client_session.h index e696c707..2536848d 100644 --- a/src/ballistica/game/session/client_session.h +++ b/src/ballistica/logic/session/client_session.h @@ -1,14 +1,14 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_SESSION_CLIENT_SESSION_H_ -#define BALLISTICA_GAME_SESSION_CLIENT_SESSION_H_ +#ifndef BALLISTICA_LOGIC_SESSION_CLIENT_SESSION_H_ +#define BALLISTICA_LOGIC_SESSION_CLIENT_SESSION_H_ #include #include #include -#include "ballistica/game/client_controller_interface.h" -#include "ballistica/game/session/session.h" +#include "ballistica/logic/client_controller_interface.h" +#include "ballistica/logic/session/session.h" namespace ballistica { @@ -135,4 +135,4 @@ class ClientSession : public Session { } // namespace ballistica -#endif // BALLISTICA_GAME_SESSION_CLIENT_SESSION_H_ +#endif // BALLISTICA_LOGIC_SESSION_CLIENT_SESSION_H_ diff --git a/src/ballistica/game/session/host_session.cc b/src/ballistica/logic/session/host_session.cc similarity index 96% rename from src/ballistica/game/session/host_session.cc rename to src/ballistica/logic/session/host_session.cc index 2a35b169..6dbbe3a1 100644 --- a/src/ballistica/game/session/host_session.cc +++ b/src/ballistica/logic/session/host_session.cc @@ -1,17 +1,17 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/session/host_session.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/assets/component/data.h" #include "ballistica/assets/component/model.h" #include "ballistica/assets/component/sound.h" #include "ballistica/assets/component/texture.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/player.h" #include "ballistica/generic/lambda_runnable.h" #include "ballistica/generic/timer.h" #include "ballistica/graphics/graphics.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/player.h" #include "ballistica/python/python.h" #include "ballistica/python/python_command.h" #include "ballistica/python/python_context_call.h" @@ -22,7 +22,7 @@ namespace ballistica { HostSession::HostSession(PyObject* session_type_obj) : last_kick_idle_players_decrement_time_(GetRealTime()) { - assert(g_game); + assert(g_logic); assert(InLogicThread()); assert(session_type_obj != nullptr); @@ -34,7 +34,7 @@ HostSession::HostSession(PyObject* session_type_obj) "bastd.mainmenu.MainMenuSession")); // Log("MAIN MENU? " + std::to_string(is_main_menu())); - kick_idle_players_ = g_game->kick_idle_players(); + kick_idle_players_ = g_logic->kick_idle_players(); // Create a timer to step our session scene. step_scene_timer_ = @@ -90,7 +90,7 @@ HostSession::HostSession(PyObject* session_type_obj) // Lastly, keep the python layer fed with our latest player count in case // it is updating the master-server with our current/max player counts. - g_game->SetPublicPartyPlayerCount(static_cast(players_.size())); + g_logic->SetPublicPartyPlayerCount(static_cast(players_.size())); } auto HostSession::GetHostSession() -> HostSession* { return this; } @@ -272,12 +272,12 @@ void HostSession::RequestPlayer(InputDevice* device) { // If he was accepted, update our game roster with the new info. if (accept) { - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); } // Lastly, keep the python layer fed with our latest player count in case it // is updating the master-server with our current/max player counts. - g_game->SetPublicPartyPlayerCount(static_cast(players_.size())); + g_logic->SetPublicPartyPlayerCount(static_cast(players_.size())); } void HostSession::RemovePlayer(Player* player) { @@ -296,11 +296,11 @@ void HostSession::RemovePlayer(Player* player) { } // Update our game roster with the departure. - g_game->UpdateGameRoster(); + g_logic->UpdateGameRoster(); // Lastly, keep the python layer fed with our latest player count in case // it is updating the master-server with our current/max player counts. - g_game->SetPublicPartyPlayerCount(static_cast(players_.size())); + g_logic->SetPublicPartyPlayerCount(static_cast(players_.size())); return; } @@ -369,7 +369,7 @@ void HostSession::SetForegroundHostActivity(HostActivity* a) { // Now go through telling each host-activity whether it's foregrounded or not. // FIXME: Dying sessions never get told they're un-foregrounded.. could that // ever be a problem? - bool session_is_foreground = (g_game->GetForegroundSession() != nullptr); + bool session_is_foreground = (g_logic->GetForegroundSession() != nullptr); for (auto&& i : host_activities_) { i->SetIsForeground(session_is_foreground && (i == a)); } @@ -442,7 +442,7 @@ void HostSession::DecrementPlayerTimeOuts(millisecs_t millisecs) { assert(player); if (player->time_out() < millisecs) { std::string kick_str = - g_game->GetResourceString("kickIdlePlayersKickedText"); + g_logic->GetResourceString("kickIdlePlayersKickedText"); Utils::StringReplaceOne(&kick_str, "${NAME}", player->GetName()); ScreenMessage(kick_str); RemovePlayer(player); @@ -450,12 +450,12 @@ void HostSession::DecrementPlayerTimeOuts(millisecs_t millisecs) { } else if (player->time_out() > BA_PLAYER_TIME_OUT_WARN && (player->time_out() - millisecs <= BA_PLAYER_TIME_OUT_WARN)) { std::string kick_str_1 = - g_game->GetResourceString("kickIdlePlayersWarning1Text"); + g_logic->GetResourceString("kickIdlePlayersWarning1Text"); Utils::StringReplaceOne(&kick_str_1, "${NAME}", player->GetName()); Utils::StringReplaceOne(&kick_str_1, "${COUNT}", std::to_string(BA_PLAYER_TIME_OUT_WARN / 1000)); ScreenMessage(kick_str_1); - ScreenMessage(g_game->GetResourceString("kickIdlePlayersWarning2Text")); + ScreenMessage(g_logic->GetResourceString("kickIdlePlayersWarning2Text")); } player->set_time_out(player->time_out() - millisecs); } diff --git a/src/ballistica/game/session/host_session.h b/src/ballistica/logic/session/host_session.h similarity index 95% rename from src/ballistica/game/session/host_session.h rename to src/ballistica/logic/session/host_session.h index 2f5e7546..20729dfa 100644 --- a/src/ballistica/game/session/host_session.h +++ b/src/ballistica/logic/session/host_session.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_SESSION_HOST_SESSION_H_ -#define BALLISTICA_GAME_SESSION_HOST_SESSION_H_ +#ifndef BALLISTICA_LOGIC_SESSION_HOST_SESSION_H_ +#define BALLISTICA_LOGIC_SESSION_HOST_SESSION_H_ #include #include @@ -9,8 +9,8 @@ #include #include "ballistica/core/context.h" -#include "ballistica/game/session/session.h" #include "ballistica/generic/timer_list.h" +#include "ballistica/logic/session/session.h" #include "ballistica/python/python_ref.h" namespace ballistica { @@ -128,4 +128,4 @@ class HostSession : public Session { } // namespace ballistica -#endif // BALLISTICA_GAME_SESSION_HOST_SESSION_H_ +#endif // BALLISTICA_LOGIC_SESSION_HOST_SESSION_H_ diff --git a/src/ballistica/game/session/net_client_session.cc b/src/ballistica/logic/session/net_client_session.cc similarity index 98% rename from src/ballistica/game/session/net_client_session.cc rename to src/ballistica/logic/session/net_client_session.cc index 4826a057..795bd1ee 100644 --- a/src/ballistica/game/session/net_client_session.cc +++ b/src/ballistica/logic/session/net_client_session.cc @@ -1,12 +1,12 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/session/net_client_session.h" +#include "ballistica/logic/session/net_client_session.h" #include "ballistica/app/app.h" #include "ballistica/assets/assets_server.h" -#include "ballistica/game/connection/connection_to_host.h" #include "ballistica/graphics/graphics.h" #include "ballistica/graphics/net_graph.h" +#include "ballistica/logic/connection/connection_to_host.h" namespace ballistica { diff --git a/src/ballistica/game/session/net_client_session.h b/src/ballistica/logic/session/net_client_session.h similarity index 88% rename from src/ballistica/game/session/net_client_session.h rename to src/ballistica/logic/session/net_client_session.h index de232896..c53e9b0f 100644 --- a/src/ballistica/game/session/net_client_session.h +++ b/src/ballistica/logic/session/net_client_session.h @@ -1,11 +1,11 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_SESSION_NET_CLIENT_SESSION_H_ -#define BALLISTICA_GAME_SESSION_NET_CLIENT_SESSION_H_ +#ifndef BALLISTICA_LOGIC_SESSION_NET_CLIENT_SESSION_H_ +#define BALLISTICA_LOGIC_SESSION_NET_CLIENT_SESSION_H_ #include -#include "ballistica/game/session/client_session.h" +#include "ballistica/logic/session/client_session.h" namespace ballistica { @@ -59,4 +59,4 @@ class NetClientSession : public ClientSession { } // namespace ballistica -#endif // BALLISTICA_GAME_SESSION_NET_CLIENT_SESSION_H_ +#endif // BALLISTICA_LOGIC_SESSION_NET_CLIENT_SESSION_H_ diff --git a/src/ballistica/game/session/replay_client_session.cc b/src/ballistica/logic/session/replay_client_session.cc similarity index 93% rename from src/ballistica/game/session/replay_client_session.cc rename to src/ballistica/logic/session/replay_client_session.cc index 3d299168..c93fb45f 100644 --- a/src/ballistica/game/session/replay_client_session.cc +++ b/src/ballistica/logic/session/replay_client_session.cc @@ -1,12 +1,12 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/session/replay_client_session.h" +#include "ballistica/logic/session/replay_client_session.h" #include "ballistica/dynamics/material/material.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client.h" #include "ballistica/generic/huffman.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/networking.h" #include "ballistica/platform/platform.h" @@ -17,13 +17,13 @@ namespace ballistica { auto ReplayClientSession::GetActualTimeAdvance(int advance_in) -> int { return static_cast( - round(advance_in * pow(2.0f, g_game->replay_speed_exponent()))); + round(advance_in * pow(2.0f, g_logic->replay_speed_exponent()))); } ReplayClientSession::ReplayClientSession(std::string filename) : file_name_(std::move(filename)) { // take responsibility for feeding all clients to this device.. - g_game->connections()->RegisterClientController(this); + g_logic->connections()->RegisterClientController(this); // go ahead and just do a reset here, which will get things going.. Reset(true); @@ -31,7 +31,7 @@ ReplayClientSession::ReplayClientSession(std::string filename) ReplayClientSession::~ReplayClientSession() { // we no longer are responsible for feeding clients to this device.. - g_game->connections()->UnregisterClientController(this); + g_logic->connections()->UnregisterClientController(this); if (file_) { fclose(file_); @@ -198,7 +198,7 @@ void ReplayClientSession::FetchMessages() { void ReplayClientSession::Error(const std::string& description) { // Close the replay, announce something went wrong with it, and then do // standard error response.. - ScreenMessage(g_game->GetResourceString("replayReadErrorText"), {1, 0, 0}); + ScreenMessage(g_logic->GetResourceString("replayReadErrorText"), {1, 0, 0}); if (file_) { fclose(file_); file_ = nullptr; @@ -246,7 +246,7 @@ void ReplayClientSession::OnReset(bool rewind) { return; } if (version > kProtocolVersion || version < kProtocolVersionMin) { - ScreenMessage(g_game->GetResourceString("replayVersionErrorText"), + ScreenMessage(g_logic->GetResourceString("replayVersionErrorText"), {1, 0, 0}); End(); return; diff --git a/src/ballistica/game/session/replay_client_session.h b/src/ballistica/logic/session/replay_client_session.h similarity index 79% rename from src/ballistica/game/session/replay_client_session.h rename to src/ballistica/logic/session/replay_client_session.h index 411da3db..5e03044a 100644 --- a/src/ballistica/game/session/replay_client_session.h +++ b/src/ballistica/logic/session/replay_client_session.h @@ -1,13 +1,13 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_SESSION_REPLAY_CLIENT_SESSION_H_ -#define BALLISTICA_GAME_SESSION_REPLAY_CLIENT_SESSION_H_ +#ifndef BALLISTICA_LOGIC_SESSION_REPLAY_CLIENT_SESSION_H_ +#define BALLISTICA_LOGIC_SESSION_REPLAY_CLIENT_SESSION_H_ #include #include -#include "ballistica/game/client_controller_interface.h" -#include "ballistica/game/session/client_session.h" +#include "ballistica/logic/client_controller_interface.h" +#include "ballistica/logic/session/client_session.h" namespace ballistica { @@ -39,4 +39,4 @@ class ReplayClientSession : public ClientSession, } // namespace ballistica -#endif // BALLISTICA_GAME_SESSION_REPLAY_CLIENT_SESSION_H_ +#endif // BALLISTICA_LOGIC_SESSION_REPLAY_CLIENT_SESSION_H_ diff --git a/src/ballistica/game/session/session.cc b/src/ballistica/logic/session/session.cc similarity index 85% rename from src/ballistica/game/session/session.cc rename to src/ballistica/logic/session/session.cc index 0a93eede..facb0460 100644 --- a/src/ballistica/game/session/session.cc +++ b/src/ballistica/logic/session/session.cc @@ -1,9 +1,9 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/session/session.h" +#include "ballistica/logic/session/session.h" #include "ballistica/app/app.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" namespace ballistica { @@ -11,7 +11,7 @@ Session::Session() { g_app->session_count++; // New sessions immediately become foreground. - g_game->SetForegroundSession(this); + g_logic->SetForegroundSession(this); } Session::~Session() { g_app->session_count--; } diff --git a/src/ballistica/game/session/session.h b/src/ballistica/logic/session/session.h similarity index 90% rename from src/ballistica/game/session/session.h rename to src/ballistica/logic/session/session.h index 476cc11f..e212b79f 100644 --- a/src/ballistica/game/session/session.h +++ b/src/ballistica/logic/session/session.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_SESSION_SESSION_H_ -#define BALLISTICA_GAME_SESSION_SESSION_H_ +#ifndef BALLISTICA_LOGIC_SESSION_SESSION_H_ +#define BALLISTICA_LOGIC_SESSION_SESSION_H_ #include "ballistica/core/context.h" #include "ballistica/core/object.h" @@ -41,4 +41,4 @@ class Session : public ContextTarget { } // namespace ballistica -#endif // BALLISTICA_GAME_SESSION_SESSION_H_ +#endif // BALLISTICA_LOGIC_SESSION_SESSION_H_ diff --git a/src/ballistica/game/v1_account.cc b/src/ballistica/logic/v1_account.cc similarity index 90% rename from src/ballistica/game/v1_account.cc rename to src/ballistica/logic/v1_account.cc index 3b16bd91..23ccd39b 100644 --- a/src/ballistica/game/v1_account.cc +++ b/src/ballistica/logic/v1_account.cc @@ -1,11 +1,11 @@ // Released under the MIT License. See LICENSE for details. -#include "ballistica/game/v1_account.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/app/app.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/platform.h" namespace ballistica { @@ -66,24 +66,24 @@ auto V1Account::AccountTypeToString(V1AccountType type) -> std::string { auto V1Account::AccountTypeToIconString(V1AccountType type) -> std::string { switch (type) { case V1AccountType::kTest: - return g_game->CharStr(SpecialChar::kTestAccount); + return g_logic->CharStr(SpecialChar::kTestAccount); case V1AccountType::kNvidiaChina: - return g_game->CharStr(SpecialChar::kNvidiaLogo); + return g_logic->CharStr(SpecialChar::kNvidiaLogo); case V1AccountType::kGooglePlay: - return g_game->CharStr(SpecialChar::kGooglePlayGamesLogo); + return g_logic->CharStr(SpecialChar::kGooglePlayGamesLogo); case V1AccountType::kSteam: - return g_game->CharStr(SpecialChar::kSteamLogo); + return g_logic->CharStr(SpecialChar::kSteamLogo); case V1AccountType::kOculus: - return g_game->CharStr(SpecialChar::kOculusLogo); + return g_logic->CharStr(SpecialChar::kOculusLogo); case V1AccountType::kGameCenter: - return g_game->CharStr(SpecialChar::kGameCenterLogo); + return g_logic->CharStr(SpecialChar::kGameCenterLogo); case V1AccountType::kGameCircle: - return g_game->CharStr(SpecialChar::kGameCircleLogo); + return g_logic->CharStr(SpecialChar::kGameCircleLogo); case V1AccountType::kDevice: case V1AccountType::kServer: - return g_game->CharStr(SpecialChar::kLocalAccount); + return g_logic->CharStr(SpecialChar::kLocalAccount); case V1AccountType::kV2: - return g_game->CharStr(SpecialChar::kV2Logo); + return g_logic->CharStr(SpecialChar::kV2Logo); default: return ""; } diff --git a/src/ballistica/game/v1_account.h b/src/ballistica/logic/v1_account.h similarity index 94% rename from src/ballistica/game/v1_account.h rename to src/ballistica/logic/v1_account.h index d7c03345..6b61243b 100644 --- a/src/ballistica/game/v1_account.h +++ b/src/ballistica/logic/v1_account.h @@ -1,7 +1,7 @@ // Released under the MIT License. See LICENSE for details. -#ifndef BALLISTICA_GAME_V1_ACCOUNT_H_ -#define BALLISTICA_GAME_V1_ACCOUNT_H_ +#ifndef BALLISTICA_LOGIC_V1_ACCOUNT_H_ +#define BALLISTICA_LOGIC_V1_ACCOUNT_H_ #include #include @@ -63,4 +63,4 @@ class V1Account { } // namespace ballistica -#endif // BALLISTICA_GAME_V1_ACCOUNT_H_ +#endif // BALLISTICA_LOGIC_V1_ACCOUNT_H_ diff --git a/src/ballistica/networking/network_reader.cc b/src/ballistica/networking/network_reader.cc index 653a28c6..203afb4f 100644 --- a/src/ballistica/networking/network_reader.cc +++ b/src/ballistica/networking/network_reader.cc @@ -2,11 +2,11 @@ #include "ballistica/networking/network_reader.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" -#include "ballistica/game/player_spec.h" #include "ballistica/generic/json.h" #include "ballistica/input/remote_app.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/player_spec.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/network_writer.h" #include "ballistica/networking/sockaddr.h" @@ -97,8 +97,8 @@ static auto HandleJSONPing(const std::string& data_str) -> std::string { int party_size = 0; int party_size_max = 10; if (g_python != nullptr) { - party_size = g_game->public_party_size(); - party_size_max = g_game->public_party_max_size(); + party_size = g_logic->public_party_size(); + party_size_max = g_logic->public_party_max_size(); } snprintf(buffer, sizeof(buffer), R"({"b":%d,"ps":%d,"psmx":%d})", kAppBuildNumber, party_size, party_size_max); @@ -110,7 +110,7 @@ static auto HandleGameQuery(const char* buffer, size_t size, if (size == 5) { // If we're already in a party, don't advertise since they // wouldn't be able to join us anyway. - if (g_game->connections()->has_connection_to_host()) { + if (g_logic->connections()->has_connection_to_host()) { return; } @@ -348,7 +348,7 @@ auto NetworkReader::RunThread() -> int { // connections.. pass them to the game thread to wrangle. std::vector msg_buffer(rresult2); memcpy(&(msg_buffer[0]), buffer, rresult2); - g_game->connections()->PushUDPConnectionPacketCall( + g_logic->connections()->PushUDPConnectionPacketCall( msg_buffer, SockAddr(from)); break; } diff --git a/src/ballistica/networking/networking.cc b/src/ballistica/networking/networking.cc index 1cfbcbf0..3aaca894 100644 --- a/src/ballistica/networking/networking.cc +++ b/src/ballistica/networking/networking.cc @@ -3,7 +3,7 @@ #include "ballistica/networking/networking.h" #include "ballistica/app/app.h" -#include "ballistica/game/player_spec.h" +#include "ballistica/logic/player_spec.h" #include "ballistica/networking/network_reader.h" #include "ballistica/networking/sockaddr.h" #include "ballistica/platform/platform.h" diff --git a/src/ballistica/networking/telnet_server.cc b/src/ballistica/networking/telnet_server.cc index 224afaca..91c430c1 100644 --- a/src/ballistica/networking/telnet_server.cc +++ b/src/ballistica/networking/telnet_server.cc @@ -5,7 +5,7 @@ #include "ballistica/app/app.h" #include "ballistica/core/context.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/networking.h" #include "ballistica/networking/networking_sys.h" #include "ballistica/platform/platform.h" @@ -106,16 +106,16 @@ auto TelnetServer::RunThread() -> int { } // If we dont have access and havnt asked the user for it yet, ask them. - if (!user_has_granted_access_ && g_game + if (!user_has_granted_access_ && g_logic && !have_asked_user_for_access_) { - g_game->PushAskUserForTelnetAccessCall(); + g_logic->PushAskUserForTelnetAccessCall(); have_asked_user_for_access_ = true; } // Require password for each connection if we have one reading_password_ = require_password_; - if (g_game) { + if (g_logic) { if (reading_password_) { PushPrint(password_prompt); } else { @@ -144,7 +144,7 @@ auto TelnetServer::RunThread() -> int { if (result > 1 && (buffer[result - 2] == '\r')) buffer[result - 2] = 0; } - if (g_game) { + if (g_logic) { if (user_has_granted_access_) { if (reading_password_) { if (GetRealTime() - last_try_time_ < 2000) { @@ -163,7 +163,7 @@ auto TelnetServer::RunThread() -> int { PushTelnetScriptCommand(buffer); } } else { - PushPrint(g_game->GetResourceString("telnetAccessDeniedText")); + PushPrint(g_logic->GetResourceString("telnetAccessDeniedText")); } } } @@ -185,13 +185,13 @@ auto TelnetServer::RunThread() -> int { #pragma clang diagnostic pop void TelnetServer::PushTelnetScriptCommand(const std::string& command) { - assert(g_game); - if (g_game == nullptr) { + assert(g_logic); + if (g_logic == nullptr) { return; } - g_game->thread()->PushCall([this, command] { + g_logic->thread()->PushCall([this, command] { // These are always run in whichever context is 'visible'. - ScopedSetContext cp(g_game->GetForegroundContext()); + ScopedSetContext cp(g_logic->GetForegroundContext()); if (!g_app->user_ran_commands) { g_app->user_ran_commands = true; } @@ -216,8 +216,8 @@ void TelnetServer::PushTelnetScriptCommand(const std::string& command) { } void TelnetServer::PushPrint(const std::string& s) { - assert(g_game); - g_game->thread()->PushCall([this, s] { Print(s); }); + assert(g_logic); + g_logic->thread()->PushCall([this, s] { Print(s); }); } void TelnetServer::Print(const std::string& s) { diff --git a/src/ballistica/platform/platform.cc b/src/ballistica/platform/platform.cc index 292355e0..8ce6ada9 100644 --- a/src/ballistica/platform/platform.cc +++ b/src/ballistica/platform/platform.cc @@ -22,14 +22,14 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/core/thread.h" #include "ballistica/dynamics/bg/bg_dynamics_server.h" -#include "ballistica/game/friend_score_set.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/graphics.h" #include "ballistica/graphics/mesh/sprite_mesh.h" #include "ballistica/graphics/vr_graphics.h" #include "ballistica/input/input.h" +#include "ballistica/logic/friend_score_set.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/networking_sys.h" #include "ballistica/platform/sdl/sdl_app.h" #include "ballistica/platform/stdio_console.h" @@ -849,7 +849,7 @@ void Platform::GetFriendScores(const std::string& game, const std::string& game_version, void* data) { // As a default, just fail gracefully. Log("FIXME: GetFriendScores unimplemented"); - g_game->PushFriendScoreSetCall(FriendScoreSet(false, data)); + g_logic->PushFriendScoreSetCall(FriendScoreSet(false, data)); } void Platform::SubmitScore(const std::string& game, const std::string& version, @@ -940,7 +940,7 @@ void Platform::DrainAutoReleasePool(void* pool) { throw Exception(); } void Platform::OpenURL(const std::string& url) { // Can't open URLs in VR - just tell the game thread to show the url. if (IsVRMode()) { - g_game->PushShowURLCall(url); + g_logic->PushShowURLCall(url); return; } @@ -1277,10 +1277,10 @@ auto Platform::HavePermission(Permission p) -> bool { #if !BA_OSTYPE_WINDOWS static void HandleSIGINT(int s) { - if (g_game) { - g_game->PushInterruptSignalCall(); + if (g_logic) { + g_logic->PushInterruptSignalCall(); } else { - Log("SigInt handler called before g_game exists."); + Log("SigInt handler called before g_logic exists."); } } #endif diff --git a/src/ballistica/platform/sdl/sdl_app.cc b/src/ballistica/platform/sdl/sdl_app.cc index bda417c7..24801293 100644 --- a/src/ballistica/platform/sdl/sdl_app.cc +++ b/src/ballistica/platform/sdl/sdl_app.cc @@ -7,11 +7,11 @@ #include "ballistica/app/stress_test.h" #include "ballistica/core/thread.h" #include "ballistica/dynamics/bg/bg_dynamics.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/gl/gl_sys.h" #include "ballistica/graphics/graphics_server.h" #include "ballistica/input/device/joystick.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" @@ -155,7 +155,7 @@ void SDLApp::HandleSDLEvent(const SDL_Event& event) { #endif case SDL_QUIT: - g_game->PushShutdownCall(false); + g_logic->PushShutdownCall(false); break; #if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD diff --git a/src/ballistica/platform/stdio_console.cc b/src/ballistica/platform/stdio_console.cc index 8b7b335b..e0882e65 100644 --- a/src/ballistica/platform/stdio_console.cc +++ b/src/ballistica/platform/stdio_console.cc @@ -8,7 +8,7 @@ #include "ballistica/app/app.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/platform.h" namespace ballistica { @@ -32,7 +32,7 @@ auto StdioConsole::OnAppStart() -> void { // We send this to the logic thread so it happens AFTER the // results of the last script-command message we may have just sent. if (stdin_is_terminal) { - g_game->thread()->PushCall([] { + g_logic->thread()->PushCall([] { if (!g_app->shutting_down) { printf(">>> "); fflush(stdout); @@ -53,7 +53,7 @@ auto StdioConsole::OnAppStart() -> void { && pending_input_[pending_input_.size() - 1] == '\n') { // Get rid of the last newline and ship it to the game. pending_input_.pop_back(); - g_game->PushStdinScriptCommand(pending_input_); + g_logic->PushStdinScriptCommand(pending_input_); pending_input_.clear(); } } else { diff --git a/src/ballistica/platform/windows/platform_windows.cc b/src/ballistica/platform/windows/platform_windows.cc index 04fb6233..9269f3ad 100644 --- a/src/ballistica/platform/windows/platform_windows.cc +++ b/src/ballistica/platform/windows/platform_windows.cc @@ -32,7 +32,7 @@ #pragma comment(lib, "SDL2main.lib") #endif -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/networking/networking_sys.h" #include "ballistica/platform/min_sdl.h" @@ -108,10 +108,10 @@ PlatformWindows::PlatformWindows() { BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { switch (fdwCtrlType) { case CTRL_C_EVENT: - if (g_game) { - g_game->PushInterruptSignalCall(); + if (g_logic) { + g_logic->PushInterruptSignalCall(); } else { - Log("SigInt handler called before g_game exists."); + Log("SigInt handler called before g_logic exists."); } return TRUE; diff --git a/src/ballistica/python/class/python_class_activity_data.cc b/src/ballistica/python/class/python_class_activity_data.cc index 016a1a8b..b08927f9 100644 --- a/src/ballistica/python/class/python_class_activity_data.cc +++ b/src/ballistica/python/class/python_class_activity_data.cc @@ -3,10 +3,10 @@ #include "ballistica/python/class/python_class_activity_data.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" namespace ballistica { @@ -85,7 +85,7 @@ void PythonClassActivityData::tp_dealloc(PythonClassActivityData* self) { // it if need be; otherwise do it immediately. if (!InLogicThread()) { Object::WeakRef* h = self->host_activity_; - g_game->thread()->PushCall([h] { delete h; }); + g_logic->thread()->PushCall([h] { delete h; }); } else { delete self->host_activity_; } diff --git a/src/ballistica/python/class/python_class_collide_model.cc b/src/ballistica/python/class/python_class_collide_model.cc index 7ca5e787..6616aadc 100644 --- a/src/ballistica/python/class/python_class_collide_model.cc +++ b/src/ballistica/python/class/python_class_collide_model.cc @@ -4,7 +4,7 @@ #include "ballistica/assets/component/collide_model.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -105,7 +105,7 @@ void PythonClassCollideModel::tp_dealloc(PythonClassCollideModel* self) { // be; otherwise do it immediately if (!InLogicThread()) { Object::Ref* c = self->collide_model_; - g_game->thread()->PushCall([c] { Delete(c); }); + g_logic->thread()->PushCall([c] { Delete(c); }); } else { Delete(self->collide_model_); } diff --git a/src/ballistica/python/class/python_class_context.cc b/src/ballistica/python/class/python_class_context.cc index 09338be3..2b4c52ab 100644 --- a/src/ballistica/python/class/python_class_context.cc +++ b/src/ballistica/python/class/python_class_context.cc @@ -3,9 +3,9 @@ #include "ballistica/python/class/python_class_context.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" #include "ballistica/ui/ui.h" @@ -145,11 +145,11 @@ auto PythonClassContext::tp_new(PyTypeObject* type, PyObject* args, if (Python::IsPyString(source_obj)) { std::string source = Python::GetPyString(source_obj); if (source == "ui") { - cs = Context(g_game->GetUIContextTarget()); + cs = Context(g_logic->GetUIContextTarget()); } else if (source == "UI") { BA_LOG_ONCE("'UI' context-target option is deprecated; please use 'ui'"); Python::PrintStackTrace(); - cs = Context(g_game->GetUIContextTarget()); + cs = Context(g_logic->GetUIContextTarget()); } else if (source == "current") { cs = Context::current(); } else if (source == "empty") { @@ -188,7 +188,7 @@ void PythonClassContext::tp_dealloc(PythonClassContext* self) { if (!InLogicThread()) { Context* c = self->context_; Context* c2 = self->context_prev_; - g_game->thread()->PushCall([c, c2] { + g_logic->thread()->PushCall([c, c2] { delete c; delete c2; }); diff --git a/src/ballistica/python/class/python_class_context_call.cc b/src/ballistica/python/class/python_class_context_call.cc index 9e5eac31..2aa433dc 100644 --- a/src/ballistica/python/class/python_class_context_call.cc +++ b/src/ballistica/python/class/python_class_context_call.cc @@ -3,7 +3,7 @@ #include "ballistica/python/class/python_class_context_call.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" @@ -119,7 +119,7 @@ void PythonClassContextCall::tp_dealloc(PythonClassContextCall* self) { // be; otherwise do it immediately if (!InLogicThread()) { Object::Ref* c = self->context_call_; - g_game->thread()->PushCall([c] { delete c; }); + g_logic->thread()->PushCall([c] { delete c; }); } else { delete self->context_call_; } diff --git a/src/ballistica/python/class/python_class_data.cc b/src/ballistica/python/class/python_class_data.cc index 79bf242e..4f6584dc 100644 --- a/src/ballistica/python/class/python_class_data.cc +++ b/src/ballistica/python/class/python_class_data.cc @@ -4,7 +4,7 @@ #include "ballistica/assets/component/data.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -102,7 +102,7 @@ void PythonClassData::tp_dealloc(PythonClassData* self) { // be; otherwise do it immediately if (!InLogicThread()) { Object::Ref* s = self->data_; - g_game->thread()->PushCall([s] { Delete(s); }); + g_logic->thread()->PushCall([s] { Delete(s); }); } else { Delete(self->data_); } diff --git a/src/ballistica/python/class/python_class_input_device.cc b/src/ballistica/python/class/python_class_input_device.cc index 38e04607..d9b6ecd6 100644 --- a/src/ballistica/python/class/python_class_input_device.cc +++ b/src/ballistica/python/class/python_class_input_device.cc @@ -3,8 +3,8 @@ #include "ballistica/python/class/python_class_input_device.h" #include "ballistica/core/thread.h" -#include "ballistica/game/player.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/player.h" #include "ballistica/python/python.h" namespace ballistica { @@ -143,7 +143,7 @@ void PythonClassInputDevice::tp_dealloc(PythonClassInputDevice* self) { // until the delete goes through; could that ever be a problem? if (!InLogicThread()) { Object::WeakRef* d = self->input_device_; - g_game->thread()->PushCall([d] { delete d; }); + g_logic->thread()->PushCall([d] { delete d; }); } else { delete self->input_device_; } diff --git a/src/ballistica/python/class/python_class_material.cc b/src/ballistica/python/class/python_class_material.cc index 2999279e..c1a049ad 100644 --- a/src/ballistica/python/class/python_class_material.cc +++ b/src/ballistica/python/class/python_class_material.cc @@ -15,8 +15,8 @@ #include "ballistica/dynamics/material/roll_sound_material_action.h" #include "ballistica/dynamics/material/skid_sound_material_action.h" #include "ballistica/dynamics/material/sound_material_action.h" -#include "ballistica/game/game.h" -#include "ballistica/game/host_activity.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -148,7 +148,7 @@ void PythonClassMaterial::tp_dealloc(PythonClassMaterial* self) { // need be.. otherwise do it immediately. if (!InLogicThread()) { Object::Ref* ptr = self->material_; - g_game->thread()->PushCall([ptr] { Delete(ptr); }); + g_logic->thread()->PushCall([ptr] { Delete(ptr); }); } else { Delete(self->material_); } diff --git a/src/ballistica/python/class/python_class_model.cc b/src/ballistica/python/class/python_class_model.cc index 5fd51ccc..7e0d637d 100644 --- a/src/ballistica/python/class/python_class_model.cc +++ b/src/ballistica/python/class/python_class_model.cc @@ -4,7 +4,7 @@ #include "ballistica/assets/component/model.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -103,7 +103,7 @@ void PythonClassModel::tp_dealloc(PythonClassModel* self) { // be; otherwise do it immediately if (!InLogicThread()) { Object::Ref* m = self->model_; - g_game->thread()->PushCall([m] { Delete(m); }); + g_logic->thread()->PushCall([m] { Delete(m); }); } else { Delete(self->model_); } diff --git a/src/ballistica/python/class/python_class_node.cc b/src/ballistica/python/class/python_class_node.cc index b6f11427..ef4b67ed 100644 --- a/src/ballistica/python/class/python_class_node.cc +++ b/src/ballistica/python/class/python_class_node.cc @@ -114,7 +114,7 @@ void PythonClassNode::tp_dealloc(PythonClassNode* self) { // be; otherwise do it immediately. if (!InLogicThread()) { Object::WeakRef* n = self->node_; - g_game->thread()->PushCall([n] { delete n; }); + g_logic->thread()->PushCall([n] { delete n; }); } else { delete self->node_; } diff --git a/src/ballistica/python/class/python_class_session_data.cc b/src/ballistica/python/class/python_class_session_data.cc index ec97ae43..db534145 100644 --- a/src/ballistica/python/class/python_class_session_data.cc +++ b/src/ballistica/python/class/python_class_session_data.cc @@ -3,9 +3,9 @@ #include "ballistica/python/class/python_class_session_data.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" -#include "ballistica/game/session/session.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/session.h" #include "ballistica/python/python.h" namespace ballistica { @@ -83,7 +83,7 @@ void PythonClassSessionData::tp_dealloc(PythonClassSessionData* self) { // until the delete goes through; could that ever be a problem? if (!InLogicThread()) { Object::WeakRef* s = self->session_; - g_game->thread()->PushCall([s] { delete s; }); + g_logic->thread()->PushCall([s] { delete s; }); } else { delete self->session_; } diff --git a/src/ballistica/python/class/python_class_session_player.cc b/src/ballistica/python/class/python_class_session_player.cc index 2c3a7ffc..9e92af8f 100644 --- a/src/ballistica/python/class/python_class_session_player.cc +++ b/src/ballistica/python/class/python_class_session_player.cc @@ -3,10 +3,10 @@ #include "ballistica/python/class/python_class_session_player.h" #include "ballistica/core/thread.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/player.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" namespace ballistica { @@ -188,7 +188,7 @@ void PythonClassSessionPlayer::tp_dealloc(PythonClassSessionPlayer* self) { // be; otherwise do it immediately. if (!InLogicThread()) { Object::WeakRef* p = self->player_; - g_game->thread()->PushCall([p] { delete p; }); + g_logic->thread()->PushCall([p] { delete p; }); } else { delete self->player_; } diff --git a/src/ballistica/python/class/python_class_sound.cc b/src/ballistica/python/class/python_class_sound.cc index 5025c3a6..59491749 100644 --- a/src/ballistica/python/class/python_class_sound.cc +++ b/src/ballistica/python/class/python_class_sound.cc @@ -4,7 +4,7 @@ #include "ballistica/assets/component/sound.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -102,7 +102,7 @@ void PythonClassSound::tp_dealloc(PythonClassSound* self) { // be; otherwise do it immediately if (!InLogicThread()) { Object::Ref* s = self->sound_; - g_game->thread()->PushCall([s] { Delete(s); }); + g_logic->thread()->PushCall([s] { Delete(s); }); } else { Delete(self->sound_); } diff --git a/src/ballistica/python/class/python_class_texture.cc b/src/ballistica/python/class/python_class_texture.cc index aeb27dda..33d13cd4 100644 --- a/src/ballistica/python/class/python_class_texture.cc +++ b/src/ballistica/python/class/python_class_texture.cc @@ -4,7 +4,7 @@ #include "ballistica/assets/component/texture.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" namespace ballistica { @@ -95,7 +95,7 @@ void PythonClassTexture::tp_dealloc(PythonClassTexture* self) { // be; otherwise do it immediately. if (!InLogicThread()) { Object::Ref* t = self->texture_; - g_game->thread()->PushCall([t] { Delete(t); }); + g_logic->thread()->PushCall([t] { Delete(t); }); } else { Delete(self->texture_); } diff --git a/src/ballistica/python/class/python_class_timer.cc b/src/ballistica/python/class/python_class_timer.cc index 8a53687d..ac553819 100644 --- a/src/ballistica/python/class/python_class_timer.cc +++ b/src/ballistica/python/class/python_class_timer.cc @@ -3,7 +3,7 @@ #include "ballistica/python/class/python_class_timer.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python_context_call_runnable.h" namespace ballistica { @@ -167,7 +167,7 @@ void PythonClassTimer::tp_dealloc(PythonClassTimer* self) { auto a1 = self->time_type_; auto a2 = self->timer_id_; auto a3 = self->context_; - g_game->thread()->PushCall( + g_logic->thread()->PushCall( [a0, a1, a2, a3] { PythonClassTimer::DoDelete(a0, a1, a2, a3); }); } else { DoDelete(self->have_timer_, self->time_type_, self->timer_id_, diff --git a/src/ballistica/python/class/python_class_widget.cc b/src/ballistica/python/class/python_class_widget.cc index cf8e0a07..8ebf2b39 100644 --- a/src/ballistica/python/class/python_class_widget.cc +++ b/src/ballistica/python/class/python_class_widget.cc @@ -3,9 +3,9 @@ #include "ballistica/python/class/python_class_widget.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/graphics.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" #include "ballistica/ui/widget/container_widget.h" @@ -93,7 +93,7 @@ void PythonClassWidget::tp_dealloc(PythonClassWidget* self) { // need be if (!InLogicThread()) { Object::WeakRef* w = self->widget_; - g_game->thread()->PushCall([w] { delete w; }); + g_logic->thread()->PushCall([w] { delete w; }); } else { delete self->widget_; } diff --git a/src/ballistica/python/methods/python_methods_app.cc b/src/ballistica/python/methods/python_methods_app.cc index 4f12a15a..54a10daf 100644 --- a/src/ballistica/python/methods/python_methods_app.cc +++ b/src/ballistica/python/methods/python_methods_app.cc @@ -6,11 +6,11 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/assets/component/texture.h" #include "ballistica/core/logging.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" -#include "ballistica/game/session/replay_client_session.h" #include "ballistica/graphics/graphics.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/session/host_session.h" +#include "ballistica/logic/session/replay_client_session.h" #include "ballistica/python/class/python_class_activity_data.h" #include "ballistica/python/class/python_class_session_data.h" #include "ballistica/python/python.h" @@ -107,7 +107,7 @@ auto PyNewHostSession(PyObject* self, PyObject* args, PyObject* keywds) PyExcType::kValue); } } - g_game->LaunchHostSession(sessiontype_obj, benchmark_type); + g_logic->LaunchHostSession(sessiontype_obj, benchmark_type); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -123,7 +123,7 @@ auto PyNewReplaySession(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } file_name = Python::GetPyString(file_name_obj); - g_game->LaunchReplaySession(file_name); + g_logic->LaunchReplaySession(file_name); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -137,7 +137,7 @@ auto PyIsInReplay(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist))) { return nullptr; } - if (dynamic_cast(g_game->GetForegroundSession())) { + if (dynamic_cast(g_logic->GetForegroundSession())) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; @@ -199,7 +199,7 @@ auto PyGetForegroundHostSession(PyObject* self, PyObject* args, // Note: we return None if not in the game thread. HostSession* s = InLogicThread() - ? g_game->GetForegroundContext().GetHostSession() + ? g_logic->GetForegroundContext().GetHostSession() : nullptr; if (s != nullptr) { PyObject* obj = s->GetSessionPyObj(); @@ -303,12 +303,12 @@ auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { // just increment the python object's refcount and pass it along raw; // the game thread decrements it on the other end. Py_INCREF(call_obj); - g_game->PushPythonRawCallable(call_obj); + g_logic->PushPythonRawCallable(call_obj); } else { if (!InLogicThread()) { throw Exception("You must use from_other_thread mode."); } - g_game->PushPythonCall(Object::New(call_obj)); + g_logic->PushPythonCall(Object::New(call_obj)); } Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -483,11 +483,11 @@ auto PyScreenMessage(PyObject* self, PyObject* args, PyObject* keywds) std::vector client_ids; if (clients_obj != Py_None) { std::vector client_ids2 = Python::GetPyInts(clients_obj); - g_game->connections()->SendScreenMessageToSpecificClients( + g_logic->connections()->SendScreenMessageToSpecificClients( message, color.x, color.y, color.z, client_ids2); } else { - g_game->connections()->SendScreenMessageToAll(message, color.x, color.y, - color.z); + g_logic->connections()->SendScreenMessageToAll(message, color.x, color.y, + color.z); } } else { // Currently specifying client_ids only works for transient messages; we'd @@ -610,7 +610,7 @@ auto PyQuit(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { } } if (!handled) { - g_game->PushShutdownCall(false); + g_logic->PushShutdownCall(false); } Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -630,7 +630,7 @@ auto PyApplyConfig(PyObject* self, PyObject* args) -> PyObject* { // Hmm; python runs in the game thread; technically we could just run // ApplyConfig() immediately (though pushing is probably safer). - g_game->PushApplyConfigCall(); + g_logic->PushApplyConfigCall(); Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/python/methods/python_methods_assets.cc b/src/ballistica/python/methods/python_methods_assets.cc index cc516ffe..0eb9ba88 100644 --- a/src/ballistica/python/methods/python_methods_assets.cc +++ b/src/ballistica/python/methods/python_methods_assets.cc @@ -12,8 +12,8 @@ #include "ballistica/assets/component/model.h" #include "ballistica/assets/component/sound.h" #include "ballistica/assets/component/texture.h" -#include "ballistica/game/host_activity.h" #include "ballistica/graphics/graphics_server.h" +#include "ballistica/logic/host_activity.h" #include "ballistica/python/python.h" #include "ballistica/python/python_sys.h" #include "ballistica/ui/ui.h" diff --git a/src/ballistica/python/methods/python_methods_gameplay.cc b/src/ballistica/python/methods/python_methods_gameplay.cc index aabcf0d2..4ba23115 100644 --- a/src/ballistica/python/methods/python_methods_gameplay.cc +++ b/src/ballistica/python/methods/python_methods_gameplay.cc @@ -10,13 +10,13 @@ #include "ballistica/dynamics/collision.h" #include "ballistica/dynamics/dynamics.h" #include "ballistica/dynamics/material/material_action.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client.h" -#include "ballistica/game/host_activity.h" #include "ballistica/generic/json.h" #include "ballistica/graphics/graphics.h" #include "ballistica/input/device/input_device.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client.h" +#include "ballistica/logic/host_activity.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call_runnable.h" @@ -45,7 +45,7 @@ auto PyNewNode(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { auto PyPrintNodes(PyObject* self, PyObject* args) -> PyObject* { BA_PYTHON_TRY; HostActivity* host_activity = - g_game->GetForegroundContext().GetHostActivity(); + g_logic->GetForegroundContext().GetHostActivity(); if (!host_activity) { throw Exception(PyExcType::kContext); } @@ -383,7 +383,7 @@ auto PyGetForegroundHostActivity(PyObject* self, PyObject* args, // Note: we return None if not in the game thread. HostActivity* h = InLogicThread() - ? g_game->GetForegroundContext().GetHostActivity() + ? g_logic->GetForegroundContext().GetHostActivity() : nullptr; if (h != nullptr) { PyObject* obj = h->GetPyActivity(); @@ -404,7 +404,7 @@ auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } PythonRef py_client_list(PyList_New(0), PythonRef::kSteal); - cJSON* party = g_game->game_roster(); + cJSON* party = g_logic->game_roster(); assert(party); int len = cJSON_GetArraySize(party); for (int i = 0; i < len; i++) { @@ -458,8 +458,8 @@ auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) account_id = g_app_internal->GetPublicV1AccountID(); } else { auto client2 = - g_game->connections()->connections_to_clients().find(clientid); - if (client2 != g_game->connections()->connections_to_clients().end()) { + g_logic->connections()->connections_to_clients().find(clientid); + if (client2 != g_logic->connections()->connections_to_clients().end()) { account_id = client2->second->peer_public_account_id(); } } @@ -500,7 +500,7 @@ auto PySetDebugSpeedExponent(PyObject* self, PyObject* args) -> PyObject* { throw Exception(PyExcType::kContext); } #if BA_DEBUG_BUILD - g_game->SetDebugSpeedExponent(speed); + g_logic->SetDebugSpeedExponent(speed); #else throw Exception("This call only functions in the debug build."); #endif @@ -510,8 +510,8 @@ auto PySetDebugSpeedExponent(PyObject* self, PyObject* args) -> PyObject* { auto PyGetReplaySpeedExponent(PyObject* self, PyObject* args) -> PyObject* { BA_PYTHON_TRY; - assert(g_game); - return PyLong_FromLong(g_game->replay_speed_exponent()); + assert(g_logic); + return PyLong_FromLong(g_logic->replay_speed_exponent()); BA_PYTHON_CATCH; } @@ -519,8 +519,8 @@ auto PySetReplaySpeedExponent(PyObject* self, PyObject* args) -> PyObject* { BA_PYTHON_TRY; int speed; if (!PyArg_ParseTuple(args, "i", &speed)) return nullptr; - assert(g_game); - g_game->SetReplaySpeedExponent(speed); + assert(g_logic); + g_logic->SetReplaySpeedExponent(speed); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -533,8 +533,8 @@ auto PyResetGameActivityTracking(PyObject* self, PyObject* args, const_cast(kwlist))) { return nullptr; } - if (g_game) { - g_game->ResetActivityTracking(); + if (g_logic) { + g_logic->ResetActivityTracking(); } Py_RETURN_NONE; BA_PYTHON_CATCH; diff --git a/src/ballistica/python/methods/python_methods_graphics.cc b/src/ballistica/python/methods/python_methods_graphics.cc index 87f72ca9..0e59a559 100644 --- a/src/ballistica/python/methods/python_methods_graphics.cc +++ b/src/ballistica/python/methods/python_methods_graphics.cc @@ -2,10 +2,10 @@ #include "ballistica/python/methods/python_methods_graphics.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/graphics.h" #include "ballistica/graphics/text/text_graphics.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call_runnable.h" @@ -52,7 +52,7 @@ auto PySetCameraPosition(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist), &x, &y, &z)) { return nullptr; } - assert(g_game); + assert(g_logic); g_graphics->camera()->SetPosition(x, y, z); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -69,7 +69,7 @@ auto PySetCameraTarget(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist), &x, &y, &z)) { return nullptr; } - assert(g_game); + assert(g_logic); g_graphics->camera()->SetTarget(x, y, z); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -84,7 +84,7 @@ auto PySetCameraManual(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist), &value)) { return nullptr; } - assert(g_game); + assert(g_logic); g_graphics->camera()->SetManual(value); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -98,10 +98,10 @@ auto PyCharStr(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { const_cast(kwlist), &name_obj)) { return nullptr; } - assert(g_game); + assert(g_logic); auto id(Python::GetPyEnum_SpecialChar(name_obj)); - assert(Utils::IsValidUTF8(g_game->CharStr(id))); - return PyUnicode_FromString(g_game->CharStr(id).c_str()); + assert(Utils::IsValidUTF8(g_logic->CharStr(id))); + return PyUnicode_FromString(g_logic->CharStr(id).c_str()); BA_PYTHON_CATCH; } @@ -164,7 +164,7 @@ auto PyEvaluateLstr(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } return PyUnicode_FromString( - g_game->CompileResourceString(value, "evaluate_lstr").c_str()); + g_logic->CompileResourceString(value, "evaluate_lstr").c_str()); BA_PYTHON_CATCH; } @@ -188,7 +188,7 @@ auto PyGetStringHeight(PyObject* self, PyObject* args, PyObject* keywds) } s = Python::GetPyString(s_obj); #if BA_DEBUG_BUILD - if (g_game->CompileResourceString(s, "get_string_height test") != s) { + if (g_logic->CompileResourceString(s, "get_string_height test") != s) { BA_LOG_PYTHON_TRACE( "resource-string passed to get_string_height; this should be avoided"); } @@ -218,7 +218,7 @@ auto PyGetStringWidth(PyObject* self, PyObject* args, PyObject* keywds) } s = Python::GetPyString(s_obj); #if BA_DEBUG_BUILD - if (g_game->CompileResourceString(s, "get_string_width debug test") != s) { + if (g_logic->CompileResourceString(s, "get_string_width debug test") != s) { BA_LOG_PYTHON_TRACE( "resource-string passed to get_string_width; this should be avoided"); } diff --git a/src/ballistica/python/methods/python_methods_input.cc b/src/ballistica/python/methods/python_methods_input.cc index c03bf5b4..8f1cde34 100644 --- a/src/ballistica/python/methods/python_methods_input.cc +++ b/src/ballistica/python/methods/python_methods_input.cc @@ -3,10 +3,10 @@ #include "ballistica/python/methods/python_methods_input.h" #include "ballistica/app/app.h" -#include "ballistica/game/game.h" #include "ballistica/input/device/input_device.h" #include "ballistica/input/device/touch_input.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/platform.h" #include "ballistica/python/python.h" #include "ballistica/python/python_sys.h" diff --git a/src/ballistica/python/methods/python_methods_networking.cc b/src/ballistica/python/methods/python_methods_networking.cc index 8066dfd5..27eb5a2d 100644 --- a/src/ballistica/python/methods/python_methods_networking.cc +++ b/src/ballistica/python/methods/python_methods_networking.cc @@ -3,10 +3,10 @@ #include "ballistica/python/methods/python_methods_networking.h" #include "ballistica/app/app.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client.h" -#include "ballistica/game/connection/connection_to_host.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client.h" +#include "ballistica/logic/connection/connection_to_host.h" +#include "ballistica/logic/logic.h" #include "ballistica/math/vector3f.h" #include "ballistica/networking/network_reader.h" #include "ballistica/networking/networking.h" @@ -30,7 +30,7 @@ auto PyGetPublicPartyEnabled(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist))) return nullptr; assert(g_python); - if (g_game->public_party_enabled()) { + if (g_logic->public_party_enabled()) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; @@ -48,7 +48,7 @@ auto PySetPublicPartyEnabled(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } assert(g_python); - g_game->SetPublicPartyEnabled(static_cast(enable)); + g_logic->SetPublicPartyEnabled(static_cast(enable)); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -64,7 +64,7 @@ auto PySetPublicPartyName(PyObject* self, PyObject* args, PyObject* keywds) } std::string name = Python::GetPyString(name_obj); assert(g_python); - g_game->SetPublicPartyName(name); + g_logic->SetPublicPartyName(name); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -81,7 +81,7 @@ auto PySetPublicPartyStatsURL(PyObject* self, PyObject* args, PyObject* keywds) // The call expects an empty string for the no-url option. std::string url = (url_obj == Py_None) ? "" : Python::GetPyString(url_obj); assert(g_python); - g_game->SetPublicPartyStatsURL(url); + g_logic->SetPublicPartyStatsURL(url); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -95,7 +95,7 @@ auto PyGetPublicPartyMaxSize(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } assert(g_python); - return PyLong_FromLong(g_game->public_party_max_size()); + return PyLong_FromLong(g_logic->public_party_max_size()); BA_PYTHON_CATCH; } @@ -109,7 +109,7 @@ auto PySetPublicPartyMaxSize(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } assert(g_python); - g_game->SetPublicPartyMaxSize(max_size); + g_logic->SetPublicPartyMaxSize(max_size); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -123,8 +123,8 @@ auto PySetAuthenticateClients(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist), &enable)) { return nullptr; } - assert(g_game); - g_game->set_require_client_authentication(static_cast(enable)); + assert(g_logic); + g_logic->set_require_client_authentication(static_cast(enable)); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -138,14 +138,14 @@ auto PySetAdmins(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist), &admins_obj)) { return nullptr; } - assert(g_game); + assert(g_logic); auto admins = Python::GetPyStrings(admins_obj); std::set adminset; for (auto&& admin : admins) { adminset.insert(admin); } - g_game->set_admin_public_ids(adminset); + g_logic->set_admin_public_ids(adminset); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -160,8 +160,8 @@ auto PySetEnableDefaultKickVoting(PyObject* self, PyObject* args, const_cast(kwlist), &enable)) { return nullptr; } - assert(g_game); - g_game->set_kick_voting_enabled(static_cast(enable)); + assert(g_logic); + g_logic->set_kick_voting_enabled(static_cast(enable)); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -202,11 +202,11 @@ auto PyConnectToParty(PyObject* self, PyObject* args, PyObject* keywds) throw Exception(); } } catch (const std::exception&) { - ScreenMessage(g_game->GetResourceString("invalidAddressErrorText"), + ScreenMessage(g_logic->GetResourceString("invalidAddressErrorText"), {1, 0, 0}); Py_RETURN_NONE; } - g_game->connections()->PushHostConnectedUDPCall( + g_logic->connections()->PushHostConnectedUDPCall( s, static_cast(print_progress)); Py_RETURN_NONE; BA_PYTHON_CATCH; @@ -223,7 +223,7 @@ auto PyClientInfoQueryResponse(PyObject* self, PyObject* args, PyObject* keywds) &response_obj)) { return nullptr; } - g_game->connections()->SetClientInfoFromMasterServer(token, response_obj); + g_logic->connections()->SetClientInfoFromMasterServer(token, response_obj); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -236,7 +236,7 @@ auto PyGetConnectionToHostInfo(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist))) { return nullptr; } - ConnectionToHost* hc = g_game->connections()->connection_to_host(); + ConnectionToHost* hc = g_logic->connections()->connection_to_host(); if (hc) { return Py_BuildValue("{sssi}", "name", hc->party_name().c_str(), "build_number", hc->build_number()); @@ -255,7 +255,7 @@ auto PyDisconnectFromHost(PyObject* self, PyObject* args, PyObject* keywds) const_cast(kwlist))) { return nullptr; } - g_game->connections()->PushDisconnectFromHostCall(); + g_logic->connections()->PushDisconnectFromHostCall(); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -271,7 +271,7 @@ auto PyDisconnectClient(PyObject* self, PyObject* args, PyObject* keywds) &ban_time)) { return nullptr; } - bool kickable = g_game->connections()->DisconnectClient(client_id, ban_time); + bool kickable = g_logic->connections()->DisconnectClient(client_id, ban_time); if (kickable) { Py_RETURN_TRUE; } else { @@ -290,10 +290,10 @@ auto PyGetClientPublicDeviceUUID(PyObject* self, PyObject* args, return nullptr; } auto&& connection{ - g_game->connections()->connections_to_clients().find(client_id)}; + g_logic->connections()->connections_to_clients().find(client_id)}; // Does this connection exist? - if (connection == g_game->connections()->connections_to_clients().end()) { + if (connection == g_logic->connections()->connections_to_clients().end()) { Py_RETURN_NONE; } @@ -379,7 +379,7 @@ auto PyEndHostScanning(PyObject* self, PyObject* args, PyObject* keywds) auto PyHaveConnectedClients(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; - if (g_game->connections()->GetConnectedClientCount() > 0) { + if (g_logic->connections()->GetConnectedClientCount() > 0) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; diff --git a/src/ballistica/python/methods/python_methods_system.cc b/src/ballistica/python/methods/python_methods_system.cc index aac12fa6..7b593c8f 100644 --- a/src/ballistica/python/methods/python_methods_system.cc +++ b/src/ballistica/python/methods/python_methods_system.cc @@ -10,12 +10,12 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/assets/assets.h" #include "ballistica/assets/component/texture.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" -#include "ballistica/game/session/replay_client_session.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/graphics.h" #include "ballistica/input/input.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/session/host_session.h" +#include "ballistica/logic/session/replay_client_session.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call_runnable.h" #include "ballistica/python/python_sys.h" @@ -652,8 +652,8 @@ auto PySetInternalLanguageKeys(PyObject* self, PyObject* args) -> PyObject* { random_names.emplace_back(PyUnicode_AsUTF8(entry)); } Utils::SetRandomNameList(random_names); - assert(g_game); - g_game->SetLanguageKeys(language); + assert(g_logic); + g_logic->SetLanguageKeys(language); Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/python/methods/python_methods_ui.cc b/src/ballistica/python/methods/python_methods_ui.cc index d249b519..f5a7a6cc 100644 --- a/src/ballistica/python/methods/python_methods_ui.cc +++ b/src/ballistica/python/methods/python_methods_ui.cc @@ -4,11 +4,11 @@ #include "ballistica/app/app.h" #include "ballistica/app/app_flavor.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" -#include "ballistica/game/v1_account.h" #include "ballistica/input/input.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/python/python.h" #include "ballistica/python/python_sys.h" #include "ballistica/ui/root_ui.h" @@ -130,12 +130,12 @@ auto PyButtonWidget(PyObject* self, PyObject* args, PyObject* keywds) &text_res_scale_obj, &enabled_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs)", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref b; @@ -381,12 +381,12 @@ auto PyCheckBoxWidget(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref widget; @@ -525,12 +525,12 @@ auto PyImageWidget(PyObject* self, PyObject* args, PyObject* keywds) &tilt_scale_obj, &mask_texture_obj, &radial_amount_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref b; @@ -681,15 +681,15 @@ auto PyColumnWidget(PyObject* self, PyObject* args, PyObject* keywds) &margin_obj, &claims_left_right_obj, &claims_tab_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context " "docs).", PyExcType::kContext); } - // if (!g_game->IsInUIContext()) { BA_LOG_PYTHON_TRACE("ERROR: This should be + // if (!g_logic->IsInUIContext()) { BA_LOG_PYTHON_TRACE("ERROR: This should be // called within the UI context (see ba.Context docs)");} - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref widget; @@ -859,11 +859,11 @@ auto PyContainerWidget(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } - if (!g_game->IsInUIContext()) + if (!g_logic->IsInUIContext()) throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref widget; @@ -1080,13 +1080,13 @@ auto PyRowWidget(PyObject* /* self */, PyObject* args, PyObject* keywds) &claims_tab_obj, &selection_loops_to_parent_obj)) return nullptr; - if (!g_game->IsInUIContext()) + if (!g_logic->IsInUIContext()) throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); // Called within the UI context (see ba.Context docs)");} - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // Grab the edited widget or create a new one. Object::Ref widget; @@ -1202,12 +1202,12 @@ auto PyScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) &claims_up_down_obj, &claims_tab_obj, &autoselect_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // Grab the edited widget or create a new one. --------------------- Object::Ref widget; @@ -1348,12 +1348,12 @@ auto PyHScrollWidget(PyObject* self, PyObject* args, PyObject* keywds) &claims_up_down_obj, &claims_tab_obj, &autoselect_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref widget; @@ -1528,13 +1528,13 @@ auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) &extra_touch_border_scale_obj, &res_scale_obj)) return nullptr; - if (!g_game->IsInUIContext()) + if (!g_logic->IsInUIContext()) throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); - // if (!g_game->IsInUIContext()) { BA_LOG_PYTHON_TRACE("ERROR: This should be + // if (!g_logic->IsInUIContext()) { BA_LOG_PYTHON_TRACE("ERROR: This should be // called within the UI context (see ba.Context docs)");} - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); // grab the edited widget or create a new one --------------------- Object::Ref widget; @@ -1578,7 +1578,7 @@ auto PyTextWidget(PyObject* self, PyObject* args, PyObject* keywds) // FIXME - compiling Lstr values to flat strings before passing them in; // we should probably extend TextWidget to handle this internally, but // punting on that for now.. - widget->set_description(g_game->CompileResourceString( + widget->set_description(g_logic->CompileResourceString( Python::GetPyString(description_obj), "textwidget set desc")); } if (autoselect_obj != Py_None) { @@ -1753,12 +1753,12 @@ auto PyWidgetCall(PyObject* self, PyObject* args, PyObject* keywds) &show_buffer_right_obj, &autoselect_obj)) return nullptr; - if (!g_game->IsInUIContext()) { + if (!g_logic->IsInUIContext()) { throw Exception( "This must be called within the UI context (see ba.Context docs).", PyExcType::kContext); } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); Widget* widget = nullptr; if (edit_obj != Py_None) { @@ -2032,7 +2032,8 @@ auto PyChatMessage(PyObject* self, PyObject* args, PyObject* keywds) clients = Python::GetPyInts(clients_obj); clients_p = &clients; } - g_game->connections()->SendChatMessage(message, clients_p, sender_override_p); + g_logic->connections()->SendChatMessage(message, clients_p, + sender_override_p); Py_RETURN_NONE; BA_PYTHON_CATCH; } @@ -2048,7 +2049,7 @@ auto PyGetChatMessages(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } PyObject* py_list = PyList_New(0); - for (auto&& i : g_game->chat_messages()) { + for (auto&& i : g_logic->chat_messages()) { PyList_Append(py_list, PyUnicode_FromString(i.c_str())); } return py_list; @@ -2121,8 +2122,8 @@ auto PyCanShowAd(PyObject* self, PyObject* args, PyObject* keywds) // them or whatnot) also disallow ads if remote apps are connected; at least // on android ads pause our activity which disconnects the remote app.. (could // potentially still allow on other platforms; should verify..) - if (g_game->connections()->connection_to_host() - || g_game->connections()->has_connection_to_clients() + if (g_logic->connections()->connection_to_host() + || g_logic->connections()->has_connection_to_clients() || g_input->HaveRemoteAppController()) { Py_RETURN_FALSE; } @@ -2212,7 +2213,7 @@ auto PyConsolePrint(PyObject* self, PyObject* args) -> PyObject* { throw Exception(); } const char* c = PyUnicode_AsUTF8(str_obj); - g_game->PushConsolePrintCall(c); + g_logic->PushConsolePrintCall(c); Py_DECREF(str_obj); } #endif // !BA_HEADLESS_BUILD @@ -2224,8 +2225,8 @@ auto PyIsPartyIconVisible(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { BA_PYTHON_TRY; bool party_button_active = - (g_game->connections()->GetConnectedClientCount() > 0 - || g_game->connections()->connection_to_host() + (g_logic->connections()->GetConnectedClientCount() > 0 + || g_logic->connections()->connection_to_host() || g_ui->root_ui()->always_draw_party_icon()); if (party_button_active) { Py_RETURN_TRUE; diff --git a/src/ballistica/python/python.cc b/src/ballistica/python/python.cc index 5739a151..169564bd 100644 --- a/src/ballistica/python/python.cc +++ b/src/ballistica/python/python.cc @@ -10,14 +10,14 @@ #include "ballistica/audio/audio.h" #include "ballistica/core/thread.h" #include "ballistica/dynamics/material/material.h" -#include "ballistica/game/friend_score_set.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/player.h" -#include "ballistica/game/v1_account.h" #include "ballistica/graphics/graphics.h" #include "ballistica/input/device/joystick.h" #include "ballistica/input/device/keyboard_input.h" #include "ballistica/internal/app_internal.h" +#include "ballistica/logic/friend_score_set.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/player.h" +#include "ballistica/logic/v1_account.h" #include "ballistica/python/class/python_class_activity_data.h" #include "ballistica/python/class/python_class_collide_model.h" #include "ballistica/python/class/python_class_context.h" @@ -1099,15 +1099,15 @@ auto Python::InitModuleClasses(PyObject* module) -> void { } void Python::PushObjCall(ObjID obj_id) { - g_game->thread()->PushCall([obj_id] { - ScopedSetContext cp(g_game->GetUIContext()); + g_logic->thread()->PushCall([obj_id] { + ScopedSetContext cp(g_logic->GetUIContext()); g_python->obj(obj_id).Call(); }); } void Python::PushObjCall(ObjID obj_id, const std::string& arg) { - g_game->thread()->PushCall([this, obj_id, arg] { - ScopedSetContext cp(g_game->GetUIContext()); + g_logic->thread()->PushCall([this, obj_id, arg] { + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(s)", arg.c_str()), ballistica::PythonRef::kSteal); obj(obj_id).Call(args); @@ -1191,7 +1191,7 @@ auto Python::GetTranslation(const char* category, const char* s) void Python::RunDeepLink(const std::string& url) { assert(InLogicThread()); if (objexists(ObjID::kDeepLinkCall)) { - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(s)", url.c_str()), PythonRef::kSteal); obj(ObjID::kDeepLinkCall).Call(args); } else { @@ -1216,7 +1216,7 @@ void Python::PlayMusic(const std::string& music_type, bool continuous) { void Python::ShowURL(const std::string& url) { if (objexists(ObjID::kShowURLWindowCall)) { - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(s)", url.c_str()), PythonRef::kSteal); obj(ObjID::kShowURLWindowCall).Call(args); } else { @@ -1244,7 +1244,7 @@ auto Python::SingleMemberTuple(const PythonRef& member) -> PythonRef { auto Python::FilterChatMessage(std::string* message, int client_id) -> bool { assert(message); - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(si)", message->c_str(), client_id), PythonRef::kSteal); PythonRef result = obj(ObjID::kFilterChatMessageCall).Call(args); @@ -1269,7 +1269,7 @@ auto Python::FilterChatMessage(std::string* message, int client_id) -> bool { } void Python::HandleLocalChatMessage(const std::string& message) { - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(s)", message.c_str()), PythonRef::kSteal); obj(ObjID::kHandleLocalChatMessageCall).Call(args); } @@ -2016,14 +2016,14 @@ void Python::LaunchStringEdit(TextWidget* w) { assert(InLogicThread()); BA_PRECONDITION(w); - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); g_audio->PlaySound(g_assets->GetSound(SystemSoundID::kSwish)); // Gotta run this in the next cycle. PythonRef args(Py_BuildValue("(Osi)", w->BorrowPyRef(), w->description().c_str(), w->max_chars()), PythonRef::kSteal); - g_game->PushPythonCallArgs( + g_logic->PushPythonCallArgs( Object::New(obj(ObjID::kOnScreenKeyboardClass).get()), args); } @@ -2066,11 +2066,11 @@ void Python::HandleFriendScoresCB(const FriendScoreSet& score_set) { PyObject* py_list = PyList_New(0); std::string icon_str; #if BA_USE_GOOGLE_PLAY_GAME_SERVICES - icon_str = g_game->CharStr(SpecialChar::kGooglePlayGamesLogo); + icon_str = g_logic->CharStr(SpecialChar::kGooglePlayGamesLogo); #elif BA_USE_GAME_CIRCLE - icon_str = g_game->CharStr(SpecialChar::kGameCircleLogo); + icon_str = g_logic->CharStr(SpecialChar::kGameCircleLogo); #elif BA_USE_GAME_CENTER - icon_str = g_game->CharStr(SpecialChar::kGameCenterLogo); + icon_str = g_logic->CharStr(SpecialChar::kGameCenterLogo); #endif for (auto&& i : score_set.entries) { PyObject* obj = @@ -2090,7 +2090,7 @@ auto Python::HandleKeyPressEvent(const SDL_Keysym& keysym) -> bool { if (!keyboard_call_.exists()) { return false; } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); InputDevice* keyboard = g_input->keyboard_input(); PythonRef args( Py_BuildValue("({s:s,s:i,s:O})", "type", "BUTTONDOWN", "button", @@ -2105,7 +2105,7 @@ auto Python::HandleKeyReleaseEvent(const SDL_Keysym& keysym) -> bool { if (!keyboard_call_.exists()) { return false; } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); InputDevice* keyboard = g_input->keyboard_input(); PythonRef args(Py_BuildValue("({s:s,s:i,s:O})", "type", "BUTTONUP", "button", static_cast(keysym.sym), "input_device", @@ -2122,7 +2122,7 @@ auto Python::HandleJoystickEvent(const SDL_Event& event, if (!game_pad_call_.exists()) { return false; } - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); InputDevice* device{}; device = input_device; @@ -2335,7 +2335,7 @@ void Python::HandleDeviceMenuPress(InputDevice* input_device) { if (g_input->IsInputLocked()) { return; } - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); PythonRef args(Py_BuildValue("(O)", input_device ? input_device->BorrowPyRef() : Py_None), PythonRef::kSteal); diff --git a/src/ballistica/python/python.h b/src/ballistica/python/python.h index 95eb02ca..e1094129 100644 --- a/src/ballistica/python/python.h +++ b/src/ballistica/python/python.h @@ -111,7 +111,7 @@ class Python { /// results. static auto generic_dir(PyObject* self) -> PyObject*; - /// For use by g_game in passing events along to the python layer (for + /// For use by g_logic in passing events along to the python layer (for /// captured input, etc). auto HandleJoystickEvent(const SDL_Event& event, InputDevice* input_device = nullptr) -> bool; diff --git a/src/ballistica/python/python_context_call.cc b/src/ballistica/python/python_context_call.cc index 958e599c..279d58c0 100644 --- a/src/ballistica/python/python_context_call.cc +++ b/src/ballistica/python/python_context_call.cc @@ -2,8 +2,8 @@ #include "ballistica/python/python_context_call.h" -#include "ballistica/game/host_activity.h" -#include "ballistica/game/session/host_session.h" +#include "ballistica/logic/host_activity.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" #include "ballistica/python/python_sys.h" diff --git a/src/ballistica/scene/node/globals_node.cc b/src/ballistica/scene/node/globals_node.cc index 9cc39704..34772cb3 100644 --- a/src/ballistica/scene/node/globals_node.cc +++ b/src/ballistica/scene/node/globals_node.cc @@ -4,9 +4,9 @@ #include "ballistica/audio/audio.h" #include "ballistica/dynamics/bg/bg_dynamics.h" -#include "ballistica/game/host_activity.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/graphics.h" +#include "ballistica/logic/host_activity.h" #include "ballistica/python/python.h" #include "ballistica/scene/node/node_attribute.h" #include "ballistica/scene/node/node_type.h" @@ -121,7 +121,7 @@ GlobalsNode::GlobalsNode(Scene* scene) : Node(scene, node_type) { // If our scene is currently the game's foreground one, go ahead and // push our values globally. - if (g_game->GetForegroundScene() == this->scene()) { + if (g_logic->GetForegroundScene() == this->scene()) { SetAsForeground(); } } @@ -154,7 +154,7 @@ auto GlobalsNode::IsCurrentGlobals() const -> bool { // node for our scene. Scene* scene = this->scene(); assert(scene); - return (g_game->GetForegroundScene() == this->scene() + return (g_logic->GetForegroundScene() == this->scene() && scene->globals_node() == this); } diff --git a/src/ballistica/scene/node/spaz_node.h b/src/ballistica/scene/node/spaz_node.h index f1e76af5..4133c127 100644 --- a/src/ballistica/scene/node/spaz_node.h +++ b/src/ballistica/scene/node/spaz_node.h @@ -7,8 +7,8 @@ #include #include "ballistica/dynamics/part.h" -#include "ballistica/game/player.h" #include "ballistica/graphics/renderer.h" +#include "ballistica/logic/player.h" #include "ballistica/scene/node/node.h" namespace ballistica { diff --git a/src/ballistica/scene/node/text_node.cc b/src/ballistica/scene/node/text_node.cc index 10a0c0f8..a6f27062 100644 --- a/src/ballistica/scene/node/text_node.cc +++ b/src/ballistica/scene/node/text_node.cc @@ -113,7 +113,7 @@ void TextNode::SetText(const std::string& val) { if (do_format_check) { bool valid; - g_game->CompileResourceString(val, "setText format check", &valid); + g_logic->CompileResourceString(val, "setText format check", &valid); if (!valid) { BA_LOG_ONCE("Invalid resource string: '" + val + "' on node '" + label() + "'"); @@ -348,7 +348,7 @@ void TextNode::Draw(FrameDef* frame_def) { // Apply subs/resources to get our actual text if need be. if (text_translation_dirty_) { text_translated_ = - g_game->CompileResourceString(text_raw_, "TextNode::OnDraw"); + g_logic->CompileResourceString(text_raw_, "TextNode::OnDraw"); text_translation_dirty_ = false; text_group_dirty_ = true; text_width_dirty_ = true; diff --git a/src/ballistica/scene/node/time_display_node.cc b/src/ballistica/scene/node/time_display_node.cc index ff23f07e..17bc7ebf 100644 --- a/src/ballistica/scene/node/time_display_node.cc +++ b/src/ballistica/scene/node/time_display_node.cc @@ -4,8 +4,8 @@ #include -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" +#include "ballistica/logic/logic.h" #include "ballistica/scene/node/node_attribute.h" #include "ballistica/scene/node/node_type.h" @@ -48,10 +48,10 @@ auto TimeDisplayNode::GetOutput() -> std::string { assert(InLogicThread()); if (translations_dirty_) { time_suffix_hours_ = - g_game->CompileResourceString(R"({"r":"timeSuffixHoursText"})", "tda"); - time_suffix_minutes_ = g_game->CompileResourceString( + g_logic->CompileResourceString(R"({"r":"timeSuffixHoursText"})", "tda"); + time_suffix_minutes_ = g_logic->CompileResourceString( R"({"r":"timeSuffixMinutesText"})", "tdb"); - time_suffix_seconds_ = g_game->CompileResourceString( + time_suffix_seconds_ = g_logic->CompileResourceString( R"({"r":"timeSuffixSecondsText"})", "tdc"); translations_dirty_ = false; output_dirty_ = true; diff --git a/src/ballistica/scene/scene.cc b/src/ballistica/scene/scene.cc index 0f3ede77..a77ce3ff 100644 --- a/src/ballistica/scene/scene.cc +++ b/src/ballistica/scene/scene.cc @@ -8,10 +8,10 @@ #include "ballistica/dynamics/bg/bg_dynamics.h" #include "ballistica/dynamics/dynamics.h" #include "ballistica/dynamics/part.h" -#include "ballistica/game/player.h" #include "ballistica/graphics/camera.h" #include "ballistica/graphics/graphics.h" #include "ballistica/input/device/input_device.h" +#include "ballistica/logic/player.h" #include "ballistica/networking/networking.h" #include "ballistica/python/python_context_call.h" #include "ballistica/scene/node/anim_curve_node.h" @@ -235,7 +235,7 @@ void Scene::Step() { } in_step_ = false; } - bool is_foreground = (g_game->GetForegroundScene() == this); + bool is_foreground = (g_logic->GetForegroundScene() == this); // Add a step command to the output stream. if (output_stream_.exists()) { @@ -377,7 +377,7 @@ void Scene::Dump(SceneStream* stream) { stream->AddScene(this); // If we're the foreground one, communicate that fact as well. - if (g_game->GetForegroundScene() == this) { + if (g_logic->GetForegroundScene() == this) { stream->SetForegroundScene(this); } } diff --git a/src/ballistica/scene/scene.h b/src/ballistica/scene/scene.h index 9907a029..9f7dbf92 100644 --- a/src/ballistica/scene/scene.h +++ b/src/ballistica/scene/scene.h @@ -8,7 +8,7 @@ #include #include "ballistica/core/object.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/scene/node/node.h" namespace ballistica { diff --git a/src/ballistica/scene/scene_stream.cc b/src/ballistica/scene/scene_stream.cc index f3b7074b..cdea88f5 100644 --- a/src/ballistica/scene/scene_stream.cc +++ b/src/ballistica/scene/scene_stream.cc @@ -15,9 +15,9 @@ #include "ballistica/dynamics/material/material_component.h" #include "ballistica/dynamics/material/material_condition_node.h" #include "ballistica/dynamics/part.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/connection/connection_to_client.h" -#include "ballistica/game/session/host_session.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/connection/connection_to_client.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/networking/networking.h" #include "ballistica/scene/node/node_attribute.h" #include "ballistica/scene/node/node_type.h" @@ -46,7 +46,7 @@ SceneStream::SceneStream(HostSession* host_session, bool save_replay) // If we're the live output-stream from a host-session, // take responsibility for feeding all clients to this device. if (host_session_) { - g_game->connections()->RegisterClientController(this); + g_logic->connections()->RegisterClientController(this); } } @@ -67,7 +67,7 @@ SceneStream::~SceneStream() { // If we're wired to the host-session, go ahead and release clients. if (host_session_) { - g_game->connections()->UnregisterClientController(this); + g_logic->connections()->UnregisterClientController(this); #pragma clang diagnostic push #pragma ide diagnostic ignored "UnreachableCode" diff --git a/src/ballistica/scene/scene_stream.h b/src/ballistica/scene/scene_stream.h index 43187319..a43906a4 100644 --- a/src/ballistica/scene/scene_stream.h +++ b/src/ballistica/scene/scene_stream.h @@ -7,7 +7,7 @@ #include #include "ballistica/core/object.h" -#include "ballistica/game/client_controller_interface.h" +#include "ballistica/logic/client_controller_interface.h" namespace ballistica { diff --git a/src/ballistica/ui/console.cc b/src/ballistica/ui/console.cc index a40bcec0..89cff2e0 100644 --- a/src/ballistica/ui/console.cc +++ b/src/ballistica/ui/console.cc @@ -4,10 +4,10 @@ #include "ballistica/app/app.h" #include "ballistica/audio/audio.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/component/simple_component.h" #include "ballistica/graphics/text/text_graphics.h" +#include "ballistica/logic/logic.h" #include "ballistica/platform/min_sdl.h" namespace ballistica { @@ -53,8 +53,8 @@ auto Console::HandleKeyPress(const SDL_Keysym* keysym) -> bool { case kActivateKey2: { if (!g_buildconfig.demo_build() && !g_buildconfig.arcade_build()) { // (reset input so characters don't continue walking and stuff) - g_game->ResetInput(); - g_game->ToggleConsole(); + g_logic->ResetInput(); + g_logic->ToggleConsole(); } return true; } @@ -113,7 +113,7 @@ auto Console::HandleKeyPress(const SDL_Keysym* keysym) -> bool { last_line_.clear(); lines_.clear(); } else { - g_game->PushInGameConsoleScriptCommand(input_string_); + g_logic->PushInGameConsoleScriptCommand(input_string_); } input_history_.push_front(input_string_); if (input_history_.size() > 100) input_history_.pop_back(); diff --git a/src/ballistica/ui/root_ui.cc b/src/ballistica/ui/root_ui.cc index 8f13411b..1b0cbe72 100644 --- a/src/ballistica/ui/root_ui.cc +++ b/src/ballistica/ui/root_ui.cc @@ -2,13 +2,13 @@ #include "ballistica/ui/root_ui.h" -#include "ballistica/game/connection/connection_set.h" -#include "ballistica/game/game.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/graphics/component/simple_component.h" #include "ballistica/input/device/keyboard_input.h" #include "ballistica/input/device/touch_input.h" #include "ballistica/input/input.h" +#include "ballistica/logic/connection/connection_set.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" #include "ballistica/ui/ui.h" #include "ballistica/ui/widget/container_widget.h" @@ -43,7 +43,8 @@ RootUI::~RootUI() = default; void RootUI::TogglePartyWindowKeyPress() { assert(InLogicThread()); - if (g_game->GetPartySize() > 1 || g_game->connections()->connection_to_host() + if (g_logic->GetPartySize() > 1 + || g_logic->connections()->connection_to_host() || always_draw_party_icon()) { ActivatePartyIcon(); } @@ -51,7 +52,7 @@ void RootUI::TogglePartyWindowKeyPress() { void RootUI::ActivatePartyIcon() const { assert(InLogicThread()); - ScopedSetContext cp(g_game->GetUIContext()); + ScopedSetContext cp(g_logic->GetUIContext()); // Originate from center of party icon. If menu button is shown, it is to the // left of that. @@ -78,8 +79,8 @@ auto RootUI::HandleMouseButtonDown(float x, float y) -> bool { if (explicit_bool(DO_OLD_MENU_PARTY_BUTTONS)) { bool party_button_active = (!party_window_open_ - && (g_game->connections()->GetConnectedClientCount() > 0 - || g_game->connections()->connection_to_host() + && (g_logic->connections()->GetConnectedClientCount() > 0 + || g_logic->connections()->connection_to_host() || always_draw_party_icon())); float party_button_left = menu_active ? 2 * menu_button_size_ : menu_button_size_; @@ -123,7 +124,7 @@ void RootUI::HandleMouseButtonUp(float x, float y) { } if ((g_graphics->screen_virtual_width() - x < menu_button_size_) && (g_graphics->screen_virtual_height() - y < menu_button_size_)) { - g_game->PushMainMenuPressCall(input_device); + g_logic->PushMainMenuPressCall(input_device); last_menu_button_press_time_ = GetRealTime(); } } @@ -199,17 +200,17 @@ void RootUI::Draw(FrameDef* frame_def) { // To the left of the menu button, draw our connected-players indicator // (this probably shouldn't live here). bool draw_connected_players_icon = false; - int party_size = g_game->GetPartySize(); - bool is_host = (g_game->connections()->connection_to_host() == nullptr); + int party_size = g_logic->GetPartySize(); + bool is_host = (g_logic->connections()->connection_to_host() == nullptr); millisecs_t last_connection_to_client_join_time = - g_game->last_connection_to_client_join_time(); + g_logic->last_connection_to_client_join_time(); bool show_client_joined = (is_host && last_connection_to_client_join_time != 0 && real_time - last_connection_to_client_join_time < 5000); if (!party_window_open_ - && (party_size != 0 || g_game->connections()->connection_to_host() + && (party_size != 0 || g_logic->connections()->connection_to_host() || always_draw_party_icon_)) { draw_connected_players_icon = true; } @@ -218,7 +219,7 @@ void RootUI::Draw(FrameDef* frame_def) { // Flash and show a message if we're in the main menu instructing the // player to start a game. bool flash = false; - HostSession* s = g_game->GetForegroundContext().GetHostSession(); + HostSession* s = g_logic->GetForegroundContext().GetHostSession(); if (s && s->is_main_menu() && party_size > 0 && show_client_joined) flash = true; @@ -306,7 +307,7 @@ void RootUI::Draw(FrameDef* frame_def) { } if (party_size == 2) { // (includes us as host) start_a_game_text_group_->SetText( - g_game->GetResourceString("joinedPartyInstructionsText"), + g_logic->GetResourceString("joinedPartyInstructionsText"), TextMesh::HAlign::kRight, TextMesh::VAlign::kTop); } else if (party_size > 2) { start_a_game_text_group_->SetText( diff --git a/src/ballistica/ui/ui.cc b/src/ballistica/ui/ui.cc index 9389eb9a..b33fe840 100644 --- a/src/ballistica/ui/ui.cc +++ b/src/ballistica/ui/ui.cc @@ -219,7 +219,7 @@ void UI::AddWidget(Widget* w, ContainerWidget* parent) { // will not get stuck running or whatnot. if (screen_root_widget_.exists() && !screen_root_widget_->HasChildren() && parent == &(*screen_root_widget_)) { - g_game->ResetInput(); + g_logic->ResetInput(); } parent->AddWidget(w); @@ -305,18 +305,18 @@ auto UI::GetWidgetForInput(InputDevice* input_device) -> Widget* { kUIOwnerTimeoutSeconds - (time - last_input_device_use_time_) / 1000; std::string time_out_str; if (timeout > 0 && timeout < (kUIOwnerTimeoutSeconds - 10)) { - time_out_str = " " + g_game->GetResourceString("timeOutText"); + time_out_str = " " + g_logic->GetResourceString("timeOutText"); Utils::StringReplaceOne(&time_out_str, "${TIME}", std::to_string(timeout)); } else { - time_out_str = " " + g_game->GetResourceString("willTimeOutText"); + time_out_str = " " + g_logic->GetResourceString("willTimeOutText"); } std::string name; if (input->GetDeviceName() == "Keyboard") { - name = g_game->GetResourceString("keyboardText"); + name = g_logic->GetResourceString("keyboardText"); } else if (input->GetDeviceName() == "TouchScreen") { - name = g_game->GetResourceString("touchScreenText"); + name = g_logic->GetResourceString("touchScreenText"); } else { // We used to use player names here, but that's kinda sloppy and random; // lets just go with device names/numbers. @@ -331,7 +331,7 @@ auto UI::GetWidgetForInput(InputDevice* input_device) -> Widget* { } } - std::string b = g_game->GetResourceString("hasMenuControlText"); + std::string b = g_logic->GetResourceString("hasMenuControlText"); Utils::StringReplaceOne(&b, "${NAME}", name); ScreenMessage(b + time_out_str, {0.45f, 0.4f, 0.5f}); } @@ -371,7 +371,7 @@ auto UI::NewTimer(TimeType timetype, TimerMedium length, bool repeat, case TimeType::kSim: case TimeType::kBase: case TimeType::kReal: - return g_game->NewRealTimer(length, repeat, runnable); + return g_logic->NewRealTimer(length, repeat, runnable); default: // Fall back to default for descriptive error otherwise. return ContextTarget::NewTimer(timetype, length, repeat, runnable); @@ -383,7 +383,7 @@ void UI::DeleteTimer(TimeType timetype, int timer_id) { case TimeType::kSim: case TimeType::kBase: case TimeType::kReal: - g_game->DeleteRealTimer(timer_id); + g_logic->DeleteRealTimer(timer_id); break; default: // Fall back to default for descriptive error otherwise. diff --git a/src/ballistica/ui/widget/button_widget.cc b/src/ballistica/ui/widget/button_widget.cc index de09fb05..507d45d7 100644 --- a/src/ballistica/ui/widget/button_widget.cc +++ b/src/ballistica/ui/widget/button_widget.cc @@ -14,7 +14,7 @@ namespace ballistica { -ButtonWidget::ButtonWidget() : birth_time_{g_game->master_time()} { +ButtonWidget::ButtonWidget() : birth_time_{g_logic->master_time()} { text_ = Object::New(); SetText("Button"); text_->set_valign(TextWidget::VAlign::kCenter); @@ -560,7 +560,7 @@ void ButtonWidget::DoActivate(bool isRepeat) { // We don't want holding down a repeat-button to keep flashing it. if (!isRepeat) { - last_activate_time_ = g_game->master_time(); + last_activate_time_ = g_logic->master_time(); } if (sound_enabled_) { int r = rand() % 3; // NOLINT @@ -575,7 +575,7 @@ void ButtonWidget::DoActivate(bool isRepeat) { if (on_activate_call_.exists()) { // Call this in the next cycle (don't want to risk mucking with UI from // within a UI loop.) - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_activate_call_)); return; } diff --git a/src/ballistica/ui/widget/check_box_widget.cc b/src/ballistica/ui/widget/check_box_widget.cc index f45ecafd..8341fffd 100644 --- a/src/ballistica/ui/widget/check_box_widget.cc +++ b/src/ballistica/ui/widget/check_box_widget.cc @@ -3,9 +3,9 @@ #include "ballistica/ui/widget/check_box_widget.h" #include "ballistica/audio/audio.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/component/empty_component.h" #include "ballistica/graphics/component/simple_component.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python_context_call.h" #include "ballistica/python/python_sys.h" #include "ballistica/ui/ui.h" @@ -245,7 +245,7 @@ void CheckBoxWidget::Activate() { // Call this in the next cycle (don't want to risk mucking with UI from // within a UI loop) - g_game->PushPythonWeakCallArgs( + g_logic->PushPythonWeakCallArgs( Object::WeakRef(on_value_change_call_), args); } } diff --git a/src/ballistica/ui/widget/container_widget.cc b/src/ballistica/ui/widget/container_widget.cc index dbd41b05..9d1e0eeb 100644 --- a/src/ballistica/ui/widget/container_widget.cc +++ b/src/ballistica/ui/widget/container_widget.cc @@ -4,10 +4,10 @@ #include "ballistica/audio/audio.h" #include "ballistica/core/thread.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/component/empty_component.h" #include "ballistica/graphics/component/simple_component.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" #include "ballistica/ui/ui.h" @@ -32,7 +32,7 @@ namespace ballistica { ContainerWidget::ContainerWidget(float width_in, float height_in) : width_(width_in), height_(height_in), - dynamics_update_time_(g_game->master_time()) {} + dynamics_update_time_(g_logic->master_time()) {} ContainerWidget::~ContainerWidget() { BA_DEBUG_UI_READ_LOCK; @@ -343,7 +343,7 @@ auto ContainerWidget::HandleMessage(const WidgetMessage& m) -> bool { // Call this in the next cycle (don't wanna risk mucking with UI from // within a UI loop). - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_cancel_call_)); } else { OnCancelCustom(); @@ -619,7 +619,7 @@ auto ContainerWidget::HandleMessage(const WidgetMessage& m) -> bool { if (!claimed && on_outside_click_call_.exists()) { // Call this in the next cycle (don't wanna risk mucking with UI from // within a UI loop). - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_outside_click_call_)); } @@ -809,7 +809,7 @@ void ContainerWidget::Draw(RenderPass* pass, bool draw_transparent) { // Probably not safe to delete ourself here since we're in // the draw loop, but we can push a call to do it. Object::WeakRef weakref(this); - g_game->thread()->PushCall([weakref] { + g_logic->thread()->PushCall([weakref] { Widget* w = weakref.get(); if (w) g_ui->DeleteWidget(w); }); @@ -864,7 +864,7 @@ void ContainerWidget::Draw(RenderPass* pass, bool draw_transparent) { // Probably not safe to delete ourself here since we're in the // draw loop, but we can set up an event to do it. Object::WeakRef weakref(this); - g_game->thread()->PushCall([weakref] { + g_logic->thread()->PushCall([weakref] { Widget* w = weakref.get(); if (w) g_ui->DeleteWidget(w); }); @@ -1046,11 +1046,11 @@ void ContainerWidget::TransformPointFromChild(float* x, float* y, } void ContainerWidget::Activate() { - last_activate_time_ = g_game->master_time(); + last_activate_time_ = g_logic->master_time(); if (on_activate_call_.exists()) { // Call this in the next cycle (don't wanna risk mucking with UI from within // a UI loop). - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_activate_call_)); } } @@ -1143,7 +1143,7 @@ void ContainerWidget::SetTransition(TransitionType t) { return; } parent->CheckLayout(); - millisecs_t net_time = g_game->master_time(); + millisecs_t net_time = g_logic->master_time(); transition_type_ = t; // Scale transitions are simpler. @@ -1779,7 +1779,7 @@ void ContainerWidget::SelectNextWidget() { millisecs_t old_last_prev_next_time = last_prev_next_time_; if (should_print_list_exit_instructions_) { - last_prev_next_time_ = g_game->master_time(); + last_prev_next_time_ = g_logic->master_time(); } // Grab the iterator for our selected widget if possible. @@ -1839,21 +1839,21 @@ void ContainerWidget::SelectNextWidget() { void ContainerWidget::PrintExitListInstructions( millisecs_t old_last_prev_next_time) { if (should_print_list_exit_instructions_) { - millisecs_t t = g_game->master_time(); + millisecs_t t = g_logic->master_time(); if ((t - old_last_prev_next_time > 250) && (t - last_list_exit_instructions_print_time_ > 5000)) { last_list_exit_instructions_print_time_ = t; g_audio->PlaySound(g_assets->GetSound(SystemSoundID::kErrorBeep)); - std::string s = g_game->GetResourceString("arrowsToExitListText"); + std::string s = g_logic->GetResourceString("arrowsToExitListText"); { // Left arrow. Utils::StringReplaceOne(&s, "${LEFT}", - g_game->CharStr(SpecialChar::kLeftArrow)); + g_logic->CharStr(SpecialChar::kLeftArrow)); } { // Right arrow. Utils::StringReplaceOne(&s, "${RIGHT}", - g_game->CharStr(SpecialChar::kRightArrow)); + g_logic->CharStr(SpecialChar::kRightArrow)); } ScreenMessage(s); } @@ -1865,7 +1865,7 @@ void ContainerWidget::SelectPrevWidget() { millisecs_t old_last_prev_next_time = last_prev_next_time_; if (should_print_list_exit_instructions_) { - last_prev_next_time_ = g_game->master_time(); + last_prev_next_time_ = g_logic->master_time(); } // Grab the iterator for our selected widget if possible. diff --git a/src/ballistica/ui/widget/h_scroll_widget.cc b/src/ballistica/ui/widget/h_scroll_widget.cc index 27aecc66..49e0e2b7 100644 --- a/src/ballistica/ui/widget/h_scroll_widget.cc +++ b/src/ballistica/ui/widget/h_scroll_widget.cc @@ -348,7 +348,7 @@ auto HScrollWidget::HandleMessage(const WidgetMessage& m) -> bool { inertia_scroll_rate_ = smoothing * inertia_scroll_rate_ + (1.0f - smoothing) * new_val; } - last_velocity_event_time_ = g_game->master_time(); + last_velocity_event_time_ = g_logic->master_time(); MarkForUpdate(); } else { // Not within our widget; dont allow children to claim. diff --git a/src/ballistica/ui/widget/image_widget.cc b/src/ballistica/ui/widget/image_widget.cc index 75c63b86..28b2a369 100644 --- a/src/ballistica/ui/widget/image_widget.cc +++ b/src/ballistica/ui/widget/image_widget.cc @@ -2,12 +2,12 @@ #include "ballistica/ui/widget/image_widget.h" -#include "ballistica/game/game.h" #include "ballistica/graphics/component/simple_component.h" +#include "ballistica/logic/logic.h" namespace ballistica { -ImageWidget::ImageWidget() : birth_time_{g_game->master_time()} {} +ImageWidget::ImageWidget() : birth_time_{g_logic->master_time()} {} ImageWidget::~ImageWidget() = default; diff --git a/src/ballistica/ui/widget/root_widget.cc b/src/ballistica/ui/widget/root_widget.cc index 846a92b0..f3d24b03 100644 --- a/src/ballistica/ui/widget/root_widget.cc +++ b/src/ballistica/ui/widget/root_widget.cc @@ -2,10 +2,10 @@ #include "ballistica/ui/widget/root_widget.h" -#include "ballistica/game/game.h" -#include "ballistica/game/session/host_session.h" #include "ballistica/graphics/renderer.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" +#include "ballistica/logic/session/host_session.h" #include "ballistica/python/python.h" #include "ballistica/ui/ui.h" #include "ballistica/ui/widget/button_widget.h" @@ -346,7 +346,7 @@ void RootWidget::Setup() { td.x = 5.0f; td.y = 3.0f; td.width = bd.width * 0.9f; - td.text = g_game->CharStr(SpecialChar::kBack); + td.text = g_logic->CharStr(SpecialChar::kBack); td.color_a = 1.0f; td.scale = 2.0f; td.flatness = 0.0f; @@ -812,7 +812,7 @@ void RootWidget::Draw(RenderPass* pass, bool transparent) { } auto RootWidget::AddButton(const ButtonDef& def) -> RootWidget::Button* { - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); buttons_.emplace_back(); Button& b(buttons_.back()); b.x = b.x_smoothed = b.x_target = def.x; @@ -862,7 +862,7 @@ auto RootWidget::AddButton(const ButtonDef& def) -> RootWidget::Button* { } auto RootWidget::AddText(const TextDef& def) -> RootWidget::Text* { - ScopedSetContext cp(g_game->GetUIContextTarget()); + ScopedSetContext cp(g_logic->GetUIContextTarget()); texts_.emplace_back(); Text& t(texts_.back()); t.button = def.button; @@ -896,7 +896,7 @@ void RootWidget::UpdateForFocusedWindow() { void RootWidget::UpdateForFocusedWindow(Widget* widget) { // Take note if the current session is the main menu; we do a few things // differently there. - HostSession* s = g_game->GetForegroundContext().GetHostSession(); + HostSession* s = g_logic->GetForegroundContext().GetHostSession(); in_main_menu_ = (s ? s->is_main_menu() : false); if (widget == nullptr) { diff --git a/src/ballistica/ui/widget/scroll_widget.cc b/src/ballistica/ui/widget/scroll_widget.cc index 3e9ba042..9c3b29f3 100644 --- a/src/ballistica/ui/widget/scroll_widget.cc +++ b/src/ballistica/ui/widget/scroll_widget.cc @@ -265,7 +265,7 @@ auto ScrollWidget::HandleMessage(const WidgetMessage& m) -> bool { inertia_scroll_rate_ = smoothing * inertia_scroll_rate_ + (1.0f - smoothing) * new_val; } - last_velocity_event_time_ = g_game->master_time(); + last_velocity_event_time_ = g_logic->master_time(); MarkForUpdate(); } else { // Not within our widget; don't allow children to claim. diff --git a/src/ballistica/ui/widget/text_widget.cc b/src/ballistica/ui/widget/text_widget.cc index 795a009d..060ea48a 100644 --- a/src/ballistica/ui/widget/text_widget.cc +++ b/src/ballistica/ui/widget/text_widget.cc @@ -4,13 +4,13 @@ #include "ballistica/app/app_flavor.h" #include "ballistica/audio/audio.h" -#include "ballistica/game/game.h" #include "ballistica/generic/utils.h" #include "ballistica/graphics/component/empty_component.h" #include "ballistica/graphics/component/simple_component.h" #include "ballistica/graphics/text/text_graphics.h" #include "ballistica/input/device/keyboard_input.h" #include "ballistica/input/input.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/python.h" #include "ballistica/python/python_context_call.h" #include "ballistica/ui/ui.h" @@ -39,7 +39,7 @@ TextWidget::TextWidget() { } } - birth_time_ = g_game->master_time(); + birth_time_ = g_logic->master_time(); } TextWidget::~TextWidget() = default; @@ -461,8 +461,8 @@ void TextWidget::SetText(const std::string& text_in_raw) { if (do_format_check) { bool valid; - g_game->CompileResourceString(text_in_raw, - "TextWidget::SetText format check", &valid); + g_logic->CompileResourceString(text_in_raw, + "TextWidget::SetText format check", &valid); if (!valid) { BA_LOG_ONCE("Invalid resource string: '" + text_in_raw + "'"); Python::PrintStackTrace(); @@ -557,12 +557,12 @@ void TextWidget::BringUpEditDialog() { } void TextWidget::Activate() { - last_activate_time_ = g_game->master_time(); + last_activate_time_ = g_logic->master_time(); if (on_activate_call_.exists()) { // Call this in the next cycle (don't wanna risk mucking with UI from within // a UI loop). - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_activate_call_)); } @@ -603,7 +603,7 @@ auto TextWidget::HandleMessage(const WidgetMessage& m) -> bool { } // If we're doing inline editing, handle some key events. if (m.has_keysym && !ShouldUseStringEditDialog()) { - last_carat_change_time_ = g_game->master_time(); + last_carat_change_time_ = g_logic->master_time(); text_group_dirty_ = true; bool claimed = false; @@ -626,7 +626,7 @@ auto TextWidget::HandleMessage(const WidgetMessage& m) -> bool { if (on_return_press_call_.exists()) { // Call this in the next cycle (don't wanna risk mucking with UI // from within a UI loop) - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_return_press_call_)); } } @@ -933,7 +933,7 @@ void TextWidget::UpdateTranslation() { if (editable()) { text_translated_ = text_raw_; } else { - text_translated_ = g_game->CompileResourceString( + text_translated_ = g_logic->CompileResourceString( text_raw_, "TextWidget::UpdateTranslation"); } text_translation_dirty_ = false; diff --git a/src/ballistica/ui/widget/widget.cc b/src/ballistica/ui/widget/widget.cc index ced12799..ea0f1bab 100644 --- a/src/ballistica/ui/widget/widget.cc +++ b/src/ballistica/ui/widget/widget.cc @@ -2,7 +2,7 @@ #include "ballistica/ui/widget/widget.h" -#include "ballistica/game/game.h" +#include "ballistica/logic/logic.h" #include "ballistica/python/class/python_class_widget.h" #include "ballistica/python/python_context_call.h" #include "ballistica/ui/ui.h" @@ -87,7 +87,7 @@ void Widget::SetSelected(bool s, SelectionCause cause) { if (selected_ && on_select_call_.exists()) { // Call this in the next cycle (don't wanna risk mucking // with UI from within a UI loop). - g_game->PushPythonWeakCall( + g_logic->PushPythonWeakCall( Object::WeakRef(on_select_call_)); } } diff --git a/tools/batools/project.py b/tools/batools/project.py index 507b8ebe..a810b09f 100755 --- a/tools/batools/project.py +++ b/tools/batools/project.py @@ -202,7 +202,9 @@ class Updater: if auto_changes: if not self._fix: for i, change in enumerate(auto_changes): - print(f'{Clr.RED}#{i}: {change[0]}:{Clr.RST}') + print(f'{Clr.RED}#{i}:' + f' {change[0]}:{change[1].line_number+1}:' + f'{Clr.RST}') print( f'{Clr.RED} Expected "{change[1].expected}"{Clr.RST}') with open(change[0], encoding='utf-8') as infile: @@ -262,6 +264,9 @@ class Updater: def _add_line_correction(self, filename: str, line_number: int, expected: str, can_auto_update: bool) -> None: + # No longer allowing negatives here since they don't show up nicely + # in correction list. + assert line_number >= 0 self._line_corrections.setdefault(filename, []).append( LineChange(line_number=line_number, expected=expected, @@ -301,7 +306,7 @@ class Updater: if self._license_line_checks: self._check_c_license(fname, lines) - # Check for header guard at top + # Check for header guard lines at top line = '#ifndef ' + guard lnum = 2 if lines[lnum] != line: @@ -312,10 +317,20 @@ class Updater: line_number=lnum, expected=line, can_auto_update=allow_auto) + line = '#define ' + guard + lnum = 3 + if lines[lnum] != line: + # Allow auto-correcting if it looks close already + # (don't want to blow away an unrelated line) + allow_auto = lines[lnum].startswith('#define BALLISTICA_') + self._add_line_correction(fname, + line_number=lnum, + expected=line, + can_auto_update=allow_auto) # Check for header guard at bottom line = '#endif // ' + guard - lnum = -1 + lnum = len(lines) - 1 if lines[lnum] != line: # Allow auto-correcting if it looks close already # (don't want to blow away an unrelated line)