mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-03 22:14:45 +08:00
cpp layer logging cleanup
This commit is contained in:
parent
9c54a3a8b1
commit
6980164220
90
.efrocachemap
generated
90
.efrocachemap
generated
@ -4096,56 +4096,56 @@
|
|||||||
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
||||||
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
||||||
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
||||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "a598766836cd0ea28a1943b5dfa2cf48",
|
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "059baedbe0b66d30d0aa6689da4d63f3",
|
||||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "2c7d6f8355451598be474d7ea7461ac4",
|
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "3ed7b000a1ab91e479752a3888c83667",
|
||||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "f738c276faf69ac6b23b46a0e00e66cc",
|
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "36c737e7702d8c06bc4fd2cfb07da351",
|
||||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "4f917646e3626fd49943b2f681e8bc27",
|
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "6f487cdb9ba97fab91f04146afafe7dd",
|
||||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "2d044a28fd391fcf6e2c807c0fe51cbf",
|
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "2c65291868c5d663aed8e091b3918560",
|
||||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "6974a7ba1384719ff3f34c5eacc6a2a4",
|
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "907e310432844bc1a81e16cf2520e9b3",
|
||||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "382cf2436d7c488a6a20758e3d3c1f2b",
|
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "057e48bb93965e035ce5a41f86efef46",
|
||||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "ee990132a12cca7877c341399b7b8deb",
|
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "3a0831e5e874d7dae4698c726c522a27",
|
||||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "27a952ea3647eca2b7ef0395409aa676",
|
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "5510a4efe5876817d7378f4c7c7eeb34",
|
||||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "c181d7b07f9120502b3a88c949e99e3c",
|
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "40535aed4289ab6c6cb2b1fb2756c510",
|
||||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "6530013d13781cb7f29a107df54f362c",
|
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "762777a4a85b1306fb7cc66de9fe930f",
|
||||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "c18fec69637b72f98a617cb22f0f0df7",
|
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "4559fca91a2e663714f65c88960a8550",
|
||||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "04b70eb5f8f6bb0e07a4f3025903bda6",
|
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "d9b8e42c9a51b803d7fd8d79b0c1089a",
|
||||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "ad9ef6d83fa478ee9d1a40f61ca38730",
|
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "2bbda26d94f3c42eb50ae38f36736c41",
|
||||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "f43917836334f3bc0277cbff0503878c",
|
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "28501bcf6678e9828b7c93d7124cb895",
|
||||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "0dcf8315c0b8cc2da817e80d0577197b",
|
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "6f333b02870caea43e8b47b751e31c41",
|
||||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "3812999bfbc14ec860e49317c69aeb64",
|
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "8df10a5d0119225f0ed1168380df70db",
|
||||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "59da09b01e23f080569ee0e59483479c",
|
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "354f163cc24b1196fcf43c2949c7cabe",
|
||||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "e0992d0954ba8d3a74d332f535676cde",
|
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "064aa919dda3f74787751c4c82133bd8",
|
||||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "aa5256e587f4b93bc1ef988308a84113",
|
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "36eeeac892119b8080c99e8cc97ed825",
|
||||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "51e81607756f0dca35b4aad4a183e82f",
|
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "8390ede3c9748e859f23db258289abf5",
|
||||||
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "1e18027d82990576b97b02dc4bb0fb01",
|
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "8361f4adc958e914301959ca55680fd5",
|
||||||
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "51e81607756f0dca35b4aad4a183e82f",
|
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "8390ede3c9748e859f23db258289abf5",
|
||||||
"build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "1e18027d82990576b97b02dc4bb0fb01",
|
"build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "8361f4adc958e914301959ca55680fd5",
|
||||||
"build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "b791b77e04bd1459487ced079b8875d8",
|
"build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "5149cfef7284e1ba8ca9ec9cae4070a5",
|
||||||
"build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "8863c430ff6c2a11670c655ba35ccfc4",
|
"build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "4f5a0efc253ad90fb543214449b853f8",
|
||||||
"build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "b791b77e04bd1459487ced079b8875d8",
|
"build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "5149cfef7284e1ba8ca9ec9cae4070a5",
|
||||||
"build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "8863c430ff6c2a11670c655ba35ccfc4",
|
"build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "4f5a0efc253ad90fb543214449b853f8",
|
||||||
"build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "8e6da834224087d2b773ddc8890c768e",
|
"build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "6f0409237172a162c07e3c413d2969ab",
|
||||||
"build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "a6f99bc0b4a5bcfdbe56941845622777",
|
"build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "d11a17346662df85b844afa7bc1afb56",
|
||||||
"build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "8e6da834224087d2b773ddc8890c768e",
|
"build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "6f0409237172a162c07e3c413d2969ab",
|
||||||
"build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "a6f99bc0b4a5bcfdbe56941845622777",
|
"build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "d11a17346662df85b844afa7bc1afb56",
|
||||||
"build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "a79716311cc136c207d979ad2a6b6e98",
|
"build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "2a0eb5631a45c5724713e5e6cdc2b06e",
|
||||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "e602fad2ea96f7d026f3f8c20773e931",
|
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "af3468e5de5a0c2cb4e431239a5c0f2d",
|
||||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "bc134f0972102db689dffd422ac97621",
|
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "2405fb09f9d1f85f23f6ea3734913aa3",
|
||||||
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "e602fad2ea96f7d026f3f8c20773e931",
|
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "af3468e5de5a0c2cb4e431239a5c0f2d",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "de9a96c4f76bb7c44329b95d8666a87d",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "000e8ab249264b6757fe9a5d80ac2954",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "7f746ad4356d533c12838b7ac9305ba1",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "9c37a69f926d48fc442e4fce842db161",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "33893747ea446f83a87f144ee8965799",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "e135d9e45e063a6eae61b8d8e621452e",
|
||||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "e4d6245e0f25579ddc99c7aba78141d5",
|
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "edae00044408aeb1e2c8bf8df14dbbec",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "a686e191d9d3a7d36a62f101a823b08c",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "78b57913e94e8106c443b15b14264c43",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "048e8dd6a7f783479ebb3ad3bfa92c65",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "1d1dc16cc03ba9ed0330cf3e2d069b94",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "a8fcea1b40352e73fc3b7ad87820c06b",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "25aaf8090719e05b7a76a0c9cd10f6d1",
|
||||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "264f656b3cc167f4bfe797f4a579b0f5",
|
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "e3593efe1a6c48977d70bc51f72e419e",
|
||||||
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
||||||
"src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad",
|
"src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad",
|
||||||
"src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d",
|
"src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d",
|
||||||
"src/ballistica/base/mgen/pyembed/binding_base_app.inc": "f0f9dc33ecd4ef7a384f131d62c96c97",
|
"src/ballistica/base/mgen/pyembed/binding_base_app.inc": "f0f9dc33ecd4ef7a384f131d62c96c97",
|
||||||
"src/ballistica/classic/mgen/pyembed/binding_classic.inc": "3ceb412513963f0818ab39c58bf292e3",
|
"src/ballistica/classic/mgen/pyembed/binding_classic.inc": "3ceb412513963f0818ab39c58bf292e3",
|
||||||
"src/ballistica/core/mgen/pyembed/binding_core.inc": "3afbd58f56fd04bdd6fc2aa7ae166275",
|
"src/ballistica/core/mgen/pyembed/binding_core.inc": "02bf828e423d0fced4d87aa74f25cbdc",
|
||||||
"src/ballistica/core/mgen/pyembed/env.inc": "f015d726b44d2922112fc14d9f146d8b",
|
"src/ballistica/core/mgen/pyembed/env.inc": "f015d726b44d2922112fc14d9f146d8b",
|
||||||
"src/ballistica/core/mgen/python_modules_monolithic.h": "fb967ed1c7db0c77d8deb4f00a7103c5",
|
"src/ballistica/core/mgen/python_modules_monolithic.h": "fb967ed1c7db0c77d8deb4f00a7103c5",
|
||||||
"src/ballistica/scene_v1/mgen/pyembed/binding_scene_v1.inc": "c25b263f2a31fb5ebe057db07d144879",
|
"src/ballistica/scene_v1/mgen/pyembed/binding_scene_v1.inc": "c25b263f2a31fb5ebe057db07d144879",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
### 1.7.37 (build 22052, api 9, 2024-10-21)
|
### 1.7.37 (build 22057, api 9, 2024-10-22)
|
||||||
- Bumping api version to 9. As you'll see below, there's some UI changes that
|
- 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
|
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.
|
touch UI stuff at all you can simply bump your api version and call it a day.
|
||||||
|
|||||||
@ -53,7 +53,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
# Build number and version of the ballistica binary we expect to be
|
# Build number and version of the ballistica binary we expect to be
|
||||||
# using.
|
# using.
|
||||||
TARGET_BALLISTICA_BUILD = 22052
|
TARGET_BALLISTICA_BUILD = 22057
|
||||||
TARGET_BALLISTICA_VERSION = '1.7.37'
|
TARGET_BALLISTICA_VERSION = '1.7.37'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -61,9 +61,9 @@ void AppAdapterSDL::OnMainThreadStartApp() {
|
|||||||
uint32_t sdl_flags{SDL_INIT_VIDEO | SDL_INIT_JOYSTICK};
|
uint32_t sdl_flags{SDL_INIT_VIDEO | SDL_INIT_JOYSTICK};
|
||||||
|
|
||||||
if (strict_graphics_context_) {
|
if (strict_graphics_context_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kWarning,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kWarning,
|
||||||
"AppAdapterSDL strict_graphics_context_ is enabled."
|
"AppAdapterSDL strict_graphics_context_ is enabled."
|
||||||
" Remember to turn this off.");
|
" Remember to turn this off.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// We may or may not want xinput on windows.
|
// We may or may not want xinput on windows.
|
||||||
@ -309,8 +309,8 @@ void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) {
|
|||||||
const microsecs_t min_sleep{2000};
|
const microsecs_t min_sleep{2000};
|
||||||
if (now + min_sleep >= target_time) {
|
if (now + min_sleep >= target_time) {
|
||||||
if (debug_log_sdl_frame_timing_) {
|
if (debug_log_sdl_frame_timing_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kDebug,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kDebug,
|
||||||
"no sleep."); // 'till brooklyn!
|
"no sleep."); // 'till brooklyn!
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (debug_log_sdl_frame_timing_) {
|
if (debug_log_sdl_frame_timing_) {
|
||||||
@ -318,7 +318,7 @@ void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) {
|
|||||||
snprintf(buf, sizeof(buf), "render %.1f sleep %.1f",
|
snprintf(buf, sizeof(buf), "render %.1f sleep %.1f",
|
||||||
(now - cycle_start_time) / 1000.0f,
|
(now - cycle_start_time) / 1000.0f,
|
||||||
(target_time - now) / 1000.0f);
|
(target_time - now) / 1000.0f);
|
||||||
Log(LogName::kBaNetworking, LogLevel::kDebug, buf);
|
g_core->Log(LogName::kBaNetworking, LogLevel::kDebug, buf);
|
||||||
}
|
}
|
||||||
g_core->platform->SleepMicrosecs(target_time - now);
|
g_core->platform->SleepMicrosecs(target_time - now);
|
||||||
}
|
}
|
||||||
@ -376,9 +376,9 @@ void AppAdapterSDL::HandleSDLEvent_(const SDL_Event& event) {
|
|||||||
g_base->input->PushJoystickEvent(event, js);
|
g_base->input->PushJoystickEvent(event, js);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Unable to get SDL Joystick for event type "
|
"Unable to get SDL Joystick for event type "
|
||||||
+ std::to_string(event.type));
|
+ std::to_string(event.type));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -565,10 +565,10 @@ void AppAdapterSDL::OnSDLJoystickAdded_(int device_index) {
|
|||||||
try {
|
try {
|
||||||
j = Object::NewDeferred<JoystickInput>(device_index);
|
j = Object::NewDeferred<JoystickInput>(device_index);
|
||||||
} catch (const std::exception& exc) {
|
} catch (const std::exception& exc) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
std::string("Error creating JoystickInput for SDL device-index "
|
std::string("Error creating JoystickInput for SDL device-index "
|
||||||
+ std::to_string(device_index) + ": ")
|
+ std::to_string(device_index) + ": ")
|
||||||
+ exc.what());
|
+ exc.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(j != nullptr);
|
assert(j != nullptr);
|
||||||
@ -604,7 +604,8 @@ void AppAdapterSDL::RemoveSDLInputDevice_(int index) {
|
|||||||
|
|
||||||
// Note: am running into this with a PS5 controller on macOS Sequoia beta.
|
// Note: am running into this with a PS5 controller on macOS Sequoia beta.
|
||||||
if (!j) {
|
if (!j) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaInput, LogLevel::kError,
|
||||||
"GetSDLJoystickInput_() returned nullptr on RemoveSDLInputDevice_();"
|
"GetSDLJoystickInput_() returned nullptr on RemoveSDLInputDevice_();"
|
||||||
" joysticks size is "
|
" joysticks size is "
|
||||||
+ std::to_string(sdl_joysticks_.size()) + "; index is "
|
+ std::to_string(sdl_joysticks_.size()) + "; index is "
|
||||||
@ -616,10 +617,10 @@ void AppAdapterSDL::RemoveSDLInputDevice_(int index) {
|
|||||||
if (static_cast_check_fit<int>(sdl_joysticks_.size()) > index) {
|
if (static_cast_check_fit<int>(sdl_joysticks_.size()) > index) {
|
||||||
sdl_joysticks_[index] = nullptr;
|
sdl_joysticks_[index] = nullptr;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Invalid index on RemoveSDLInputDevice: size is "
|
"Invalid index on RemoveSDLInputDevice: size is "
|
||||||
+ std::to_string(sdl_joysticks_.size()) + "; index is "
|
+ std::to_string(sdl_joysticks_.size()) + "; index is "
|
||||||
+ std::to_string(index) + ".");
|
+ std::to_string(index) + ".");
|
||||||
}
|
}
|
||||||
g_base->input->PushRemoveInputDeviceCall(j, true);
|
g_base->input->PushRemoveInputDeviceCall(j, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,8 +52,8 @@ void AppAdapterVR::VRPreDraw() {
|
|||||||
assert(g_base->app_adapter->InGraphicsContext());
|
assert(g_base->app_adapter->InGraphicsContext());
|
||||||
// FIXME - this is internal graphics-server details that the render-server
|
// FIXME - this is internal graphics-server details that the render-server
|
||||||
// should handle.
|
// should handle.
|
||||||
Log(LogName::kBaGraphics, LogLevel::kWarning,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kWarning,
|
||||||
"FIXME: Have GraphicsServer handle VR drawing.");
|
"FIXME: Have GraphicsServer handle VR drawing.");
|
||||||
// if (FrameDef* frame_def = g_base->graphics_server->GetRenderFrameDef()) {
|
// if (FrameDef* frame_def = g_base->graphics_server->GetRenderFrameDef()) {
|
||||||
// // Note: this could be part of PreprocessRenderFrameDef but the non-vr
|
// // Note: this could be part of PreprocessRenderFrameDef but the non-vr
|
||||||
// // path needs it to be separate since preprocess doesn't happen
|
// // path needs it to be separate since preprocess doesn't happen
|
||||||
@ -76,8 +76,8 @@ void AppAdapterVR::VRPostDraw() {
|
|||||||
g_base->graphics_server->FinishRenderFrameDef(vr_render_frame_def_);
|
g_base->graphics_server->FinishRenderFrameDef(vr_render_frame_def_);
|
||||||
vr_render_frame_def_ = nullptr;
|
vr_render_frame_def_ = nullptr;
|
||||||
}
|
}
|
||||||
Log(LogName::kBaGraphics, LogLevel::kWarning,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kWarning,
|
||||||
"WOULD RUN RENDER UPKEEP CYCLE");
|
"WOULD RUN RENDER UPKEEP CYCLE");
|
||||||
// RunRenderUpkeepCycle();
|
// RunRenderUpkeepCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -302,7 +302,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
snprintf(buffer, sizeof(buffer), " %-50s %10s %10s", "FILE",
|
snprintf(buffer, sizeof(buffer), " %-50s %10s %10s", "FILE",
|
||||||
"PRELOAD_TIME", "LOAD_TIME");
|
"PRELOAD_TIME", "LOAD_TIME");
|
||||||
s += buffer;
|
s += buffer;
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, s);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, s);
|
||||||
millisecs_t total_preload_time = 0;
|
millisecs_t total_preload_time = 0;
|
||||||
millisecs_t total_load_time = 0;
|
millisecs_t total_load_time = 0;
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
@ -315,7 +315,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
i.second->GetName().c_str(),
|
i.second->GetName().c_str(),
|
||||||
static_cast_check_fit<int>(preload_time),
|
static_cast_check_fit<int>(preload_time),
|
||||||
static_cast_check_fit<int>(load_time));
|
static_cast_check_fit<int>(load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
@ -328,7 +328,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
i.second->GetName().c_str(),
|
i.second->GetName().c_str(),
|
||||||
static_cast_check_fit<int>(preload_time),
|
static_cast_check_fit<int>(preload_time),
|
||||||
static_cast_check_fit<int>(load_time));
|
static_cast_check_fit<int>(load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
@ -341,7 +341,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
i.second->GetName().c_str(),
|
i.second->GetName().c_str(),
|
||||||
static_cast_check_fit<int>(preload_time),
|
static_cast_check_fit<int>(preload_time),
|
||||||
static_cast_check_fit<int>(load_time));
|
static_cast_check_fit<int>(load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
@ -354,7 +354,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
i.second->GetName().c_str(),
|
i.second->GetName().c_str(),
|
||||||
static_cast_check_fit<int>(preload_time),
|
static_cast_check_fit<int>(preload_time),
|
||||||
static_cast_check_fit<int>(load_time));
|
static_cast_check_fit<int>(load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
@ -367,7 +367,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
i.second->file_name_full().c_str(),
|
i.second->file_name_full().c_str(),
|
||||||
static_cast_check_fit<int>(preload_time),
|
static_cast_check_fit<int>(preload_time),
|
||||||
static_cast_check_fit<int>(load_time));
|
static_cast_check_fit<int>(load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
snprintf(buffer, sizeof(buffer),
|
snprintf(buffer, sizeof(buffer),
|
||||||
@ -375,7 +375,7 @@ void Assets::PrintLoadInfo() {
|
|||||||
"(feeding data to OpenGL, etc): %i",
|
"(feeding data to OpenGL, etc): %i",
|
||||||
static_cast<int>(total_preload_time),
|
static_cast<int>(total_preload_time),
|
||||||
static_cast<int>(total_load_time));
|
static_cast<int>(total_load_time));
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Assets::MarkAllAssetsForLoad() {
|
void Assets::MarkAllAssetsForLoad() {
|
||||||
@ -1029,35 +1029,37 @@ void Assets::Prune(int level) {
|
|||||||
if (kShowPruningInfo) {
|
if (kShowPruningInfo) {
|
||||||
assert(asset_lists_locked_);
|
assert(asset_lists_locked_);
|
||||||
if (textures_.size() != old_texture_count) {
|
if (textures_.size() != old_texture_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"Textures pruned from " + std::to_string(old_texture_count) + " to "
|
"Textures pruned from " + std::to_string(old_texture_count)
|
||||||
+ std::to_string(textures_.size()));
|
+ " to " + std::to_string(textures_.size()));
|
||||||
}
|
}
|
||||||
if (text_textures_.size() != old_text_texture_count) {
|
if (text_textures_.size() != old_text_texture_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"TextTextures pruned from " + std::to_string(old_text_texture_count)
|
"TextTextures pruned from "
|
||||||
+ " to " + std::to_string(text_textures_.size()));
|
+ std::to_string(old_text_texture_count) + " to "
|
||||||
|
+ std::to_string(text_textures_.size()));
|
||||||
}
|
}
|
||||||
if (qr_textures_.size() != old_qr_texture_count) {
|
if (qr_textures_.size() != old_qr_texture_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"QrTextures pruned from " + std::to_string(old_qr_texture_count)
|
"QrTextures pruned from "
|
||||||
+ " to " + std::to_string(qr_textures_.size()));
|
+ std::to_string(old_qr_texture_count) + " to "
|
||||||
|
+ std::to_string(qr_textures_.size()));
|
||||||
}
|
}
|
||||||
if (meshes_.size() != old_mesh_count) {
|
if (meshes_.size() != old_mesh_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"Meshes pruned from " + std::to_string(old_mesh_count) + " to "
|
"Meshes pruned from " + std::to_string(old_mesh_count)
|
||||||
+ std::to_string(meshes_.size()));
|
+ " to " + std::to_string(meshes_.size()));
|
||||||
}
|
}
|
||||||
if (collision_meshes_.size() != old_collision_mesh_count) {
|
if (collision_meshes_.size() != old_collision_mesh_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"CollisionMeshes pruned from "
|
"CollisionMeshes pruned from "
|
||||||
+ std::to_string(old_collision_mesh_count) + " to "
|
+ std::to_string(old_collision_mesh_count) + " to "
|
||||||
+ std::to_string(collision_meshes_.size()));
|
+ std::to_string(collision_meshes_.size()));
|
||||||
}
|
}
|
||||||
if (sounds_.size() != old_sound_count) {
|
if (sounds_.size() != old_sound_count) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAssets, LogLevel::kInfo,
|
||||||
"Sounds pruned from " + std::to_string(old_sound_count) + " to "
|
"Sounds pruned from " + std::to_string(old_sound_count)
|
||||||
+ std::to_string(sounds_.size()));
|
+ " to " + std::to_string(sounds_.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1164,12 +1166,12 @@ auto Assets::FindAssetFile(FileType type, const std::string& name)
|
|||||||
|
|
||||||
// We wanna fail gracefully for some types.
|
// We wanna fail gracefully for some types.
|
||||||
if (type == FileType::kSound && name != "blank") {
|
if (type == FileType::kSound && name != "blank") {
|
||||||
Log(LogName::kBaAssets, LogLevel::kError,
|
g_core->Log(LogName::kBaAssets, LogLevel::kError,
|
||||||
"Unable to load audio: '" + name + "'; trying fallback...");
|
"Unable to load audio: '" + name + "'; trying fallback...");
|
||||||
return FindAssetFile(type, "blank");
|
return FindAssetFile(type, "blank");
|
||||||
} else if (type == FileType::kTexture && name != "white") {
|
} else if (type == FileType::kTexture && name != "white") {
|
||||||
Log(LogName::kBaAssets, LogLevel::kError,
|
g_core->Log(LogName::kBaAssets, LogLevel::kError,
|
||||||
"Unable to load texture: '" + name + "'; trying fallback...");
|
"Unable to load texture: '" + name + "'; trying fallback...");
|
||||||
return FindAssetFile(type, "white");
|
return FindAssetFile(type, "white");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,8 +1230,8 @@ void Assets::AddPackage(const std::string& name, const std::string& path) {
|
|||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
if (packages_.find(name) != packages_.end()) {
|
if (packages_.find(name) != packages_.end()) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAssets, LogLevel::kWarning,
|
||||||
"adding duplicate package: '" + name + "'");
|
"adding duplicate package: '" + name + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packages_[name] = path;
|
packages_[name] = path;
|
||||||
@ -1573,9 +1575,9 @@ auto Assets::CompileResourceString(const std::string& s, const std::string& loc,
|
|||||||
|
|
||||||
cJSON* root = cJSON_Parse(s.c_str());
|
cJSON* root = cJSON_Parse(s.c_str());
|
||||||
if (root == nullptr) {
|
if (root == nullptr) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kError,
|
g_core->Log(LogName::kBaAssets, LogLevel::kError,
|
||||||
"CompileResourceString failed (loc " + loc + "); invalid json: '" + s
|
"CompileResourceString failed (loc " + loc
|
||||||
+ "'");
|
+ "); invalid json: '" + s + "'");
|
||||||
*valid = false;
|
*valid = false;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -1584,9 +1586,9 @@ auto Assets::CompileResourceString(const std::string& s, const std::string& loc,
|
|||||||
result = DoCompileResourceString(root);
|
result = DoCompileResourceString(root);
|
||||||
*valid = true;
|
*valid = true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kError,
|
g_core->Log(LogName::kBaAssets, LogLevel::kError,
|
||||||
"CompileResourceString failed (loc " + loc
|
"CompileResourceString failed (loc " + loc
|
||||||
+ "): " + std::string(e.what()) + "; str='" + s + "'");
|
+ "): " + std::string(e.what()) + "; str='" + s + "'");
|
||||||
result = "<error>";
|
result = "<error>";
|
||||||
*valid = false;
|
*valid = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,8 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) {
|
|||||||
// We only allow writing one replay at once; make sure that's actually
|
// We only allow writing one replay at once; make sure that's actually
|
||||||
// the case.
|
// the case.
|
||||||
if (writing_replay_) {
|
if (writing_replay_) {
|
||||||
Log(LogName::kBaAssets, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaAssets, LogLevel::kError,
|
||||||
"AssetsServer got BeginWriteReplayCall while already writing");
|
"AssetsServer got BeginWriteReplayCall while already writing");
|
||||||
WriteReplayMessages();
|
WriteReplayMessages();
|
||||||
if (replay_out_file_) {
|
if (replay_out_file_) {
|
||||||
@ -76,8 +77,8 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) {
|
|||||||
replay_bytes_written_ = 0;
|
replay_bytes_written_ = 0;
|
||||||
|
|
||||||
if (!replay_out_file_) {
|
if (!replay_out_file_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"unable to open output-stream file: '" + file_path + "'");
|
"unable to open output-stream file: '" + file_path + "'");
|
||||||
} else {
|
} else {
|
||||||
// Write file id and protocol-version.
|
// Write file id and protocol-version.
|
||||||
// NOTE: We always write replays in our host protocol version
|
// NOTE: We always write replays in our host protocol version
|
||||||
@ -88,9 +89,9 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) {
|
|||||||
|| (fwrite(&version, sizeof(version), 1, replay_out_file_) != 1)) {
|
|| (fwrite(&version, sizeof(version), 1, replay_out_file_) != 1)) {
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"error writing replay file header: "
|
"error writing replay file header: "
|
||||||
+ g_core->platform->GetErrnoString());
|
+ g_core->platform->GetErrnoString());
|
||||||
}
|
}
|
||||||
replay_bytes_written_ = 5;
|
replay_bytes_written_ = 5;
|
||||||
}
|
}
|
||||||
@ -110,7 +111,8 @@ void AssetsServer::PushAddMessageToReplayCall(
|
|||||||
|
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
if (!writing_replay_) {
|
if (!writing_replay_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"AssetsServer got AddMessageToReplayCall while not writing replay");
|
"AssetsServer got AddMessageToReplayCall while not writing replay");
|
||||||
replays_broken_ = true;
|
replays_broken_ = true;
|
||||||
return;
|
return;
|
||||||
@ -121,8 +123,8 @@ void AssetsServer::PushAddMessageToReplayCall(
|
|||||||
// If we've got too much data built up (lets go with 10 megs for now),
|
// If we've got too much data built up (lets go with 10 megs for now),
|
||||||
// abort.
|
// abort.
|
||||||
if (replay_message_bytes_ > 10000000) {
|
if (replay_message_bytes_ > 10000000) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"replay output buffer exceeded 10 megs; aborting replay");
|
"replay output buffer exceeded 10 megs; aborting replay");
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
replay_message_bytes_ = 0;
|
replay_message_bytes_ = 0;
|
||||||
@ -143,8 +145,8 @@ void AssetsServer::PushEndWriteReplayCall() {
|
|||||||
|
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
if (!writing_replay_) {
|
if (!writing_replay_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"_finishWritingReplay called while not writing");
|
"_finishWritingReplay called while not writing");
|
||||||
replays_broken_ = true;
|
replays_broken_ = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -181,9 +183,9 @@ void AssetsServer::WriteReplayMessages() {
|
|||||||
if (fwrite(&len8, 1, 1, replay_out_file_) != 1) {
|
if (fwrite(&len8, 1, 1, replay_out_file_) != 1) {
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"error writing replay file: "
|
"error writing replay file: "
|
||||||
+ g_core->platform->GetErrnoString());
|
+ g_core->platform->GetErrnoString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,18 +196,18 @@ void AssetsServer::WriteReplayMessages() {
|
|||||||
if (fwrite(&len16, 2, 1, replay_out_file_) != 1) {
|
if (fwrite(&len16, 2, 1, replay_out_file_) != 1) {
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"error writing replay file: "
|
"error writing replay file: "
|
||||||
+ g_core->platform->GetErrnoString());
|
+ g_core->platform->GetErrnoString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fwrite(&len32, 4, 1, replay_out_file_) != 1) {
|
if (fwrite(&len32, 4, 1, replay_out_file_) != 1) {
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"error writing replay file: "
|
"error writing replay file: "
|
||||||
+ g_core->platform->GetErrnoString());
|
+ g_core->platform->GetErrnoString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +218,8 @@ void AssetsServer::WriteReplayMessages() {
|
|||||||
if (result != 1) {
|
if (result != 1) {
|
||||||
fclose(replay_out_file_);
|
fclose(replay_out_file_);
|
||||||
replay_out_file_ = nullptr;
|
replay_out_file_ = nullptr;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaAudio, LogLevel::kError,
|
||||||
"error writing replay file: " + g_core->platform->GetErrnoString());
|
"error writing replay file: " + g_core->platform->GetErrnoString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,9 +62,9 @@ static auto LoadOgg(const char* file_name, std::vector<char>* buffer,
|
|||||||
f = g_core->platform->FOpen(file_name, "rb");
|
f = g_core->platform->FOpen(file_name, "rb");
|
||||||
if (f == nullptr) {
|
if (f == nullptr) {
|
||||||
fallback = true;
|
fallback = true;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
std::string("Can't open sound file '") + file_name
|
std::string("Can't open sound file '") + file_name
|
||||||
+ "' for reading...");
|
+ "' for reading...");
|
||||||
|
|
||||||
// Attempt a fallback standin; if that doesn't work, throw in the towel.
|
// Attempt a fallback standin; if that doesn't work, throw in the towel.
|
||||||
file_name = "data/global/audio/blank.ogg";
|
file_name = "data/global/audio/blank.ogg";
|
||||||
@ -84,8 +84,8 @@ static auto LoadOgg(const char* file_name, std::vector<char>* buffer,
|
|||||||
|
|
||||||
// Try opening the given file
|
// Try opening the given file
|
||||||
if (ov_open_callbacks(f, &ogg_file, nullptr, 0, callbacks) != 0) {
|
if (ov_open_callbacks(f, &ogg_file, nullptr, 0, callbacks) != 0) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
std::string("Error decoding sound file '") + file_name + "'");
|
std::string("Error decoding sound file '") + file_name + "'");
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
@ -208,9 +208,9 @@ static void LoadCachedOgg(const char* file_name, std::vector<char>* buffer,
|
|||||||
// with invalid formats of 0 once. Report and ignore if we see
|
// with invalid formats of 0 once. Report and ignore if we see
|
||||||
// something like that.
|
// something like that.
|
||||||
if (*format != AL_FORMAT_MONO16 && *format != AL_FORMAT_STEREO16) {
|
if (*format != AL_FORMAT_MONO16 && *format != AL_FORMAT_STEREO16) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
std::string("Ignoring invalid audio cache of ") + file_name
|
std::string("Ignoring invalid audio cache of ") + file_name
|
||||||
+ " with format " + std::to_string(*format));
|
+ " with format " + std::to_string(*format));
|
||||||
} else {
|
} else {
|
||||||
return; // SUCCESS!!!!
|
return; // SUCCESS!!!!
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,7 @@ TextureAsset::TextureAsset(const std::string& qr_url) : is_qr_code_(true) {
|
|||||||
"QR code url byte length %zu exceeds soft-limit of %zu;"
|
"QR code url byte length %zu exceeds soft-limit of %zu;"
|
||||||
" please use shorter urls. (url=%s)",
|
" please use shorter urls. (url=%s)",
|
||||||
qr_url.size(), soft_limit, qr_url.c_str());
|
qr_url.size(), soft_limit, qr_url.c_str());
|
||||||
Log(LogName::kBaAssets, LogLevel::kWarning, buffer);
|
g_core->Log(LogName::kBaAssets, LogLevel::kWarning, buffer);
|
||||||
}
|
}
|
||||||
file_name_ = qr_url;
|
file_name_ = qr_url;
|
||||||
valid_ = true;
|
valid_ = true;
|
||||||
|
|||||||
@ -18,15 +18,15 @@ namespace ballistica::base {
|
|||||||
|
|
||||||
void _check_al_error(const char* file, int line) {
|
void _check_al_error(const char* file, int line) {
|
||||||
if (g_base->audio_server->paused()) {
|
if (g_base->audio_server->paused()) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
Utils::BaseName(file) + ":" + std::to_string(line)
|
Utils::BaseName(file) + ":" + std::to_string(line)
|
||||||
+ ": Checking OpenAL error while paused.");
|
+ ": Checking OpenAL error while paused.");
|
||||||
}
|
}
|
||||||
ALenum al_err = alGetError();
|
ALenum al_err = alGetError();
|
||||||
if (al_err != AL_NO_ERROR) {
|
if (al_err != AL_NO_ERROR) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
Utils::BaseName(file) + ":" + std::to_string(line)
|
Utils::BaseName(file) + ":" + std::to_string(line)
|
||||||
+ ": OpenAL Error: " + GetALErrorString(al_err) + ";");
|
+ ": OpenAL Error: " + GetALErrorString(al_err) + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -166,21 +166,21 @@ auto Audio::SafePlaySysSound(SysSoundID sound_id) -> std::optional<uint32_t> {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!g_base->InLogicThread()) {
|
if (!g_base->InLogicThread()) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Audio::SafePlaySysSound called from non-logic thread. id="
|
"Audio::SafePlaySysSound called from non-logic thread. id="
|
||||||
+ std::to_string(static_cast<int>(sound_id)));
|
+ std::to_string(static_cast<int>(sound_id)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!g_base->assets->sys_assets_loaded()) {
|
if (!g_base->assets->sys_assets_loaded()) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Audio::SafePlaySysSound called before sys assets loaded. id="
|
"Audio::SafePlaySysSound called before sys assets loaded. id="
|
||||||
+ std::to_string(static_cast<int>(sound_id)));
|
+ std::to_string(static_cast<int>(sound_id)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!g_base->assets->IsValidSysSound(sound_id)) {
|
if (!g_base->assets->IsValidSysSound(sound_id)) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Audio::SafePlaySysSound called with invalid sound_id. id="
|
"Audio::SafePlaySysSound called with invalid sound_id. id="
|
||||||
+ std::to_string(static_cast<int>(sound_id)));
|
+ std::to_string(static_cast<int>(sound_id)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return PlaySound(g_base->assets->SysSound(sound_id));
|
return PlaySound(g_base->assets->SysSound(sound_id));
|
||||||
|
|||||||
@ -179,9 +179,9 @@ static void ALEventCallback_(ALenum eventType, ALuint object, ALuint param,
|
|||||||
[] { g_base->audio_server->OnDeviceDisconnected(); });
|
[] { g_base->audio_server->OnDeviceDisconnected(); });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Got unexpected OpenAL callback event "
|
"Got unexpected OpenAL callback event "
|
||||||
+ std::to_string(static_cast<int>(eventType)));
|
+ std::to_string(static_cast<int>(eventType)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,8 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
if (g_core->platform->GetOSVersionString().compare(0, prefix2.size(),
|
if (g_core->platform->GetOSVersionString().compare(0, prefix2.size(),
|
||||||
prefix2)
|
prefix2)
|
||||||
== 0) {
|
== 0) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaAudio, LogLevel::kInfo,
|
||||||
"Xiaomi Android 11 detected; using OpenSL instead of AAudio.");
|
"Xiaomi Android 11 detected; using OpenSL instead of AAudio.");
|
||||||
g_core->platform->SetEnv("BA_OBOE_USE_OPENSLES", "1");
|
g_core->platform->SetEnv("BA_OBOE_USE_OPENSLES", "1");
|
||||||
}
|
}
|
||||||
@ -261,8 +262,8 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
ALboolean enumeration =
|
ALboolean enumeration =
|
||||||
alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT");
|
alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT");
|
||||||
if (enumeration == AL_FALSE) {
|
if (enumeration == AL_FALSE) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"OpenAL enumeration extensions missing.");
|
"OpenAL enumeration extensions missing.");
|
||||||
} else {
|
} else {
|
||||||
const ALCchar* devices =
|
const ALCchar* devices =
|
||||||
alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
@ -300,7 +301,7 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
if (!device) {
|
if (!device) {
|
||||||
if (g_buildconfig.ostype_android()) {
|
if (g_buildconfig.ostype_android()) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -317,11 +318,11 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
|
|
||||||
// Android special case: if we fail, try again after a few seconds.
|
// Android special case: if we fail, try again after a few seconds.
|
||||||
if (!impl_->alc_context && g_buildconfig.ostype_android()) {
|
if (!impl_->alc_context && g_buildconfig.ostype_android()) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Failed creating AL context; waiting and trying again.");
|
"Failed creating AL context; waiting and trying again.");
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -336,7 +337,7 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -348,18 +349,19 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
impl_->alc_context = alcCreateContext(device, nullptr);
|
impl_->alc_context = alcCreateContext(device, nullptr);
|
||||||
if (impl_->alc_context) {
|
if (impl_->alc_context) {
|
||||||
// For now want to explicitly know if this works.
|
// For now want to explicitly know if this works.
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Backup AL context creation successful!");
|
"Backup AL context creation successful!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android special case: if we fail, try OpenSL back-end.
|
// Android special case: if we fail, try OpenSL back-end.
|
||||||
if (!impl_->alc_context && g_buildconfig.ostype_android()) {
|
if (!impl_->alc_context && g_buildconfig.ostype_android()) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaAudio, LogLevel::kError,
|
||||||
"Failed second time creating AL context; trying OpenSL backend.");
|
"Failed second time creating AL context; trying OpenSL backend.");
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -373,7 +375,7 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
alGetError(); // Clear any errors.
|
alGetError(); // Clear any errors.
|
||||||
if (!device) {
|
if (!device) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -385,8 +387,8 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
impl_->alc_context = alcCreateContext(device, nullptr);
|
impl_->alc_context = alcCreateContext(device, nullptr);
|
||||||
if (impl_->alc_context) {
|
if (impl_->alc_context) {
|
||||||
// For now want to explicitly know if this works.
|
// For now want to explicitly know if this works.
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Backup AL context creation 2 successful!");
|
"Backup AL context creation 2 successful!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +396,7 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
if (!impl_->alc_context) {
|
if (!impl_->alc_context) {
|
||||||
if (g_buildconfig.ostype_android()) {
|
if (g_buildconfig.ostype_android()) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n"
|
||||||
+ openalsoft_android_log_
|
+ openalsoft_android_log_
|
||||||
@ -463,9 +465,9 @@ void AudioServer::OnAppStartInThread_() {
|
|||||||
sound_source_refs_.push_back(s);
|
sound_source_refs_.push_back(s);
|
||||||
sources_.push_back(&(*s));
|
sources_.push_back(&(*s));
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Made " + std::to_string(i) + " sources; (wanted "
|
"Made " + std::to_string(i) + " sources; (wanted "
|
||||||
+ std::to_string(target_source_count) + ").");
|
+ std::to_string(target_source_count) + ").");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -503,23 +505,24 @@ void AudioServer::CompleteShutdown_() {
|
|||||||
#if BA_ENABLE_AUDIO
|
#if BA_ENABLE_AUDIO
|
||||||
ALCboolean check = alcMakeContextCurrent(nullptr);
|
ALCboolean check = alcMakeContextCurrent(nullptr);
|
||||||
if (!check) {
|
if (!check) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Error on alcMakeContextCurrent at shutdown.");
|
"Error on alcMakeContextCurrent at shutdown.");
|
||||||
}
|
}
|
||||||
auto* device = alcGetContextsDevice(impl_->alc_context);
|
auto* device = alcGetContextsDevice(impl_->alc_context);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Unable to get ALCdevice at shutdown.");
|
"Unable to get ALCdevice at shutdown.");
|
||||||
} else {
|
} else {
|
||||||
alcDestroyContext(impl_->alc_context);
|
alcDestroyContext(impl_->alc_context);
|
||||||
ALenum err = alcGetError(device);
|
ALenum err = alcGetError(device);
|
||||||
if (err != ALC_NO_ERROR) {
|
if (err != ALC_NO_ERROR) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning, "Error on AL shutdown.");
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
|
"Error on AL shutdown.");
|
||||||
}
|
}
|
||||||
check = alcCloseDevice(device);
|
check = alcCloseDevice(device);
|
||||||
if (!check) {
|
if (!check) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Error on alcCloseDevice at shutdown.");
|
"Error on alcCloseDevice at shutdown.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -542,8 +545,8 @@ struct AudioServer::SoundFadeNode_ {
|
|||||||
void AudioServer::SetSuspended_(bool suspend) {
|
void AudioServer::SetSuspended_(bool suspend) {
|
||||||
if (!suspended_) {
|
if (!suspended_) {
|
||||||
if (!suspend) {
|
if (!suspend) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Got audio unsuspend request when already unsuspended.");
|
"Got audio unsuspend request when already unsuspended.");
|
||||||
} else {
|
} else {
|
||||||
#if BA_OSTYPE_IOS_TVOS
|
#if BA_OSTYPE_IOS_TVOS
|
||||||
// apple recommends this during audio-interruptions..
|
// apple recommends this during audio-interruptions..
|
||||||
@ -565,16 +568,16 @@ void AudioServer::SetSuspended_(bool suspend) {
|
|||||||
+ std::to_string(g_core->GetAppTimeSeconds()));
|
+ std::to_string(g_core->GetAppTimeSeconds()));
|
||||||
alcDevicePauseSOFT(device);
|
alcDevicePauseSOFT(device);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Error in alcDevicePauseSOFT at time "
|
"Error in alcDevicePauseSOFT at time "
|
||||||
+ std::to_string(g_core->GetAppTimeSeconds())
|
+ std::to_string(g_core->GetAppTimeSeconds())
|
||||||
+ "( playing since "
|
+ "( playing since "
|
||||||
+ std::to_string(last_started_playing_time_)
|
+ std::to_string(last_started_playing_time_) + "): "
|
||||||
+ "): " + g_core->platform->DemangleCXXSymbol(typeid(e).name())
|
+ g_core->platform->DemangleCXXSymbol(typeid(e).name())
|
||||||
+ " " + e.what());
|
+ " " + e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Unknown error in alcDevicePauseSOFT");
|
"Unknown error in alcDevicePauseSOFT");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -583,8 +586,8 @@ void AudioServer::SetSuspended_(bool suspend) {
|
|||||||
} else {
|
} else {
|
||||||
// Unsuspend if requested.
|
// Unsuspend if requested.
|
||||||
if (suspend) {
|
if (suspend) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Got audio suspend request when already suspended.");
|
"Got audio suspend request when already suspended.");
|
||||||
} else {
|
} else {
|
||||||
#if BA_OSTYPE_IOS_TVOS
|
#if BA_OSTYPE_IOS_TVOS
|
||||||
// Apple recommends this during audio-interruptions.
|
// Apple recommends this during audio-interruptions.
|
||||||
@ -608,14 +611,14 @@ void AudioServer::SetSuspended_(bool suspend) {
|
|||||||
+ std::to_string(g_core->GetAppTimeSeconds()));
|
+ std::to_string(g_core->GetAppTimeSeconds()));
|
||||||
alcDeviceResumeSOFT(device);
|
alcDeviceResumeSOFT(device);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Error in alcDeviceResumeSOFT at time "
|
"Error in alcDeviceResumeSOFT at time "
|
||||||
+ std::to_string(g_core->GetAppTimeSeconds()) + ": "
|
+ std::to_string(g_core->GetAppTimeSeconds()) + ": "
|
||||||
+ g_core->platform->DemangleCXXSymbol(typeid(e).name()) + " "
|
+ g_core->platform->DemangleCXXSymbol(typeid(e).name())
|
||||||
+ e.what());
|
+ " " + e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Unknown error in alcDeviceResumeSOFT");
|
"Unknown error in alcDeviceResumeSOFT");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
last_started_playing_time_ = g_core->GetAppTimeSeconds();
|
last_started_playing_time_ = g_core->GetAppTimeSeconds();
|
||||||
@ -787,10 +790,11 @@ void AudioServer::UpdateAvailableSources_() {
|
|||||||
// that probably means somebody's grabbing a source but never
|
// that probably means somebody's grabbing a source but never
|
||||||
// resubmitting it.
|
// resubmitting it.
|
||||||
if (t - i->client_source()->last_lock_time() > 10000) {
|
if (t - i->client_source()->last_lock_time() > 10000) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Client audio source has been locked for too long; "
|
"Client audio source has been locked for too long; "
|
||||||
"probably leaked. (debug id "
|
"probably leaked. (debug id "
|
||||||
+ std::to_string(i->client_source()->lock_debug_id()) + ")");
|
+ std::to_string(i->client_source()->lock_debug_id())
|
||||||
|
+ ")");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -936,8 +940,8 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) {
|
|||||||
|
|
||||||
if (connected == 0
|
if (connected == 0
|
||||||
&& real_time_seconds - last_reset_attempt_time_ >= retry_interval) {
|
&& real_time_seconds - last_reset_attempt_time_ >= retry_interval) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kInfo,
|
g_core->Log(LogName::kBaAudio, LogLevel::kInfo,
|
||||||
"OpenAL device disconnected; resetting...");
|
"OpenAL device disconnected; resetting...");
|
||||||
if (g_buildconfig.ostype_android()) {
|
if (g_buildconfig.ostype_android()) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
openalsoft_android_log_ +=
|
openalsoft_android_log_ +=
|
||||||
@ -1006,7 +1010,7 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) {
|
|||||||
shipped_reconnect_logs_ = true;
|
shipped_reconnect_logs_ = true;
|
||||||
if (g_buildconfig.ostype_android()) {
|
if (g_buildconfig.ostype_android()) {
|
||||||
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
std::scoped_lock lock(openalsoft_android_log_mutex_);
|
||||||
Log(LogName::kBaAudio, LogLevel::kWarning,
|
g_core->Log(LogName::kBaAudio, LogLevel::kWarning,
|
||||||
"Have been disconnected for a while; dumping OpenAL log.\n"
|
"Have been disconnected for a while; dumping OpenAL log.\n"
|
||||||
"------------------------"
|
"------------------------"
|
||||||
" OPENALSOFT-RECONNECT-LOG-BEGIN ----------------------\n"
|
" OPENALSOFT-RECONNECT-LOG-BEGIN ----------------------\n"
|
||||||
@ -1164,9 +1168,9 @@ AudioServer::ThreadSource_::ThreadSource_(AudioServer* audio_server_in,
|
|||||||
ALenum err = alGetError();
|
ALenum err = alGetError();
|
||||||
valid_ = (err == AL_NO_ERROR);
|
valid_ = (err == AL_NO_ERROR);
|
||||||
if (!valid_) {
|
if (!valid_) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
std::string("AL Error ") + GetALErrorString(err)
|
std::string("AL Error ") + GetALErrorString(err)
|
||||||
+ " on source creation.");
|
+ " on source creation.");
|
||||||
} else {
|
} else {
|
||||||
// In vr mode we keep the microphone a bit closer to the camera
|
// In vr mode we keep the microphone a bit closer to the camera
|
||||||
// for realism purposes, so we need stuff louder in general.
|
// for realism purposes, so we need stuff louder in general.
|
||||||
|
|||||||
@ -42,8 +42,8 @@ void AudioSource::SetPosition(float x, float y, float z) {
|
|||||||
assert(client_queue_size_ > 0);
|
assert(client_queue_size_ > 0);
|
||||||
#if BA_DEBUG_BUILD
|
#if BA_DEBUG_BUILD
|
||||||
if (std::isnan(x) || std::isnan(y) || std::isnan(z)) {
|
if (std::isnan(x) || std::isnan(y) || std::isnan(z)) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Got nan value in AudioSource::SetPosition.");
|
"Got nan value in AudioSource::SetPosition.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
g_base->audio_server->PushSourceSetPositionCall(play_id_, Vector3f(x, y, z));
|
g_base->audio_server->PushSourceSetPositionCall(play_id_, Vector3f(x, y, z));
|
||||||
|
|||||||
@ -89,9 +89,9 @@ void AudioStreamer::Update() {
|
|||||||
// A fun anomaly in the linux version; we sometimes get more
|
// A fun anomaly in the linux version; we sometimes get more
|
||||||
// "processed" buffers than we have queued.
|
// "processed" buffers than we have queued.
|
||||||
if (queued < processed) {
|
if (queued < processed) {
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Streamer oddness: queued(" + std::to_string(queued) + "); processed("
|
"Streamer oddness: queued(" + std::to_string(queued)
|
||||||
+ std::to_string(processed) + ")");
|
+ "); processed(" + std::to_string(processed) + ")");
|
||||||
processed = queued;
|
processed = queued;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,8 +93,8 @@ void OggStream::DoStream(char* pcm, int* size, unsigned int* rate) {
|
|||||||
static bool reported_error = false;
|
static bool reported_error = false;
|
||||||
if (!reported_error) {
|
if (!reported_error) {
|
||||||
reported_error = true;
|
reported_error = true;
|
||||||
Log(LogName::kBaAudio, LogLevel::kError,
|
g_core->Log(LogName::kBaAudio, LogLevel::kError,
|
||||||
"Error streaming ogg file: '" + file_name() + "'.");
|
"Error streaming ogg file: '" + file_name() + "'.");
|
||||||
}
|
}
|
||||||
if (loops()) {
|
if (loops()) {
|
||||||
ov_pcm_seek(&ogg_file_, 0);
|
ov_pcm_seek(&ogg_file_, 0);
|
||||||
|
|||||||
@ -155,7 +155,8 @@ void BaseFeatureSet::SuccessScreenMessage() {
|
|||||||
python->objs().Get(BasePython::ObjID::kSuccessMessageCall).Call();
|
python->objs().Get(BasePython::ObjID::kSuccessMessageCall).Call();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"SuccessScreenMessage called without logic event_loop in place.");
|
"SuccessScreenMessage called without logic event_loop in place.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,8 +167,8 @@ void BaseFeatureSet::ErrorScreenMessage() {
|
|||||||
python->objs().Get(BasePython::ObjID::kErrorMessageCall).Call();
|
python->objs().Get(BasePython::ObjID::kErrorMessageCall).Call();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"ErrorScreenMessage called without logic event_loop in place.");
|
"ErrorScreenMessage called without logic event_loop in place.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +182,8 @@ auto BaseFeatureSet::GetV2AccountID() -> std::optional<std::string> {
|
|||||||
}
|
}
|
||||||
return result.ValueAsString();
|
return result.ValueAsString();
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "GetV2AccountID() py call errored.");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"GetV2AccountID() py call errored.");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,7 +255,7 @@ void BaseFeatureSet::StartApp() {
|
|||||||
char buffer[128];
|
char buffer[128];
|
||||||
snprintf(buffer, sizeof(buffer),
|
snprintf(buffer, sizeof(buffer),
|
||||||
"StartApp() took too long (%.2lf seconds).", duration);
|
"StartApp() took too long (%.2lf seconds).", duration);
|
||||||
Log(LogName::kBa, LogLevel::kWarning, buffer);
|
g_core->Log(LogName::kBa, LogLevel::kWarning, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,8 +264,8 @@ void BaseFeatureSet::SuspendApp() {
|
|||||||
assert(g_core->InMainThread());
|
assert(g_core->InMainThread());
|
||||||
|
|
||||||
if (app_suspended_) {
|
if (app_suspended_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"AppAdapter::SuspendApp() called with app already suspended.");
|
"AppAdapter::SuspendApp() called with app already suspended.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +306,8 @@ void BaseFeatureSet::SuspendApp() {
|
|||||||
// running_loop_count = loops.size();
|
// running_loop_count = loops.size();
|
||||||
if (running_loops.empty()) {
|
if (running_loops.empty()) {
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
Log(LogName::kBa, LogLevel::kDebug,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kDebug,
|
||||||
"SuspendApp() completed in "
|
"SuspendApp() completed in "
|
||||||
+ std::to_string(core::CorePlatform::GetCurrentMillisecs()
|
+ std::to_string(core::CorePlatform::GetCurrentMillisecs()
|
||||||
- start_time)
|
- start_time)
|
||||||
@ -365,7 +368,7 @@ void BaseFeatureSet::SuspendApp() {
|
|||||||
}
|
}
|
||||||
msg += ").";
|
msg += ").";
|
||||||
|
|
||||||
Log(LogName::kBa, LogLevel::kError, msg);
|
g_core->Log(LogName::kBa, LogLevel::kError, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFeatureSet::UnsuspendApp() {
|
void BaseFeatureSet::UnsuspendApp() {
|
||||||
@ -373,7 +376,8 @@ void BaseFeatureSet::UnsuspendApp() {
|
|||||||
assert(g_core->InMainThread());
|
assert(g_core->InMainThread());
|
||||||
|
|
||||||
if (!app_suspended_) {
|
if (!app_suspended_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kWarning,
|
||||||
"AppAdapter::UnsuspendApp() called with app not in suspendedstate.");
|
"AppAdapter::UnsuspendApp() called with app not in suspendedstate.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -391,11 +395,11 @@ void BaseFeatureSet::UnsuspendApp() {
|
|||||||
g_base->networking->OnAppUnsuspend();
|
g_base->networking->OnAppUnsuspend();
|
||||||
|
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
Log(LogName::kBa, LogLevel::kDebug,
|
g_core->Log(LogName::kBa, LogLevel::kDebug,
|
||||||
"UnsuspendApp() completed in "
|
"UnsuspendApp() completed in "
|
||||||
+ std::to_string(core::CorePlatform::GetCurrentMillisecs()
|
+ std::to_string(core::CorePlatform::GetCurrentMillisecs()
|
||||||
- start_time)
|
- start_time)
|
||||||
+ "ms.");
|
+ "ms.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +426,7 @@ void BaseFeatureSet::LogVersionInfo_() {
|
|||||||
snprintf(buffer, sizeof(buffer), "BallisticaKit %s build %d.",
|
snprintf(buffer, sizeof(buffer), "BallisticaKit %s build %d.",
|
||||||
kEngineVersion, kEngineBuildNumber);
|
kEngineVersion, kEngineBuildNumber);
|
||||||
}
|
}
|
||||||
Log(LogName::kBaLifecycle, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBaLifecycle, LogLevel::kInfo, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFeatureSet::set_app_mode(AppMode* mode) {
|
void BaseFeatureSet::set_app_mode(AppMode* mode) {
|
||||||
@ -431,7 +435,8 @@ void BaseFeatureSet::set_app_mode(AppMode* mode) {
|
|||||||
// Redundant sets should not happen (make an exception here for empty mode
|
// Redundant sets should not happen (make an exception here for empty mode
|
||||||
// since that's in place before any app mode is officially set).
|
// since that's in place before any app mode is officially set).
|
||||||
if (mode == app_mode_ && mode != EmptyAppMode::GetSingleton()) {
|
if (mode == app_mode_ && mode != EmptyAppMode::GetSingleton()) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kWarning,
|
||||||
"set_app_mode called with already-current app-mode; unexpected.");
|
"set_app_mode called with already-current app-mode; unexpected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,8 +564,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& {
|
|||||||
if (!have_app_instance_uuid) {
|
if (!have_app_instance_uuid) {
|
||||||
// As an emergency fallback simply use a single random number. We
|
// As an emergency fallback simply use a single random number. We
|
||||||
// should probably simply disallow this before Python is up.
|
// should probably simply disallow this before Python is up.
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"GetSessionUUID() using rand fallback.");
|
"GetSessionUUID() using rand fallback.");
|
||||||
srand(static_cast<unsigned int>(
|
srand(static_cast<unsigned int>(
|
||||||
core::CorePlatform::GetCurrentMillisecs())); // NOLINT
|
core::CorePlatform::GetCurrentMillisecs())); // NOLINT
|
||||||
app_instance_uuid =
|
app_instance_uuid =
|
||||||
@ -568,8 +573,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& {
|
|||||||
have_app_instance_uuid = true;
|
have_app_instance_uuid = true;
|
||||||
}
|
}
|
||||||
if (app_instance_uuid.size() >= 100) {
|
if (app_instance_uuid.size() >= 100) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"session id longer than it should be.");
|
"session id longer than it should be.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return app_instance_uuid;
|
return app_instance_uuid;
|
||||||
@ -962,9 +967,9 @@ void BaseFeatureSet::SetAppActive(bool active) {
|
|||||||
// Issue a gentle warning if they are feeding us the same state twice in a
|
// Issue a gentle warning if they are feeding us the same state twice in a
|
||||||
// row; might imply faulty logic on an app-adapter or whatnot.
|
// row; might imply faulty logic on an app-adapter or whatnot.
|
||||||
if (app_active_set_ && app_active_ == active) {
|
if (app_active_set_ && app_active_ == active) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"SetAppActive called with state " + std::to_string(active)
|
"SetAppActive called with state " + std::to_string(active)
|
||||||
+ " twice in a row.");
|
+ " twice in a row.");
|
||||||
}
|
}
|
||||||
app_active_set_ = true;
|
app_active_set_ = true;
|
||||||
app_active_ = active;
|
app_active_ = active;
|
||||||
|
|||||||
@ -86,8 +86,8 @@ class RendererGL::ProgramBlurGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,8 @@ class RendererGL::ProgramBlurGL : public RendererGL::ProgramGL {
|
|||||||
"(colorTex,vUV8));\n"
|
"(colorTex,vUV8));\n"
|
||||||
"}";
|
"}";
|
||||||
if (flags & SHD_DEBUG_PRINT) {
|
if (flags & SHD_DEBUG_PRINT) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@ -49,12 +49,12 @@ class RendererGL::ShaderGL : public Object {
|
|||||||
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
||||||
// Let's not crash here. We have a better chance of calling home this
|
// Let's not crash here. We have a better chance of calling home this
|
||||||
// way and theres a chance the game will still be playable.
|
// way and theres a chance the game will still be playable.
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
std::string("Compile failed for ") + GetTypeName()
|
std::string("Compile failed for ") + GetTypeName()
|
||||||
+ " shader:\n------------SOURCE BEGIN-------------\n" + src_fin
|
+ " shader:\n------------SOURCE BEGIN-------------\n"
|
||||||
+ "\n-----------SOURCE END-------------\n" + GetInfo()
|
+ src_fin + "\n-----------SOURCE END-------------\n"
|
||||||
+ "\nrenderer: " + renderer + "\nvendor: " + vendor
|
+ GetInfo() + "\nrenderer: " + renderer
|
||||||
+ "\nversion:" + version);
|
+ "\nvendor: " + vendor + "\nversion:" + version);
|
||||||
} else {
|
} else {
|
||||||
assert(compile_status == GL_TRUE);
|
assert(compile_status == GL_TRUE);
|
||||||
std::string info = GetInfo();
|
std::string info = GetInfo();
|
||||||
@ -65,12 +65,12 @@ class RendererGL::ShaderGL : public Object {
|
|||||||
const char* version = (const char*)glGetString(GL_VERSION);
|
const char* version = (const char*)glGetString(GL_VERSION);
|
||||||
const char* vendor = (const char*)glGetString(GL_VENDOR);
|
const char* vendor = (const char*)glGetString(GL_VENDOR);
|
||||||
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
std::string("WARNING: info returned for ") + GetTypeName()
|
std::string("WARNING: info returned for ") + GetTypeName()
|
||||||
+ " shader:\n------------SOURCE BEGIN-------------\n" + src_fin
|
+ " shader:\n------------SOURCE BEGIN-------------\n"
|
||||||
+ "\n-----------SOURCE END-------------\n" + info
|
+ src_fin + "\n-----------SOURCE END-------------\n"
|
||||||
+ "\nrenderer: " + renderer + "\nvendor: " + vendor
|
+ info + "\nrenderer: " + renderer
|
||||||
+ "\nversion:" + version);
|
+ "\nvendor: " + vendor + "\nversion:" + version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BA_DEBUG_CHECK_GL_ERROR;
|
BA_DEBUG_CHECK_GL_ERROR;
|
||||||
@ -166,8 +166,8 @@ class RendererGL::ProgramGL {
|
|||||||
GLint linkStatus;
|
GLint linkStatus;
|
||||||
glGetProgramiv(program_, GL_LINK_STATUS, &linkStatus);
|
glGetProgramiv(program_, GL_LINK_STATUS, &linkStatus);
|
||||||
if (linkStatus == GL_FALSE) {
|
if (linkStatus == GL_FALSE) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Link failed for program '" + name_ + "':\n" + GetInfo());
|
"Link failed for program '" + name_ + "':\n" + GetInfo());
|
||||||
} else {
|
} else {
|
||||||
assert(linkStatus == GL_TRUE);
|
assert(linkStatus == GL_TRUE);
|
||||||
|
|
||||||
@ -176,9 +176,9 @@ class RendererGL::ProgramGL {
|
|||||||
&& (strstr(info.c_str(), "error:") || strstr(info.c_str(), "warning:")
|
&& (strstr(info.c_str(), "error:") || strstr(info.c_str(), "warning:")
|
||||||
|| strstr(info.c_str(), "Error:")
|
|| strstr(info.c_str(), "Error:")
|
||||||
|| strstr(info.c_str(), "Warning:"))) {
|
|| strstr(info.c_str(), "Warning:"))) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"WARNING: program using frag shader '" + name_
|
"WARNING: program using frag shader '" + name_
|
||||||
+ "' returned info:\n" + info);
|
+ "' returned info:\n" + info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,9 +315,10 @@ class RendererGL::ProgramGL {
|
|||||||
assert(IsBound());
|
assert(IsBound());
|
||||||
int c = glGetUniformLocation(program_, tex_name);
|
int c = glGetUniformLocation(program_, tex_name);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"ShaderGL: " + name_ + ": Can't set texture unit for texture '"
|
"ShaderGL: " + name_
|
||||||
+ tex_name + "'");
|
+ ": Can't set texture unit for texture '" + tex_name
|
||||||
|
+ "'");
|
||||||
BA_DEBUG_CHECK_GL_ERROR;
|
BA_DEBUG_CHECK_GL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
glUniform1i(c, unit);
|
glUniform1i(c, unit);
|
||||||
|
|||||||
@ -235,8 +235,8 @@ class RendererGL::ProgramObjectGL : public RendererGL::ProgramGL {
|
|||||||
}
|
}
|
||||||
s += "}";
|
s += "}";
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +321,8 @@ class RendererGL::ProgramObjectGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,8 +158,8 @@ class RendererGL::ProgramPostProcessGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,8 @@ class RendererGL::ProgramPostProcessGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,8 +54,8 @@ class RendererGL::ProgramShieldGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,8 @@ class RendererGL::ProgramShieldGL : public RendererGL::ProgramGL {
|
|||||||
//" " BA_GLSL_FRAGCOLOR " = vec4(vec3(depth),1);\n"
|
//" " BA_GLSL_FRAGCOLOR " = vec4(vec3(depth),1);\n"
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,7 +234,7 @@ class RendererGL::ProgramSimpleGL : public RendererGL::ProgramGL {
|
|||||||
"}";
|
"}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT) {
|
if (flags & SHD_DEBUG_PRINT) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ class RendererGL::ProgramSimpleGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT) {
|
if (flags & SHD_DEBUG_PRINT) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -114,8 +114,8 @@ class RendererGL::ProgramSmokeGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,8 @@ class RendererGL::ProgramSmokeGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT)
|
if (flags & SHD_DEBUG_PRINT)
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,8 +122,8 @@ class RendererGL::ProgramSpriteGL : public RendererGL::ProgramGL {
|
|||||||
s += "}";
|
s += "}";
|
||||||
|
|
||||||
if (flags & SHD_DEBUG_PRINT) {
|
if (flags & SHD_DEBUG_PRINT) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,8 @@ class RendererGL::ProgramSpriteGL : public RendererGL::ProgramGL {
|
|||||||
}
|
}
|
||||||
s += "}";
|
s += "}";
|
||||||
if (flags & SHD_DEBUG_PRINT) {
|
if (flags & SHD_DEBUG_PRINT) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@ -90,7 +90,8 @@ void RendererGL::CheckGLError(const char* file, int line) {
|
|||||||
BA_PRECONDITION_FATAL(vendor);
|
BA_PRECONDITION_FATAL(vendor);
|
||||||
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
||||||
BA_PRECONDITION_FATAL(renderer);
|
BA_PRECONDITION_FATAL(renderer);
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kError,
|
||||||
"OpenGL Error at " + std::string(file) + " line " + std::to_string(line)
|
"OpenGL Error at " + std::string(file) + " line " + std::to_string(line)
|
||||||
+ ": " + GLErrorToString(err) + "\nrenderer: " + renderer
|
+ ": " + GLErrorToString(err) + "\nrenderer: " + renderer
|
||||||
+ "\nvendor: " + vendor + "\nversion: " + version
|
+ "\nvendor: " + vendor + "\nversion: " + version
|
||||||
@ -223,9 +224,10 @@ void RendererGL::CheckGLCapabilities_() {
|
|||||||
basestr = "OpenGL";
|
basestr = "OpenGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogName::kBaGraphics, LogLevel::kInfo,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kInfo,
|
||||||
std::string("Using ") + basestr + " (vendor: " + vendor
|
std::string("Using ") + basestr + " (vendor: " + vendor
|
||||||
+ ", renderer: " + renderer + ", version: " + version_str + ").");
|
+ ", renderer: " + renderer + ", version: " + version_str
|
||||||
|
+ ").");
|
||||||
|
|
||||||
// Build a vector of extensions. Newer GLs give us extensions as lists
|
// Build a vector of extensions. Newer GLs give us extensions as lists
|
||||||
// already, but on older ones we may need to break a single string apart
|
// already, but on older ones we may need to break a single string apart
|
||||||
@ -244,8 +246,8 @@ void RendererGL::CheckGLCapabilities_() {
|
|||||||
extensions.push_back(extension);
|
extensions.push_back(extension);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kWarning,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kWarning,
|
||||||
"Falling back on legacy GL_EXTENSIONS parsing.");
|
"Falling back on legacy GL_EXTENSIONS parsing.");
|
||||||
// Fall back on parsing the single giant string if need be.
|
// Fall back on parsing the single giant string if need be.
|
||||||
// (Can probably kill this).
|
// (Can probably kill this).
|
||||||
auto* ex = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
|
auto* ex = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
|
||||||
@ -291,8 +293,8 @@ void RendererGL::CheckGLCapabilities_() {
|
|||||||
c_types.push_back(TextureCompressionType::kETC1);
|
c_types.push_back(TextureCompressionType::kETC1);
|
||||||
} else {
|
} else {
|
||||||
if (g_buildconfig.ostype_android()) {
|
if (g_buildconfig.ostype_android()) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Android device missing ETC1 support.");
|
"Android device missing ETC1 support.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2387,8 +2389,8 @@ void RendererGL::UpdateVignetteTex_(bool force) {
|
|||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
static bool reported = false;
|
static bool reported = false;
|
||||||
if (!reported) {
|
if (!reported) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"32-bit vignette creation failed; falling back to 16.");
|
"32-bit vignette creation failed; falling back to 16.");
|
||||||
reported = true;
|
reported = true;
|
||||||
}
|
}
|
||||||
const int kVignetteTexWidth = 64;
|
const int kVignetteTexWidth = 64;
|
||||||
|
|||||||
@ -27,8 +27,8 @@ class RendererGL::TextureDataGL : public TextureAssetRendererData {
|
|||||||
|
|
||||||
~TextureDataGL() override {
|
~TextureDataGL() override {
|
||||||
if (!g_base->app_adapter->InGraphicsContext()) {
|
if (!g_base->app_adapter->InGraphicsContext()) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"TextureDataGL dying outside of graphics thread.");
|
"TextureDataGL dying outside of graphics thread.");
|
||||||
} else {
|
} else {
|
||||||
// If we're currently bound as anything, clear that out (otherwise a
|
// If we're currently bound as anything, clear that out (otherwise a
|
||||||
// new texture with that same ID won't be bindable).
|
// new texture with that same ID won't be bindable).
|
||||||
|
|||||||
@ -204,7 +204,8 @@ auto Graphics::TextureQualityFromAppConfig() -> TextureQualityRequest {
|
|||||||
} else if (texqualstr == "Low") {
|
} else if (texqualstr == "Low") {
|
||||||
texture_quality_requested = TextureQualityRequest::kLow;
|
texture_quality_requested = TextureQualityRequest::kLow;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Invalid texture quality: '" + texqualstr + "'; defaulting to low.");
|
"Invalid texture quality: '" + texqualstr + "'; defaulting to low.");
|
||||||
texture_quality_requested = TextureQualityRequest::kLow;
|
texture_quality_requested = TextureQualityRequest::kLow;
|
||||||
}
|
}
|
||||||
@ -221,8 +222,8 @@ auto Graphics::VSyncFromAppConfig() -> VSyncRequest {
|
|||||||
} else if (v_sync == "Never") {
|
} else if (v_sync == "Never") {
|
||||||
return VSyncRequest::kNever;
|
return VSyncRequest::kNever;
|
||||||
}
|
}
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Invalid 'Vertical Sync' value: '" + v_sync + "'");
|
"Invalid 'Vertical Sync' value: '" + v_sync + "'");
|
||||||
return VSyncRequest::kNever;
|
return VSyncRequest::kNever;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +242,8 @@ auto Graphics::GraphicsQualityFromAppConfig() -> GraphicsQualityRequest {
|
|||||||
} else if (gqualstr == "Low") {
|
} else if (gqualstr == "Low") {
|
||||||
graphics_quality_requested = GraphicsQualityRequest::kLow;
|
graphics_quality_requested = GraphicsQualityRequest::kLow;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Invalid graphics quality: '" + gqualstr + "'; defaulting to auto.");
|
"Invalid graphics quality: '" + gqualstr + "'; defaulting to auto.");
|
||||||
graphics_quality_requested = GraphicsQualityRequest::kAuto;
|
graphics_quality_requested = GraphicsQualityRequest::kAuto;
|
||||||
}
|
}
|
||||||
@ -628,8 +630,8 @@ void Graphics::FadeScreen(bool to, millisecs_t time, PyObject* endcall) {
|
|||||||
// (otherwise, overlapping fades can cause things to get lost)
|
// (otherwise, overlapping fades can cause things to get lost)
|
||||||
if (fade_end_call_.Exists()) {
|
if (fade_end_call_.Exists()) {
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kWarning,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kWarning,
|
||||||
"2 fades overlapping; running first fade-end-call early.");
|
"2 fades overlapping; running first fade-end-call early.");
|
||||||
}
|
}
|
||||||
fade_end_call_->Schedule();
|
fade_end_call_->Schedule();
|
||||||
fade_end_call_.Clear();
|
fade_end_call_.Clear();
|
||||||
@ -1016,7 +1018,8 @@ void Graphics::DrawFades(FrameDef* frame_def) {
|
|||||||
// TEMP HACK - don't trigger this while inactive.
|
// TEMP HACK - don't trigger this while inactive.
|
||||||
// Need to make overall fade logic smarter.
|
// Need to make overall fade logic smarter.
|
||||||
if (faded_time > 15000 && g_base->app_active()) {
|
if (faded_time > 15000 && g_base->app_active()) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError, "FORCE-ENDING STUCK FADE");
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
|
"FORCE-ENDING STUCK FADE");
|
||||||
fade_out_ = false;
|
fade_out_ = false;
|
||||||
fade_ = 1.0f;
|
fade_ = 1.0f;
|
||||||
fade_time_ = 1000;
|
fade_time_ = 1000;
|
||||||
@ -1673,7 +1676,8 @@ auto Graphics::ReflectionTypeFromString(const std::string& s)
|
|||||||
void Graphics::LanguageChanged() {
|
void Graphics::LanguageChanged() {
|
||||||
assert(g_base && g_base->InLogicThread());
|
assert(g_base && g_base->InLogicThread());
|
||||||
if (building_frame_def_) {
|
if (building_frame_def_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kWarning,
|
||||||
"Graphics::LanguageChanged() called during draw; should not happen.");
|
"Graphics::LanguageChanged() called during draw; should not happen.");
|
||||||
}
|
}
|
||||||
screenmessages->ClearScreenMessageTranslations();
|
screenmessages->ClearScreenMessageTranslations();
|
||||||
@ -1694,9 +1698,9 @@ auto Graphics::GraphicsQualityFromRequest(GraphicsQualityRequest request,
|
|||||||
case GraphicsQualityRequest::kAuto:
|
case GraphicsQualityRequest::kAuto:
|
||||||
return auto_val;
|
return auto_val;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Unhandled GraphicsQualityRequest value: "
|
"Unhandled GraphicsQualityRequest value: "
|
||||||
+ std::to_string(static_cast<int>(request)));
|
+ std::to_string(static_cast<int>(request)));
|
||||||
return GraphicsQuality::kLow;
|
return GraphicsQuality::kLow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1714,9 +1718,9 @@ auto Graphics::TextureQualityFromRequest(TextureQualityRequest request,
|
|||||||
case TextureQualityRequest::kAuto:
|
case TextureQualityRequest::kAuto:
|
||||||
return auto_val;
|
return auto_val;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"Unhandled TextureQualityRequest value: "
|
"Unhandled TextureQualityRequest value: "
|
||||||
+ std::to_string(static_cast<int>(request)));
|
+ std::to_string(static_cast<int>(request)));
|
||||||
return TextureQuality::kLow;
|
return TextureQuality::kLow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,9 +178,9 @@ auto GraphicsServer::WaitForRenderFrameDef_() -> FrameDef* {
|
|||||||
millisecs_t t = g_core->GetAppTimeMillisecs() - start_time;
|
millisecs_t t = g_core->GetAppTimeMillisecs() - start_time;
|
||||||
if (t >= 1000) {
|
if (t >= 1000) {
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kWarning,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kWarning,
|
||||||
"GraphicsServer: timed out at " + std::to_string(t)
|
"GraphicsServer: timed out at " + std::to_string(t)
|
||||||
+ "ms waiting for logic thread to send us a FrameDef.");
|
+ "ms waiting for logic thread to send us a FrameDef.");
|
||||||
}
|
}
|
||||||
break; // Fail.
|
break; // Fail.
|
||||||
}
|
}
|
||||||
@ -266,8 +266,8 @@ void GraphicsServer::ReloadLostRenderer() {
|
|||||||
assert(g_base->app_adapter->InGraphicsContext());
|
assert(g_base->app_adapter->InGraphicsContext());
|
||||||
|
|
||||||
if (!renderer_) {
|
if (!renderer_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"No renderer on GraphicsServer::ReloadLostRenderer.");
|
"No renderer on GraphicsServer::ReloadLostRenderer.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,12 +324,13 @@ void GraphicsServer::set_renderer(Renderer* renderer) {
|
|||||||
void GraphicsServer::LoadRenderer() {
|
void GraphicsServer::LoadRenderer() {
|
||||||
assert(g_base->app_adapter->InGraphicsContext());
|
assert(g_base->app_adapter->InGraphicsContext());
|
||||||
if (!renderer_) {
|
if (!renderer_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"LoadRenderer() called with no renderer present.");
|
"LoadRenderer() called with no renderer present.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (renderer_loaded_) {
|
if (renderer_loaded_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kError,
|
||||||
"LoadRenderer() called with an already-loaded renderer present.");
|
"LoadRenderer() called with an already-loaded renderer present.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -371,12 +372,13 @@ void GraphicsServer::LoadRenderer() {
|
|||||||
void GraphicsServer::UnloadRenderer() {
|
void GraphicsServer::UnloadRenderer() {
|
||||||
assert(g_base->app_adapter->InGraphicsContext());
|
assert(g_base->app_adapter->InGraphicsContext());
|
||||||
if (!renderer_) {
|
if (!renderer_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"UnloadRenderer() called with no renderer present.");
|
"UnloadRenderer() called with no renderer present.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!renderer_loaded_) {
|
if (!renderer_loaded_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaGraphics, LogLevel::kError,
|
||||||
"UnloadRenderer() called with an already unloaded renderer present.");
|
"UnloadRenderer() called with an already unloaded renderer present.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -535,7 +537,7 @@ void GraphicsServer::PushRemoveRenderHoldCall() {
|
|||||||
assert(render_hold_);
|
assert(render_hold_);
|
||||||
render_hold_--;
|
render_hold_--;
|
||||||
if (render_hold_ < 0) {
|
if (render_hold_ < 0) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError, "RenderHold < 0");
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError, "RenderHold < 0");
|
||||||
render_hold_ = 0;
|
render_hold_ = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -17,8 +17,8 @@ class MeshData {
|
|||||||
: type_(type), draw_type_(draw_type) {}
|
: type_(type), draw_type_(draw_type) {}
|
||||||
virtual ~MeshData() {
|
virtual ~MeshData() {
|
||||||
if (renderer_data_) {
|
if (renderer_data_) {
|
||||||
Log(LogName::kBaGraphics, LogLevel::kError,
|
g_core->Log(LogName::kBaGraphics, LogLevel::kError,
|
||||||
"MeshData going down with rendererData intact!");
|
"MeshData going down with rendererData intact!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::list<MeshData*>::iterator iterator_;
|
std::list<MeshData*>::iterator iterator_;
|
||||||
|
|||||||
@ -289,7 +289,8 @@ auto JoystickInput::GetButtonName(int index) -> std::string {
|
|||||||
|
|
||||||
JoystickInput::~JoystickInput() {
|
JoystickInput::~JoystickInput() {
|
||||||
if (!g_base->InLogicThread()) {
|
if (!g_base->InLogicThread()) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError, "Joystick dying in wrong thread.");
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
|
"Joystick dying in wrong thread.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill our child if need be.
|
// Kill our child if need be.
|
||||||
@ -311,8 +312,8 @@ JoystickInput::~JoystickInput() {
|
|||||||
[joystick] { SDL_JoystickClose(joystick); });
|
[joystick] { SDL_JoystickClose(joystick); });
|
||||||
sdl_joystick_ = nullptr;
|
sdl_joystick_ = nullptr;
|
||||||
#else
|
#else
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"sdl_joystick_ set in non-sdl-joystick build destructor.");
|
"sdl_joystick_ set in non-sdl-joystick build destructor.");
|
||||||
#endif // BA_ENABLE_SDL_JOYSTICKS
|
#endif // BA_ENABLE_SDL_JOYSTICKS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1231,8 +1232,8 @@ void JoystickInput::UpdateMapping() {
|
|||||||
auto* cl{g_base->HaveClassic() ? g_base->classic() : nullptr};
|
auto* cl{g_base->HaveClassic() ? g_base->classic() : nullptr};
|
||||||
|
|
||||||
if (!cl) {
|
if (!cl) {
|
||||||
Log(LogName::kBaInput, LogLevel::kWarning,
|
g_core->Log(LogName::kBaInput, LogLevel::kWarning,
|
||||||
"Classic not present; can't config joystick mapping.");
|
"Classic not present; can't config joystick mapping.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're a child, use our parent's id to search for config values and just
|
// If we're a child, use our parent's id to search for config values and just
|
||||||
|
|||||||
@ -852,8 +852,8 @@ void TouchInput::UpdateMapping() {
|
|||||||
} else if (touch_movement_type == "joystick") {
|
} else if (touch_movement_type == "joystick") {
|
||||||
movement_control_type_ = TouchInput::MovementControlType::kJoystick;
|
movement_control_type_ = TouchInput::MovementControlType::kJoystick;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Invalid touch-movement-type: " + touch_movement_type);
|
"Invalid touch-movement-type: " + touch_movement_type);
|
||||||
movement_control_type_ = TouchInput::MovementControlType::kSwipe;
|
movement_control_type_ = TouchInput::MovementControlType::kSwipe;
|
||||||
}
|
}
|
||||||
std::string touch_action_type =
|
std::string touch_action_type =
|
||||||
@ -863,8 +863,8 @@ void TouchInput::UpdateMapping() {
|
|||||||
} else if (touch_action_type == "buttons") {
|
} else if (touch_action_type == "buttons") {
|
||||||
action_control_type_ = TouchInput::ActionControlType::kButtons;
|
action_control_type_ = TouchInput::ActionControlType::kButtons;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Invalid touch-action-type: " + touch_action_type);
|
"Invalid touch-action-type: " + touch_action_type);
|
||||||
action_control_type_ = TouchInput::ActionControlType::kSwipe;
|
action_control_type_ = TouchInput::ActionControlType::kSwipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,8 @@ void Input::PushCreateKeyboardInputDevices() {
|
|||||||
void Input::CreateKeyboardInputDevices_() {
|
void Input::CreateKeyboardInputDevices_() {
|
||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
if (keyboard_input_ != nullptr || keyboard_input_2_ != nullptr) {
|
if (keyboard_input_ != nullptr || keyboard_input_2_ != nullptr) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"CreateKeyboardInputDevices called with existing kbs.");
|
"CreateKeyboardInputDevices called with existing kbs.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keyboard_input_ = Object::NewDeferred<KeyboardInput>(nullptr);
|
keyboard_input_ = Object::NewDeferred<KeyboardInput>(nullptr);
|
||||||
@ -53,8 +53,8 @@ void Input::PushDestroyKeyboardInputDevices() {
|
|||||||
void Input::DestroyKeyboardInputDevices_() {
|
void Input::DestroyKeyboardInputDevices_() {
|
||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
if (keyboard_input_ == nullptr || keyboard_input_2_ == nullptr) {
|
if (keyboard_input_ == nullptr || keyboard_input_2_ == nullptr) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"DestroyKeyboardInputDevices called with null kb(s).");
|
"DestroyKeyboardInputDevices called with null kb(s).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RemoveInputDevice(keyboard_input_, false);
|
RemoveInputDevice(keyboard_input_, false);
|
||||||
@ -558,8 +558,8 @@ void Input::StepDisplayTime() {
|
|||||||
// If input has been locked an excessively long amount of time, unlock it.
|
// If input has been locked an excessively long amount of time, unlock it.
|
||||||
if (input_lock_count_temp_) {
|
if (input_lock_count_temp_) {
|
||||||
if (real_time - last_input_temp_lock_time_ > 10000) {
|
if (real_time - last_input_temp_lock_time_ > 10000) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Input has been temp-locked for 10 seconds; unlocking.");
|
"Input has been temp-locked for 10 seconds; unlocking.");
|
||||||
input_lock_count_temp_ = 0;
|
input_lock_count_temp_ = 0;
|
||||||
PrintLockLabels_();
|
PrintLockLabels_();
|
||||||
input_lock_temp_labels_.clear();
|
input_lock_temp_labels_.clear();
|
||||||
@ -664,10 +664,10 @@ void Input::UnlockAllInput(bool permanent, const std::string& label) {
|
|||||||
input_lock_count_temp_--;
|
input_lock_count_temp_--;
|
||||||
input_unlock_temp_labels_.push_back(label);
|
input_unlock_temp_labels_.push_back(label);
|
||||||
if (input_lock_count_temp_ < 0) {
|
if (input_lock_count_temp_ < 0) {
|
||||||
Log(LogName::kBaInput, LogLevel::kWarning,
|
g_core->Log(LogName::kBaInput, LogLevel::kWarning,
|
||||||
"temp input unlock at time "
|
"temp input unlock at time "
|
||||||
+ std::to_string(g_core->GetAppTimeMillisecs())
|
+ std::to_string(g_core->GetAppTimeMillisecs())
|
||||||
+ " with no active lock: '" + label + "'");
|
+ " with no active lock: '" + label + "'");
|
||||||
// This is to be expected since we can reset this to 0.
|
// This is to be expected since we can reset this to 0.
|
||||||
input_lock_count_temp_ = 0;
|
input_lock_count_temp_ = 0;
|
||||||
}
|
}
|
||||||
@ -719,7 +719,7 @@ void Input::PrintLockLabels_() {
|
|||||||
s += "\n " + std::to_string(num++) + ": " + recent_input_locks_unlock;
|
s += "\n " + std::to_string(num++) + ": " + recent_input_locks_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogName::kBaInput, LogLevel::kError, s);
|
g_core->Log(LogName::kBaInput, LogLevel::kError, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::PushTextInputEvent(const std::string& text) {
|
void Input::PushTextInputEvent(const std::string& text) {
|
||||||
@ -757,8 +757,8 @@ void Input::PushTextInputEvent(const std::string& text) {
|
|||||||
// platforms) but make a stink if they sent us something that we can't
|
// platforms) but make a stink if they sent us something that we can't
|
||||||
// at least translate to unicode.
|
// at least translate to unicode.
|
||||||
if (!Utils::IsValidUTF8(text)) {
|
if (!Utils::IsValidUTF8(text)) {
|
||||||
Log(LogName::kBaInput, LogLevel::kWarning,
|
g_core->Log(LogName::kBaInput, LogLevel::kWarning,
|
||||||
"PushTextInputEvent passed invalid utf-8 text.");
|
"PushTextInputEvent passed invalid utf-8 text.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,8 +845,8 @@ void Input::CaptureKeyboardInput(HandleKeyPressCall* press_call,
|
|||||||
HandleKeyReleaseCall* release_call) {
|
HandleKeyReleaseCall* release_call) {
|
||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
if (keyboard_input_capture_press_ || keyboard_input_capture_release_) {
|
if (keyboard_input_capture_press_ || keyboard_input_capture_release_) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Setting key capture redundantly.");
|
"Setting key capture redundantly.");
|
||||||
}
|
}
|
||||||
keyboard_input_capture_press_ = press_call;
|
keyboard_input_capture_press_ = press_call;
|
||||||
keyboard_input_capture_release_ = release_call;
|
keyboard_input_capture_release_ = release_call;
|
||||||
@ -861,8 +861,8 @@ void Input::ReleaseKeyboardInput() {
|
|||||||
void Input::CaptureJoystickInput(HandleJoystickEventCall* call) {
|
void Input::CaptureJoystickInput(HandleJoystickEventCall* call) {
|
||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
if (joystick_input_capture_) {
|
if (joystick_input_capture_) {
|
||||||
Log(LogName::kBaInput, LogLevel::kError,
|
g_core->Log(LogName::kBaInput, LogLevel::kError,
|
||||||
"Setting joystick capture redundantly.");
|
"Setting joystick capture redundantly.");
|
||||||
}
|
}
|
||||||
joystick_input_capture_ = call;
|
joystick_input_capture_ = call;
|
||||||
}
|
}
|
||||||
@ -1570,7 +1570,7 @@ void Input::LsInputDevices() {
|
|||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogName::kBaInput, LogLevel::kInfo, out);
|
g_core->Log(LogName::kBaInput, LogLevel::kInfo, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Input::ShouldAllowInputInAttractMode_(InputDevice* device) const -> bool {
|
auto Input::ShouldAllowInputInAttractMode_(InputDevice* device) const -> bool {
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "ballistica/base/app_adapter/app_adapter.h"
|
#include "ballistica/base/app_adapter/app_adapter.h"
|
||||||
#include "ballistica/base/app_mode/app_mode.h"
|
#include "ballistica/base/app_mode/app_mode.h"
|
||||||
@ -24,13 +25,7 @@
|
|||||||
|
|
||||||
namespace ballistica::base {
|
namespace ballistica::base {
|
||||||
|
|
||||||
Logic::Logic() : display_timers_(new TimerList()) {
|
Logic::Logic() : display_timers_(new TimerList()) {}
|
||||||
// Enable display-time debug logs via env var.
|
|
||||||
auto val = g_core->platform->GetEnv("BA_DEBUG_LOG_DISPLAY_TIME");
|
|
||||||
if (val && *val == "1") {
|
|
||||||
debug_log_display_time_ = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logic::OnMainThreadStartApp() {
|
void Logic::OnMainThreadStartApp() {
|
||||||
// Spin up our logic thread and sit and wait for it to init.
|
// Spin up our logic thread and sit and wait for it to init.
|
||||||
@ -383,8 +378,9 @@ void Logic::OnAppModeChanged() {
|
|||||||
// Kick our headless stepping into high gear; this will snap us out of any
|
// Kick our headless stepping into high gear; this will snap us out of any
|
||||||
// long sleep we're currently in the middle of.
|
// long sleep we're currently in the middle of.
|
||||||
if (g_core->HeadlessMode()) {
|
if (g_core->HeadlessMode()) {
|
||||||
if (debug_log_display_time_) {
|
if (g_core->LogLevelEnabled(LogName::kBaDisplayTime, LogLevel::kDebug)) {
|
||||||
Log(LogName::kBa, LogLevel::kDebug,
|
g_core->Log(
|
||||||
|
LogName::kBaDisplayTime, LogLevel::kDebug,
|
||||||
"Resetting headless display step timer due to app-mode change.");
|
"Resetting headless display step timer due to app-mode change.");
|
||||||
}
|
}
|
||||||
assert(headless_display_time_step_timer_);
|
assert(headless_display_time_step_timer_);
|
||||||
@ -415,12 +411,12 @@ void Logic::UpdateDisplayTimeForHeadlessMode_() {
|
|||||||
display_time_increment_ =
|
display_time_increment_ =
|
||||||
static_cast<double>(display_time_increment_microsecs_) / 1000000.0;
|
static_cast<double>(display_time_increment_microsecs_) / 1000000.0;
|
||||||
|
|
||||||
if (debug_log_display_time_) {
|
g_core->Log(LogName::kBaDisplayTime, LogLevel::kDebug, [app_time_microsecs] {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
snprintf(buffer, sizeof(buffer), "stepping display-time at app-time %.4f",
|
snprintf(buffer, sizeof(buffer), "stepping display-time at app-time %.4f",
|
||||||
static_cast<double>(app_time_microsecs) / 1000000.0);
|
static_cast<double>(app_time_microsecs) / 1000000.0);
|
||||||
Log(LogName::kBa, LogLevel::kDebug, buffer);
|
return std::string(buffer);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logic::PostUpdateDisplayTimeForHeadlessMode_() {
|
void Logic::PostUpdateDisplayTimeForHeadlessMode_() {
|
||||||
@ -433,16 +429,18 @@ void Logic::PostUpdateDisplayTimeForHeadlessMode_() {
|
|||||||
kHeadlessMaxDisplayTimeStep),
|
kHeadlessMaxDisplayTimeStep),
|
||||||
kHeadlessMinDisplayTimeStep);
|
kHeadlessMinDisplayTimeStep);
|
||||||
|
|
||||||
if (debug_log_display_time_) {
|
g_core->Log(
|
||||||
auto sleepsecs =
|
LogName::kBaDisplayTime, LogLevel::kDebug,
|
||||||
static_cast<double>(headless_display_step_microsecs) / 1000000.0;
|
[headless_display_step_microsecs] {
|
||||||
auto apptimesecs = g_core->GetAppTimeSeconds();
|
auto sleepsecs =
|
||||||
char buffer[256];
|
static_cast<double>(headless_display_step_microsecs) / 1000000.0;
|
||||||
snprintf(buffer, sizeof(buffer),
|
auto apptimesecs = g_core->GetAppTimeSeconds();
|
||||||
"will try to sleep for %.4f at app-time %.4f (until %.4f)",
|
char buffer[256];
|
||||||
sleepsecs, apptimesecs, apptimesecs + sleepsecs);
|
snprintf(buffer, sizeof(buffer),
|
||||||
Log(LogName::kBa, LogLevel::kDebug, buffer);
|
"will try to sleep for %.4f at app-time %.4f (until %.4f)",
|
||||||
}
|
sleepsecs, apptimesecs, apptimesecs + sleepsecs);
|
||||||
|
return std::string(buffer);
|
||||||
|
});
|
||||||
|
|
||||||
auto sleep_microsecs = headless_display_step_microsecs;
|
auto sleep_microsecs = headless_display_step_microsecs;
|
||||||
headless_display_time_step_timer_->SetLength(sleep_microsecs);
|
headless_display_time_step_timer_->SetLength(sleep_microsecs);
|
||||||
@ -543,24 +541,28 @@ void Logic::UpdateDisplayTimeForFrameDraw_() {
|
|||||||
if (trailing_dist > trail_buffer) {
|
if (trailing_dist > trail_buffer) {
|
||||||
auto offs =
|
auto offs =
|
||||||
(trailing_dist - trail_buffer) * (trailing_diff > 0.0 ? 1.0 : -1.0);
|
(trailing_dist - trail_buffer) * (trailing_diff > 0.0 ? 1.0 : -1.0);
|
||||||
if (debug_log_display_time_) {
|
g_core->Log(
|
||||||
char buffer[256];
|
LogName::kBaDisplayTime, LogLevel::kDebug,
|
||||||
snprintf(buffer, sizeof(buffer),
|
[trailing_dist, trail_buffer, offs] {
|
||||||
"trailing_dist %.6f > trail_buffer %.6f; will offset %.6f).",
|
char buffer[256];
|
||||||
trailing_dist, trail_buffer, offs);
|
snprintf(
|
||||||
Log(LogName::kBa, LogLevel::kDebug, buffer);
|
buffer, sizeof(buffer),
|
||||||
}
|
"trailing_dist %.6f > trail_buffer %.6f; will offset %.6f).",
|
||||||
|
trailing_dist, trail_buffer, offs);
|
||||||
|
return std::string(buffer);
|
||||||
|
});
|
||||||
display_time_increment_ = display_time_increment_ + offs;
|
display_time_increment_ = display_time_increment_ + offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_log_display_time_) {
|
g_core->Log(LogName::kBaDisplayTime, LogLevel::kDebug,
|
||||||
char buffer[256];
|
[this, use_avg, this_increment, chaos, used] {
|
||||||
snprintf(buffer, sizeof(buffer),
|
char buffer[256];
|
||||||
"final %.5f current(%s) %.5f sample %.5f chaos %.5f",
|
snprintf(buffer, sizeof(buffer),
|
||||||
display_time_increment_, use_avg ? "avg" : "sample", used,
|
"final %.5f current(%s) %.5f sample %.5f chaos %.5f",
|
||||||
this_increment, chaos);
|
display_time_increment_, use_avg ? "avg" : "sample",
|
||||||
Log(LogName::kBa, LogLevel::kDebug, buffer);
|
used, this_increment, chaos);
|
||||||
}
|
return std::string(buffer);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lastly, apply our updated increment value to our time.
|
// Lastly, apply our updated increment value to our time.
|
||||||
@ -660,8 +662,8 @@ void Logic::SetAppTimerLength(int timer_id, microsecs_t length) {
|
|||||||
if (t) {
|
if (t) {
|
||||||
t->SetLength(length);
|
t->SetLength(length);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Logic::SetAppTimerLength() called on nonexistent timer.");
|
"Logic::SetAppTimerLength() called on nonexistent timer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,8 +689,8 @@ void Logic::SetDisplayTimerLength(int timer_id, microsecs_t length) {
|
|||||||
if (t) {
|
if (t) {
|
||||||
t->SetLength(length);
|
t->SetLength(length);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Logic::SetDisplayTimerLength() called on nonexistent timer.");
|
"Logic::SetDisplayTimerLength() called on nonexistent timer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,6 @@ class Logic {
|
|||||||
bool app_active_{true};
|
bool app_active_{true};
|
||||||
bool app_bootstrapping_complete_{};
|
bool app_bootstrapping_complete_{};
|
||||||
bool have_pending_loads_{};
|
bool have_pending_loads_{};
|
||||||
bool debug_log_display_time_{};
|
|
||||||
bool applied_app_config_{};
|
bool applied_app_config_{};
|
||||||
bool shutting_down_{};
|
bool shutting_down_{};
|
||||||
bool shutdown_completed_{};
|
bool shutdown_completed_{};
|
||||||
|
|||||||
@ -61,9 +61,9 @@ void NetworkReader::OnAppUnsuspend() {
|
|||||||
void NetworkReader::PokeSelf_() {
|
void NetworkReader::PokeSelf_() {
|
||||||
int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
int sd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sd < 0) {
|
if (sd < 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unable to create sleep ping socket; errno "
|
"Unable to create sleep ping socket; errno "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
} else {
|
} else {
|
||||||
struct sockaddr_in serv_addr{};
|
struct sockaddr_in serv_addr{};
|
||||||
memset(&serv_addr, 0, sizeof(serv_addr));
|
memset(&serv_addr, 0, sizeof(serv_addr));
|
||||||
@ -72,9 +72,9 @@ void NetworkReader::PokeSelf_() {
|
|||||||
serv_addr.sin_port = 0; // any
|
serv_addr.sin_port = 0; // any
|
||||||
int bresult = ::bind(sd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
|
int bresult = ::bind(sd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
|
||||||
if (bresult == 1) {
|
if (bresult == 1) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unable to bind sleep socket: "
|
"Unable to bind sleep socket: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
} else {
|
} else {
|
||||||
struct sockaddr_in t_addr{};
|
struct sockaddr_in t_addr{};
|
||||||
memset(&t_addr, 0, sizeof(t_addr));
|
memset(&t_addr, 0, sizeof(t_addr));
|
||||||
@ -85,9 +85,9 @@ void NetworkReader::PokeSelf_() {
|
|||||||
ssize_t sresult =
|
ssize_t sresult =
|
||||||
sendto(sd, b, 1, 0, (struct sockaddr*)(&t_addr), sizeof(t_addr));
|
sendto(sd, b, 1, 0, (struct sockaddr*)(&t_addr), sizeof(t_addr));
|
||||||
if (sresult == -1) {
|
if (sresult == -1) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error on sleep self-sendto: "
|
"Error on sleep self-sendto: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_core->platform->CloseSocket(sd);
|
g_core->platform->CloseSocket(sd);
|
||||||
@ -118,7 +118,8 @@ void NetworkReader::DoPoll_(bool* can_read_4, bool* can_read_6) {
|
|||||||
// Aint no thang.
|
// Aint no thang.
|
||||||
} else {
|
} else {
|
||||||
// Let's complain for anything else though.
|
// Let's complain for anything else though.
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error on select: " + g_core->platform->GetSocketErrorString());
|
"Error on select: " + g_core->platform->GetSocketErrorString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -171,7 +172,8 @@ void NetworkReader::DoSelect_(bool* can_read_4, bool* can_read_6) {
|
|||||||
// Aint no thang.
|
// Aint no thang.
|
||||||
} else {
|
} else {
|
||||||
// Let's complain for anything else though.
|
// Let's complain for anything else though.
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error on select: " + g_core->platform->GetSocketErrorString());
|
"Error on select: " + g_core->platform->GetSocketErrorString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -239,9 +241,9 @@ auto NetworkReader::RunThread_() -> int {
|
|||||||
recvfrom(sd, buffer, sizeof(buffer), 0,
|
recvfrom(sd, buffer, sizeof(buffer), 0,
|
||||||
reinterpret_cast<sockaddr*>(&from), &from_size);
|
reinterpret_cast<sockaddr*>(&from), &from_size);
|
||||||
if (rresult == 0) {
|
if (rresult == 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"NetworkReader Recv got length 0; this shouldn't "
|
"NetworkReader Recv got length 0; this shouldn't "
|
||||||
"happen");
|
"happen");
|
||||||
} else if (rresult == -1) {
|
} else if (rresult == -1) {
|
||||||
// This needs to be locked during any sd changes/writes.
|
// This needs to be locked during any sd changes/writes.
|
||||||
std::scoped_lock lock(sd_mutex_);
|
std::scoped_lock lock(sd_mutex_);
|
||||||
@ -417,9 +419,9 @@ void NetworkReader::OpenSockets_() {
|
|||||||
|
|
||||||
sd4_ = socket(AF_INET, SOCK_DGRAM, 0);
|
sd4_ = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sd4_ < 0) {
|
if (sd4_ < 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unable to open host socket; errno "
|
"Unable to open host socket; errno "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
} else {
|
} else {
|
||||||
g_core->platform->SetSocketNonBlocking(sd4_);
|
g_core->platform->SetSocketNonBlocking(sd4_);
|
||||||
|
|
||||||
@ -470,9 +472,9 @@ void NetworkReader::OpenSockets_() {
|
|||||||
// available everywhere (win XP, etc) so let's do this for now.
|
// available everywhere (win XP, etc) so let's do this for now.
|
||||||
sd6_ = socket(AF_INET6, SOCK_DGRAM, 0);
|
sd6_ = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
if (sd6_ < 0) {
|
if (sd6_ < 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unable to open ipv6 socket: "
|
"Unable to open ipv6 socket: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
} else {
|
} else {
|
||||||
// Since we're explicitly creating both a v4 and v6 socket, tell the v6
|
// Since we're explicitly creating both a v4 and v6 socket, tell the v6
|
||||||
// to *not* do both itself (not sure if this is necessary; on mac it
|
// to *not* do both itself (not sure if this is necessary; on mac it
|
||||||
@ -481,8 +483,8 @@ void NetworkReader::OpenSockets_() {
|
|||||||
if (setsockopt(sd6_, IPPROTO_IPV6, IPV6_V6ONLY,
|
if (setsockopt(sd6_, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
reinterpret_cast<char*>(&on), sizeof(on))
|
reinterpret_cast<char*>(&on), sizeof(on))
|
||||||
== -1) {
|
== -1) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error setting socket as ipv6-only");
|
"Error setting socket as ipv6-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_core->platform->SetSocketNonBlocking(sd6_);
|
g_core->platform->SetSocketNonBlocking(sd6_);
|
||||||
@ -529,9 +531,10 @@ void NetworkReader::OpenSockets_() {
|
|||||||
+ std::to_string(initial_requested_port)
|
+ std::to_string(initial_requested_port)
|
||||||
+ "; some network functionality may fail.",
|
+ "; some network functionality may fail.",
|
||||||
{1, 0.5f, 0});
|
{1, 0.5f, 0});
|
||||||
Log(LogName::kBaNetworking, LogLevel::kWarning,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kWarning,
|
||||||
"Unable to bind udp port " + std::to_string(initial_requested_port)
|
"Unable to bind udp port "
|
||||||
+ "; some network functionality may fail.");
|
+ std::to_string(initial_requested_port)
|
||||||
|
+ "; some network functionality may fail.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,8 +116,8 @@ void BasePlatformApple::LoginAdapterGetSignInToken(
|
|||||||
if (login_type == "game_center") {
|
if (login_type == "game_center") {
|
||||||
BallisticaKit::GameCenterContext::getSignInToken(attempt_id);
|
BallisticaKit::GameCenterContext::getSignInToken(attempt_id);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got unexpected get-sign-in-token login-type: " + login_type);
|
"Got unexpected get-sign-in-token login-type: " + login_type);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
BasePlatform::LoginAdapterGetSignInToken(login_type, attempt_id);
|
BasePlatform::LoginAdapterGetSignInToken(login_type, attempt_id);
|
||||||
@ -130,7 +130,8 @@ void BasePlatformApple::LoginAdapterBackEndActiveChange(
|
|||||||
if (login_type == "game_center") {
|
if (login_type == "game_center") {
|
||||||
BallisticaKit::GameCenterContext::backEndActiveChange(active);
|
BallisticaKit::GameCenterContext::backEndActiveChange(active);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Got unexpected back-end-active-change login-type: " + login_type);
|
"Got unexpected back-end-active-change login-type: " + login_type);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -104,12 +104,13 @@ void BasePlatform::DoPurchase(const std::string& item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::RestorePurchases() {
|
void BasePlatform::RestorePurchases() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "RestorePurchases() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"RestorePurchases() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::PurchaseAck(const std::string& purchase,
|
void BasePlatform::PurchaseAck(const std::string& purchase,
|
||||||
const std::string& order_id) {
|
const std::string& order_id) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "PurchaseAck() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError, "PurchaseAck() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::OpenURL(const std::string& url) {
|
void BasePlatform::OpenURL(const std::string& url) {
|
||||||
@ -134,7 +135,8 @@ void BasePlatform::OverlayWebBrowserOpenURL(const std::string& url) {
|
|||||||
|
|
||||||
std::scoped_lock lock(web_overlay_mutex_);
|
std::scoped_lock lock(web_overlay_mutex_);
|
||||||
if (web_overlay_open_) {
|
if (web_overlay_open_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"OverlayWebBrowserOnClose called with already existing overlay.");
|
"OverlayWebBrowserOnClose called with already existing overlay.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -155,8 +157,8 @@ auto BasePlatform::OverlayWebBrowserIsOpen() -> bool {
|
|||||||
void BasePlatform::OverlayWebBrowserOnClose() {
|
void BasePlatform::OverlayWebBrowserOnClose() {
|
||||||
std::scoped_lock lock(web_overlay_mutex_);
|
std::scoped_lock lock(web_overlay_mutex_);
|
||||||
if (!web_overlay_open_) {
|
if (!web_overlay_open_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"OverlayWebBrowserOnClose called with no known overlay.");
|
"OverlayWebBrowserOnClose called with no known overlay.");
|
||||||
}
|
}
|
||||||
web_overlay_open_ = false;
|
web_overlay_open_ = false;
|
||||||
}
|
}
|
||||||
@ -174,13 +176,14 @@ void BasePlatform::OverlayWebBrowserClose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::DoOverlayWebBrowserOpenURL(const std::string& url) {
|
void BasePlatform::DoOverlayWebBrowserOpenURL(const std::string& url) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"DoOpenURLInOverlayBrowser unimplemented");
|
"DoOpenURLInOverlayBrowser unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::DoOverlayWebBrowserClose() {
|
void BasePlatform::DoOverlayWebBrowserClose() {
|
||||||
// As a default, use Python's webbrowser module functionality.
|
// As a default, use Python's webbrowser module functionality.
|
||||||
Log(LogName::kBa, LogLevel::kError, "DoOverlayWebBrowserClose unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"DoOverlayWebBrowserClose unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BA_OSTYPE_WINDOWS
|
#if !BA_OSTYPE_WINDOWS
|
||||||
@ -189,7 +192,8 @@ static void HandleSIGINT(int s) {
|
|||||||
g_base->logic->event_loop()->PushCall(
|
g_base->logic->event_loop()->PushCall(
|
||||||
[] { g_base->logic->HandleInterruptSignal(); });
|
[] { g_base->logic->HandleInterruptSignal(); });
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"SigInt handler called before g_base->logic->event_loop exists.");
|
"SigInt handler called before g_base->logic->event_loop exists.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +202,8 @@ static void HandleSIGTERM(int s) {
|
|||||||
g_base->logic->event_loop()->PushCall(
|
g_base->logic->event_loop()->PushCall(
|
||||||
[] { g_base->logic->HandleTerminateSignal(); });
|
[] { g_base->logic->HandleTerminateSignal(); });
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"SigInt handler called before g_base->logic->event_loop exists.");
|
"SigInt handler called before g_base->logic->event_loop exists.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,18 +282,20 @@ void BasePlatform::StringEditorCancel() {
|
|||||||
void BasePlatform::DoInvokeStringEditor(const std::string& title,
|
void BasePlatform::DoInvokeStringEditor(const std::string& title,
|
||||||
const std::string& value,
|
const std::string& value,
|
||||||
std::optional<int> max_chars) {
|
std::optional<int> max_chars) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"FIXME: DoInvokeStringEditor() unimplemented");
|
"FIXME: DoInvokeStringEditor() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BasePlatform::SupportsOpenDirExternally() -> bool { return false; }
|
auto BasePlatform::SupportsOpenDirExternally() -> bool { return false; }
|
||||||
|
|
||||||
void BasePlatform::OpenDirExternally(const std::string& path) {
|
void BasePlatform::OpenDirExternally(const std::string& path) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "OpenDirExternally() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"OpenDirExternally() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePlatform::OpenFileExternally(const std::string& path) {
|
void BasePlatform::OpenFileExternally(const std::string& path) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "OpenFileExternally() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"OpenFileExternally() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BasePlatform::SafeStdinFGetS(char* s, int n, FILE* iop) -> char* {
|
auto BasePlatform::SafeStdinFGetS(char* s, int n, FILE* iop) -> char* {
|
||||||
|
|||||||
@ -23,9 +23,9 @@ void BasePlatformLinux::OpenDirExternally(const std::string& path) {
|
|||||||
std::string cmd = std::string("xdg-open \"") + path + "\"";
|
std::string cmd = std::string("xdg-open \"") + path + "\"";
|
||||||
int result = system(cmd.c_str());
|
int result = system(cmd.c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got return value " + std::to_string(result) + " on xdg-open cmd '"
|
"Got return value " + std::to_string(result)
|
||||||
+ cmd + "'");
|
+ " on xdg-open cmd '" + cmd + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,9 +33,9 @@ void BasePlatformLinux::OpenFileExternally(const std::string& path) {
|
|||||||
std::string cmd = std::string("xdg-open \"") + path + "\"";
|
std::string cmd = std::string("xdg-open \"") + path + "\"";
|
||||||
int result = system(cmd.c_str());
|
int result = system(cmd.c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got return value " + std::to_string(result) + " on xdg-open cmd '"
|
"Got return value " + std::to_string(result)
|
||||||
+ cmd + "'");
|
+ " on xdg-open cmd '" + cmd + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,8 @@ void BasePlatformWindows::DoOpenURL(const std::string& url) {
|
|||||||
|
|
||||||
// This should return > 32 on success.
|
// This should return > 32 on success.
|
||||||
if (r <= 32) {
|
if (r <= 32) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error " + std::to_string(r) + " opening URL '" + url + "'");
|
"Error " + std::to_string(r) + " opening URL '" + url + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,8 +49,8 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) {
|
|||||||
g_base->logic->event_loop()->PushCall(
|
g_base->logic->event_loop()->PushCall(
|
||||||
[] { g_base->logic->HandleInterruptSignal(); });
|
[] { g_base->logic->HandleInterruptSignal(); });
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SigInt handler called before g_logic exists.");
|
"SigInt handler called before g_logic exists.");
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -62,7 +62,8 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) {
|
|||||||
void BasePlatformWindows::SetupInterruptHandling() {
|
void BasePlatformWindows::SetupInterruptHandling() {
|
||||||
// Set up Ctrl-C handling.
|
// Set up Ctrl-C handling.
|
||||||
if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) {
|
if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error on SetConsoleCtrlHandler()");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error on SetConsoleCtrlHandler()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,9 +75,9 @@ void BasePlatformWindows::OpenDirExternally(const std::string& path) {
|
|||||||
core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr,
|
core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr,
|
||||||
SW_SHOWNORMAL));
|
SW_SHOWNORMAL));
|
||||||
if (r <= 32) {
|
if (r <= 32) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error " + std::to_string(r) + " on open_dir_externally for '" + path
|
"Error " + std::to_string(r) + " on open_dir_externally for '"
|
||||||
+ "'");
|
+ path + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +87,9 @@ void BasePlatformWindows::OpenFileExternally(const std::string& path) {
|
|||||||
core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr,
|
core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr,
|
||||||
SW_SHOWNORMAL));
|
SW_SHOWNORMAL));
|
||||||
if (r <= 32) {
|
if (r <= 32) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error " + std::to_string(r) + " on open_file_externally for '" + path
|
"Error " + std::to_string(r) + " on open_file_externally for '"
|
||||||
+ "'");
|
+ path + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -341,7 +341,8 @@ auto BasePython::GetRawConfigValue(const char* name, float default_value)
|
|||||||
try {
|
try {
|
||||||
return Python::GetPyFloat(value);
|
return Python::GetPyFloat(value);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"expected a float for config value '" + std::string(name) + "'");
|
"expected a float for config value '" + std::string(name) + "'");
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
@ -363,7 +364,8 @@ auto BasePython::GetRawConfigValue(const char* name,
|
|||||||
}
|
}
|
||||||
return Python::GetPyFloat(value);
|
return Python::GetPyFloat(value);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"expected a float for config value '" + std::string(name) + "'");
|
"expected a float for config value '" + std::string(name) + "'");
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
@ -380,7 +382,8 @@ auto BasePython::GetRawConfigValue(const char* name, int default_value) -> int {
|
|||||||
try {
|
try {
|
||||||
return static_cast_check_fit<int>(Python::GetPyInt64(value));
|
return static_cast_check_fit<int>(Python::GetPyInt64(value));
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Expected an int value for config value '" + std::string(name) + "'.");
|
"Expected an int value for config value '" + std::string(name) + "'.");
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
@ -398,7 +401,8 @@ auto BasePython::GetRawConfigValue(const char* name, bool default_value)
|
|||||||
try {
|
try {
|
||||||
return Python::GetPyBool(value);
|
return Python::GetPyBool(value);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Expected a bool value for config value '" + std::string(name) + "'.");
|
"Expected a bool value for config value '" + std::string(name) + "'.");
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
@ -506,16 +510,16 @@ auto BasePython::GetResource(const char* key, const char* fallback_resource,
|
|||||||
try {
|
try {
|
||||||
return g_base->python->GetPyLString(results.Get());
|
return g_base->python->GetPyLString(results.Get());
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GetResource failed for '" + std::string(key) + "'");
|
"GetResource failed for '" + std::string(key) + "'");
|
||||||
|
|
||||||
// Hmm; I guess let's just return the key to help identify/fix the
|
// Hmm; I guess let's just return the key to help identify/fix the
|
||||||
// issue?..
|
// issue?..
|
||||||
return std::string("<res-err: ") + key + ">";
|
return std::string("<res-err: ") + key + ">";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GetResource failed for '" + std::string(key) + "'");
|
"GetResource failed for '" + std::string(key) + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hmm; I guess let's just return the key to help identify/fix the issue?..
|
// Hmm; I guess let's just return the key to help identify/fix the issue?..
|
||||||
@ -535,12 +539,13 @@ auto BasePython::GetTranslation(const char* category, const char* s)
|
|||||||
try {
|
try {
|
||||||
return g_base->python->GetPyLString(results.Get());
|
return g_base->python->GetPyLString(results.Get());
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GetTranslation failed for '" + std::string(category) + "'");
|
"GetTranslation failed for '" + std::string(category) + "'");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"GetTranslation failed for category '" + std::string(category) + "'");
|
"GetTranslation failed for category '" + std::string(category) + "'");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
@ -556,7 +561,7 @@ void BasePython::RunDeepLink(const std::string& url) {
|
|||||||
.Get(base::BasePython::ObjID::kAppHandleDeepLinkCall)
|
.Get(base::BasePython::ObjID::kAppHandleDeepLinkCall)
|
||||||
.Call(args);
|
.Call(args);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error on deep-link call");
|
g_core->Log(LogName::kBa, LogLevel::kError, "Error on deep-link call");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,8 +582,8 @@ auto BasePython::CanPyStringEditAdapterBeReplaced(PyObject* o) -> bool {
|
|||||||
.Get(BasePython::ObjID::kStringEditAdapterCanBeReplacedCall)
|
.Get(BasePython::ObjID::kStringEditAdapterCanBeReplacedCall)
|
||||||
.Call(args);
|
.Call(args);
|
||||||
if (!result.Exists()) {
|
if (!result.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error getting StringEdit valid state.");
|
"Error getting StringEdit valid state.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (result.Get() == Py_True) {
|
if (result.Get() == Py_True) {
|
||||||
@ -587,8 +592,8 @@ auto BasePython::CanPyStringEditAdapterBeReplaced(PyObject* o) -> bool {
|
|||||||
if (result.Get() == Py_False) {
|
if (result.Get() == Py_False) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got unexpected value for StringEdit valid.");
|
"Got unexpected value for StringEdit valid.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "ballistica/base/python/class/python_class_feature_set_data.h"
|
#include "ballistica/base/python/class/python_class_feature_set_data.h"
|
||||||
|
|
||||||
|
#include "ballistica/base/base.h"
|
||||||
|
|
||||||
namespace ballistica::base {
|
namespace ballistica::base {
|
||||||
|
|
||||||
auto PythonClassFeatureSetData::type_name() -> const char* {
|
auto PythonClassFeatureSetData::type_name() -> const char* {
|
||||||
|
|||||||
@ -275,12 +275,12 @@ static auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds)
|
|||||||
// Warn the user not to use this from the logic thread since it doesnt
|
// Warn the user not to use this from the logic thread since it doesnt
|
||||||
// save/restore context.
|
// save/restore context.
|
||||||
if (!suppress_warning && g_base->InLogicThread()) {
|
if (!suppress_warning && g_base->InLogicThread()) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"babase.pushcall() called from the logic thread with "
|
"babase.pushcall() called from the logic thread with "
|
||||||
"from_other_thread set to true (call "
|
"from_other_thread set to true (call "
|
||||||
+ Python::ObjToString(call_obj) + " at "
|
+ Python::ObjToString(call_obj) + " at "
|
||||||
+ Python::GetPythonFileLocation()
|
+ Python::GetPythonFileLocation()
|
||||||
+ "). That arg should only be used from other threads.");
|
+ "). That arg should only be used from other threads.");
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Python::HaveGIL());
|
assert(Python::HaveGIL());
|
||||||
|
|||||||
@ -190,7 +190,7 @@ static auto PyScreenMessage(PyObject* self, PyObject* args, PyObject* keywds)
|
|||||||
color = BasePython::GetPyVector3f(color_obj);
|
color = BasePython::GetPyVector3f(color_obj);
|
||||||
}
|
}
|
||||||
if (log) {
|
if (log) {
|
||||||
Log(LogName::kBa, LogLevel::kInfo, message_str);
|
g_core->Log(LogName::kBa, LogLevel::kInfo, message_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This version simply displays it locally.
|
// This version simply displays it locally.
|
||||||
|
|||||||
@ -327,8 +327,8 @@ static auto PySetUpSigInt(PyObject* self) -> PyObject* {
|
|||||||
if (g_base) {
|
if (g_base) {
|
||||||
g_base->platform->SetupInterruptHandling();
|
g_base->platform->SetupInterruptHandling();
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"setup_sigint called before g_base exists.");
|
"setup_sigint called before g_base exists.");
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
BA_PYTHON_CATCH;
|
BA_PYTHON_CATCH;
|
||||||
|
|||||||
@ -718,7 +718,8 @@ void DevConsole::InvokeStringEditor_() {
|
|||||||
.Get(BasePython::ObjID::kDevConsoleStringEditAdapterClass)
|
.Get(BasePython::ObjID::kDevConsoleStringEditAdapterClass)
|
||||||
.Call();
|
.Call();
|
||||||
if (!result.Exists()) {
|
if (!result.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error invoking string edit dialog.");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error invoking string edit dialog.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1078,8 @@ auto DevConsole::HandleKeyRelease(const SDL_Keysym* keysym) -> bool {
|
|||||||
void DevConsole::Exec() {
|
void DevConsole::Exec() {
|
||||||
BA_PRECONDITION(g_base->InLogicThread());
|
BA_PRECONDITION(g_base->InLogicThread());
|
||||||
if (!input_enabled_) {
|
if (!input_enabled_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning, "Console input is not allowed yet.");
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
|
"Console input is not allowed yet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input_history_position_ = 0;
|
input_history_position_ = 0;
|
||||||
|
|||||||
@ -166,13 +166,16 @@ void UI::OnAppStart() {
|
|||||||
if (force_scale_) {
|
if (force_scale_) {
|
||||||
if (scale_ == UIScale::kSmall) {
|
if (scale_ == UIScale::kSmall) {
|
||||||
ScreenMessage("FORCING SMALL UI FOR TESTING", Vector3f(1, 0, 0));
|
ScreenMessage("FORCING SMALL UI FOR TESTING", Vector3f(1, 0, 0));
|
||||||
Log(LogName::kBa, LogLevel::kInfo, "FORCING SMALL UI FOR TESTING");
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
|
"FORCING SMALL UI FOR TESTING");
|
||||||
} else if (scale_ == UIScale::kMedium) {
|
} else if (scale_ == UIScale::kMedium) {
|
||||||
ScreenMessage("FORCING MEDIUM UI FOR TESTING", Vector3f(1, 0, 0));
|
ScreenMessage("FORCING MEDIUM UI FOR TESTING", Vector3f(1, 0, 0));
|
||||||
Log(LogName::kBa, LogLevel::kInfo, "FORCING MEDIUM UI FOR TESTING");
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
|
"FORCING MEDIUM UI FOR TESTING");
|
||||||
} else if (scale_ == UIScale::kLarge) {
|
} else if (scale_ == UIScale::kLarge) {
|
||||||
ScreenMessage("FORCING LARGE UI FOR TESTING", Vector3f(1, 0, 0));
|
ScreenMessage("FORCING LARGE UI FOR TESTING", Vector3f(1, 0, 0));
|
||||||
Log(LogName::kBa, LogLevel::kInfo, "FORCING LARGE UI FOR TESTING");
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
|
"FORCING LARGE UI FOR TESTING");
|
||||||
} else {
|
} else {
|
||||||
FatalError("Unhandled scale.");
|
FatalError("Unhandled scale.");
|
||||||
}
|
}
|
||||||
@ -577,8 +580,8 @@ void UI::ShowURL(const std::string& url) {
|
|||||||
g_base->logic->event_loop()->PushCall(
|
g_base->logic->event_loop()->PushCall(
|
||||||
[ui_delegate, url] { ui_delegate->DoShowURL(url); });
|
[ui_delegate, url] { ui_delegate->DoShowURL(url); });
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"UI::ShowURL called without ui_delegate present.");
|
"UI::ShowURL called without ui_delegate present.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -151,9 +151,9 @@ auto ClassicFeatureSet::GetV1AccountLoginStateString() -> std::string {
|
|||||||
out = "signing_in";
|
out = "signing_in";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Unknown V1LoginState '" + std::to_string(static_cast<int>(state))
|
"Unknown V1LoginState '"
|
||||||
+ "'");
|
+ std::to_string(static_cast<int>(state)) + "'");
|
||||||
out = "signed_out";
|
out = "signed_out";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,10 +128,10 @@ void ClassicAppMode::Reset_() {
|
|||||||
|
|
||||||
// If all is well our sessions should all be dead at this point.
|
// If all is well our sessions should all be dead at this point.
|
||||||
if (g_scene_v1->session_count != 0) {
|
if (g_scene_v1->session_count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneV1 session count is non-zero ("
|
"SceneV1 session count is non-zero ("
|
||||||
+ std::to_string(g_scene_v1->session_count)
|
+ std::to_string(g_scene_v1->session_count)
|
||||||
+ ") on ClassicAppMode::Reset_().");
|
+ ") on ClassicAppMode::Reset_().");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the engine itself to a default state.
|
// Reset the engine itself to a default state.
|
||||||
@ -160,16 +160,16 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
scan_socket_ = socket(AF_INET, SOCK_DGRAM, 0);
|
scan_socket_ = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
if (scan_socket_ == -1) {
|
if (scan_socket_ == -1) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error opening scan socket: "
|
"Error opening scan socket: "
|
||||||
+ g_core->platform->GetSocketErrorString() + ".");
|
+ g_core->platform->GetSocketErrorString() + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since this guy lives in the logic-thread we need it to not block.
|
// Since this guy lives in the logic-thread we need it to not block.
|
||||||
if (!g_core->platform->SetSocketNonBlocking(scan_socket_)) {
|
if (!g_core->platform->SetSocketNonBlocking(scan_socket_)) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error setting socket non-blocking.");
|
"Error setting socket non-blocking.");
|
||||||
g_core->platform->CloseSocket(scan_socket_);
|
g_core->platform->CloseSocket(scan_socket_);
|
||||||
scan_socket_ = -1;
|
scan_socket_ = -1;
|
||||||
return;
|
return;
|
||||||
@ -184,9 +184,9 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
int result =
|
int result =
|
||||||
::bind(scan_socket_, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
|
::bind(scan_socket_, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error binding socket: " + g_core->platform->GetSocketErrorString()
|
"Error binding socket: "
|
||||||
+ ".");
|
+ g_core->platform->GetSocketErrorString() + ".");
|
||||||
g_core->platform->CloseSocket(scan_socket_);
|
g_core->platform->CloseSocket(scan_socket_);
|
||||||
scan_socket_ = -1;
|
scan_socket_ = -1;
|
||||||
return;
|
return;
|
||||||
@ -198,9 +198,9 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
sizeof(op_val));
|
sizeof(op_val));
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error enabling broadcast for scan-socket: "
|
"Error enabling broadcast for scan-socket: "
|
||||||
+ g_core->platform->GetSocketErrorString() + ".");
|
+ g_core->platform->GetSocketErrorString() + ".");
|
||||||
g_core->platform->CloseSocket(scan_socket_);
|
g_core->platform->CloseSocket(scan_socket_);
|
||||||
scan_socket_ = -1;
|
scan_socket_ = -1;
|
||||||
return;
|
return;
|
||||||
@ -232,9 +232,9 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
case ENETUNREACH:
|
case ENETUNREACH:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error on scan-socket sendto: "
|
"Error on scan-socket sendto: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,9 +256,9 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error: recvfrom error: "
|
"Error: recvfrom error: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -315,12 +315,12 @@ void ClassicAppMode::HostScanCycle() {
|
|||||||
PruneScanResults_();
|
PruneScanResults_();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet");
|
"Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet");
|
"Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,8 +392,8 @@ bool ClassicAppMode::HasConnectionToClients() const {
|
|||||||
auto ClassicAppMode::GetActiveOrWarn() -> ClassicAppMode* {
|
auto ClassicAppMode::GetActiveOrWarn() -> ClassicAppMode* {
|
||||||
auto* val{GetActive()};
|
auto* val{GetActive()};
|
||||||
if (val == nullptr) {
|
if (val == nullptr) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Attempting to access ClassicAppMode while it is inactive.");
|
"Attempting to access ClassicAppMode while it is inactive.");
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@ -573,9 +573,9 @@ void ClassicAppMode::StepDisplayTime() {
|
|||||||
|
|
||||||
// Complain when our full update takes longer than 1/60th second.
|
// Complain when our full update takes longer than 1/60th second.
|
||||||
if (duration > (1000 / 60)) {
|
if (duration > (1000 / 60)) {
|
||||||
Log(LogName::kBa, LogLevel::kInfo,
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
"Logic::StepDisplayTime update took too long ("
|
"Logic::StepDisplayTime update took too long ("
|
||||||
+ std::to_string(duration) + " ms).");
|
+ std::to_string(duration) + " ms).");
|
||||||
|
|
||||||
// Limit these if we want (not doing so for now).
|
// Limit these if we want (not doing so for now).
|
||||||
next_long_update_report_time_ = app_time;
|
next_long_update_report_time_ = app_time;
|
||||||
@ -1230,8 +1230,8 @@ void ClassicAppMode::PruneSessions_() {
|
|||||||
try {
|
try {
|
||||||
i.Clear();
|
i.Clear();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Exception killing Session: " + std::string(e.what()));
|
"Exception killing Session: " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
have_dead_session = true;
|
have_dead_session = true;
|
||||||
}
|
}
|
||||||
@ -1418,8 +1418,8 @@ void ClassicAppMode::HandleQuitOnIdle_() {
|
|||||||
if (!idle_exiting_ && idle_seconds > (idle_exit_minutes_.value() * 60.0f)) {
|
if (!idle_exiting_ && idle_seconds > (idle_exit_minutes_.value() * 60.0f)) {
|
||||||
idle_exiting_ = true;
|
idle_exiting_ = true;
|
||||||
|
|
||||||
Log(LogName::kBa, LogLevel::kInfo,
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
"Quitting due to reaching idle-exit-minutes.");
|
"Quitting due to reaching idle-exit-minutes.");
|
||||||
g_base->logic->event_loop()->PushCall([] { g_base->logic->Shutdown(); });
|
g_base->logic->event_loop()->PushCall([] { g_base->logic->Shutdown(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1478,8 +1478,8 @@ void ClassicAppMode::HandleGameQuery(const char* buffer, size_t size,
|
|||||||
|
|
||||||
BA_PRECONDITION_FATAL(!usid.empty());
|
BA_PRECONDITION_FATAL(!usid.empty());
|
||||||
if (usid.size() > 100) {
|
if (usid.size() > 100) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"had to truncate session-id; shouldn't happen");
|
"had to truncate session-id; shouldn't happen");
|
||||||
usid.resize(100);
|
usid.resize(100);
|
||||||
}
|
}
|
||||||
if (usid.empty()) {
|
if (usid.empty()) {
|
||||||
@ -1505,9 +1505,9 @@ void ClassicAppMode::HandleGameQuery(const char* buffer, size_t size,
|
|||||||
g_base->network_writer->PushSendToCall(msg_buffer, SockAddr(*from));
|
g_base->network_writer->PushSendToCall(msg_buffer, SockAddr(*from));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid game-query packet of len " + std::to_string(size)
|
"Got invalid game-query packet of len " + std::to_string(size)
|
||||||
+ "; expected 5.");
|
+ "; expected 5.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "ballistica/core/platform/core_platform.h"
|
#include "ballistica/core/platform/core_platform.h"
|
||||||
#include "ballistica/core/python/core_python.h"
|
#include "ballistica/core/python/core_python.h"
|
||||||
#include "ballistica/shared/foundation/inline.h"
|
#include "ballistica/shared/foundation/inline.h"
|
||||||
|
#include "ballistica/shared/foundation/logging.h"
|
||||||
#include "ballistica/shared/foundation/macros.h"
|
#include "ballistica/shared/foundation/macros.h"
|
||||||
#include "ballistica/shared/foundation/types.h"
|
#include "ballistica/shared/foundation/types.h"
|
||||||
#include "ballistica/shared/generic/runnable.h"
|
#include "ballistica/shared/generic/runnable.h"
|
||||||
@ -230,7 +231,7 @@ auto CoreFeatureSet::CalcBuildSrcDir_() -> std::string {
|
|||||||
"core" BA_DIRSLASH "core.cc");
|
"core" BA_DIRSLASH "core.cc");
|
||||||
if (!f_end) {
|
if (!f_end) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Unable to calc build source dir from __FILE__.");
|
[] { return "Unable to calc build source dir from __FILE__."; });
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return std::string(f).substr(0, f_end - f);
|
return std::string(f).substr(0, f_end - f);
|
||||||
@ -280,14 +281,16 @@ void CoreFeatureSet::RunSanityChecks_() {
|
|||||||
// from. Use this to adjust the filtering as necessary so the resulting
|
// from. Use this to adjust the filtering as necessary so the resulting
|
||||||
// type name matches what is expected.
|
// type name matches what is expected.
|
||||||
if (explicit_bool(false)) {
|
if (explicit_bool(false)) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
Log(LogName::kBa, LogLevel::kError, [] {
|
||||||
"static_type_name check; name is '"
|
return "static_type_name check; name is '"
|
||||||
+ static_type_name<decltype(g_core)>() + "' debug_full is '"
|
+ static_type_name<decltype(g_core)>() + "' debug_full is '"
|
||||||
+ static_type_name<decltype(g_core)>(true) + "'");
|
+ static_type_name<decltype(g_core)>(true) + "'";
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
});
|
||||||
"static_type_name check; name is '"
|
Log(LogName::kBa, LogLevel::kError, [] {
|
||||||
+ static_type_name<decltype(testrunnable)>() + "' debug_full is '"
|
return "static_type_name check; name is '"
|
||||||
+ static_type_name<decltype(testrunnable)>(true) + "'");
|
+ static_type_name<decltype(testrunnable)>() + "' debug_full is '"
|
||||||
|
+ static_type_name<decltype(testrunnable)>(true) + "'";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vr_mode_ && !g_buildconfig.vr_build()) {
|
if (vr_mode_ && !g_buildconfig.vr_build()) {
|
||||||
@ -324,6 +327,30 @@ void CoreFeatureSet::LifecycleLog(const char* msg, double offset_seconds) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreFeatureSet::Log(LogName name, LogLevel level, char* msg) {
|
||||||
|
// Avoid touching the Python layer if the log will get ignored there
|
||||||
|
// anyway.
|
||||||
|
if (LogLevelEnabled(name, level)) {
|
||||||
|
Logging::Log(name, level, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreFeatureSet::Log(LogName name, LogLevel level, const char* msg) {
|
||||||
|
// Avoid touching the Python layer if the log will get ignored there
|
||||||
|
// anyway.
|
||||||
|
if (LogLevelEnabled(name, level)) {
|
||||||
|
Logging::Log(name, level, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreFeatureSet::Log(LogName name, LogLevel level, const std::string& msg) {
|
||||||
|
// Avoid touching the Python layer if the log will get ignored there
|
||||||
|
// anyway.
|
||||||
|
if (LogLevelEnabled(name, level)) {
|
||||||
|
Logging::Log(name, level, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto CoreFeatureSet::HeadlessMode() -> bool {
|
auto CoreFeatureSet::HeadlessMode() -> bool {
|
||||||
// This is currently a hard-coded value but could theoretically change
|
// This is currently a hard-coded value but could theoretically change
|
||||||
// later if we support running in headless mode from a gui build/etc.
|
// later if we support running in headless mode from a gui build/etc.
|
||||||
|
|||||||
@ -208,10 +208,22 @@ class CoreFeatureSet {
|
|||||||
return ba_env_launch_timestamp_;
|
return ba_env_launch_timestamp_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Log(LogName name, LogLevel level, const std::string& msg);
|
||||||
|
void Log(LogName name, LogLevel level, const char* msg);
|
||||||
|
void Log(LogName name, LogLevel level, char* msg);
|
||||||
|
|
||||||
|
template <typename C>
|
||||||
|
void Log(LogName name, LogLevel level, C getmsgcall) {
|
||||||
|
if (!LogLevelEnabled(name, level)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log(name, level, getmsgcall());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CoreFeatureSet(CoreConfig config);
|
explicit CoreFeatureSet(CoreConfig config);
|
||||||
static void DoImport_(const CoreConfig& config);
|
static void DoImport_(const CoreConfig& config);
|
||||||
static auto CalcBuildSrcDir_() -> std::string;
|
auto CalcBuildSrcDir_() -> std::string;
|
||||||
void RunSanityChecks_();
|
void RunSanityChecks_();
|
||||||
void UpdateAppTime_();
|
void UpdateAppTime_();
|
||||||
void PostInit_();
|
void PostInit_();
|
||||||
|
|||||||
@ -178,11 +178,12 @@ auto CorePlatform::GetLegacyDeviceUUID() -> const std::string& {
|
|||||||
if (FILE* f2 = FOpen(path.c_str(), "wb")) {
|
if (FILE* f2 = FOpen(path.c_str(), "wb")) {
|
||||||
size_t result = fwrite(val.c_str(), val.size(), 1, f2);
|
size_t result = fwrite(val.c_str(), val.size(), 1, f2);
|
||||||
if (result != 1)
|
if (result != 1)
|
||||||
Log(LogName::kBa, LogLevel::kError, "unable to write bsuuid file.");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"unable to write bsuuid file.");
|
||||||
fclose(f2);
|
fclose(f2);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"unable to open bsuuid file for writing: '" + path + "'");
|
"unable to open bsuuid file for writing: '" + path + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,8 +193,8 @@ auto CorePlatform::GetLegacyDeviceUUID() -> const std::string& {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto CorePlatform::GetDeviceV1AccountUUIDPrefix() -> std::string {
|
auto CorePlatform::GetDeviceV1AccountUUIDPrefix() -> std::string {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GetDeviceV1AccountUUIDPrefix() unimplemented");
|
"GetDeviceV1AccountUUIDPrefix() unimplemented");
|
||||||
return "u";
|
return "u";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,12 +250,12 @@ void CorePlatform::SetLowLevelConfigValue(const char* key, int value) {
|
|||||||
if (f) {
|
if (f) {
|
||||||
size_t result = fwrite(out.c_str(), out.size(), 1, f);
|
size_t result = fwrite(out.c_str(), out.size(), 1, f);
|
||||||
if (result != 1)
|
if (result != 1)
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"unable to write low level config file.");
|
"unable to write low level config file.");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"unable to open low level config file for writing.");
|
"unable to open low level config file for writing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +692,8 @@ auto CorePlatform::ConvertIncomingLeaderboardScore(
|
|||||||
|
|
||||||
void CorePlatform::SubmitScore(const std::string& game,
|
void CorePlatform::SubmitScore(const std::string& game,
|
||||||
const std::string& version, int64_t score) {
|
const std::string& version, int64_t score) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "FIXME: SubmitScore() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"FIXME: SubmitScore() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::ReportAchievement(const std::string& achievement) {}
|
void CorePlatform::ReportAchievement(const std::string& achievement) {}
|
||||||
@ -704,8 +706,8 @@ auto CorePlatform::HaveLeaderboard(const std::string& game,
|
|||||||
void CorePlatform::ShowGameServiceUI(const std::string& show,
|
void CorePlatform::ShowGameServiceUI(const std::string& show,
|
||||||
const std::string& game,
|
const std::string& game,
|
||||||
const std::string& game_version) {
|
const std::string& game_version) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"FIXME: ShowGameServiceUI() unimplemented");
|
"FIXME: ShowGameServiceUI() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::AndroidSetResString(const std::string& res) {
|
void CorePlatform::AndroidSetResString(const std::string& res) {
|
||||||
@ -748,29 +750,30 @@ auto CorePlatform::DemangleCXXSymbol(const std::string& s) -> std::string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::ResetAchievements() {
|
void CorePlatform::ResetAchievements() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "ResetAchievements() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"ResetAchievements() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::RunEvents() {}
|
void CorePlatform::RunEvents() {}
|
||||||
|
|
||||||
void CorePlatform::MusicPlayerPlay(PyObject* target) {
|
void CorePlatform::MusicPlayerPlay(PyObject* target) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MusicPlayerPlay() unimplemented on this platform");
|
"MusicPlayerPlay() unimplemented on this platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MusicPlayerStop() {
|
void CorePlatform::MusicPlayerStop() {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MusicPlayerStop() unimplemented on this platform");
|
"MusicPlayerStop() unimplemented on this platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MusicPlayerShutdown() {
|
void CorePlatform::MusicPlayerShutdown() {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MusicPlayerShutdown() unimplemented on this platform");
|
"MusicPlayerShutdown() unimplemented on this platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MusicPlayerSetVolume(float volume) {
|
void CorePlatform::MusicPlayerSetVolume(float volume) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MusicPlayerSetVolume() unimplemented on this platform");
|
"MusicPlayerSetVolume() unimplemented on this platform");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CorePlatform::IsOSPlayingMusic() -> bool { return false; }
|
auto CorePlatform::IsOSPlayingMusic() -> bool { return false; }
|
||||||
@ -792,7 +795,7 @@ void CorePlatform::SubmitAnalyticsCounts() {}
|
|||||||
void CorePlatform::SetPlatformMiscReadVals(const std::string& vals) {}
|
void CorePlatform::SetPlatformMiscReadVals(const std::string& vals) {}
|
||||||
|
|
||||||
void CorePlatform::ShowAd(const std::string& purpose) {
|
void CorePlatform::ShowAd(const std::string& purpose) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "ShowAd() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError, "ShowAd() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CorePlatform::GetHasAds() -> bool { return false; }
|
auto CorePlatform::GetHasAds() -> bool { return false; }
|
||||||
@ -803,7 +806,7 @@ auto CorePlatform::GetHasVideoAds() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::SignInV1(const std::string& account_type) {
|
void CorePlatform::SignInV1(const std::string& account_type) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "SignInV1() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError, "SignInV1() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::V1LoginDidChange() {
|
void CorePlatform::V1LoginDidChange() {
|
||||||
@ -811,35 +814,39 @@ void CorePlatform::V1LoginDidChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::SignOutV1() {
|
void CorePlatform::SignOutV1() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "SignOutV1() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError, "SignOutV1() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MacMusicAppInit() {
|
void CorePlatform::MacMusicAppInit() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "MacMusicAppInit() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"MacMusicAppInit() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CorePlatform::MacMusicAppGetVolume() -> int {
|
auto CorePlatform::MacMusicAppGetVolume() -> int {
|
||||||
Log(LogName::kBa, LogLevel::kError, "MacMusicAppGetVolume() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"MacMusicAppGetVolume() unimplemented");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MacMusicAppSetVolume(int volume) {
|
void CorePlatform::MacMusicAppSetVolume(int volume) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "MacMusicAppSetVolume() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"MacMusicAppSetVolume() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlatform::MacMusicAppStop() {
|
void CorePlatform::MacMusicAppStop() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "MacMusicAppStop() unimplemented");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"MacMusicAppStop() unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto CorePlatform::MacMusicAppPlayPlaylist(const std::string& playlist)
|
auto CorePlatform::MacMusicAppPlayPlaylist(const std::string& playlist)
|
||||||
-> bool {
|
-> bool {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MacMusicAppPlayPlaylist() unimplemented");
|
"MacMusicAppPlayPlaylist() unimplemented");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto CorePlatform::MacMusicAppGetPlaylists() -> std::list<std::string> {
|
auto CorePlatform::MacMusicAppGetPlaylists() -> std::list<std::string> {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"MacMusicAppGetPlaylists() unimplemented");
|
"MacMusicAppGetPlaylists() unimplemented");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -944,9 +951,9 @@ auto CorePlatform::SetSocketNonBlocking(int sd) -> bool {
|
|||||||
#else
|
#else
|
||||||
int result = fcntl(sd, F_SETFL, O_NONBLOCK);
|
int result = fcntl(sd, F_SETFL, O_NONBLOCK);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error setting non-blocking socket: "
|
"Error setting non-blocking socket: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -919,8 +919,8 @@ auto CorePlatformWindows::GetEnv(const std::string& name)
|
|||||||
|
|
||||||
// This should always succeed at this point; make noise if not.
|
// This should always succeed at this point; make noise if not.
|
||||||
if (result == 0 || result > big_buffer.size()) {
|
if (result == 0 || result > big_buffer.size()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GetEnv to allocated buffer failed; unexpected.");
|
"GetEnv to allocated buffer failed; unexpected.");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return UTF8Encode(big_buffer.data());
|
return UTF8Encode(big_buffer.data());
|
||||||
@ -998,15 +998,16 @@ std::vector<uint32_t> CorePlatformWindows::GetBroadcastAddrs() {
|
|||||||
pIPAddrTable = static_cast<MIB_IPADDRTABLE*>(MALLOC(dwSize));
|
pIPAddrTable = static_cast<MIB_IPADDRTABLE*>(MALLOC(dwSize));
|
||||||
}
|
}
|
||||||
if (pIPAddrTable == nullptr) {
|
if (pIPAddrTable == nullptr) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Memory allocation failed for GetIpAddrTable\n");
|
"Memory allocation failed for GetIpAddrTable\n");
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
// Make a second call to GetIpAddrTable to get the actual data we want
|
// Make a second call to GetIpAddrTable to get the actual data we want
|
||||||
if ((dwRetVal = GetIpAddrTable(pIPAddrTable, &dwSize, 0)) != NO_ERROR) {
|
if ((dwRetVal = GetIpAddrTable(pIPAddrTable, &dwSize, 0)) != NO_ERROR) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"GetIpAddrTable failed with error " + std::to_string(dwRetVal));
|
"GetIpAddrTable failed with error " + std::to_string(dwRetVal));
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
@ -1042,9 +1043,9 @@ bool CorePlatformWindows::SetSocketNonBlocking(int sd) {
|
|||||||
unsigned long dataval = 1; // NOLINT (func signature wants long)
|
unsigned long dataval = 1; // NOLINT (func signature wants long)
|
||||||
int result = ioctlsocket(sd, FIONBIO, &dataval);
|
int result = ioctlsocket(sd, FIONBIO, &dataval);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error setting non-blocking socket: "
|
"Error setting non-blocking socket: "
|
||||||
+ g_core->platform->GetSocketErrorString());
|
+ g_core->platform->GetSocketErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -189,6 +189,8 @@ void CorePython::EnablePythonLoggingCalls() {
|
|||||||
assert(objs().Exists(ObjID::kLoggerBaLogCall));
|
assert(objs().Exists(ObjID::kLoggerBaLogCall));
|
||||||
assert(objs().Exists(ObjID::kLoggerBaAudio));
|
assert(objs().Exists(ObjID::kLoggerBaAudio));
|
||||||
assert(objs().Exists(ObjID::kLoggerBaAudioLogCall));
|
assert(objs().Exists(ObjID::kLoggerBaAudioLogCall));
|
||||||
|
assert(objs().Exists(ObjID::kLoggerBaDisplayTime));
|
||||||
|
assert(objs().Exists(ObjID::kLoggerBaDisplayTimeLogCall));
|
||||||
assert(objs().Exists(ObjID::kLoggerBaGraphics));
|
assert(objs().Exists(ObjID::kLoggerBaGraphics));
|
||||||
assert(objs().Exists(ObjID::kLoggerBaGraphicsLogCall));
|
assert(objs().Exists(ObjID::kLoggerBaGraphicsLogCall));
|
||||||
assert(objs().Exists(ObjID::kLoggerBaLifecycle));
|
assert(objs().Exists(ObjID::kLoggerBaLifecycle));
|
||||||
@ -260,6 +262,7 @@ void CorePython::UpdateInternalLoggerLevels(LogLevel* log_levels) {
|
|||||||
{LogName::kBa, ObjID::kLoggerBa},
|
{LogName::kBa, ObjID::kLoggerBa},
|
||||||
{LogName::kBaAudio, ObjID::kLoggerBaAudio},
|
{LogName::kBaAudio, ObjID::kLoggerBaAudio},
|
||||||
{LogName::kBaGraphics, ObjID::kLoggerBaGraphics},
|
{LogName::kBaGraphics, ObjID::kLoggerBaGraphics},
|
||||||
|
{LogName::kBaDisplayTime, ObjID::kLoggerBaDisplayTime},
|
||||||
{LogName::kBaLifecycle, ObjID::kLoggerBaLifecycle},
|
{LogName::kBaLifecycle, ObjID::kLoggerBaLifecycle},
|
||||||
{LogName::kBaAssets, ObjID::kLoggerBaAssets},
|
{LogName::kBaAssets, ObjID::kLoggerBaAssets},
|
||||||
{LogName::kBaInput, ObjID::kLoggerBaInput},
|
{LogName::kBaInput, ObjID::kLoggerBaInput},
|
||||||
@ -439,6 +442,10 @@ void CorePython::LoggingCall(LogName logname, LogLevel loglevel,
|
|||||||
logcallobj = ObjID::kLoggerBaGraphicsLogCall;
|
logcallobj = ObjID::kLoggerBaGraphicsLogCall;
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
case LogName::kBaDisplayTime:
|
||||||
|
logcallobj = ObjID::kLoggerBaDisplayTimeLogCall;
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
case LogName::kBaAssets:
|
case LogName::kBaAssets:
|
||||||
logcallobj = ObjID::kLoggerBaAssetsLogCall;
|
logcallobj = ObjID::kLoggerBaAssetsLogCall;
|
||||||
handled = true;
|
handled = true;
|
||||||
|
|||||||
@ -36,6 +36,8 @@ class CorePython {
|
|||||||
kLoggerBaLogCall,
|
kLoggerBaLogCall,
|
||||||
kLoggerBaAudio,
|
kLoggerBaAudio,
|
||||||
kLoggerBaAudioLogCall,
|
kLoggerBaAudioLogCall,
|
||||||
|
kLoggerBaDisplayTime,
|
||||||
|
kLoggerBaDisplayTimeLogCall,
|
||||||
kLoggerBaGraphics,
|
kLoggerBaGraphics,
|
||||||
kLoggerBaGraphicsLogCall,
|
kLoggerBaGraphicsLogCall,
|
||||||
kLoggerBaLifecycle,
|
kLoggerBaLifecycle,
|
||||||
|
|||||||
@ -156,7 +156,8 @@ void Connection::HandleGamePacketCompressed(const std::vector<uint8_t>& data) {
|
|||||||
try {
|
try {
|
||||||
data_decompressed = g_base->huffman->decompress(data);
|
data_decompressed = g_base->huffman->decompress(data);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
std::string("Error in huffman decompression for packet: ") + e.what());
|
std::string("Error in huffman decompression for packet: ") + e.what());
|
||||||
|
|
||||||
// Hmmm i guess lets just ignore this packet and keep on trucking?.. or
|
// Hmmm i guess lets just ignore this packet and keep on trucking?.. or
|
||||||
@ -190,8 +191,8 @@ void Connection::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
|
|
||||||
// Expect 1 byte type, 2 byte num, 3 byte acks, at least 1 byte payload.
|
// Expect 1 byte type, 2 byte num, 3 byte acks, at least 1 byte payload.
|
||||||
if (data.size() < 7) {
|
if (data.size() < 7) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid BA_PACKET_STATE packet.");
|
"Got invalid BA_PACKET_STATE packet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t num;
|
uint16_t num;
|
||||||
@ -222,8 +223,8 @@ void Connection::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
// Expect 1 byte type, 2 byte num, 2 byte unreliable-num, 3 byte acks,
|
// Expect 1 byte type, 2 byte num, 2 byte unreliable-num, 3 byte acks,
|
||||||
// at least 1 byte payload.
|
// at least 1 byte payload.
|
||||||
if (data.size() < 9) {
|
if (data.size() < 9) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid BA_PACKET_STATE_UNRELIABLE packet.");
|
"Got invalid BA_PACKET_STATE_UNRELIABLE packet.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint16_t num, num_unreliable;
|
uint16_t num, num_unreliable;
|
||||||
@ -244,9 +245,9 @@ void Connection::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Connection got unknown packet type: "
|
"Connection got unknown packet type: "
|
||||||
+ std::to_string(static_cast<int>(data[0])));
|
+ std::to_string(static_cast<int>(data[0])));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,8 +442,8 @@ void Connection::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
multipart_buffer_.resize(old_size + (buffer.size() - 1));
|
multipart_buffer_.resize(old_size + (buffer.size() - 1));
|
||||||
memcpy(&(multipart_buffer_[old_size]), &(buffer[1]), buffer.size() - 1);
|
memcpy(&(multipart_buffer_[old_size]), &(buffer[1]), buffer.size() - 1);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"got invalid BA_MESSAGE_MULTIPART");
|
"got invalid BA_MESSAGE_MULTIPART");
|
||||||
}
|
}
|
||||||
if (buffer[0] == BA_MESSAGE_MULTIPART_END) {
|
if (buffer[0] == BA_MESSAGE_MULTIPART_END) {
|
||||||
if (multipart_buffer_[0] == BA_MESSAGE_MULTIPART) {
|
if (multipart_buffer_[0] == BA_MESSAGE_MULTIPART) {
|
||||||
|
|||||||
@ -31,9 +31,9 @@ void ConnectionSet::RegisterClientController(ClientControllerInterface* c) {
|
|||||||
// This shouldn't happen, but if there's already a controller registered,
|
// This shouldn't happen, but if there's already a controller registered,
|
||||||
// detach all clients from it.
|
// detach all clients from it.
|
||||||
if (client_controller_) {
|
if (client_controller_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"RegisterClientController() called "
|
"RegisterClientController() called "
|
||||||
"but already have a controller; bad.");
|
"but already have a controller; bad.");
|
||||||
for (auto&& i : connections_to_clients_) {
|
for (auto&& i : connections_to_clients_) {
|
||||||
assert(i.second.Exists());
|
assert(i.second.Exists());
|
||||||
i.second->SetController(nullptr);
|
i.second->SetController(nullptr);
|
||||||
@ -214,8 +214,8 @@ auto ConnectionSet::GetConnectionsToClients()
|
|||||||
if (connections_to_client.second.Exists()) {
|
if (connections_to_client.second.Exists()) {
|
||||||
connections.push_back(connections_to_client.second.Get());
|
connections.push_back(connections_to_client.second.Get());
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"HAVE NONEXISTENT CONNECTION_TO_CLIENT IN LIST; UNEXPECTED");
|
"HAVE NONEXISTENT CONNECTION_TO_CLIENT IN LIST; UNEXPECTED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return connections;
|
return connections;
|
||||||
@ -274,7 +274,8 @@ void ConnectionSet::SendScreenMessageToAll(const std::string& s, float r,
|
|||||||
void ConnectionSet::PrepareForLaunchHostSession() {
|
void ConnectionSet::PrepareForLaunchHostSession() {
|
||||||
// If for some reason we're still attached to a host, kill the connection.
|
// If for some reason we're still attached to a host, kill the connection.
|
||||||
if (connection_to_host_.Exists()) {
|
if (connection_to_host_.Exists()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Had host-connection during LaunchHostSession(); shouldn't happen.");
|
"Had host-connection during LaunchHostSession(); shouldn't happen.");
|
||||||
connection_to_host_->RequestDisconnect();
|
connection_to_host_->RequestDisconnect();
|
||||||
connection_to_host_.Clear();
|
connection_to_host_.Clear();
|
||||||
@ -320,9 +321,9 @@ auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (client_id > 255) {
|
if (client_id > 255) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"DisconnectClient got client_id > 255 (" + std::to_string(client_id)
|
"DisconnectClient got client_id > 255 ("
|
||||||
+ ")");
|
+ std::to_string(client_id) + ")");
|
||||||
} else {
|
} else {
|
||||||
std::vector<uint8_t> msg_out(2);
|
std::vector<uint8_t> msg_out(2);
|
||||||
msg_out[0] = BA_MESSAGE_KICK_VOTE;
|
msg_out[0] = BA_MESSAGE_KICK_VOTE;
|
||||||
@ -410,9 +411,9 @@ void ConnectionSet::UnregisterClientController(ClientControllerInterface* c) {
|
|||||||
|
|
||||||
// This shouldn't happen.
|
// This shouldn't happen.
|
||||||
if (client_controller_ != c) {
|
if (client_controller_ != c) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"UnregisterClientController() called with a non-registered "
|
"UnregisterClientController() called with a non-registered "
|
||||||
"controller");
|
"controller");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,8 +677,8 @@ void ConnectionSet::HandleIncomingUDPPacket(const std::vector<uint8_t>& data_in,
|
|||||||
msg_out[0] = BA_PACKET_CLIENT_DENY;
|
msg_out[0] = BA_PACKET_CLIENT_DENY;
|
||||||
msg_out[1] = request_id;
|
msg_out[1] = request_id;
|
||||||
g_base->network_writer->PushSendToCall(msg_out, addr);
|
g_base->network_writer->PushSendToCall(msg_out, addr);
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"All client slots full; really?..");
|
"All client slots full; really?..");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
connection_to_client = Object::New<ConnectionToClientUDP>(
|
connection_to_client = Object::New<ConnectionToClientUDP>(
|
||||||
@ -732,9 +733,9 @@ void ConnectionSet::SetClientInfoFromMasterServer(
|
|||||||
const std::string& client_token, PyObject* info_obj) {
|
const std::string& client_token, PyObject* info_obj) {
|
||||||
// NOLINTNEXTLINE (python doing bitwise math on signed int)
|
// NOLINTNEXTLINE (python doing bitwise math on signed int)
|
||||||
if (!PyDict_Check(info_obj)) {
|
if (!PyDict_Check(info_obj)) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"got non-dict for master-server client info for token " + client_token
|
"got non-dict for master-server client info for token "
|
||||||
+ ": " + Python::ObjToString(info_obj));
|
+ client_token + ": " + Python::ObjToString(info_obj));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (ConnectionToClient* client : GetConnectionsToClients()) {
|
for (ConnectionToClient* client : GetConnectionsToClients()) {
|
||||||
|
|||||||
@ -144,8 +144,8 @@ void ConnectionToClient::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ConnectionToClient got data size 0.");
|
"ConnectionToClient got data size 0.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +158,8 @@ void ConnectionToClient::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
case BA_SCENEPACKET_HANDSHAKE_RESPONSE: {
|
case BA_SCENEPACKET_HANDSHAKE_RESPONSE: {
|
||||||
// We sent the client a handshake and they're responding.
|
// We sent the client a handshake and they're responding.
|
||||||
if (data.size() < 3) {
|
if (data.size() < 3) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"got invalid BA_SCENEPACKET_HANDSHAKE_RESPONSE");
|
"got invalid BA_SCENEPACKET_HANDSHAKE_RESPONSE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,8 +352,8 @@ void ConnectionToClient::SendScreenMessage(const std::string& s, float r,
|
|||||||
void ConnectionToClient::HandleMessagePacket(
|
void ConnectionToClient::HandleMessagePacket(
|
||||||
const std::vector<uint8_t>& buffer) {
|
const std::vector<uint8_t>& buffer) {
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid HandleMessagePacket.");
|
"Got invalid HandleMessagePacket.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +407,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
if (b) {
|
if (b) {
|
||||||
build_number_ = b->valueint;
|
build_number_ = b->valueint;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"No buildnumber in clientinfo msg.");
|
"No buildnumber in clientinfo msg.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab their token (we use this to ask the
|
// Grab their token (we use this to ask the
|
||||||
@ -417,8 +417,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
if (t) {
|
if (t) {
|
||||||
token_ = t->valuestring;
|
token_ = t->valuestring;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"No token in clientinfo msg.");
|
"No token in clientinfo msg.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Newer clients also pass a peer-hash, which
|
// Newer clients also pass a peer-hash, which
|
||||||
@ -437,7 +437,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
}
|
}
|
||||||
cJSON_Delete(info);
|
cJSON_Delete(info);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid json in clientinfo message: '"
|
"Got invalid json in clientinfo message: '"
|
||||||
+ std::string(reinterpret_cast<const char*>(&(buffer[1])))
|
+ std::string(reinterpret_cast<const char*>(&(buffer[1])))
|
||||||
+ "'.");
|
+ "'.");
|
||||||
@ -506,8 +507,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
// spamming before we can verify their identities)
|
// spamming before we can verify their identities)
|
||||||
if (appmode->require_client_authentication()
|
if (appmode->require_client_authentication()
|
||||||
&& !got_info_from_master_server_) {
|
&& !got_info_from_master_server_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Ignoring chat message from peer with no client info.");
|
"Ignoring chat message from peer with no client info.");
|
||||||
SendScreenMessage(R"({"r":"loadingTryAgainText"})", 1, 0, 0);
|
SendScreenMessage(R"({"r":"loadingTryAgainText"})", 1, 0, 0);
|
||||||
} else if (last_chat_times_.size() >= 5) {
|
} else if (last_chat_times_.size() >= 5) {
|
||||||
chat_block_time_ = now + next_chat_block_seconds_ * 1000;
|
chat_block_time_ = now + next_chat_block_seconds_ * 1000;
|
||||||
@ -604,8 +605,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
GetClientInputDevice(buffer[1])) {
|
GetClientInputDevice(buffer[1])) {
|
||||||
int count = static_cast<int>((buffer.size() - 2) / 5);
|
int count = static_cast<int>((buffer.size() - 2) / 5);
|
||||||
if ((buffer.size() - 2) % 5 != 0) {
|
if ((buffer.size() - 2) % 5 != 0) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error: invalid player-input-commands packet");
|
"Error: invalid player-input-commands packet");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int index = 2;
|
int index = 2;
|
||||||
@ -623,8 +624,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
case BA_MESSAGE_REMOVE_REMOTE_PLAYER: {
|
case BA_MESSAGE_REMOVE_REMOTE_PLAYER: {
|
||||||
last_remove_player_time_ = g_core->GetAppTimeMillisecs();
|
last_remove_player_time_ = g_core->GetAppTimeMillisecs();
|
||||||
if (buffer.size() != 2) {
|
if (buffer.size() != 2) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error: invalid remove-remote-player packet");
|
"Error: invalid remove-remote-player packet");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ClientInputDevice* cid = GetClientInputDevice(buffer[1])) {
|
if (ClientInputDevice* cid = GetClientInputDevice(buffer[1])) {
|
||||||
@ -639,7 +640,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
host_session->RemovePlayer(player);
|
host_session->RemovePlayer(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unable to get ClientInputDevice for remove-remote-player msg.");
|
"Unable to get ClientInputDevice for remove-remote-player msg.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,8 +650,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
|
|
||||||
case BA_MESSAGE_REQUEST_REMOTE_PLAYER: {
|
case BA_MESSAGE_REQUEST_REMOTE_PLAYER: {
|
||||||
if (buffer.size() != 2) {
|
if (buffer.size() != 2) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error: invalid remote-player-request packet");
|
"Error: invalid remote-player-request packet");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +662,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
// It should have one of our special client delegates attached.
|
// It should have one of our special client delegates attached.
|
||||||
auto* cid_d = dynamic_cast<ClientInputDeviceDelegate*>(&cid->delegate());
|
auto* cid_d = dynamic_cast<ClientInputDeviceDelegate*>(&cid->delegate());
|
||||||
if (!cid_d) {
|
if (!cid_d) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Can't get client-input-device-delegate in request-remote-player "
|
"Can't get client-input-device-delegate in request-remote-player "
|
||||||
"msg.");
|
"msg.");
|
||||||
break;
|
break;
|
||||||
@ -684,7 +687,8 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
} else {
|
} else {
|
||||||
// Either timed out or have info; let the request go through.
|
// Either timed out or have info; let the request go through.
|
||||||
if (still_waiting_for_auth) {
|
if (still_waiting_for_auth) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Allowing player-request without client\'s master-server "
|
"Allowing player-request without client\'s master-server "
|
||||||
"info (build "
|
"info (build "
|
||||||
+ std::to_string(build_number_) + ")");
|
+ std::to_string(build_number_) + ")");
|
||||||
@ -693,9 +697,9 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ConnectionToClient got remote player"
|
"ConnectionToClient got remote player"
|
||||||
" request but have no host session");
|
" request but have no host session");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -707,9 +711,9 @@ void ConnectionToClient::HandleMessagePacket(
|
|||||||
if (multipart_buffer_size() > 50000) {
|
if (multipart_buffer_size() > 50000) {
|
||||||
// Its not actually unknown but shhh don't tell the hackers...
|
// Its not actually unknown but shhh don't tell the hackers...
|
||||||
SendScreenMessage(R"({"r":"errorUnknownText"})", 1, 0, 0);
|
SendScreenMessage(R"({"r":"errorUnknownText"})", 1, 0, 0);
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Client data limit exceeded by '" + peer_spec().GetShortName()
|
"Client data limit exceeded by '"
|
||||||
+ "'; kicking.");
|
+ peer_spec().GetShortName() + "'; kicking.");
|
||||||
appmode->BanPlayer(peer_spec(), 1000 * 60);
|
appmode->BanPlayer(peer_spec(), 1000 * 60);
|
||||||
Error("");
|
Error("");
|
||||||
return;
|
return;
|
||||||
@ -800,9 +804,9 @@ void ConnectionToClient::HandleMasterServerClientInfo(PyObject* info_obj) {
|
|||||||
"{\"t\":[\"serverResponses\","
|
"{\"t\":[\"serverResponses\","
|
||||||
"\"Your account was rejected. Are you signed in?\"]}",
|
"\"Your account was rejected. Are you signed in?\"]}",
|
||||||
1, 0, 0);
|
1, 0, 0);
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Master server found no valid account for '"
|
"Master server found no valid account for '"
|
||||||
+ peer_spec().GetShortName() + "'; kicking.");
|
+ peer_spec().GetShortName() + "'; kicking.");
|
||||||
|
|
||||||
// Not benning anymore. People were exploiting this by impersonating
|
// Not benning anymore. People were exploiting this by impersonating
|
||||||
// other players using their public ids to get them banned from
|
// other players using their public ids to get them banned from
|
||||||
|
|||||||
@ -72,8 +72,8 @@ void ConnectionToClientUDP::HandleGamePacket(
|
|||||||
|
|
||||||
void ConnectionToClientUDP::Die() {
|
void ConnectionToClientUDP::Die() {
|
||||||
if (did_die_) {
|
if (did_die_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Posting multiple die messages; probably not good.");
|
"Posting multiple die messages; probably not good.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// this will actually clear the object..
|
// this will actually clear the object..
|
||||||
|
|||||||
@ -250,8 +250,8 @@ void ConnectionToHost::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
g_base->python->GetRawConfigValue("Player Profiles");
|
g_base->python->GetRawConfigValue("Player Profiles");
|
||||||
PythonRef empty_dict;
|
PythonRef empty_dict;
|
||||||
if (!profiles) {
|
if (!profiles) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"No profiles found; sending empty list to host");
|
"No profiles found; sending empty list to host");
|
||||||
empty_dict.Steal(PyDict_New());
|
empty_dict.Steal(PyDict_New());
|
||||||
profiles = empty_dict.Get();
|
profiles = empty_dict.Get();
|
||||||
}
|
}
|
||||||
@ -265,8 +265,8 @@ void ConnectionToHost::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
.Get(core::CorePython::ObjID::kJsonDumpsCall)
|
.Get(core::CorePython::ObjID::kJsonDumpsCall)
|
||||||
.Call(args, keywds);
|
.Call(args, keywds);
|
||||||
if (!results.Exists()) {
|
if (!results.Exists()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Error getting json dump of local profiles");
|
"Error getting json dump of local profiles");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// Pull the string as utf8 and send.
|
// Pull the string as utf8 and send.
|
||||||
@ -276,15 +276,16 @@ void ConnectionToHost::HandleGamePacket(const std::vector<uint8_t>& data) {
|
|||||||
memcpy(&(msg[1]), &s[0], s.size());
|
memcpy(&(msg[1]), &s[0], s.size());
|
||||||
SendReliableMessage(msg);
|
SendReliableMessage(msg);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
std::string("Error sending player profiles to host: ")
|
std::string("Error sending player profiles to host: ")
|
||||||
+ e.what());
|
+ e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Connected to old protocol; can't send player profiles");
|
"Connected to old protocol; can't send player profiles");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -311,8 +312,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
assert(g_base->InLogicThread());
|
assert(g_base->InLogicThread());
|
||||||
|
|
||||||
if (buffer.empty()) {
|
if (buffer.empty()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Got invalid HandleMessagePacket");
|
"Got invalid HandleMessagePacket");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,8 +337,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
if (b) {
|
if (b) {
|
||||||
build_number_ = b->valueint;
|
build_number_ = b->valueint;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"no buildnumber in hostinfo msg");
|
"no buildnumber in hostinfo msg");
|
||||||
}
|
}
|
||||||
// Party name.
|
// Party name.
|
||||||
cJSON* n = cJSON_GetObjectItem(info, "n");
|
cJSON* n = cJSON_GetObjectItem(info, "n");
|
||||||
@ -346,8 +347,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
}
|
}
|
||||||
cJSON_Delete(info);
|
cJSON_Delete(info);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"got invalid json in hostinfo message");
|
"got invalid json in hostinfo message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
got_host_info_ = true;
|
got_host_info_ = true;
|
||||||
@ -443,8 +444,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
case BA_MESSAGE_ATTACH_REMOTE_PLAYER_2: {
|
case BA_MESSAGE_ATTACH_REMOTE_PLAYER_2: {
|
||||||
// New-style packet which includes a 32-bit player_id.
|
// New-style packet which includes a 32-bit player_id.
|
||||||
if (buffer.size() != 6) {
|
if (buffer.size() != 6) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Invalid attach-remote-player-2 msg");
|
"Invalid attach-remote-player-2 msg");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +462,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
delegate->AttachToRemotePlayer(this,
|
delegate->AttachToRemotePlayer(this,
|
||||||
static_cast_check_fit<int>(player_id));
|
static_cast_check_fit<int>(player_id));
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"InputDevice does not have a SceneV1 delegate as expected "
|
"InputDevice does not have a SceneV1 delegate as expected "
|
||||||
"(loc1).");
|
"(loc1).");
|
||||||
}
|
}
|
||||||
@ -480,8 +482,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
// public servers.
|
// public servers.
|
||||||
// TODO(ericf): can remove this once back-compat-protocol > 29.
|
// TODO(ericf): can remove this once back-compat-protocol > 29.
|
||||||
if (buffer.size() != 3) {
|
if (buffer.size() != 3) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Invalid attach-remote-player msg.");
|
"Invalid attach-remote-player msg.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +497,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
&input_device->delegate())) {
|
&input_device->delegate())) {
|
||||||
delegate->AttachToRemotePlayer(this, buffer[2]);
|
delegate->AttachToRemotePlayer(this, buffer[2]);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"InputDevice does not have a SceneV1 delegate as expected "
|
"InputDevice does not have a SceneV1 delegate as expected "
|
||||||
"(loc2).");
|
"(loc2).");
|
||||||
}
|
}
|
||||||
@ -513,8 +516,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
|
|
||||||
case BA_MESSAGE_DETACH_REMOTE_PLAYER: {
|
case BA_MESSAGE_DETACH_REMOTE_PLAYER: {
|
||||||
if (buffer.size() != 2) {
|
if (buffer.size() != 2) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Invalid detach-remote-player msg");
|
"Invalid detach-remote-player msg");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Server is telling us that our local input device is no longer
|
// Server is telling us that our local input device is no longer
|
||||||
@ -538,7 +541,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
|
|||||||
// be cleared out at this point. Just complain if that's not
|
// be cleared out at this point. Just complain if that's not
|
||||||
// the case.
|
// the case.
|
||||||
if (connection_to_host != nullptr) {
|
if (connection_to_host != nullptr) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"InputDevice does not have a SceneV1 delegate as expected "
|
"InputDevice does not have a SceneV1 delegate as expected "
|
||||||
"(loc3).");
|
"(loc3).");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,8 +125,8 @@ void ConnectionToHostUDP::Update() {
|
|||||||
// departure before doing this when possible.
|
// departure before doing this when possible.
|
||||||
void ConnectionToHostUDP::Die() {
|
void ConnectionToHostUDP::Die() {
|
||||||
if (did_die_) {
|
if (did_die_) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Posting multiple die messages; probably not good.");
|
"Posting multiple die messages; probably not good.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto* appmode = classic::ClassicAppMode::GetActiveOrWarn()) {
|
if (auto* appmode = classic::ClassicAppMode::GetActiveOrWarn()) {
|
||||||
@ -134,9 +134,9 @@ void ConnectionToHostUDP::Die() {
|
|||||||
appmode->connections()->PushDisconnectedFromHostCall();
|
appmode->connections()->PushDisconnectedFromHostCall();
|
||||||
did_die_ = true;
|
did_die_ = true;
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Running update for non-current host-connection; shouldn't "
|
"Running update for non-current host-connection; shouldn't "
|
||||||
"happen.");
|
"happen.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,9 +143,9 @@ Dynamics::Dynamics(Scene* scene_in)
|
|||||||
|
|
||||||
Dynamics::~Dynamics() {
|
Dynamics::~Dynamics() {
|
||||||
if (in_process_) {
|
if (in_process_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Dynamics going down within Process() call;"
|
"Dynamics going down within Process() call;"
|
||||||
" should not happen.");
|
" should not happen.");
|
||||||
}
|
}
|
||||||
ShutdownODE_();
|
ShutdownODE_();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,9 +215,9 @@ void MaterialComponent::Restore(const char** buffer, ClientSession* cs) {
|
|||||||
action = Object::New<NodeModMaterialAction>();
|
action = Object::New<NodeModMaterialAction>();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Invalid material action: '"
|
"Invalid material action: '"
|
||||||
+ std::to_string(static_cast<int>(type)) + "'.");
|
+ std::to_string(static_cast<int>(type)) + "'.");
|
||||||
throw Exception();
|
throw Exception();
|
||||||
}
|
}
|
||||||
action->Restore(buffer, cs);
|
action->Restore(buffer, cs);
|
||||||
|
|||||||
@ -99,8 +99,8 @@ void Part::SetCollidingWith(int64_t node_id, int part, bool colliding,
|
|||||||
for (auto&& i : collisions_) {
|
for (auto&& i : collisions_) {
|
||||||
if (i.node == node_id && i.part == part) {
|
if (i.node == node_id && i.part == part) {
|
||||||
BA_PRECONDITION(node());
|
BA_PRECONDITION(node());
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got SetCollidingWith for part already colliding with.");
|
"Got SetCollidingWith for part already colliding with.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,9 +120,9 @@ void Part::SetCollidingWith(int64_t node_id, int part, bool colliding,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Got SetCollidingWith (separated) call for part we're "
|
"Got SetCollidingWith (separated) call for part we're "
|
||||||
"not colliding with.");
|
"not colliding with.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ void RigidBody::Check() {
|
|||||||
if (std::isnan(q[3])) err = true;
|
if (std::isnan(q[3])) err = true;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Got error in rbd values!");
|
g_core->Log(LogName::kBa, LogLevel::kError, "Got error in rbd values!");
|
||||||
}
|
}
|
||||||
#if BA_DEBUG_BUILD
|
#if BA_DEBUG_BUILD
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|||||||
@ -112,9 +112,9 @@ GlobalsNode::GlobalsNode(Scene* scene) : Node(scene, node_type) {
|
|||||||
// FIXME: Need to update this for non-host activities at some point.
|
// FIXME: Need to update this for non-host activities at some point.
|
||||||
if (HostActivity* ha = context_ref().GetHostActivity()) {
|
if (HostActivity* ha = context_ref().GetHostActivity()) {
|
||||||
if (ha->globals_node()) {
|
if (ha->globals_node()) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"More than one globals node created in HostActivity; this "
|
"More than one globals node created in HostActivity; this "
|
||||||
"shouldn't happen");
|
"shouldn't happen");
|
||||||
}
|
}
|
||||||
ha->SetGlobalsNode(this);
|
ha->SetGlobalsNode(this);
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,8 @@
|
|||||||
namespace ballistica::scene_v1 {
|
namespace ballistica::scene_v1 {
|
||||||
|
|
||||||
NodeType::~NodeType() {
|
NodeType::~NodeType() {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SHOULD NOT BE DESTRUCTING A TYPE type=(" + name_ + ")");
|
"SHOULD NOT BE DESTRUCTING A TYPE type=(" + name_ + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::Node(Scene* scene_in, NodeType* node_type)
|
Node::Node(Scene* scene_in, NodeType* node_type)
|
||||||
@ -265,7 +265,8 @@ void Node::DispatchOutOfBoundsMessage() {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node OutOfBoundsMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node OutOfBoundsMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating OutOfBoundsMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error creating OutOfBoundsMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +283,7 @@ void Node::DispatchPickUpMessage(Node* node) {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node PickUpMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node PickUpMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating PickUpMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError, "Error creating PickUpMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +298,7 @@ void Node::DispatchDropMessage() {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node DropMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node DropMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating DropMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError, "Error creating DropMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +316,8 @@ void Node::DispatchPickedUpMessage(Node* by_node) {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node PickedUpMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node PickedUpMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating PickedUpMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error creating PickedUpMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +335,8 @@ void Node::DispatchDroppedMessage(Node* by_node) {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node DroppedMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node DroppedMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating DroppedMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error creating DroppedMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +351,8 @@ void Node::DispatchShouldShatterMessage() {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node ShouldShatterMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node ShouldShatterMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating ShouldShatterMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error creating ShouldShatterMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +368,8 @@ void Node::DispatchImpactDamageMessage(float intensity) {
|
|||||||
if (instance.Exists()) {
|
if (instance.Exists()) {
|
||||||
DispatchUserMessage(instance.Get(), "Node ImpactDamageMessage dispatch");
|
DispatchUserMessage(instance.Get(), "Node ImpactDamageMessage dispatch");
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error creating ImpactDamageMessage");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"Error creating ImpactDamageMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,10 +397,10 @@ void Node::DispatchUserMessage(PyObject* obj, const char* label) {
|
|||||||
c.Call(PythonRef(Py_BuildValue("(O)", obj), PythonRef::kSteal));
|
c.Call(PythonRef(Py_BuildValue("(O)", obj), PythonRef::kSteal));
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
std::string("Error in handlemessage() with message ")
|
std::string("Error in handlemessage() with message ")
|
||||||
+ PythonRef(obj, PythonRef::kAcquire).Str() + ": '" + e.what()
|
+ PythonRef(obj, PythonRef::kAcquire).Str() + ": '"
|
||||||
+ "'");
|
+ e.what() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,8 @@ auto NodeAttributeUnbound::GetNodeAttributeTypeName(NodeAttributeType t)
|
|||||||
case NodeAttributeType::kCollisionMeshArray:
|
case NodeAttributeType::kCollisionMeshArray:
|
||||||
return "collision-mesh-array";
|
return "collision-mesh-array";
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Unknown attr type name: " + std::to_string(static_cast<int>(t)));
|
"Unknown attr type name: " + std::to_string(static_cast<int>(t)));
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
@ -102,8 +103,8 @@ void NodeAttributeUnbound::DisconnectIncoming(Node* node) {
|
|||||||
|
|
||||||
#if BA_DEBUG_BUILD
|
#if BA_DEBUG_BUILD
|
||||||
if (test_ref.Exists()) {
|
if (test_ref.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Attr connection still exists after ref releases!");
|
"Attr connection still exists after ref releases!");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,13 +97,13 @@ void NodeAttributeConnection::Update() {
|
|||||||
src_node->type()->GetAttribute(src_attr_index);
|
src_node->type()->GetAttribute(src_attr_index);
|
||||||
NodeAttributeUnbound* dst_attr =
|
NodeAttributeUnbound* dst_attr =
|
||||||
dst_node->type()->GetAttribute(dst_attr_index);
|
dst_node->type()->GetAttribute(dst_attr_index);
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Attribute connection update: " + std::string(e.what())
|
"Attribute connection update: " + std::string(e.what())
|
||||||
+ "; srcAttr='" + src_attr->name() + "', src_node='"
|
+ "; srcAttr='" + src_attr->name() + "', src_node='"
|
||||||
+ src_node->type()->name() + "', srcNodeName='"
|
+ src_node->type()->name() + "', srcNodeName='"
|
||||||
+ src_node->label() + "', dstAttr='" + dst_attr->name()
|
+ src_node->label() + "', dstAttr='" + dst_attr->name()
|
||||||
+ "', dstNode='" + dst_node->type()->name() + "', dstNodeName='"
|
+ "', dstNode='" + dst_node->type()->name()
|
||||||
+ dst_node->label() + "'");
|
+ "', dstNodeName='" + dst_node->label() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -274,8 +274,8 @@ void PropNode::SetBody(const std::string& val) {
|
|||||||
// we're ok with redundant sets, but complain/ignore if they try to switch..
|
// we're ok with redundant sets, but complain/ignore if they try to switch..
|
||||||
if (body_.Exists()) {
|
if (body_.Exists()) {
|
||||||
if (body_type_ != body_type || shape_ != shape) {
|
if (body_type_ != body_type || shape_ != shape) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"body attr can not be changed from its initial value");
|
"body attr can not be changed from its initial value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -436,9 +436,9 @@ void PropNode::Step() {
|
|||||||
if (body_type_ == BodyType::UNSET) {
|
if (body_type_ == BodyType::UNSET) {
|
||||||
if (!reported_unset_body_type_) {
|
if (!reported_unset_body_type_) {
|
||||||
reported_unset_body_type_ = true;
|
reported_unset_body_type_ = true;
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"prop-node " + GetObjectDescription()
|
"prop-node " + GetObjectDescription()
|
||||||
+ " did not have its 'body' attr set.");
|
+ " did not have its 'body' attr set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5977,8 +5977,8 @@ auto SpazNode::GetRigidBody(int id) -> RigidBody* {
|
|||||||
return hair_ponytail_bottom_body_.Get();
|
return hair_ponytail_bottom_body_.Get();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Request for unknown spaz body: " + std::to_string(id));
|
"Request for unknown spaz body: " + std::to_string(id));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6698,25 +6698,30 @@ void SpazNode::SetHoldNode(Node* val) {
|
|||||||
assert(dynamics);
|
assert(dynamics);
|
||||||
Collision* c = dynamics->active_collision();
|
Collision* c = dynamics->active_collision();
|
||||||
if (c) {
|
if (c) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"SRC NODE: " + ObjToString(dynamics->GetActiveCollideSrcNode()));
|
"SRC NODE: " + ObjToString(dynamics->GetActiveCollideSrcNode()));
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"OPP NODE: " + ObjToString(dynamics->GetActiveCollideDstNode()));
|
"OPP NODE: " + ObjToString(dynamics->GetActiveCollideDstNode()));
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"SRC BODY "
|
"SRC BODY "
|
||||||
+ std::to_string(dynamics->GetCollideMessageReverseOrder()
|
+ std::to_string(dynamics->GetCollideMessageReverseOrder()
|
||||||
? c->body_id_1
|
? c->body_id_1
|
||||||
: c->body_id_2));
|
: c->body_id_2));
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"OPP BODY "
|
"OPP BODY "
|
||||||
+ std::to_string(dynamics->GetCollideMessageReverseOrder()
|
+ std::to_string(dynamics->GetCollideMessageReverseOrder()
|
||||||
? c->body_id_2
|
? c->body_id_2
|
||||||
: c->body_id_1));
|
: c->body_id_1));
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"REVERSE "
|
"REVERSE "
|
||||||
+ std::to_string(dynamics->GetCollideMessageReverseOrder()));
|
+ std::to_string(dynamics->GetCollideMessageReverseOrder()));
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError, "<NO ACTIVE COLLISION>");
|
g_core->Log(LogName::kBa, LogLevel::kError, "<NO ACTIVE COLLISION>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw Exception("specified hold_body (" + std::to_string(hold_body_)
|
throw Exception("specified hold_body (" + std::to_string(hold_body_)
|
||||||
|
|||||||
@ -438,8 +438,8 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self,
|
|||||||
.Get(base::BasePython::ObjID::kLstrFromJsonCall)
|
.Get(base::BasePython::ObjID::kLstrFromJsonCall)
|
||||||
.Call(args2);
|
.Call(args2);
|
||||||
if (!results.Exists()) {
|
if (!results.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error creating Lstr from raw button name: '" + bname + "'");
|
"Error creating Lstr from raw button name: '" + bname + "'");
|
||||||
PythonRef args3(Py_BuildValue("(s)", "?"), PythonRef::kSteal);
|
PythonRef args3(Py_BuildValue("(s)", "?"), PythonRef::kSteal);
|
||||||
results = g_base->python->objs()
|
results = g_base->python->objs()
|
||||||
.Get(base::BasePython::ObjID::kLstrFromJsonCall)
|
.Get(base::BasePython::ObjID::kLstrFromJsonCall)
|
||||||
|
|||||||
@ -653,7 +653,7 @@ static auto PyBroadcastMessage(PyObject* self, PyObject* args, PyObject* keywds)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (log) {
|
if (log) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kInfo, message);
|
g_core->Log(LogName::kBaNetworking, LogLevel::kInfo, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transient messages get sent to clients as high-level messages instead of
|
// Transient messages get sent to clients as high-level messages instead of
|
||||||
@ -751,8 +751,8 @@ static auto PyBroadcastMessage(PyObject* self, PyObject* args, PyObject* keywds)
|
|||||||
tint_color.x, tint_color.y, tint_color.z, tint2_color.x,
|
tint_color.x, tint_color.y, tint_color.z, tint2_color.x,
|
||||||
tint2_color.y, tint2_color.z);
|
tint2_color.y, tint2_color.z);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Unhandled screenmessage output_stream case.");
|
"Unhandled screenmessage output_stream case.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,7 +862,7 @@ static auto PyPrintNodes(PyObject* self, PyObject* args) -> PyObject* {
|
|||||||
snprintf(buffer, sizeof(buffer), "#%d: type: %-14s desc: %s", count,
|
snprintf(buffer, sizeof(buffer), "#%d: type: %-14s desc: %s", count,
|
||||||
i->type()->name().c_str(), i->label().c_str());
|
i->type()->name().c_str(), i->label().c_str());
|
||||||
s += buffer;
|
s += buffer;
|
||||||
Log(LogName::kBa, LogLevel::kInfo, buffer);
|
g_core->Log(LogName::kBa, LogLevel::kInfo, buffer);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|||||||
@ -367,10 +367,10 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* {
|
|||||||
attr_vals.emplace_back(
|
attr_vals.emplace_back(
|
||||||
t->GetAttribute(std::string(PyUnicode_AsUTF8(key))), value);
|
t->GetAttribute(std::string(PyUnicode_AsUTF8(key))), value);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Attr not found on initial attr set: '"
|
"Attr not found on initial attr set: '"
|
||||||
+ std::string(PyUnicode_AsUTF8(key)) + "' on " + type
|
+ std::string(PyUnicode_AsUTF8(key)) + "' on " + type
|
||||||
+ " node '" + name + "'");
|
+ " node '" + name + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,9 +380,9 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* {
|
|||||||
try {
|
try {
|
||||||
SetNodeAttr(node, i.first->name().c_str(), i.second);
|
SetNodeAttr(node, i.first->name().c_str(), i.second);
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Exception in initial attr set for attr '" + i.first->name()
|
"Exception in initial attr set for attr '" + i.first->name()
|
||||||
+ "' on " + type + " node '" + name + "':" + e.what());
|
+ "' on " + type + " node '" + name + "':" + e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,12 +395,12 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* {
|
|||||||
if (PythonClassNode::Check(owner_obj)) {
|
if (PythonClassNode::Check(owner_obj)) {
|
||||||
Node* owner_node = GetPyNode(owner_obj, true);
|
Node* owner_node = GetPyNode(owner_obj, true);
|
||||||
if (owner_node == nullptr) {
|
if (owner_node == nullptr) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Empty node-ref passed for 'owner'; pass None if you want "
|
"Empty node-ref passed for 'owner'; pass None if you want "
|
||||||
"no owner.");
|
"no owner.");
|
||||||
} else if (owner_node->scene() != node->scene()) {
|
} else if (owner_node->scene() != node->scene()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Owner node is from a different scene; ignoring.");
|
"Owner node is from a different scene; ignoring.");
|
||||||
} else {
|
} else {
|
||||||
owner_node->AddDependentNode(node);
|
owner_node->AddDependentNode(node);
|
||||||
}
|
}
|
||||||
@ -420,9 +420,9 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* {
|
|||||||
}
|
}
|
||||||
node->OnCreate();
|
node->OnCreate();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Exception in OnCreate() for node " + ballistica::ObjToString(node)
|
"Exception in OnCreate() for node "
|
||||||
+ "':" + e.what());
|
+ ballistica::ObjToString(node) + "':" + e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
@ -1141,7 +1141,8 @@ auto SceneV1Python::FilterChatMessage(std::string* message, int client_id)
|
|||||||
try {
|
try {
|
||||||
*message = g_base->python->GetPyLString(result.Get());
|
*message = g_base->python->GetPyLString(result.Get());
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Error getting string from chat filter: " + std::string(e.what()));
|
"Error getting string from chat filter: " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -65,7 +65,8 @@ auto ClientInputDeviceDelegate::GetClientID() const -> int {
|
|||||||
if (ConnectionToClient* c = connection_to_client_.Get()) {
|
if (ConnectionToClient* c = connection_to_client_.Get()) {
|
||||||
return c->id();
|
return c->id();
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ClientInputDevice::get_client_id(): connection_to_client no longer "
|
"ClientInputDevice::get_client_id(): connection_to_client no longer "
|
||||||
"exists; returning -1..");
|
"exists; returning -1..");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -200,7 +200,8 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) {
|
|||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
if (current_cmd_ptr_ != nullptr) {
|
if (current_cmd_ptr_ != nullptr) {
|
||||||
if (current_cmd_ptr_ != &(current_cmd_[0]) + current_cmd_.size()) {
|
if (current_cmd_ptr_ != &(current_cmd_[0]) + current_cmd_.size()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"SIZE ERROR FOR CMD "
|
"SIZE ERROR FOR CMD "
|
||||||
+ std::to_string(static_cast<int>(current_cmd_[0]))
|
+ std::to_string(static_cast<int>(current_cmd_[0]))
|
||||||
+ " expected " + std::to_string(current_cmd_.size())
|
+ " expected " + std::to_string(current_cmd_.size())
|
||||||
@ -969,8 +970,8 @@ auto ClientSession::GetCollisionMesh(int id) const -> SceneCollisionMesh* {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClientSession::Error(const std::string& description) {
|
void ClientSession::Error(const std::string& description) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"Client session error: " + description);
|
"Client session error: " + description);
|
||||||
End();
|
End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,9 +17,9 @@ namespace ballistica::scene_v1 {
|
|||||||
ClientSessionNet::ClientSessionNet() {
|
ClientSessionNet::ClientSessionNet() {
|
||||||
// Sanity check: we should only ever be writing one replay at once.
|
// Sanity check: we should only ever be writing one replay at once.
|
||||||
if (g_scene_v1->replay_open) {
|
if (g_scene_v1->replay_open) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"g_scene_v1->replay_open true at netclient start;"
|
"g_scene_v1->replay_open true at netclient start;"
|
||||||
" shouldn't happen.");
|
" shouldn't happen.");
|
||||||
}
|
}
|
||||||
assert(g_base->assets_server);
|
assert(g_base->assets_server);
|
||||||
|
|
||||||
@ -33,9 +33,9 @@ ClientSessionNet::~ClientSessionNet() {
|
|||||||
if (writing_replay_) {
|
if (writing_replay_) {
|
||||||
// Sanity check: we should only ever be writing one replay at once.
|
// Sanity check: we should only ever be writing one replay at once.
|
||||||
if (!g_scene_v1->replay_open) {
|
if (!g_scene_v1->replay_open) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"g_scene_v1->replay_open false at net-client close;"
|
"g_scene_v1->replay_open false at net-client close;"
|
||||||
" shouldn't happen.");
|
" shouldn't happen.");
|
||||||
}
|
}
|
||||||
g_scene_v1->replay_open = false;
|
g_scene_v1->replay_open = false;
|
||||||
assert(g_base->assets_server);
|
assert(g_base->assets_server);
|
||||||
|
|||||||
@ -69,17 +69,17 @@ void ClientSessionReplay::OnClientConnected(ConnectionToClient* c) {
|
|||||||
// sanity check - abort if its on either of our lists already
|
// sanity check - abort if its on either of our lists already
|
||||||
for (ConnectionToClient* i : connections_to_clients_) {
|
for (ConnectionToClient* i : connections_to_clients_) {
|
||||||
if (i == c) {
|
if (i == c) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ReplayClientSession::OnClientConnected()"
|
"ReplayClientSession::OnClientConnected()"
|
||||||
" got duplicate connection");
|
" got duplicate connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ConnectionToClient* i : connections_to_clients_ignored_) {
|
for (ConnectionToClient* i : connections_to_clients_ignored_) {
|
||||||
if (i == c) {
|
if (i == c) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ReplayClientSession::OnClientConnected()"
|
"ReplayClientSession::OnClientConnected()"
|
||||||
" got duplicate connection");
|
" got duplicate connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,9 +139,9 @@ void ClientSessionReplay::OnClientDisconnected(ConnectionToClient* c) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"ReplayClientSession::OnClientDisconnected()"
|
"ReplayClientSession::OnClientDisconnected()"
|
||||||
" called for connection not on lists");
|
" called for connection not on lists");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientSessionReplay::FetchMessages() {
|
void ClientSessionReplay::FetchMessages() {
|
||||||
|
|||||||
@ -111,7 +111,7 @@ HostActivity::~HostActivity() {
|
|||||||
for (auto& python_call : context_calls_)
|
for (auto& python_call : context_calls_)
|
||||||
s += "\n " + std::to_string(count++) + ": "
|
s += "\n " + std::to_string(count++) + ": "
|
||||||
+ (*python_call).GetObjectDescription();
|
+ (*python_call).GetObjectDescription();
|
||||||
Log(LogName::kBa, LogLevel::kWarning, s);
|
g_core->Log(LogName::kBa, LogLevel::kWarning, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,28 +157,29 @@ void HostActivity::RegisterContextCall(base::PythonContextCall* call) {
|
|||||||
// If we're shutting down, just kill the call immediately.
|
// If we're shutting down, just kill the call immediately.
|
||||||
// (we turn all of our calls to no-ops as we shut down)
|
// (we turn all of our calls to no-ops as we shut down)
|
||||||
if (shutting_down_) {
|
if (shutting_down_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Adding call to expired activity; call will not function: "
|
"Adding call to expired activity; call will not function: "
|
||||||
+ call->GetObjectDescription());
|
+ call->GetObjectDescription());
|
||||||
call->MarkDead();
|
call->MarkDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostActivity::Start() {
|
void HostActivity::Start() {
|
||||||
if (started_) {
|
if (started_) {
|
||||||
Log(LogName::kBa, LogLevel::kError, "HostActivity::Start() called twice.");
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
"HostActivity::Start() called twice.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
started_ = true;
|
started_ = true;
|
||||||
if (shutting_down_) {
|
if (shutting_down_) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"HostActivity::Start() called for shutting-down activity.");
|
"HostActivity::Start() called for shutting-down activity.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto* host_session = host_session_.Get();
|
auto* host_session = host_session_.Get();
|
||||||
if (!host_session) {
|
if (!host_session) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"HostActivity::Start() called with dead session.");
|
"HostActivity::Start() called with dead session.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create our step timer - gets called whenever scene should step.
|
// Create our step timer - gets called whenever scene should step.
|
||||||
@ -290,9 +291,9 @@ void HostActivity::HandleOutOfBoundsNodes() {
|
|||||||
// Make sure someone's handling our out-of-bounds messages.
|
// Make sure someone's handling our out-of-bounds messages.
|
||||||
out_of_bounds_in_a_row_++;
|
out_of_bounds_in_a_row_++;
|
||||||
if (out_of_bounds_in_a_row_ > 100) {
|
if (out_of_bounds_in_a_row_ > 100) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"100 consecutive out-of-bounds messages sent."
|
"100 consecutive out-of-bounds messages sent."
|
||||||
" They are probably not being handled properly");
|
" They are probably not being handled properly");
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (auto&& i : scene()->out_of_bounds_nodes()) {
|
for (auto&& i : scene()->out_of_bounds_nodes()) {
|
||||||
j++;
|
j++;
|
||||||
@ -303,10 +304,11 @@ void HostActivity::HandleOutOfBoundsNodes() {
|
|||||||
if (delegate) {
|
if (delegate) {
|
||||||
dstr = PythonRef(delegate, PythonRef::kAcquire).Str();
|
dstr = PythonRef(delegate, PythonRef::kAcquire).Str();
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
" node #" + std::to_string(j) + ": type='" + n->type()->name()
|
" node #" + std::to_string(j) + ": type='"
|
||||||
+ "' addr=" + Utils::PtrToString(i.Get()) + " name='"
|
+ n->type()->name()
|
||||||
+ n->label() + "' delegate=" + dstr);
|
+ "' addr=" + Utils::PtrToString(i.Get()) + " name='"
|
||||||
|
+ n->label() + "' delegate=" + dstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out_of_bounds_in_a_row_ = 0;
|
out_of_bounds_in_a_row_ = 0;
|
||||||
|
|||||||
@ -218,8 +218,8 @@ void HostSession::RequestPlayer(SceneV1InputDeviceDelegate* device) {
|
|||||||
|
|
||||||
// Ignore if we have no Python session Obj.
|
// Ignore if we have no Python session Obj.
|
||||||
if (!GetSessionPyObj()) {
|
if (!GetSessionPyObj()) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
"HostSession::RequestPlayer() called w/no session_py_obj_.");
|
"HostSession::RequestPlayer() called w/no session_py_obj_.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,13 +312,13 @@ void HostSession::IssuePlayerLeft(Player* player) {
|
|||||||
BA_LOG_PYTHON_TRACE_ONCE("missing player on IssuePlayerLeft");
|
BA_LOG_PYTHON_TRACE_ONCE("missing player on IssuePlayerLeft");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kWarning,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kWarning,
|
||||||
"HostSession: IssuePlayerLeft caled with no "
|
"HostSession: IssuePlayerLeft caled with no "
|
||||||
"session_py_obj_");
|
"session_py_obj_");
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(LogName::kBaNetworking, LogLevel::kError,
|
||||||
std::string("Error calling on_player_leave(): ") + e.what());
|
std::string("Error calling on_player_leave(): ") + e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,9 +338,9 @@ void HostSession::SetForegroundHostActivity(HostActivity* a) {
|
|||||||
auto* appmode = classic::ClassicAppMode::GetActiveOrFatal();
|
auto* appmode = classic::ClassicAppMode::GetActiveOrFatal();
|
||||||
|
|
||||||
if (shutting_down_) {
|
if (shutting_down_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"SetForegroundHostActivity called during session shutdown; "
|
"SetForegroundHostActivity called during session shutdown; "
|
||||||
"ignoring.");
|
"ignoring.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,11 +664,12 @@ HostSession::~HostSession() {
|
|||||||
s += ("\n " + std::to_string(count++) + ": "
|
s += ("\n " + std::to_string(count++) + ": "
|
||||||
+ i->GetObjectDescription());
|
+ i->GetObjectDescription());
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kWarning, s);
|
g_core->Log(LogName::kBa, LogLevel::kWarning, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"Exception in HostSession destructor: " + std::string(e.what()));
|
"Exception in HostSession destructor: " + std::string(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -686,9 +687,9 @@ void HostSession::RegisterContextCall(base::PythonContextCall* call) {
|
|||||||
// If we're shutting down, just kill the call immediately.
|
// If we're shutting down, just kill the call immediately.
|
||||||
// (we turn all of our calls to no-ops as we shut down).
|
// (we turn all of our calls to no-ops as we shut down).
|
||||||
if (shutting_down_) {
|
if (shutting_down_) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Adding call to expired session; call will not function: "
|
"Adding call to expired session; call will not function: "
|
||||||
+ call->GetObjectDescription());
|
+ call->GetObjectDescription());
|
||||||
call->MarkDead();
|
call->MarkDead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,8 +39,8 @@ PlayerSpec::PlayerSpec(const std::string& s) {
|
|||||||
cJSON_Delete(root_obj);
|
cJSON_Delete(root_obj);
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Error creating PlayerSpec from string: '" + s + "'");
|
"Error creating PlayerSpec from string: '" + s + "'");
|
||||||
name_ = "<error>";
|
name_ = "<error>";
|
||||||
short_name_ = "";
|
short_name_ = "";
|
||||||
// account_type_ = classic::V1AccountType::kInvalid;
|
// account_type_ = classic::V1AccountType::kInvalid;
|
||||||
@ -114,8 +114,8 @@ auto PlayerSpec::GetAccountPlayerSpec() -> PlayerSpec {
|
|||||||
}
|
}
|
||||||
if (spec.name_.size() > 100) {
|
if (spec.name_.size() > 100) {
|
||||||
// FIXME should perhaps clamp this in unicode space
|
// FIXME should perhaps clamp this in unicode space
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"account name size too long: '" + spec.name_ + "'");
|
"account name size too long: '" + spec.name_ + "'");
|
||||||
spec.name_.resize(100);
|
spec.name_.resize(100);
|
||||||
spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgaps3");
|
spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgaps3");
|
||||||
}
|
}
|
||||||
@ -127,8 +127,8 @@ auto PlayerSpec::GetDummyPlayerSpec(const std::string& name) -> PlayerSpec {
|
|||||||
spec.name_ = Utils::GetValidUTF8(name.c_str(), "bsgdps1");
|
spec.name_ = Utils::GetValidUTF8(name.c_str(), "bsgdps1");
|
||||||
if (spec.name_.size() > 100) {
|
if (spec.name_.size() > 100) {
|
||||||
// FIXME should perhaps clamp this in unicode space
|
// FIXME should perhaps clamp this in unicode space
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"dummy player spec name too long: '" + spec.name_ + "'");
|
"dummy player spec name too long: '" + spec.name_ + "'");
|
||||||
spec.name_.resize(100);
|
spec.name_.resize(100);
|
||||||
spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgdps2");
|
spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgdps2");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -216,8 +216,8 @@ void Scene::DeleteNode(Node* node) {
|
|||||||
// Sanity test: at this point the node should be dead.
|
// Sanity test: at this point the node should be dead.
|
||||||
#if BA_DEBUG_BUILD
|
#if BA_DEBUG_BUILD
|
||||||
if (temp_weak_ref.Exists()) {
|
if (temp_weak_ref.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Node still exists after ref release!!");
|
"Node still exists after ref release!!");
|
||||||
}
|
}
|
||||||
#endif // BA_DEBUG_BUILD
|
#endif // BA_DEBUG_BUILD
|
||||||
|
|
||||||
@ -401,9 +401,9 @@ void Scene::DumpNodes(SessionStream* out) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Invalid attr type for Scene::DumpNodes() attr set: "
|
"Invalid attr type for Scene::DumpNodes() attr set: "
|
||||||
+ std::to_string(static_cast<int>(attr.type())));
|
+ std::to_string(static_cast<int>(attr.type())));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,8 +77,8 @@ auto SceneV1Context::NewTimer(TimeType timetype, TimerMedium length,
|
|||||||
void SceneV1Context::DeleteTimer(TimeType timetype, int timer_id) {
|
void SceneV1Context::DeleteTimer(TimeType timetype, int timer_id) {
|
||||||
// We throw on NewTimer; lets just ignore anything that comes
|
// We throw on NewTimer; lets just ignore anything that comes
|
||||||
// through here to avoid messing up destructors.
|
// through here to avoid messing up destructors.
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"ContextTarget::DeleteTimer() called; unexpected.");
|
"ContextTarget::DeleteTimer() called; unexpected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SceneV1Context::GetTime(TimeType timetype) -> millisecs_t {
|
auto SceneV1Context::GetTime(TimeType timetype) -> millisecs_t {
|
||||||
|
|||||||
@ -65,15 +65,15 @@ void SceneV1InputDeviceDelegate::RequestPlayer() {
|
|||||||
BA_PRECONDITION_FATAL(appmode);
|
BA_PRECONDITION_FATAL(appmode);
|
||||||
|
|
||||||
if (player_.Exists()) {
|
if (player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::RequestPlayer()"
|
"InputDevice::RequestPlayer()"
|
||||||
" called with already-existing player");
|
" called with already-existing player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (remote_player_.Exists()) {
|
if (remote_player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::RequestPlayer() called with already-existing "
|
"InputDevice::RequestPlayer() called with already-existing "
|
||||||
"remote-player");
|
"remote-player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,17 +101,17 @@ void SceneV1InputDeviceDelegate::RequestPlayer() {
|
|||||||
// When the host-session tells us to attach to a player
|
// When the host-session tells us to attach to a player
|
||||||
void SceneV1InputDeviceDelegate::AttachToLocalPlayer(Player* player) {
|
void SceneV1InputDeviceDelegate::AttachToLocalPlayer(Player* player) {
|
||||||
if (player_.Exists()) {
|
if (player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::AttachToLocalPlayer() called with already "
|
"InputDevice::AttachToLocalPlayer() called with already "
|
||||||
"existing "
|
"existing "
|
||||||
"player");
|
"player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (remote_player_.Exists()) {
|
if (remote_player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::AttachToLocalPlayer() called with already "
|
"InputDevice::AttachToLocalPlayer() called with already "
|
||||||
"existing "
|
"existing "
|
||||||
"remote-player");
|
"remote-player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player_ = player;
|
player_ = player;
|
||||||
@ -122,17 +122,17 @@ void SceneV1InputDeviceDelegate::AttachToRemotePlayer(
|
|||||||
ConnectionToHost* connection_to_host, int remote_player_id) {
|
ConnectionToHost* connection_to_host, int remote_player_id) {
|
||||||
assert(connection_to_host);
|
assert(connection_to_host);
|
||||||
if (player_.Exists()) {
|
if (player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::AttachToRemotePlayer()"
|
"InputDevice::AttachToRemotePlayer()"
|
||||||
" called with already existing "
|
" called with already existing "
|
||||||
"player");
|
"player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (remote_player_.Exists()) {
|
if (remote_player_.Exists()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"InputDevice::AttachToRemotePlayer()"
|
"InputDevice::AttachToRemotePlayer()"
|
||||||
" called with already existing "
|
" called with already existing "
|
||||||
"remote-player");
|
"remote-player");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remote_player_ = connection_to_host;
|
remote_player_ = connection_to_host;
|
||||||
|
|||||||
@ -36,8 +36,8 @@ void Session::LanguageChanged() {}
|
|||||||
void Session::DebugSpeedMultChanged() {}
|
void Session::DebugSpeedMultChanged() {}
|
||||||
|
|
||||||
void Session::DumpFullState(SessionStream* out) {
|
void Session::DumpFullState(SessionStream* out) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Session::DumpFullState() being called; shouldn't happen.");
|
"Session::DumpFullState() being called; shouldn't happen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ballistica::scene_v1
|
} // namespace ballistica::scene_v1
|
||||||
|
|||||||
@ -31,9 +31,9 @@ SessionStream::SessionStream(HostSession* host_session, bool save_replay)
|
|||||||
if (save_replay) {
|
if (save_replay) {
|
||||||
// Sanity check - we should only ever be writing one replay at once.
|
// Sanity check - we should only ever be writing one replay at once.
|
||||||
if (g_scene_v1->replay_open) {
|
if (g_scene_v1->replay_open) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"g_scene_v1->replay_open true at replay start;"
|
"g_scene_v1->replay_open true at replay start;"
|
||||||
" shouldn't happen.");
|
" shouldn't happen.");
|
||||||
}
|
}
|
||||||
// We always write replays as the max protocol version we support.
|
// We always write replays as the max protocol version we support.
|
||||||
assert(g_base->assets_server);
|
assert(g_base->assets_server);
|
||||||
@ -57,9 +57,9 @@ SessionStream::~SessionStream() {
|
|||||||
if (writing_replay_) {
|
if (writing_replay_) {
|
||||||
// Sanity check: We should only ever be writing one replay at once.
|
// Sanity check: We should only ever be writing one replay at once.
|
||||||
if (!g_scene_v1->replay_open) {
|
if (!g_scene_v1->replay_open) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"g_scene_v1->replay_open false at replay close;"
|
"g_scene_v1->replay_open false at replay close;"
|
||||||
" shouldn't happen.");
|
" shouldn't happen.");
|
||||||
}
|
}
|
||||||
g_scene_v1->replay_open = false;
|
g_scene_v1->replay_open = false;
|
||||||
assert(g_base->assets_server);
|
assert(g_base->assets_server);
|
||||||
@ -78,40 +78,45 @@ SessionStream::~SessionStream() {
|
|||||||
size_t count;
|
size_t count;
|
||||||
count = GetPointerCount(scenes_);
|
count = GetPointerCount(scenes_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count)
|
std::to_string(count)
|
||||||
+ " scene graphs in output stream at shutdown");
|
+ " scene graphs in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(nodes_);
|
count = GetPointerCount(nodes_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count) + " nodes in output stream at shutdown");
|
std::to_string(count) + " nodes in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(materials_);
|
count = GetPointerCount(materials_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count) + " materials in output stream at shutdown");
|
std::to_string(count) + " materials in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(textures_);
|
count = GetPointerCount(textures_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count) + " textures in output stream at shutdown");
|
std::to_string(count) + " textures in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(meshes_);
|
count = GetPointerCount(meshes_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count) + " meshes in output stream at shutdown");
|
std::to_string(count) + " meshes in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(sounds_);
|
count = GetPointerCount(sounds_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count) + " sounds in output stream at shutdown");
|
std::to_string(count) + " sounds in output stream at shutdown");
|
||||||
}
|
}
|
||||||
count = GetPointerCount(collision_meshes_);
|
count = GetPointerCount(collision_meshes_);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
std::to_string(count)
|
std::to_string(count)
|
||||||
+ " collision_meshes in output stream at shutdown");
|
+ " collision_meshes in output stream at shutdown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,8 +127,8 @@ auto SessionStream::GetOutMessage() const -> std::vector<uint8_t> {
|
|||||||
assert(!host_session_); // this should only be getting used for
|
assert(!host_session_); // this should only be getting used for
|
||||||
// standalone temp ones..
|
// standalone temp ones..
|
||||||
if (!out_command_.empty()) {
|
if (!out_command_.empty()) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneStream shutting down with non-empty outCommand");
|
"SceneStream shutting down with non-empty outCommand");
|
||||||
}
|
}
|
||||||
return out_message_;
|
return out_message_;
|
||||||
}
|
}
|
||||||
@ -188,13 +193,13 @@ void SessionStream::Remove(T* val, std::vector<T*>* vec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SessionStream::Fail() {
|
void SessionStream::Fail() {
|
||||||
Log(LogName::kBa, LogLevel::kError, "Error writing replay file");
|
g_core->Log(LogName::kBa, LogLevel::kError, "Error writing replay file");
|
||||||
if (writing_replay_) {
|
if (writing_replay_) {
|
||||||
// Sanity check: We should only ever be writing one replay at once.
|
// Sanity check: We should only ever be writing one replay at once.
|
||||||
if (!g_scene_v1->replay_open) {
|
if (!g_scene_v1->replay_open) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"g_scene_v1->replay_open false at replay close;"
|
"g_scene_v1->replay_open false at replay close;"
|
||||||
" shouldn't happen.");
|
" shouldn't happen.");
|
||||||
}
|
}
|
||||||
assert(g_base->assets_server);
|
assert(g_base->assets_server);
|
||||||
g_base->assets_server->PushEndWriteReplayCall();
|
g_base->assets_server->PushEndWriteReplayCall();
|
||||||
@ -205,8 +210,8 @@ void SessionStream::Fail() {
|
|||||||
|
|
||||||
void SessionStream::Flush() {
|
void SessionStream::Flush() {
|
||||||
if (!out_command_.empty())
|
if (!out_command_.empty())
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneStream flushing down with non-empty outCommand");
|
"SceneStream flushing down with non-empty outCommand");
|
||||||
if (!out_message_.empty()) {
|
if (!out_message_.empty()) {
|
||||||
ShipSessionCommandsMessage();
|
ShipSessionCommandsMessage();
|
||||||
}
|
}
|
||||||
@ -535,8 +540,8 @@ void SessionStream::SetTime(millisecs_t t) {
|
|||||||
}
|
}
|
||||||
millisecs_t diff = t - time_;
|
millisecs_t diff = t - time_;
|
||||||
if (diff > 255) {
|
if (diff > 255) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneStream got time diff > 255; not expected.");
|
"SceneStream got time diff > 255; not expected.");
|
||||||
diff = 255;
|
diff = 255;
|
||||||
}
|
}
|
||||||
WriteCommandInt64(SessionCommand::kBaseTimeStep, diff);
|
WriteCommandInt64(SessionCommand::kBaseTimeStep, diff);
|
||||||
@ -1195,15 +1200,15 @@ void SessionStream::OnClientConnected(ConnectionToClient* c) {
|
|||||||
// Sanity check - abort if its on either of our lists already.
|
// Sanity check - abort if its on either of our lists already.
|
||||||
for (auto& connections_to_client : connections_to_clients_) {
|
for (auto& connections_to_client : connections_to_clients_) {
|
||||||
if (connections_to_client == c) {
|
if (connections_to_client == c) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneStream::OnClientConnected() got duplicate connection.");
|
"SceneStream::OnClientConnected() got duplicate connection.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& i : connections_to_clients_ignored_) {
|
for (auto& i : connections_to_clients_ignored_) {
|
||||||
if (i == c) {
|
if (i == c) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"SceneStream::OnClientConnected() got duplicate connection.");
|
"SceneStream::OnClientConnected() got duplicate connection.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1256,7 +1261,8 @@ void SessionStream::OnClientDisconnected(ConnectionToClient* c) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(LogName::kBaNetworking, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBaNetworking, LogLevel::kError,
|
||||||
"SceneStream::OnClientDisconnected() called for connection not on "
|
"SceneStream::OnClientDisconnected() called for connection not on "
|
||||||
"lists");
|
"lists");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
#include "ballistica/core/python/core_python.h"
|
#include "ballistica/core/python/core_python.h"
|
||||||
#include "ballistica/core/support/base_soft.h"
|
#include "ballistica/core/support/base_soft.h"
|
||||||
#include "ballistica/shared/foundation/fatal_error.h"
|
#include "ballistica/shared/foundation/fatal_error.h"
|
||||||
#include "ballistica/shared/foundation/logging.h"
|
|
||||||
#include "ballistica/shared/math/vector3f.h"
|
#include "ballistica/shared/math/vector3f.h"
|
||||||
#include "ballistica/shared/python/python.h"
|
#include "ballistica/shared/python/python.h"
|
||||||
#include "ballistica/shared/python/python_command.h"
|
#include "ballistica/shared/python/python_command.h"
|
||||||
@ -40,7 +39,7 @@ auto main(int argc, char** argv) -> int {
|
|||||||
namespace ballistica {
|
namespace ballistica {
|
||||||
|
|
||||||
// These are set automatically via script; don't modify them here.
|
// These are set automatically via script; don't modify them here.
|
||||||
const int kEngineBuildNumber = 22052;
|
const int kEngineBuildNumber = 22057;
|
||||||
const char* kEngineVersion = "1.7.37";
|
const char* kEngineVersion = "1.7.37";
|
||||||
const int kEngineApiVersion = 9;
|
const int kEngineApiVersion = 9;
|
||||||
|
|
||||||
@ -134,13 +133,14 @@ auto MonolithicMain(const core::CoreConfig& core_config) -> int {
|
|||||||
auto env_config_duration = time3 - time2;
|
auto env_config_duration = time3 - time2;
|
||||||
auto base_import_duration = time4 - time3;
|
auto base_import_duration = time4 - time3;
|
||||||
auto start_app_duration = time5 - time4;
|
auto start_app_duration = time5 - time4;
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
core::g_core->Log(LogName::kBa, LogLevel::kWarning, [=] {
|
||||||
"MonolithicMain took too long (" + std::to_string(total_duration)
|
return "MonolithicMain took too long (" + std::to_string(total_duration)
|
||||||
+ " ms; " + std::to_string(core_import_duration)
|
+ " ms; " + std::to_string(core_import_duration)
|
||||||
+ " core-import, " + std::to_string(env_config_duration)
|
+ " core-import, " + std::to_string(env_config_duration)
|
||||||
+ " env-config, " + std::to_string(base_import_duration)
|
+ " env-config, " + std::to_string(base_import_duration)
|
||||||
+ " base-import, " + std::to_string(start_app_duration)
|
+ " base-import, " + std::to_string(start_app_duration)
|
||||||
+ " start-app).");
|
+ " start-app).";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l_base->AppManagesMainThreadEventLoop()) {
|
if (l_base->AppManagesMainThreadEventLoop()) {
|
||||||
@ -284,15 +284,20 @@ void FatalError(const std::string& message) {
|
|||||||
FatalError::DoFatalError(message);
|
FatalError::DoFatalError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log(LogName name, LogLevel level, const std::string& msg) {
|
// void Log(LogName name, LogLevel level, const std::string& msg) {
|
||||||
Logging::Log(name, level, msg);
|
// Logging::Log(name, level, msg);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// void Log(LogName name, LogLevel level, std::string (*msg_generator)()) {
|
||||||
|
// Logging::Log(name, level, msg_generator());
|
||||||
|
// }
|
||||||
|
|
||||||
void ScreenMessage(const std::string& s, const Vector3f& color) {
|
void ScreenMessage(const std::string& s, const Vector3f& color) {
|
||||||
if (core::g_base_soft) {
|
if (core::g_base_soft) {
|
||||||
core::g_base_soft->ScreenMessage(s, color);
|
core::g_base_soft->ScreenMessage(s, color);
|
||||||
} else {
|
} else {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
core::g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
"ScreenMessage called without base feature-set loaded (will be lost): '"
|
"ScreenMessage called without base feature-set loaded (will be lost): '"
|
||||||
+ s + "'");
|
+ s + "'");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,9 +88,6 @@ void ScreenMessage(const std::string& msg, const Vector3f& color);
|
|||||||
/// Return a human-readable name for the current thread.
|
/// Return a human-readable name for the current thread.
|
||||||
auto CurrentThreadName() -> std::string;
|
auto CurrentThreadName() -> std::string;
|
||||||
|
|
||||||
/// Convenient access to Logging::Log.
|
|
||||||
void Log(LogName name, LogLevel level, const std::string& msg);
|
|
||||||
|
|
||||||
/// Log a fatal error and kill the app. Can be called from any thread at any
|
/// Log a fatal error and kill the app. Can be called from any thread at any
|
||||||
/// time. Provided message will be shown to the user if possible. This will
|
/// time. Provided message will be shown to the user if possible. This will
|
||||||
/// attempt to ship all accumulated logs to the master-server so the
|
/// attempt to ship all accumulated logs to the master-server so the
|
||||||
|
|||||||
@ -545,7 +545,7 @@ void EventLoop::PushThreadMessage_(const ThreadMessage_& t) {
|
|||||||
|
|
||||||
// Now log anything we accumulated safely outside of the locked section.
|
// Now log anything we accumulated safely outside of the locked section.
|
||||||
for (auto&& log_entry : log_entries) {
|
for (auto&& log_entry : log_entries) {
|
||||||
Log(LogName::kBa, log_entry.first, log_entry.second);
|
g_core->Log(LogName::kBa, log_entry.first, log_entry.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,9 +728,9 @@ void EventLoop::AcquireGIL_() {
|
|||||||
if (debug_timing) {
|
if (debug_timing) {
|
||||||
auto duration{core::CorePlatform::GetCurrentMillisecs() - startmillisecs};
|
auto duration{core::CorePlatform::GetCurrentMillisecs() - startmillisecs};
|
||||||
if (duration > (1000 / 120)) {
|
if (duration > (1000 / 120)) {
|
||||||
Log(LogName::kBa, LogLevel::kInfo,
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
"GIL acquire took too long (" + std::to_string(duration)
|
"GIL acquire took too long (" + std::to_string(duration)
|
||||||
+ " millisecs).");
|
+ " millisecs).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,14 +20,9 @@ using core::g_core;
|
|||||||
int g_early_v1_cloud_log_writes{10};
|
int g_early_v1_cloud_log_writes{10};
|
||||||
|
|
||||||
void Logging::Log(LogName name, LogLevel level, const std::string& msg) {
|
void Logging::Log(LogName name, LogLevel level, const std::string& msg) {
|
||||||
BA_PRECONDITION(g_core);
|
// Wrappers calling us should check these bits.
|
||||||
|
assert(g_core);
|
||||||
// Optimization: avoid touching Python at all if this log level isn't
|
assert(g_core->LogLevelEnabled(name, level));
|
||||||
// enabled.
|
|
||||||
if (!g_core->LogLevelEnabled(name, level)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_core->python->LoggingCall(name, level, msg);
|
g_core->python->LoggingCall(name, level, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,33 +36,26 @@ void Logging::EmitLog(const std::string& name, LogLevel level, double timestamp,
|
|||||||
auto rel_time{timestamp - g_core->ba_env_launch_timestamp()};
|
auto rel_time{timestamp - g_core->ba_env_launch_timestamp()};
|
||||||
|
|
||||||
if (g_base_soft) {
|
if (g_base_soft) {
|
||||||
// const char* loglevelname{"?"};
|
|
||||||
Vector4f logcolor;
|
Vector4f logcolor;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LogLevel::kDebug:
|
case LogLevel::kDebug:
|
||||||
// loglevelname = "D";
|
|
||||||
logcolor = Vector4f(0.0f, 0.5f, 1.0f, 1.0f);
|
logcolor = Vector4f(0.0f, 0.5f, 1.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
case LogLevel::kInfo:
|
case LogLevel::kInfo:
|
||||||
// loglevelname = "I";
|
|
||||||
logcolor = Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
|
logcolor = Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
case LogLevel::kWarning:
|
case LogLevel::kWarning:
|
||||||
// loglevelname = "W";
|
|
||||||
logcolor = Vector4f(1.0f, 0.7f, 0.0f, 1.0f);
|
logcolor = Vector4f(1.0f, 0.7f, 0.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
case LogLevel::kError:
|
case LogLevel::kError:
|
||||||
// loglevelname = "E";
|
|
||||||
logcolor = Vector4f(1.0f, 0.0, 0.0f, 1.0f);
|
logcolor = Vector4f(1.0f, 0.0, 0.0f, 1.0f);
|
||||||
break;
|
break;
|
||||||
case LogLevel::kCritical:
|
case LogLevel::kCritical:
|
||||||
// loglevelname = "C";
|
|
||||||
logcolor = Vector4f(0.6f, 0.0, 0.25f, 1.0f);
|
logcolor = Vector4f(0.6f, 0.0, 0.25f, 1.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char prestr[256];
|
char prestr[256];
|
||||||
snprintf(prestr, sizeof(prestr), "%.3f %s", rel_time, name.c_str());
|
snprintf(prestr, sizeof(prestr), "%.3f %s", rel_time, name.c_str());
|
||||||
// std::string msgfull = prestr + msg;
|
|
||||||
g_base_soft->PushDevConsolePrintCall("", 0.3f, kVector4f1);
|
g_base_soft->PushDevConsolePrintCall("", 0.3f, kVector4f1);
|
||||||
g_base_soft->PushDevConsolePrintCall(
|
g_base_soft->PushDevConsolePrintCall(
|
||||||
prestr, 0.75f,
|
prestr, 0.75f,
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
namespace ballistica {
|
namespace ballistica {
|
||||||
|
|
||||||
|
using core::g_core;
|
||||||
|
|
||||||
void MacroFunctionTimerEnd(core::CoreFeatureSet* corefs, millisecs_t starttime,
|
void MacroFunctionTimerEnd(core::CoreFeatureSet* corefs, millisecs_t starttime,
|
||||||
millisecs_t time, const char* funcname) {
|
millisecs_t time, const char* funcname) {
|
||||||
// Currently disabling this for test builds; not really useful for
|
// Currently disabling this for test builds; not really useful for
|
||||||
@ -25,9 +27,9 @@ void MacroFunctionTimerEnd(core::CoreFeatureSet* corefs, millisecs_t starttime,
|
|||||||
assert(corefs);
|
assert(corefs);
|
||||||
millisecs_t endtime = corefs->platform->GetTicks();
|
millisecs_t endtime = corefs->platform->GetTicks();
|
||||||
if (endtime - starttime > time) {
|
if (endtime - starttime > time) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
core::g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
std::to_string(endtime - starttime) + " milliseconds spent in "
|
std::to_string(endtime - starttime)
|
||||||
+ funcname);
|
+ " milliseconds spent in " + funcname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,9 +44,10 @@ void MacroFunctionTimerEndThread(core::CoreFeatureSet* corefs,
|
|||||||
assert(corefs);
|
assert(corefs);
|
||||||
millisecs_t endtime = corefs->platform->GetTicks();
|
millisecs_t endtime = corefs->platform->GetTicks();
|
||||||
if (endtime - starttime > time) {
|
if (endtime - starttime > time) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
std::to_string(endtime - starttime) + " milliseconds spent by "
|
std::to_string(endtime - starttime) + " milliseconds spent by "
|
||||||
+ ballistica::CurrentThreadName() + " thread in " + funcname);
|
+ ballistica::CurrentThreadName() + " thread in "
|
||||||
|
+ funcname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,9 +62,9 @@ void MacroFunctionTimerEndEx(core::CoreFeatureSet* corefs,
|
|||||||
assert(corefs);
|
assert(corefs);
|
||||||
millisecs_t endtime = corefs->platform->GetTicks();
|
millisecs_t endtime = corefs->platform->GetTicks();
|
||||||
if (endtime - starttime > time) {
|
if (endtime - starttime > time) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
std::to_string(endtime - starttime) + " milliseconds spent in "
|
std::to_string(endtime - starttime) + " milliseconds spent in "
|
||||||
+ funcname + " for " + what);
|
+ funcname + " for " + what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,10 +80,10 @@ void MacroFunctionTimerEndThreadEx(core::CoreFeatureSet* corefs,
|
|||||||
assert(corefs);
|
assert(corefs);
|
||||||
millisecs_t endtime = corefs->platform->GetTicks();
|
millisecs_t endtime = corefs->platform->GetTicks();
|
||||||
if (endtime - starttime > time) {
|
if (endtime - starttime > time) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
std::to_string(endtime - starttime) + " milliseconds spent by "
|
std::to_string(endtime - starttime) + " milliseconds spent by "
|
||||||
+ ballistica::CurrentThreadName() + " thread in " + funcname
|
+ ballistica::CurrentThreadName() + " thread in " + funcname
|
||||||
+ " for " + what);
|
+ " for " + what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +98,10 @@ void MacroTimeCheckEnd(core::CoreFeatureSet* corefs, millisecs_t starttime,
|
|||||||
assert(corefs);
|
assert(corefs);
|
||||||
millisecs_t e = corefs->platform->GetTicks();
|
millisecs_t e = corefs->platform->GetTicks();
|
||||||
if (e - starttime > time) {
|
if (e - starttime > time) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
std::string(name) + " took " + std::to_string(e - starttime)
|
std::string(name) + " took " + std::to_string(e - starttime)
|
||||||
+ " milliseconds; " + MacroPathFilter(corefs, file) + " line "
|
+ " milliseconds; " + MacroPathFilter(corefs, file)
|
||||||
+ std::to_string(line));
|
+ " line " + std::to_string(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +114,8 @@ void MacroLogErrorNativeTrace(core::CoreFeatureSet* corefs,
|
|||||||
auto trace = corefs->platform->GetNativeStackTrace();
|
auto trace = corefs->platform->GetNativeStackTrace();
|
||||||
auto trace_s =
|
auto trace_s =
|
||||||
trace ? trace->FormatForDisplay() : "<native stack trace unavailable>";
|
trace ? trace->FormatForDisplay() : "<native stack trace unavailable>";
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
std::string(buffer) + " error: " + msg + "\n" + trace_s);
|
std::string(buffer) + " error: " + msg + "\n" + trace_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroLogErrorPythonTrace(core::CoreFeatureSet* corefs,
|
void MacroLogErrorPythonTrace(core::CoreFeatureSet* corefs,
|
||||||
@ -125,7 +128,8 @@ void MacroLogErrorPythonTrace(core::CoreFeatureSet* corefs,
|
|||||||
// Since our logging goes through Python anyway, we should just ask
|
// Since our logging goes through Python anyway, we should just ask
|
||||||
// Python do include the trace in our log call.
|
// Python do include the trace in our log call.
|
||||||
Python::PrintStackTrace();
|
Python::PrintStackTrace();
|
||||||
Log(LogName::kBa, LogLevel::kError, std::string(buffer) + " error: " + msg);
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
std::string(buffer) + " error: " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroLogError(core::CoreFeatureSet* corefs, const std::string& msg,
|
void MacroLogError(core::CoreFeatureSet* corefs, const std::string& msg,
|
||||||
@ -133,12 +137,13 @@ void MacroLogError(core::CoreFeatureSet* corefs, const std::string& msg,
|
|||||||
char e_buffer[2048];
|
char e_buffer[2048];
|
||||||
snprintf(e_buffer, sizeof(e_buffer), "%s:%d:", MacroPathFilter(corefs, fname),
|
snprintf(e_buffer, sizeof(e_buffer), "%s:%d:", MacroPathFilter(corefs, fname),
|
||||||
line);
|
line);
|
||||||
Log(LogName::kBa, LogLevel::kError, std::string(e_buffer) + " error: " + msg);
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
|
std::string(e_buffer) + " error: " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacroLogPythonTrace(core::CoreFeatureSet* corefs, const std::string& msg) {
|
void MacroLogPythonTrace(core::CoreFeatureSet* corefs, const std::string& msg) {
|
||||||
Python::PrintStackTrace();
|
Python::PrintStackTrace();
|
||||||
Log(LogName::kBa, LogLevel::kError, msg);
|
g_core->Log(LogName::kBa, LogLevel::kError, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MacroPathFilter(core::CoreFeatureSet* corefs, const char* filename)
|
auto MacroPathFilter(core::CoreFeatureSet* corefs, const char* filename)
|
||||||
|
|||||||
@ -104,14 +104,14 @@
|
|||||||
} \
|
} \
|
||||||
((void)0) // (see 'Trailing-semicolon note' at top)
|
((void)0) // (see 'Trailing-semicolon note' at top)
|
||||||
|
|
||||||
#define BA_LOG_ONCE(nm, lvl, msg) \
|
#define BA_LOG_ONCE(nm, lvl, msg) \
|
||||||
{ \
|
{ \
|
||||||
static bool did_log_here{}; \
|
static bool did_log_here{}; \
|
||||||
if (!did_log_here) { \
|
if (!did_log_here) { \
|
||||||
::ballistica::Log(nm, lvl, msg); \
|
g_core->Log(nm, lvl, msg); \
|
||||||
did_log_here = true; \
|
did_log_here = true; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
((void)0) // (see 'Trailing-semicolon note' at top)
|
((void)0) // (see 'Trailing-semicolon note' at top)
|
||||||
|
|
||||||
#define BA_LOG_PYTHON_TRACE(msg) ::ballistica::MacroLogPythonTrace(g_core, msg)
|
#define BA_LOG_PYTHON_TRACE(msg) ::ballistica::MacroLogPythonTrace(g_core, msg)
|
||||||
|
|||||||
@ -155,10 +155,10 @@ void Object::LsObjects() {
|
|||||||
assert(count == g_core->object_count);
|
assert(count == g_core->object_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kInfo, s);
|
g_core->Log(LogName::kBa, LogLevel::kInfo, s);
|
||||||
#else
|
#else
|
||||||
Log(LogName::kBa, LogLevel::kInfo,
|
g_core->Log(LogName::kBa, LogLevel::kInfo,
|
||||||
"LsObjects() only functions in debug builds.");
|
"LsObjects() only functions in debug builds.");
|
||||||
#endif // BA_DEBUG_BUILD
|
#endif // BA_DEBUG_BUILD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -287,6 +287,7 @@ enum class PyExcType : uint8_t {
|
|||||||
enum class LogName : uint8_t {
|
enum class LogName : uint8_t {
|
||||||
kRoot,
|
kRoot,
|
||||||
kBa,
|
kBa,
|
||||||
|
kBaDisplayTime,
|
||||||
kBaLifecycle,
|
kBaLifecycle,
|
||||||
kBaAudio,
|
kBaAudio,
|
||||||
kBaGraphics,
|
kBaGraphics,
|
||||||
|
|||||||
@ -25,7 +25,8 @@ void Runnable::RunAndLogErrors() {
|
|||||||
} else {
|
} else {
|
||||||
type_name = "<type unavailable>";
|
type_name = "<type unavailable>";
|
||||||
}
|
}
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kError,
|
||||||
std::string("Error in Runnable: " + type_name + ": ") + exc.what());
|
std::string("Error in Runnable: " + type_name + ": ") + exc.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "ballistica/shared/generic/timer_list.h"
|
#include "ballistica/shared/generic/timer_list.h"
|
||||||
|
|
||||||
|
#include "ballistica/core/core.h"
|
||||||
#include "ballistica/shared/generic/runnable.h"
|
#include "ballistica/shared/generic/runnable.h"
|
||||||
|
|
||||||
namespace ballistica {
|
namespace ballistica {
|
||||||
@ -19,17 +20,17 @@ TimerList::~TimerList() {
|
|||||||
|
|
||||||
if (g_buildconfig.debug_build()) {
|
if (g_buildconfig.debug_build()) {
|
||||||
if (timer_count_active_ != 0) {
|
if (timer_count_active_ != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
core::g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Invalid timerlist state on teardown.");
|
"Invalid timerlist state on teardown.");
|
||||||
}
|
}
|
||||||
if (timer_count_inactive_ != 0) {
|
if (timer_count_inactive_ != 0) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
core::g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Invalid timerlist state on teardown.");
|
"Invalid timerlist state on teardown.");
|
||||||
}
|
}
|
||||||
if (!((timer_count_total_ == 0)
|
if (!((timer_count_total_ == 0)
|
||||||
|| (client_timer_ != nullptr && timer_count_total_ == 1))) {
|
|| (client_timer_ != nullptr && timer_count_total_ == 1))) {
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
core::g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"Invalid timerlist state on teardown.");
|
"Invalid timerlist state on teardown.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
namespace ballistica {
|
namespace ballistica {
|
||||||
|
|
||||||
|
using core::g_core;
|
||||||
|
|
||||||
#define USE_BAKED_RANDS 1
|
#define USE_BAKED_RANDS 1
|
||||||
|
|
||||||
#if BA_OSTYPE_WINDOWS
|
#if BA_OSTYPE_WINDOWS
|
||||||
@ -223,9 +225,9 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
logged_count++;
|
logged_count++;
|
||||||
Log(LogName::kBa, LogLevel::kError,
|
g_core->Log(LogName::kBa, LogLevel::kError,
|
||||||
"GOT INVALID UTF8 SEQUENCE: (" + log_str + "); RETURNING '" + to
|
"GOT INVALID UTF8 SEQUENCE: (" + log_str + "); RETURNING '"
|
||||||
+ "'; LOC '" + loc + "'");
|
+ to + "'; LOC '" + loc + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -32,6 +32,7 @@ namespace ballistica {
|
|||||||
// We implicitly use core functionality here; our behavior is undefined
|
// We implicitly use core functionality here; our behavior is undefined
|
||||||
// if nobody has imported core yet.
|
// if nobody has imported core yet.
|
||||||
using core::g_base_soft;
|
using core::g_base_soft;
|
||||||
|
using core::g_core;
|
||||||
|
|
||||||
// Ignore signed bitwise stuff; python macros do it quite a bit.
|
// Ignore signed bitwise stuff; python macros do it quite a bit.
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
@ -96,9 +97,9 @@ void Python::PrintStackTrace() {
|
|||||||
available = g_base_soft->PrintPythonStackTrace();
|
available = g_base_soft->PrintPythonStackTrace();
|
||||||
}
|
}
|
||||||
if (!available) {
|
if (!available) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Python::PrintStackTrace() called before _babase set up; "
|
"Python::PrintStackTrace() called before _babase set up; "
|
||||||
"not printing.");
|
"not printing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace ballistica {
|
|||||||
// Using core stuff implicitly here. Our behavior is undefined if core
|
// Using core stuff implicitly here. Our behavior is undefined if core
|
||||||
// has not yet been imported by anyone.
|
// has not yet been imported by anyone.
|
||||||
using core::g_base_soft;
|
using core::g_base_soft;
|
||||||
|
using core::g_core;
|
||||||
|
|
||||||
PythonObjectSetBase::~PythonObjectSetBase() {
|
PythonObjectSetBase::~PythonObjectSetBase() {
|
||||||
// We make assumptions that ids remain valid once established.
|
// We make assumptions that ids remain valid once established.
|
||||||
@ -39,9 +40,9 @@ void PythonObjectSetBase::StoreObj(int id, PyObject* pyobj) {
|
|||||||
// Also make sure we're not storing an object that's already been stored.
|
// Also make sure we're not storing an object that's already been stored.
|
||||||
for (auto&& i : objs_) {
|
for (auto&& i : objs_) {
|
||||||
if (i.Get() != nullptr && i.Get() == pyobj) {
|
if (i.Get() != nullptr && i.Get() == pyobj) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(LogName::kBa, LogLevel::kWarning,
|
||||||
"Python::StoreObj() called twice for same ptr; id="
|
"Python::StoreObj() called twice for same ptr; id="
|
||||||
+ std::to_string(id) + ".");
|
+ std::to_string(id) + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ namespace ballistica {
|
|||||||
// Note: implicitly using core globals here; our behavior is undefined
|
// Note: implicitly using core globals here; our behavior is undefined
|
||||||
// if core has not been imported by anyone yet.
|
// if core has not been imported by anyone yet.
|
||||||
using core::g_base_soft;
|
using core::g_base_soft;
|
||||||
|
using core::g_core;
|
||||||
|
|
||||||
// Ignore a few things that python macros do.
|
// Ignore a few things that python macros do.
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
@ -29,7 +30,8 @@ static void ClearPythonExceptionAndWarnIfUnset() {
|
|||||||
// avoid that situation because it opens up the possibility of us clearing
|
// avoid that situation because it opens up the possibility of us clearing
|
||||||
// exceptions that aren't related to our nullptr.
|
// exceptions that aren't related to our nullptr.
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
Log(LogName::kBa, LogLevel::kWarning,
|
g_core->Log(
|
||||||
|
LogName::kBa, LogLevel::kWarning,
|
||||||
"A PythonRef acquire/steal call was passed nullptr but no Python "
|
"A PythonRef acquire/steal call was passed nullptr but no Python "
|
||||||
"exception is set. This situation should be avoided; only pass "
|
"exception is set. This situation should be avoided; only pass "
|
||||||
"acquire/steal if it is directly due to a Python exception.");
|
"acquire/steal if it is directly due to a Python exception.");
|
||||||
|
|||||||
@ -67,13 +67,13 @@
|
|||||||
((void)0)
|
((void)0)
|
||||||
|
|
||||||
// For use in tp_dealloc; simply prints the error.
|
// For use in tp_dealloc; simply prints the error.
|
||||||
#define BA_PYTHON_DEALLOC_CATCH \
|
#define BA_PYTHON_DEALLOC_CATCH \
|
||||||
} \
|
} \
|
||||||
catch (const std::exception& e) { \
|
catch (const std::exception& e) { \
|
||||||
Log(LogName::kBa, LogLevel::kError, \
|
g_core->Log(LogName::kBa, LogLevel::kError, \
|
||||||
std::string("tp_dealloc exception: ") \
|
std::string("tp_dealloc exception: ") \
|
||||||
+ GetShortExceptionDescription(e)); \
|
+ GetShortExceptionDescription(e)); \
|
||||||
} \
|
} \
|
||||||
((void)0)
|
((void)0)
|
||||||
|
|
||||||
// Sets Python error and returns -1.
|
// Sets Python error and returns -1.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user