From a97119b37aac08f6ef6550e4c4f2da65284344f9 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 7 Nov 2024 15:21:52 -0800 Subject: [PATCH] more logger wiring --- .efrocachemap | 88 +++++++++---------- CHANGELOG.md | 2 +- .../ba_data/python/babase/_devconsoletabs.py | 8 +- src/assets/ba_data/python/baenv.py | 2 +- .../server_package/ballisticakit_server.py | 10 ++- src/ballistica/base/assets/asset.cc | 50 ++++++++++- src/ballistica/base/assets/asset.h | 5 +- src/ballistica/base/assets/assets.cc | 1 + src/ballistica/base/assets/assets_server.cc | 43 ++++----- src/ballistica/base/assets/assets_server.h | 21 ++--- .../base/assets/collision_mesh_asset.cc | 7 +- src/ballistica/base/assets/data_asset.cc | 6 +- src/ballistica/base/assets/mesh_asset.cc | 7 +- src/ballistica/base/assets/sound_asset.cc | 7 +- src/ballistica/base/assets/texture_asset.cc | 3 +- src/ballistica/base/assets/texture_asset.h | 1 + src/ballistica/base/audio/audio.cc | 1 + src/ballistica/base/audio/audio_server.cc | 1 + src/ballistica/base/audio/audio_source.cc | 1 + src/ballistica/base/base.cc | 1 + .../base/dynamics/bg/bg_dynamics.cc | 1 + .../base/dynamics/bg/bg_dynamics_server.cc | 1 + .../base/graphics/graphics_server.cc | 1 + src/ballistica/base/input/input.cc | 1 + src/ballistica/base/logic/logic.cc | 1 + .../python/methods/python_methods_base_1.cc | 1 + .../python/methods/python_methods_base_3.cc | 3 +- src/ballistica/base/ui/dev_console.cc | 4 +- src/ballistica/base/ui/ui.cc | 1 + .../classic/support/classic_app_mode.cc | 1 + src/ballistica/core/support/core_config.cc | 5 -- src/ballistica/scene_v1/assets/scene_mesh.cc | 1 + src/ballistica/scene_v1/assets/scene_mesh.h | 5 -- src/ballistica/scene_v1/node/image_node.cc | 1 + .../scene_v1/support/host_session.cc | 1 + src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/shared/foundation/object.cc | 8 ++ src/ballistica/shared/foundation/object.h | 39 ++++++++ .../ui_v1/widget/check_box_widget.cc | 1 + .../ui_v1/widget/h_scroll_widget.cc | 1 + src/ballistica/ui_v1/widget/scroll_widget.cc | 1 + src/ballistica/ui_v1/widget/text_widget.cc | 1 + tools/bacommon/servermanager.py | 5 ++ tools/batools/build.py | 5 +- 44 files changed, 233 insertions(+), 123 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 354200a3..0249c2fc 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4099,50 +4099,50 @@ "build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1", "build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "acf25c2f0b4590116ce672d3d01b2a10", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "f0616f14d9954f20f600f7d004550fad", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "1680e59f8fd4411b3903f0049c435a59", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "d02b65452261018ce2c6b7701db0ce1b", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "ca8f19db9d17a0e6d3173150078cc6d6", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "30b4086f7f100a9ec3f2d2c41dc3a906", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "cac729b2077108eaa7499b6ca8a5d812", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "c878ae8465a1eaf0d50121dea91a61bf", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "71f4ff6839406cd14d8fd4c878ae4142", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "8127d0ecff652a3b0b8f9d66bd95d1fe", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "7f5197bc4864632a3138b5c812a03818", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "5e1f115140306cf51c97df11618de088", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "4b78329eec1d588d7def8e76ee5d8c15", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "931ada78d6e283b55c94a44a08ff1ee4", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "970b98f4b7aa42f6ca12dbb88035315d", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "241e26801373958babe60fccf3a3c650", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "2af0e30a4594fbe2f04799137fddad1f", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "8b81104944ec4e64a4fb270be09f1c50", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "359ab73709b87325ecdff059455986f3", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "b0401184660350ad7150d83a537e4d23", - "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "0908fb0b2bd96bf6430203e96e47e1ff", - "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "1f2f03992b403171ad4027a3fa6bfa1c", - "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "0908fb0b2bd96bf6430203e96e47e1ff", - "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "1f2f03992b403171ad4027a3fa6bfa1c", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "c1b8b4263516bd5f722e87387a665f96", - "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "e90f9ec3e2fc4f18283d37500df8220e", - "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "c1b8b4263516bd5f722e87387a665f96", - "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "e90f9ec3e2fc4f18283d37500df8220e", - "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "4fc0e5a14b173e2ed6151e5ead7c0e35", - "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "f727e1126463bdd256abab321d7261dd", - "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "4fc0e5a14b173e2ed6151e5ead7c0e35", - "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "f727e1126463bdd256abab321d7261dd", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "ec10904ac6e96dabbee7c9835db10be0", - "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "18fbad7b38a25994e370c01b85499e47", - "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "14fd7fa596120ad0b1cbfdfb32b79f2c", - "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "18fbad7b38a25994e370c01b85499e47", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "77871bca2a7987786817d79390c439d7", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "bd39727002a3f4094160649f18deca49", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "f3735462e3292ac07df74dbabe8ed994", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "50e2c0293621bf058dcf0960c929cdb3", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "48dd1eb95e6ef511ba828221101df0bc", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "2a97fbd995d7abb7e215b756d851ff6d", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "f4f0363f6ab65c664db2e50b651d6585", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "6ad1fbc86d593db1653b64ba40ab1da6", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "7cadc07c2e5165362692d3383646237a", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "f349db0463adbf2fe3b11fa3000c1792", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "01aacff8e2dc1f65af828e17422134b5", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "bf2c2faeaa2e28c07a8459d624786d22", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "60dab3e475bbba7e936ce7c2b52559e1", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "548f01033d5a93bb49036302ace281e2", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "1571cdae20fa989bc07239150f83d869", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "95780363ec0aea90f5d67f6ba756cf00", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "93e70445cf1456edabe1869499f8f226", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "388f3e04bdb917102a9b6f0e231b78c8", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "0390bc7f493ade35164142dc8649b3f6", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "445c881f3bf3f15ee18b9f2851d539a1", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "24448c4f51332f9b26bbb45122558378", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "17d7bd762d07d42fca435a8af6313489", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "2e3c4e3d0f2cc6b2f9380c1e85d1a9bc", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "4996a4ab92124ee8217f044c7294b5f7", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "664c2f20b66222a73caf467c03ab64d3", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "0e8e3deae9c657022c4ccb419744420e", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "dc511e79e8c4713aeadda840ec3e6eee", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "c982c13f6664640c3d1c768112064116", + "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "4e0f966529a69bf8da66cb2ee1c39aeb", + "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "5d5c02fb0a49991b0d1d987666e47702", + "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "4e0f966529a69bf8da66cb2ee1c39aeb", + "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "5d5c02fb0a49991b0d1d987666e47702", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "6dd00a2f521e1bb12f1c7d92ce6b28e6", + "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "c6fdeeca50279426b474b9cd1a3afd2b", + "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "6dd00a2f521e1bb12f1c7d92ce6b28e6", + "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "c6fdeeca50279426b474b9cd1a3afd2b", + "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "296b14a0b2bccf309e314ec1f2175318", + "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "7296cb71fc42baece5e1bc23121104be", + "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "296b14a0b2bccf309e314ec1f2175318", + "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "7296cb71fc42baece5e1bc23121104be", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "19dfba8beca806f8155f952bbfab583d", + "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "076f47790cb474f2aaf18417c0c8f803", + "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "cfc62fad488ae4033175f3b1ad022e6f", + "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "076f47790cb474f2aaf18417c0c8f803", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "1b5a88065df858440c5c80f274c0f735", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "35329f3c346807358b04100826d9d8aa", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "68a26ca4930f3559121dc7c8495d0b73", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "d4e13a16abf9ace1c358b5f1889e2087", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "f3f9a07fd501e22a9646cd4815278c29", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "a214f5e09f1c7b4d0674998ba0f8f3e9", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "a46e145296dfa7691dd415ba9309398d", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "3d77b8e9feb58884fdefe0f5047d6480", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad", "src/ballistica/base/mgen/pyembed/binding_base.inc": "3a583e7e03bd4907b21adc3bf5729d15", diff --git a/CHANGELOG.md b/CHANGELOG.md index 60b27e66..7f28691b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22076, api 9, 2024-11-06) +### 1.7.37 (build 22077, api 9, 2024-11-07) - Bumping api version to 9. As you'll see below, there's some UI changes that will require a bit of work for any UI mods to adapt to. If your mods don't touch UI stuff at all you can simply bump your api version and call it a day. diff --git a/src/assets/ba_data/python/babase/_devconsoletabs.py b/src/assets/ba_data/python/babase/_devconsoletabs.py index 279a5317..a10b523e 100644 --- a/src/assets/ba_data/python/babase/_devconsoletabs.py +++ b/src/assets/ba_data/python/babase/_devconsoletabs.py @@ -506,7 +506,7 @@ class DevConsoleTabLogging(DevConsoleTab): size=(bwidth - 2.0, height - 10), label_scale=btextscale, style=( - 'blue_bright' + 'white_bright' if level == logging.DEBUG else 'blue' if effectivelevel <= logging.DEBUG else 'black' ), @@ -536,7 +536,7 @@ class DevConsoleTabLogging(DevConsoleTab): size=(bwidth - 2.0, height - 10), label_scale=btextscale, style=( - 'yellow_bright' + 'white_bright' if level == logging.WARNING else 'yellow' if effectivelevel <= logging.WARNING else 'black' ), @@ -551,7 +551,7 @@ class DevConsoleTabLogging(DevConsoleTab): size=(bwidth - 2.0, height - 10), label_scale=btextscale, style=( - 'red_bright' + 'white_bright' if level == logging.ERROR else 'red' if effectivelevel <= logging.ERROR else 'black' ), @@ -566,7 +566,7 @@ class DevConsoleTabLogging(DevConsoleTab): size=(bwidth - 2.0, height - 10), label_scale=btextscale, style=( - 'purple_bright' + 'white_bright' if level == logging.CRITICAL else ( 'purple' if effectivelevel <= logging.CRITICAL else 'black' diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 9690cbbe..923c7d4e 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -53,7 +53,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 22076 +TARGET_BALLISTICA_BUILD = 22077 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/assets/server_package/ballisticakit_server.py b/src/assets/server_package/ballisticakit_server.py index 8e5a725c..b95924bb 100755 --- a/src/assets/server_package/ballisticakit_server.py +++ b/src/assets/server_package/ballisticakit_server.py @@ -33,10 +33,18 @@ if TYPE_CHECKING: from types import FrameType from bacommon.servermanager import ServerCommand -VERSION_STR = '1.3.2' +VERSION_STR = '1.3.3' # Version history: # +# 1.3.3 +# +# - Added log_levels dict in server config for setting levels on +# individual loggers within the server binary. Can be useful for +# debugging issues or just keeping better track of what the server is +# up to. Check the logging tab in the dev console in the graphical +# client to learn which loggers are available. +# # 1.3.2 # # - Updated to use Python 3.12. diff --git a/src/ballistica/base/assets/asset.cc b/src/ballistica/base/assets/asset.cc index e554ab60..2cb9df48 100644 --- a/src/ballistica/base/assets/asset.cc +++ b/src/ballistica/base/assets/asset.cc @@ -2,6 +2,10 @@ #include "ballistica/base/assets/asset.h" +#include + +#include "ballistica/core/platform/core_platform.h" // IWYU pragma: keep. + namespace ballistica::base { Asset::Asset() { @@ -10,10 +14,42 @@ Asset::Asset() { last_used_time_ = g_core->GetAppTimeMillisecs(); } +auto Asset::AssetTypeName(AssetType assettype) -> const char* { + const char* asset_type_name{"unknown"}; + switch (assettype) { + case AssetType::kCollisionMesh: + asset_type_name = "collision-mesh"; + break; + case AssetType::kMesh: + asset_type_name = "mesh"; + break; + case AssetType::kData: + asset_type_name = "data"; + break; + case AssetType::kSound: + asset_type_name = "sound"; + break; + case AssetType::kTexture: + asset_type_name = "texture"; + break; + case AssetType::kLast: + break; + } + return asset_type_name; +} + +void Asset::ObjectPostInit() { + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, [this] { + return std::string("allocating ") + AssetTypeName(GetAssetType()) + " " + + GetName(); + }); + Object::ObjectPostInit(); +} + Asset::~Asset() { - // at the moment whoever owns the last reference to us - // needs to make sure to unload us before we die.. - // I feel like there should be a more elegant solution to that. + // at the moment whoever owns the last reference to us needs to make sure + // to unload us before we die. I feel like there should be a more elegant + // solution to that. assert(g_base && g_base->assets); assert(!locked()); assert(!loaded()); @@ -25,6 +61,10 @@ void Asset::Preload(bool already_locked) { if (!preloaded_) { assert(!loaded_); BA_PRECONDITION(locked()); + g_core->Log(LogName::kBaAssets, LogLevel::kDebug, [this] { + return std::string("preloading ") + AssetTypeName(GetAssetType()) + " " + + GetName(); + }); preload_start_time_ = g_core->GetAppTimeMillisecs(); DoPreload(); preload_end_time_ = g_core->GetAppTimeMillisecs(); @@ -43,6 +83,10 @@ void Asset::Load(bool already_locked) { assert(preloaded_ && !loaded_); BA_DEBUG_FUNCTION_TIMER_BEGIN(); BA_PRECONDITION(locked()); + g_core->Log(LogName::kBaAssets, LogLevel::kDebug, [this] { + return std::string("loading ") + AssetTypeName(GetAssetType()) + " " + + GetName(); + }); load_start_time_ = g_core->GetAppTimeMillisecs(); DoLoad(); load_end_time_ = g_core->GetAppTimeMillisecs(); diff --git a/src/ballistica/base/assets/asset.h b/src/ballistica/base/assets/asset.h index 0284ce18..bf874791 100644 --- a/src/ballistica/base/assets/asset.h +++ b/src/ballistica/base/assets/asset.h @@ -7,7 +7,6 @@ #include #include "ballistica/base/base.h" -#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/object.h" namespace ballistica::base { @@ -19,10 +18,14 @@ namespace ballistica::base { class Asset : public Object { public: Asset(); + void ObjectPostInit() override; ~Asset() override; virtual auto GetAssetType() const -> AssetType = 0; + /// Get a human readable name for an AssetType. + static auto AssetTypeName(AssetType assettype) -> const char*; + void Preload(bool already_locked = false); void Load(bool already_locked = false); void Unload(bool already_locked = false); diff --git a/src/ballistica/base/assets/assets.cc b/src/ballistica/base/assets/assets.cc index e7cd35dd..1b22fa95 100644 --- a/src/ballistica/base/assets/assets.cc +++ b/src/ballistica/base/assets/assets.cc @@ -23,6 +23,7 @@ #include "ballistica/base/logic/logic.h" #include "ballistica/base/python/base_python.h" #include "ballistica/base/ui/ui.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/generic/json.h" #include "ballistica/shared/python/python.h" diff --git a/src/ballistica/base/assets/assets_server.cc b/src/ballistica/base/assets/assets_server.cc index d541335c..ee029bd6 100644 --- a/src/ballistica/base/assets/assets_server.cc +++ b/src/ballistica/base/assets/assets_server.cc @@ -10,6 +10,7 @@ #include "ballistica/base/assets/assets.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/support/huffman.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { @@ -21,23 +22,23 @@ void AssetsServer::OnMainThreadStartApp() { event_loop_ = new EventLoop(EventLoopID::kAssets); g_core->suspendable_event_loops.push_back(event_loop_); - event_loop_->PushCallSynchronous([this] { OnAppStartInThread(); }); + event_loop_->PushCallSynchronous([this] { OnAppStartInThread_(); }); } -void AssetsServer::OnAppStartInThread() { +void AssetsServer::OnAppStartInThread_() { assert(g_base->InAssetsThread()); - // Ask our thread to give us periodic processing time (close to but - // not *exactly* one second; try to avoid aliasing with similar updates). + // Ask our thread to give us periodic processing time (close to but not + // *exactly* one second; try to avoid aliasing with similar updates). process_timer_ = event_loop()->NewTimer( - 987 * 1000, true, NewLambdaRunnable([this] { Process(); }).Get()); + 987 * 1000, true, NewLambdaRunnable([this] { Process_(); }).Get()); } void AssetsServer::PushPendingPreload(Object::Ref* asset_ref_ptr) { event_loop()->PushCall([this, asset_ref_ptr] { assert(g_base->InAssetsThread()); - // Add our pointer to one of the preload lists and shake our preload thread - // to wake it up + // Add our pointer to one of the preload lists and shake our preload + // thread to wake it up if ((**asset_ref_ptr).GetAssetType() == AssetType::kSound) { pending_preloads_audio_.push_back(asset_ref_ptr); } else { @@ -59,7 +60,7 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) { g_core->Log( LogName::kBaAssets, LogLevel::kError, "AssetsServer got BeginWriteReplayCall while already writing"); - WriteReplayMessages(); + WriteReplayMessages_(); if (replay_out_file_) { fclose(replay_out_file_); } @@ -96,8 +97,8 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) { replay_bytes_written_ = 5; } - // Trigger our process timer to go off immediately - // (we may need to wake it up). + // Trigger our process timer to go off immediately (we may need to wake + // it up). g_base->assets_server->process_timer_->SetLength(0); }); } @@ -150,7 +151,7 @@ void AssetsServer::PushEndWriteReplayCall() { replays_broken_ = true; return; } - WriteReplayMessages(); + WriteReplayMessages_(); // Whether or not we actually have a file has no impact on our // writing_replay_ status. @@ -162,7 +163,7 @@ void AssetsServer::PushEndWriteReplayCall() { }); } -void AssetsServer::WriteReplayMessages() { +void AssetsServer::WriteReplayMessages_() { if (replay_out_file_) { for (auto&& i : replay_messages_) { std::vector data_compressed = g_base->huffman->compress(i); @@ -189,7 +190,7 @@ void AssetsServer::WriteReplayMessages() { return; } } - // write 16 bit val if need be.. + // write 16 bit val if need be. if (len32 >= 254) { if (len32 <= 65535) { auto len16 = static_cast_check_fit(len32); @@ -230,20 +231,20 @@ void AssetsServer::WriteReplayMessages() { } } -void AssetsServer::Process() { +void AssetsServer::Process_() { // Make sure we don't do any loading until we know what kind/quality of // textures we'll be loading. - // FIXME - we'll need to revisit this when adding support for - // renderer switches, since this is not especially thread-safe. + // FIXME - we'll need to revisit this when adding support for renderer + // switches, since this is not especially thread-safe. if (!g_base->graphics->has_client_context()) { return; } // Process exactly 1 preload item. Empty out our non-audio list first - // (audio is less likely to cause noticeable hitches if it needs to be loaded - // on-demand, so that's a lower priority for us). + // (audio is less likely to cause noticeable hitches if it needs to be + // loaded on-demand, so that's a lower priority for us). if (!pending_preloads_.empty()) { (**pending_preloads_.back()).Preload(); // Pass the ref-pointer along to the load queue. @@ -258,11 +259,11 @@ void AssetsServer::Process() { // If we're writing a replay, dump anything we've got built up. if (writing_replay_) { - WriteReplayMessages(); + WriteReplayMessages_(); } - // If we've got nothing left, set our timer to go off every now and then if - // we're writing a replay.. otherwise just sleep indefinitely. + // If we've got nothing left, set our timer to go off every now and then + // if we're writing a replay.. otherwise just sleep indefinitely. if (pending_preloads_.empty() && pending_preloads_audio_.empty()) { if (writing_replay_) { process_timer_->SetLength(1000 * 1000); diff --git a/src/ballistica/base/assets/assets_server.h b/src/ballistica/base/assets/assets_server.h index 754bbdd6..970cb8c2 100644 --- a/src/ballistica/base/assets/assets_server.h +++ b/src/ballistica/base/assets/assets_server.h @@ -23,19 +23,20 @@ class AssetsServer { auto event_loop() const -> EventLoop* { return event_loop_; } private: - void OnAppStartInThread(); - void Process(); - void WriteReplayMessages(); - EventLoop* event_loop_{}; - FILE* replay_out_file_{}; - size_t replay_bytes_written_{}; - bool writing_replay_{}; - bool replays_broken_{}; + void OnAppStartInThread_(); + void Process_(); + void WriteReplayMessages_(); + std::list > replay_messages_; - size_t replay_message_bytes_{}; - Timer* process_timer_{}; std::vector*> pending_preloads_; std::vector*> pending_preloads_audio_; + EventLoop* event_loop_{}; + FILE* replay_out_file_{}; + Timer* process_timer_{}; + size_t replay_bytes_written_{}; + size_t replay_message_bytes_{}; + bool writing_replay_{}; + bool replays_broken_{}; }; } // namespace ballistica::base diff --git a/src/ballistica/base/assets/collision_mesh_asset.cc b/src/ballistica/base/assets/collision_mesh_asset.cc index a52a3323..7a52716f 100644 --- a/src/ballistica/base/assets/collision_mesh_asset.cc +++ b/src/ballistica/base/assets/collision_mesh_asset.cc @@ -7,6 +7,7 @@ #include "ballistica/base/assets/assets.h" #include "ballistica/core/core.h" +#include "ballistica/core/platform/core_platform.h" namespace ballistica::base { @@ -23,11 +24,7 @@ auto CollisionMeshAsset::GetAssetType() const -> AssetType { } auto CollisionMeshAsset::GetName() const -> std::string { - if (!file_name_full_.empty()) { - return file_name_full_; - } else { - return "invalid CollisionMesh"; - } + return (!file_name_.empty()) ? file_name_ : "invalid collision mesh"; } void CollisionMeshAsset::DoPreload() { diff --git a/src/ballistica/base/assets/data_asset.cc b/src/ballistica/base/assets/data_asset.cc index 60e49f74..051158c2 100644 --- a/src/ballistica/base/assets/data_asset.cc +++ b/src/ballistica/base/assets/data_asset.cc @@ -22,11 +22,7 @@ DataAsset::DataAsset(const std::string& file_name_in) auto DataAsset::GetAssetType() const -> AssetType { return AssetType::kData; } auto DataAsset::GetName() const -> std::string { - if (!file_name_full_.empty()) { - return file_name_full_; - } else { - return "invalid data"; - } + return (!file_name_.empty()) ? file_name_ : "invalid data"; } void DataAsset::DoPreload() { diff --git a/src/ballistica/base/assets/mesh_asset.cc b/src/ballistica/base/assets/mesh_asset.cc index 8801d8c9..7be25131 100644 --- a/src/ballistica/base/assets/mesh_asset.cc +++ b/src/ballistica/base/assets/mesh_asset.cc @@ -10,6 +10,7 @@ #include "ballistica/base/graphics/graphics_server.h" #include "ballistica/base/graphics/renderer/renderer.h" #include "ballistica/core/core.h" +#include "ballistica/core/platform/core_platform.h" namespace ballistica::base { @@ -23,11 +24,7 @@ MeshAsset::MeshAsset(const std::string& file_name_in) auto MeshAsset::GetAssetType() const -> AssetType { return AssetType::kMesh; } auto MeshAsset::GetName() const -> std::string { - if (!file_name_full_.empty()) { - return file_name_full_; - } else { - return "invalid mesh"; - } + return (!file_name_.empty()) ? file_name_ : "invalid mesh"; } void MeshAsset::DoPreload() { diff --git a/src/ballistica/base/assets/sound_asset.cc b/src/ballistica/base/assets/sound_asset.cc index 1032c3fe..808b92e5 100644 --- a/src/ballistica/base/assets/sound_asset.cc +++ b/src/ballistica/base/assets/sound_asset.cc @@ -19,6 +19,7 @@ #include "ballistica/base/audio/audio_server.h" #include "ballistica/base/python/base_python.h" #include "ballistica/core/core.h" +#include "ballistica/core/platform/core_platform.h" // Need to move away from OpenAL on Apple stuff. #if __clang__ @@ -260,11 +261,7 @@ SoundAsset::SoundAsset(const std::string& file_name_in) auto SoundAsset::GetAssetType() const -> AssetType { return AssetType::kSound; } auto SoundAsset::GetName() const -> std::string { - if (!file_name_full_.empty()) { - return file_name_full_; - } else { - return "invalid sound"; - } + return (!file_name_.empty()) ? file_name_ : "invalid sound"; } void SoundAsset::DoPreload() { diff --git a/src/ballistica/base/assets/texture_asset.cc b/src/ballistica/base/assets/texture_asset.cc index 3107d73e..da6eb9eb 100644 --- a/src/ballistica/base/assets/texture_asset.cc +++ b/src/ballistica/base/assets/texture_asset.cc @@ -19,6 +19,7 @@ #include "ballistica/base/graphics/texture/dds.h" #include "ballistica/base/graphics/texture/ktx.h" #include "ballistica/base/graphics/texture/pvr.h" +#include "ballistica/core/platform/core_platform.h" #include "external/qr_code_generator/QrCode.hpp" namespace ballistica::base { @@ -88,7 +89,7 @@ TextureAsset::TextureAsset(const std::string& qr_url) : is_qr_code_(true) { valid_ = true; } -TextureAsset::~TextureAsset() = default; +TextureAsset::~TextureAsset() {} auto TextureAsset::GetName() const -> std::string { return (!file_name_.empty()) ? file_name_ : "invalid texture"; diff --git a/src/ballistica/base/assets/texture_asset.h b/src/ballistica/base/assets/texture_asset.h index b12f32f2..88e90346 100644 --- a/src/ballistica/base/assets/texture_asset.h +++ b/src/ballistica/base/assets/texture_asset.h @@ -15,6 +15,7 @@ class TextureAsset : public Asset { public: TextureAsset(); ~TextureAsset() override; + // Pass a newly allocated TextPacker pointer here; TextureData takes ownership // and handles cleaning it up. explicit TextureAsset(TextPacker* packer); diff --git a/src/ballistica/base/audio/audio.cc b/src/ballistica/base/audio/audio.cc index 6744aeea..7c7e5716 100644 --- a/src/ballistica/base/audio/audio.cc +++ b/src/ballistica/base/audio/audio.cc @@ -8,6 +8,7 @@ #include "ballistica/base/audio/audio_source.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/support/app_config.h" +#include "ballistica/core/platform/core_platform.h" // IWYU pragma: keep. #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { diff --git a/src/ballistica/base/audio/audio_server.cc b/src/ballistica/base/audio/audio_server.cc index 39e7f443..a71b84e1 100644 --- a/src/ballistica/base/audio/audio_server.cc +++ b/src/ballistica/base/audio/audio_server.cc @@ -27,6 +27,7 @@ #include "ballistica/base/audio/ogg_stream.h" #include "ballistica/base/logic/logic.h" #include "ballistica/core/core.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/math/vector3f.h" diff --git a/src/ballistica/base/audio/audio_source.cc b/src/ballistica/base/audio/audio_source.cc index 91894241..fa420c86 100644 --- a/src/ballistica/base/audio/audio_source.cc +++ b/src/ballistica/base/audio/audio_source.cc @@ -6,6 +6,7 @@ #include "ballistica/base/audio/audio.h" #include "ballistica/base/audio/audio_server.h" #include "ballistica/core/core.h" +#include "ballistica/core/platform/core_platform.h" // IWYU pragma: keep. #include "ballistica/shared/math/vector3f.h" namespace ballistica::base { diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index cb7983be..13106b94 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -31,6 +31,7 @@ #include "ballistica/base/support/plus_soft.h" #include "ballistica/base/support/stdio_console.h" #include "ballistica/base/ui/ui_delegate.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/foundation/logging.h" #include "ballistica/shared/generic/utils.h" diff --git a/src/ballistica/base/dynamics/bg/bg_dynamics.cc b/src/ballistica/base/dynamics/bg/bg_dynamics.cc index 98449d53..0c9d3a0a 100644 --- a/src/ballistica/base/dynamics/bg/bg_dynamics.cc +++ b/src/ballistica/base/dynamics/bg/bg_dynamics.cc @@ -18,6 +18,7 @@ #include "ballistica/base/graphics/mesh/mesh_indexed_simple_full.h" #include "ballistica/base/graphics/mesh/mesh_indexed_smoke_full.h" #include "ballistica/base/graphics/mesh/sprite_mesh.h" +#include "ballistica/core/platform/core_platform.h" // IWYU pragma: keep. #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { diff --git a/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc b/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc index ace3ab35..da56a67f 100644 --- a/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc +++ b/src/ballistica/base/dynamics/bg/bg_dynamics_server.cc @@ -16,6 +16,7 @@ #include "ballistica/base/dynamics/collision_cache.h" #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/logic/logic.h" +#include "ballistica/core/platform/core_platform.h" // IWYU pragma: keep. #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/generic/utils.h" diff --git a/src/ballistica/base/graphics/graphics_server.cc b/src/ballistica/base/graphics/graphics_server.cc index ce203e4a..493467ac 100644 --- a/src/ballistica/base/graphics/graphics_server.cc +++ b/src/ballistica/base/graphics/graphics_server.cc @@ -10,6 +10,7 @@ #include "ballistica/base/graphics/graphics.h" #include "ballistica/base/graphics/renderer/renderer.h" #include "ballistica/base/logic/logic.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { diff --git a/src/ballistica/base/input/input.cc b/src/ballistica/base/input/input.cc index 3dfe6a38..e3bd3210 100644 --- a/src/ballistica/base/input/input.cc +++ b/src/ballistica/base/input/input.cc @@ -18,6 +18,7 @@ #include "ballistica/base/python/base_python.h" #include "ballistica/base/ui/dev_console.h" #include "ballistica/base/ui/ui.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/generic/utils.h" diff --git a/src/ballistica/base/logic/logic.cc b/src/ballistica/base/logic/logic.cc index 8ace5db1..3214bd0d 100644 --- a/src/ballistica/base/logic/logic.cc +++ b/src/ballistica/base/logic/logic.cc @@ -21,6 +21,7 @@ #include "ballistica/base/support/stdio_console.h" #include "ballistica/base/ui/dev_console.h" #include "ballistica/base/ui/ui.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" namespace ballistica::base { diff --git a/src/ballistica/base/python/methods/python_methods_base_1.cc b/src/ballistica/base/python/methods/python_methods_base_1.cc index ea3e8648..71e5c0eb 100644 --- a/src/ballistica/base/python/methods/python_methods_base_1.cc +++ b/src/ballistica/base/python/methods/python_methods_base_1.cc @@ -16,6 +16,7 @@ #include "ballistica/base/python/support/python_context_call_runnable.h" #include "ballistica/base/ui/dev_console.h" #include "ballistica/base/ui/ui.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/foundation/logging.h" #include "ballistica/shared/python/python.h" diff --git a/src/ballistica/base/python/methods/python_methods_base_3.cc b/src/ballistica/base/python/methods/python_methods_base_3.cc index c51bd301..c9d05921 100644 --- a/src/ballistica/base/python/methods/python_methods_base_3.cc +++ b/src/ballistica/base/python/methods/python_methods_base_3.cc @@ -18,8 +18,9 @@ #include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/dev_console.h" #include "ballistica/base/ui/ui.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/macros.h" -#include "ballistica/shared/generic/native_stack_trace.h" +#include "ballistica/shared/generic/native_stack_trace.h" // IWYU pragma: keep. #include "ballistica/shared/generic/utils.h" namespace ballistica::base { diff --git a/src/ballistica/base/ui/dev_console.cc b/src/ballistica/base/ui/dev_console.cc index 03fbe5e6..504de0d3 100644 --- a/src/ballistica/base/ui/dev_console.cc +++ b/src/ballistica/base/ui/dev_console.cc @@ -372,9 +372,9 @@ class DevConsole::Button_ : public DevConsole::Widget_ { break; case DevButtonStyle_::kWhiteBright: fgcolor = - pressed ? Vector3f{1.0f, 1.0f, 1.0f} : Vector3f{0.0f, 0.0f, 0.0f}; + pressed ? Vector3f{0.0f, 0.0f, 0.0f} : Vector3f{0.0f, 0.0f, 0.0f}; bgcolor = - pressed ? Vector3f{0.4f, 0.4f, 0.4f} : Vector3f{0.8, 0.7f, 0.8f}; + pressed ? Vector3f{1.0f, 1.0f, 1.0f} : Vector3f{0.9, 0.85f, 0.95f}; break; case DevButtonStyle_::kBlack: fgcolor = diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index bc6ea468..f2ccf18e 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -15,6 +15,7 @@ #include "ballistica/base/support/app_config.h" #include "ballistica/base/ui/dev_console.h" #include "ballistica/base/ui/ui_delegate.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/event_loop.h" #include "ballistica/shared/foundation/macros.h" #include "ballistica/shared/generic/utils.h" diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index c6a4872e..bccae5c1 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -15,6 +15,7 @@ #include "ballistica/base/networking/networking.h" #include "ballistica/base/support/app_config.h" #include "ballistica/base/support/plus_soft.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/scene_v1/connection/connection_set.h" #include "ballistica/scene_v1/connection/connection_to_client.h" #include "ballistica/scene_v1/connection/connection_to_host.h" diff --git a/src/ballistica/core/support/core_config.cc b/src/ballistica/core/support/core_config.cc index 10c8376c..258377da 100644 --- a/src/ballistica/core/support/core_config.cc +++ b/src/ballistica/core/support/core_config.cc @@ -82,11 +82,6 @@ void CoreConfig::ApplyEnvVars() { // controlling log-levels via env-vars we should come up with a unified // system for that. - // if (auto* envval = getenv("BA_LIFECYCLE_LOG")) { - // if (!strcmp(envval, "1")) { - // lifecycle_log = true; - // } - // } if (auto* envval = getenv("BA_DEBUGGER_ATTACHED")) { if (!strcmp(envval, "1")) { debugger_attached = true; diff --git a/src/ballistica/scene_v1/assets/scene_mesh.cc b/src/ballistica/scene_v1/assets/scene_mesh.cc index 5db1a85a..2a30cde0 100644 --- a/src/ballistica/scene_v1/assets/scene_mesh.cc +++ b/src/ballistica/scene_v1/assets/scene_mesh.cc @@ -4,6 +4,7 @@ #include +#include "ballistica/base/assets/assets.h" #include "ballistica/scene_v1/python/class/python_class_scene_mesh.h" #include "ballistica/scene_v1/support/scene.h" #include "ballistica/scene_v1/support/session_stream.h" diff --git a/src/ballistica/scene_v1/assets/scene_mesh.h b/src/ballistica/scene_v1/assets/scene_mesh.h index adf384e7..1cc8d9f0 100644 --- a/src/ballistica/scene_v1/assets/scene_mesh.h +++ b/src/ballistica/scene_v1/assets/scene_mesh.h @@ -4,14 +4,9 @@ #define BALLISTICA_SCENE_V1_ASSETS_SCENE_MESH_H_ #include -#include -#include "ballistica/base/assets/asset.h" -#include "ballistica/base/assets/assets.h" #include "ballistica/base/assets/mesh_asset.h" -#include "ballistica/base/assets/mesh_asset_renderer_data.h" #include "ballistica/scene_v1/assets/scene_asset.h" -#include "ballistica/shared/ballistica.h" #include "ballistica/shared/foundation/object.h" namespace ballistica::scene_v1 { diff --git a/src/ballistica/scene_v1/node/image_node.cc b/src/ballistica/scene_v1/node/image_node.cc index 9ea8a0d9..b64a53de 100644 --- a/src/ballistica/scene_v1/node/image_node.cc +++ b/src/ballistica/scene_v1/node/image_node.cc @@ -5,6 +5,7 @@ #include #include +#include "ballistica/base/assets/assets.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/core/core.h" #include "ballistica/scene_v1/node/node_attribute.h" diff --git a/src/ballistica/scene_v1/support/host_session.cc b/src/ballistica/scene_v1/support/host_session.cc index 4f13403e..6bed358a 100644 --- a/src/ballistica/scene_v1/support/host_session.cc +++ b/src/ballistica/scene_v1/support/host_session.cc @@ -12,6 +12,7 @@ #include "ballistica/base/python/base_python.h" #include "ballistica/base/python/support/python_context_call.h" #include "ballistica/classic/support/classic_app_mode.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/scene_v1/assets/scene_data_asset.h" #include "ballistica/scene_v1/assets/scene_mesh.h" #include "ballistica/scene_v1/assets/scene_sound.h" diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 7283ba07..500aca73 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 22076; +const int kEngineBuildNumber = 22077; const char* kEngineVersion = "1.7.37"; const int kEngineApiVersion = 9; diff --git a/src/ballistica/shared/foundation/object.cc b/src/ballistica/shared/foundation/object.cc index e032335d..03dee019 100644 --- a/src/ballistica/shared/foundation/object.cc +++ b/src/ballistica/shared/foundation/object.cc @@ -85,6 +85,14 @@ Object::~Object() { } } +void Object::ObjectPostInit() { +#if BA_DEBUG_BUILD + // Flag this here in the top level post-init so we can ensure that classes + // are properly calling parent class post-inits. + object_is_post_inited_ = true; +#endif +} + auto Object::GetObjectTypeName() const -> std::string { // Default implementation just returns type name. if (g_core) { diff --git a/src/ballistica/shared/foundation/object.h b/src/ballistica/shared/foundation/object.h index 04418b35..5a4aef46 100644 --- a/src/ballistica/shared/foundation/object.h +++ b/src/ballistica/shared/foundation/object.h @@ -50,6 +50,12 @@ class Object { #endif + /// Called on newly constructed objects by the various New() methods. This + /// allows classes to run code after their full class heirarchy has been + /// constructed, meaning things like virtual functions will work as + /// expected. + virtual void ObjectPostInit(); + /// Called by the default ObjectThreadCheck() to determine ownership for /// an Object. By default, an object is owned by a specific thread, /// defaulting to the logic thread. @@ -567,6 +573,7 @@ class Object { template [[nodiscard]] static auto New(ARGS&&... args) -> Object::Ref { auto* ptr = new TALLOC(std::forward(args)...); + #if BA_DEBUG_BUILD /// Objects assume they are statically allocated by default; it's up /// to us to tell them when they're not. @@ -579,7 +586,16 @@ class Object { + ptr->GetObjectDescription()); } ptr->object_is_ref_counted_ = true; + assert(!ptr->object_is_post_inited_); #endif + + ptr->ObjectPostInit(); + +#if BA_DEBUG_BUILD + // Make sure top level post-init was called. + assert(ptr->object_is_post_inited_); +#endif + return Object::Ref(ptr); } @@ -595,6 +611,7 @@ class Object { template [[nodiscard]] static auto NewDeferred(ARGS&&... args) -> T* { T* ptr = new T(std::forward(args)...); + #if BA_DEBUG_BUILD /// Objects assume they are statically allocated by default; it's up /// to us to tell them when they're not. @@ -608,7 +625,16 @@ class Object { + ptr->GetObjectDescription()); } ptr->object_is_pending_deferred_ = true; + assert(!ptr->object_is_post_inited_); #endif + + ptr->ObjectPostInit(); + +#if BA_DEBUG_BUILD + // Make sure top level post-init was called. + assert(ptr->object_is_post_inited_); +#endif + return ptr; } @@ -636,6 +662,7 @@ class Object { "deferred: " + ptr->GetObjectDescription()); } + assert(ptr->object_is_post_inited_); ptr->object_is_pending_deferred_ = false; ptr->object_is_ref_counted_ = true; #endif @@ -645,17 +672,28 @@ class Object { /// Allocate an Object with no ref-counting; for use when an object /// will be manually managed/deleted. + /// /// In debug builds, these objects will complain if attempts are made to /// create strong references to them. template [[nodiscard]] static auto NewUnmanaged(ARGS&&... args) -> T* { T* ptr = new T(std::forward(args)...); + #if BA_DEBUG_BUILD /// Objects assume they are statically allocated by default; it's up /// to us to tell them when they're not. ptr->object_is_static_allocated_ = false; ptr->object_is_unmanaged_ = true; + assert(!ptr->object_is_post_inited_); #endif + + ptr->ObjectPostInit(); + +#if BA_DEBUG_BUILD + // Make sure top level post-init was called. + assert(ptr->object_is_post_inited_); +#endif + return ptr; } @@ -675,6 +713,7 @@ class Object { bool object_is_static_allocated_{true}; bool object_has_been_strong_reffed_{}; bool object_is_ref_counted_{}; + bool object_is_post_inited_{}; bool object_is_pending_deferred_{}; bool object_is_unmanaged_{}; bool object_is_dead_{}; diff --git a/src/ballistica/ui_v1/widget/check_box_widget.cc b/src/ballistica/ui_v1/widget/check_box_widget.cc index b1613414..8c1df280 100644 --- a/src/ballistica/ui_v1/widget/check_box_widget.cc +++ b/src/ballistica/ui_v1/widget/check_box_widget.cc @@ -11,6 +11,7 @@ #include "ballistica/base/graphics/component/empty_component.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/python/support/python_context_call.h" +#include "ballistica/core/platform/core_platform.h" namespace ballistica::ui_v1 { diff --git a/src/ballistica/ui_v1/widget/h_scroll_widget.cc b/src/ballistica/ui_v1/widget/h_scroll_widget.cc index 42f07ca2..ff754f5c 100644 --- a/src/ballistica/ui_v1/widget/h_scroll_widget.cc +++ b/src/ballistica/ui_v1/widget/h_scroll_widget.cc @@ -8,6 +8,7 @@ #include "ballistica/base/graphics/component/empty_component.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/support/app_timer.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/foundation/inline.h" namespace ballistica::ui_v1 { diff --git a/src/ballistica/ui_v1/widget/scroll_widget.cc b/src/ballistica/ui_v1/widget/scroll_widget.cc index 3703c901..24cb910b 100644 --- a/src/ballistica/ui_v1/widget/scroll_widget.cc +++ b/src/ballistica/ui_v1/widget/scroll_widget.cc @@ -8,6 +8,7 @@ #include "ballistica/base/graphics/component/empty_component.h" #include "ballistica/base/graphics/component/simple_component.h" #include "ballistica/base/support/app_timer.h" +#include "ballistica/core/platform/core_platform.h" namespace ballistica::ui_v1 { diff --git a/src/ballistica/ui_v1/widget/text_widget.cc b/src/ballistica/ui_v1/widget/text_widget.cc index 3658c088..543fa255 100644 --- a/src/ballistica/ui_v1/widget/text_widget.cc +++ b/src/ballistica/ui_v1/widget/text_widget.cc @@ -21,6 +21,7 @@ #include "ballistica/base/platform/base_platform.h" #include "ballistica/base/python/base_python.h" #include "ballistica/base/python/support/python_context_call.h" +#include "ballistica/core/platform/core_platform.h" #include "ballistica/shared/generic/utils.h" #include "ballistica/shared/python/python.h" #include "ballistica/ui_v1/python/ui_v1_python.h" diff --git a/tools/bacommon/servermanager.py b/tools/bacommon/servermanager.py index 31f235f9..20b9f4e6 100644 --- a/tools/bacommon/servermanager.py +++ b/tools/bacommon/servermanager.py @@ -186,6 +186,11 @@ class ServerConfig: # involving leaving and rejoining or switching teams rapidly. player_rejoin_cooldown: float = 10.0 + # Log levels for particular loggers, overriding the engine's + # defaults. Valid values are NOTSET, DEBUG, INFO, WARNING, ERROR, or + # CRITICAL. + log_levels: dict[str, str] | None = None + # NOTE: as much as possible, communication from the server-manager to # the child-process should go through these and not ad-hoc Python string diff --git a/tools/batools/build.py b/tools/batools/build.py index ae67af27..7fa8128e 100644 --- a/tools/batools/build.py +++ b/tools/batools/build.py @@ -461,8 +461,8 @@ def _get_server_config_template_toml(projroot: str) -> str: cfg = ServerConfig() - # Override some defaults with values we want to display commented - # out instead. + # Override some defaults with dummy values we want to display + # commented out instead. cfg.playlist_code = 12345 cfg.stats_url = 'https://mystatssite.com/showstats?player=${ACCOUNT}' cfg.clean_exit_minutes = 60 @@ -476,6 +476,7 @@ def _get_server_config_template_toml(projroot: str) -> str: cfg.team_colors = ((0.1, 0.25, 1.0), (1.0, 0.25, 0.2)) cfg.public_ipv4_address = '123.123.123.123' cfg.public_ipv6_address = '123A::A123:23A1:A312:12A3:A213:2A13' + cfg.log_levels = {'ba.lifecycle': 'DEBUG', 'ba.assets': 'DEBUG'} lines_in = _get_server_config_raw_contents(projroot).splitlines()