diff --git a/.efrocachemap b/.efrocachemap
index 12a3d25e..c59702fc 100644
--- a/.efrocachemap
+++ b/.efrocachemap
@@ -3995,26 +3995,26 @@
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e",
"assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34",
"ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a",
- "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0f/0d/94aa62be2e76dcb835736c843b47",
- "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9f/00/962eaa0e2f394c4b25e230da0a26",
- "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f6/ad/8d342629f0c302ecc232b53f2357",
- "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/eb/d9/2defa7dc3c271a3bd83effc7a133",
- "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/19/2d/29e867f238863c66ce9b2de56223",
- "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6f/59/0a568faf3726bb40200d9d580762",
- "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/98/5e/d4792f38ddfd1939148b12dac3e6",
- "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2d/be/381047cad3bf61c09920f6e7e39e",
- "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/23/98/31f1209b0dab20d649a91efe6b33",
- "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/17/f9/9a50487bd39dbebe8236644446db",
- "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ce/15/1e812f031786c676b482cb83f3a4",
- "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/41/2b/647bcbdc19cb3d673ad1a05ab7e5",
- "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a5/96/1ee470994dd104269bcc422f3163",
- "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/f4/de/d89484b8903b14ebb56355e6021f",
- "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/78/f4/3c95ba3ea5922813e2cef8af9019",
- "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a7/1c/6003d3470a403c5107abffcbcf36",
- "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d1/0a/6621e3505c513ba0b976ebc9d896",
- "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ef/de/110b3f2961f088524a9913975f5a",
- "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/ed/a5/e01a9d56f095b855f29cf7bf5ed3",
- "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/55/80/b022e845d983777a9244c0595a58",
+ "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/91/e4/e85f3feee6640ce65027660e5590",
+ "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/dd/50/db8d4e087b3fe272e9575b95996b",
+ "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e8/2f/1c8653ee8f0bad9cded74ebf5100",
+ "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/2e/86/b9fb1d80caf79d23b785327a0cc7",
+ "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0f/4e/67f2eea7fa848b12994d487893dc",
+ "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b2/c4/d9555b8a060d11e6b1346cd82d12",
+ "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/59/41/3aafb5bd7c6dddad37c89f304fb9",
+ "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cc/c1/a7cbdc71810ee752746eda33dd31",
+ "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/36/67/6a8b809011b4023533712d2df7b6",
+ "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/11/8c/172381e8a477cc11ee0e24460901",
+ "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/ab/05c53d0807929316235d6e7382cd",
+ "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/18/c2/415efdababdd14553c3adbeaaf7b",
+ "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/3a/2d/863cc304f4856e34c81093b59db1",
+ "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/33/fd/00a992c1d496ff85a99d381c6498",
+ "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e4/58/ac07183ee59eedbb78dcf2f0e91f",
+ "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/cf/cb/91d2181102f6045e4d19cc73a18d",
+ "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ce/f8/3e7a2452dae94b5cd857424e31fa",
+ "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/04/f8/46d2bcc4f5d5b7c7d9bcc7b91418",
+ "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/3b/10/9c15dbfbca54c1260b146de3029b",
+ "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/26/90/d2f4b8212b12508ed222609c7a7d",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e0/b3/7ccccfd8721033582cabdfe11f73",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/86/d2/d18cbc017a7d64001f96718cc5ed",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/64/9b/78cdb9eda7b30611774769859caa",
@@ -4031,14 +4031,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c8/d2/5df66f66e26c1beb8a1e2b1f0613",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7e/57/593e8ceeee37a65972f1fb30d2cd",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2f/fc/a2ac394899e6527f8def0cad4d8a",
- "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/0e/b9/eb1339fc3c692095400631c081e3",
- "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/07/30/90e690ff7358463d6a251e242138",
- "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/0e/c5/d5607da49974e3aeb55a000e3ea5",
- "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/f4/8b/99e574ea4ea13187fb401d7ae46f",
- "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/c1/53/683aef250370cb33bc8779ba1f83",
- "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/f4/33/0338c8271f7c9d75f947528023b7",
- "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/ad/7a/9adff320f5a0f68be025aabf36a0",
- "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/19/bd/bb787a4eb97ae97e7555de01ef49",
+ "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/20/4e/9afc0e73bb26d63032c3525d9373",
+ "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/f2/ab/eac71319d5184a3dd6b2ad74cf92",
+ "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/ad/20/97feffa58fcbc8ac2ed2d9892326",
+ "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/0a/d8/6e58979b57cf74c0d675508b207f",
+ "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/79/c7/cb4590d0e233fa0455f9bd3158b0",
+ "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/2a/14/99b6932f7e20e988d67faa4327d9",
+ "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/b0/77/b85ef1b5a280aa2426a613e76ec5",
+ "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/b9/22/020a23ba4dba0b5871f78622bd67",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/7d/3e/229a581cb2454ed856f1d8b564a7",
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/98/12/571b2160d69d42580e8f31fa6a8d"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e12d8313..f472ce3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-### 1.7.7 (build 20800, api 7, 2022-09-10)
+### 1.7.7 (build 20803, api 7, 2022-09-10)
- Added `ba.app.meta.load_exported_classes()` for loading classes discovered by the meta subsystem cleanly in a background thread.
- Improved logging of missing playlist game types.
- Some ba.Lstr functionality can now be used in background threads.
diff --git a/assets/src/ba_data/python/ba/_bootstrap.py b/assets/src/ba_data/python/ba/_bootstrap.py
index af43eb69..6c34fe48 100644
--- a/assets/src/ba_data/python/ba/_bootstrap.py
+++ b/assets/src/ba_data/python/ba/_bootstrap.py
@@ -38,7 +38,7 @@ def bootstrap() -> None:
# Give a soft warning if we're being used with a different binary
# version than we expect.
- expected_build = 20800
+ expected_build = 20803
running_build: int = env['build_number']
if running_build != expected_build:
print(
diff --git a/ballisticacore-cmake/CMakeLists.txt b/ballisticacore-cmake/CMakeLists.txt
index c206b385..a807d3e3 100644
--- a/ballisticacore-cmake/CMakeLists.txt
+++ b/ballisticacore-cmake/CMakeLists.txt
@@ -502,8 +502,8 @@ add_executable(ballisticacore
${BA_SRC_ROOT}/ballistica/media/media_server.h
${BA_SRC_ROOT}/ballistica/networking/network_reader.cc
${BA_SRC_ROOT}/ballistica/networking/network_reader.h
- ${BA_SRC_ROOT}/ballistica/networking/network_write_module.cc
- ${BA_SRC_ROOT}/ballistica/networking/network_write_module.h
+ ${BA_SRC_ROOT}/ballistica/networking/network_writer.cc
+ ${BA_SRC_ROOT}/ballistica/networking/network_writer.h
${BA_SRC_ROOT}/ballistica/networking/networking.cc
${BA_SRC_ROOT}/ballistica/networking/networking.h
${BA_SRC_ROOT}/ballistica/networking/networking_sys.h
diff --git a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj
index 266f06d5..4c34c25e 100644
--- a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj
+++ b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj
@@ -493,8 +493,8 @@
-
-
+
+
diff --git a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters
index 521f7a2f..8f86a56f 100644
--- a/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters
+++ b/ballisticacore-windows/Generic/BallisticaCoreGeneric.vcxproj.filters
@@ -913,10 +913,10 @@
ballistica\networking
-
+
ballistica\networking
-
+
ballistica\networking
diff --git a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj
index fafb946a..c8692ebb 100644
--- a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj
+++ b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj
@@ -488,8 +488,8 @@
-
-
+
+
diff --git a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters
index 521f7a2f..8f86a56f 100644
--- a/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters
+++ b/ballisticacore-windows/Headless/BallisticaCoreHeadless.vcxproj.filters
@@ -913,10 +913,10 @@
ballistica\networking
-
+
ballistica\networking
-
+
ballistica\networking
diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc
index 3d37710f..171ece0f 100644
--- a/src/ballistica/ballistica.cc
+++ b/src/ballistica/ballistica.cc
@@ -13,8 +13,9 @@
#include "ballistica/game/v1_account.h"
#include "ballistica/graphics/graphics_server.h"
#include "ballistica/internal/app_internal.h"
+#include "ballistica/media/media.h"
#include "ballistica/media/media_server.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/platform/platform.h"
#include "ballistica/python/python.h"
#include "ballistica/scene/scene.h"
@@ -22,7 +23,7 @@
namespace ballistica {
// These are set automatically via script; don't modify them here.
-const int kAppBuildNumber = 20800;
+const int kAppBuildNumber = 20803;
const char* kAppVersion = "1.7.7";
// Our standalone globals.
@@ -48,7 +49,7 @@ Media* g_media{};
MediaServer* g_media_server{};
NetworkReader* g_network_reader{};
Networking* g_networking{};
-NetworkWriteModule* g_network_write_module{};
+NetworkWriteModule* g_network_writer{};
Platform* g_platform{};
Python* g_python{};
StdInputModule* g_std_input_module{};
@@ -90,8 +91,8 @@ auto BallisticaMain(int argc, char** argv) -> int {
g_app = new App(argc, argv);
g_platform = Platform::Create();
- // If we're not running under a Python executable, we need to set up
- // our own Python environment.
+ // Bootstrap our Python environment as early as we can (depends on
+ // g_platform for locating OS-specific paths).
assert(g_python == nullptr);
g_python = new Python();
@@ -103,8 +104,10 @@ auto BallisticaMain(int argc, char** argv) -> int {
g_app_flavor = g_platform->CreateAppFlavor();
g_app_flavor->PostInit();
+ // Various other subsystems.
g_v1_account = new V1Account();
g_utils = new Utils();
+ g_media = new Media();
Scene::Init();
// Spin up our other standard threads.
@@ -279,8 +282,7 @@ auto InMediaThread() -> bool {
}
auto InNetworkWriteThread() -> bool {
- return (g_network_write_module
- && g_network_write_module->thread()->IsCurrent());
+ return (g_network_writer && g_network_writer->thread()->IsCurrent());
}
auto Log(const std::string& msg, bool to_stdout, bool to_server) -> void {
diff --git a/src/ballistica/ballistica.h b/src/ballistica/ballistica.h
index e9904c2d..6b290d95 100644
--- a/src/ballistica/ballistica.h
+++ b/src/ballistica/ballistica.h
@@ -122,7 +122,7 @@ extern Media* g_media;
extern MediaServer* g_media_server;
extern Networking* g_networking;
extern NetworkReader* g_network_reader;
-extern NetworkWriteModule* g_network_write_module;
+extern NetworkWriteModule* g_network_writer;
extern Platform* g_platform;
extern Python* g_python;
extern StdInputModule* g_std_input_module;
diff --git a/src/ballistica/game/connection/connection_set.cc b/src/ballistica/game/connection/connection_set.cc
index e9e164b7..25f9f027 100644
--- a/src/ballistica/game/connection/connection_set.cc
+++ b/src/ballistica/game/connection/connection_set.cc
@@ -9,7 +9,7 @@
#include "ballistica/game/player.h"
#include "ballistica/game/session/host_session.h"
#include "ballistica/input/device/input_device.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/networking/sockaddr.h"
#include "ballistica/python/python.h"
#include "ballistica/python/python_sys.h"
@@ -463,7 +463,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
PushClientDisconnectedCall(client_id);
// Now send an ack so they know it's been taken care of.
- g_network_write_module->PushSendToCall(
+ g_network_writer->PushSendToCall(
{BA_PACKET_DISCONNECT_FROM_CLIENT_ACK, client_id}, addr);
}
break;
@@ -490,7 +490,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
}
// Now send an ack so they know it's been taken care of.
- g_network_write_module->PushSendToCall(
+ g_network_writer->PushSendToCall(
{BA_PACKET_DISCONNECT_FROM_HOST_ACK, client_id}, addr);
}
break;
@@ -516,7 +516,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
return;
} else {
// Send a disconnect request aimed at them.
- g_network_write_module->PushSendToCall(
+ g_network_writer->PushSendToCall(
{BA_PACKET_DISCONNECT_FROM_HOST_REQUEST, client_id}, addr);
}
}
@@ -621,15 +621,15 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
// Newer version have a specific party-full message; send that first
// but also follow up with a generic deny message for older clients.
- g_network_write_module->PushSendToCall(
+ g_network_writer->PushSendToCall(
{BA_PACKET_CLIENT_DENY_PARTY_FULL, request_id}, addr);
- g_network_write_module->PushSendToCall(
- {BA_PACKET_CLIENT_DENY, request_id}, addr);
+ g_network_writer->PushSendToCall({BA_PACKET_CLIENT_DENY, request_id},
+ addr);
} else if (connection_to_host_.exists()) {
// If we're connected to someone else, we can't have clients.
- g_network_write_module->PushSendToCall(
+ g_network_writer->PushSendToCall(
{BA_PACKET_CLIENT_DENY_ALREADY_IN_PARTY, request_id}, addr);
} else {
// Otherwise go ahead and make them a new client connection.
@@ -666,7 +666,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
std::vector msg_out(2);
msg_out[0] = BA_PACKET_CLIENT_DENY;
msg_out[1] = request_id;
- g_network_write_module->PushSendToCall(msg_out, addr);
+ g_network_writer->PushSendToCall(msg_out, addr);
Log("All client slots full; really?..");
break;
}
@@ -684,7 +684,7 @@ auto ConnectionSet::UDPConnectionPacket(const std::vector& data_in,
msg_out[1] =
static_cast_check_fit(connection_to_client->id());
msg_out[2] = request_id;
- g_network_write_module->PushSendToCall(msg_out, addr);
+ g_network_writer->PushSendToCall(msg_out, addr);
}
}
break;
diff --git a/src/ballistica/game/connection/connection_to_client_udp.cc b/src/ballistica/game/connection/connection_to_client_udp.cc
index b75ad69a..b330ba8e 100644
--- a/src/ballistica/game/connection/connection_to_client_udp.cc
+++ b/src/ballistica/game/connection/connection_to_client_udp.cc
@@ -4,7 +4,7 @@
#include "ballistica/game/connection/connection_set.h"
#include "ballistica/game/game.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/networking/sockaddr.h"
namespace ballistica {
@@ -39,8 +39,8 @@ void ConnectionToClientUDP::SendGamePacketCompressed(
// Ship this off to the net-out thread to send; at this point we don't know
// or case what happens to it.
- assert(g_network_write_module);
- g_network_write_module->PushSendToCall(data_full, *addr_);
+ assert(g_network_writer);
+ g_network_writer->PushSendToCall(data_full, *addr_);
}
void ConnectionToClientUDP::Update() {
@@ -89,7 +89,7 @@ void ConnectionToClientUDP::SendDisconnectRequest() {
std::vector data(2);
data[0] = BA_PACKET_DISCONNECT_FROM_HOST_REQUEST;
data[1] = static_cast(id());
- g_network_write_module->PushSendToCall(data, *addr_);
+ g_network_writer->PushSendToCall(data, *addr_);
}
} // namespace ballistica
diff --git a/src/ballistica/game/connection/connection_to_host_udp.cc b/src/ballistica/game/connection/connection_to_host_udp.cc
index 79d3f906..f7dca8e8 100644
--- a/src/ballistica/game/connection/connection_to_host_udp.cc
+++ b/src/ballistica/game/connection/connection_to_host_udp.cc
@@ -5,7 +5,7 @@
#include "ballistica/game/connection/connection_set.h"
#include "ballistica/game/game.h"
#include "ballistica/math/vector3f.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/networking/sockaddr.h"
namespace ballistica {
@@ -71,7 +71,7 @@ void ConnectionToHostUDP::Update() {
memcpy(&(msg[1]), &p_version, 2);
msg[3] = request_id_;
memcpy(&(msg[4]), uuid.c_str(), uuid.size());
- g_network_write_module->PushSendToCall(msg, *addr_);
+ g_network_writer->PushSendToCall(msg, *addr_);
}
}
@@ -128,7 +128,7 @@ void ConnectionToHostUDP::SendDisconnectRequest() {
std::vector data(2);
data[0] = BA_PACKET_DISCONNECT_FROM_CLIENT_REQUEST;
data[1] = static_cast_check_fit(client_id_);
- g_network_write_module->PushSendToCall(data, *addr_);
+ g_network_writer->PushSendToCall(data, *addr_);
}
}
@@ -152,8 +152,8 @@ void ConnectionToHostUDP::SendGamePacketCompressed(
// Ship this off to the net-out thread to send; at this point we don't know
// or care what happens to it.
- assert(g_network_write_module);
- g_network_write_module->PushSendToCall(data_full, *addr_);
+ assert(g_network_writer);
+ g_network_writer->PushSendToCall(data_full, *addr_);
}
void ConnectionToHostUDP::Error(const std::string& msg) {
diff --git a/src/ballistica/game/game.cc b/src/ballistica/game/game.cc
index 81bf71d8..a5455895 100644
--- a/src/ballistica/game/game.cc
+++ b/src/ballistica/game/game.cc
@@ -28,7 +28,7 @@
#include "ballistica/input/device/keyboard_input.h"
#include "ballistica/input/device/touch_input.h"
#include "ballistica/internal/app_internal.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/networking/sockaddr.h"
#include "ballistica/networking/telnet_server.h"
#include "ballistica/python/python.h"
@@ -79,7 +79,6 @@ Game::Game(Thread* thread)
assert(g_graphics == nullptr);
g_graphics = g_platform->CreateGraphics();
TextGraphics::Init();
- Media::Init();
Audio::Init();
if (!HeadlessMode()) {
BGDynamics::Init();
diff --git a/src/ballistica/media/media.cc b/src/ballistica/media/media.cc
index b0e280d5..eb1ec6f2 100644
--- a/src/ballistica/media/media.cc
+++ b/src/ballistica/media/media.cc
@@ -22,7 +22,7 @@
namespace ballistica {
-// Debug printing.
+// Debug printing:
#define BA_SHOW_LOADS_UNLOADS 0
#define SHOW_PRUNING_INFO 0
@@ -38,12 +38,6 @@ namespace ballistica {
// How long we should spend loading media in each runPendingLoads() call.
#define PENDING_LOAD_PROCESS_TIME 5
-void Media::Init() {
- // Just create our singleton.
- assert(g_media == nullptr);
- g_media = new Media();
-}
-
Media::Media() {
media_paths_.emplace_back("ba_data");
for (bool& have_pending_load : have_pending_loads_) {
@@ -289,8 +283,6 @@ void Media::LoadSystemMedia() {
system_media_loaded_ = true;
}
-Media::~Media() = default;
-
void Media::PrintLoadInfo() {
std::string s;
char buffer[256];
@@ -615,8 +607,19 @@ void Media::MarkComponentForLoad(MediaComponentData* c) {
// ClearPendingLoadsDoneList)
auto media_ptr = new Object::Ref(c);
- g_media_server->thread()->PushRunnable(
- Object::NewDeferred(media_ptr));
+
+ g_media_server->thread()->PushCall([media_ptr] {
+ assert(InMediaThread());
+
+ // add our pointer to one of the preload lists and shake our preload thread
+ // to wake it up
+ if ((**media_ptr).GetMediaType() == MediaType::kSound) {
+ g_media_server->pending_preloads_audio_.push_back(media_ptr);
+ } else {
+ g_media_server->pending_preloads_.push_back(media_ptr);
+ }
+ g_media_server->process_timer_->SetLength(0);
+ });
}
#pragma clang diagnostic push
@@ -1216,19 +1219,6 @@ void Media::ClearPendingLoadsDoneList() {
pending_loads_done_.clear();
}
-void Media::PreloadRunnable::Run() {
- assert(InMediaThread());
-
- // add our pointer to one of the preload lists and shake our preload thread to
- // wake it up
- if ((**c).GetMediaType() == MediaType::kSound) {
- g_media_server->pending_preloads_audio_.push_back(c);
- } else {
- g_media_server->pending_preloads_.push_back(c);
- }
- g_media_server->process_timer_->SetLength(0);
-}
-
void Media::AddPackage(const std::string& name, const std::string& path) {
// we don't protect package-path access so make sure its always from here..
assert(InLogicThread());
diff --git a/src/ballistica/media/media.h b/src/ballistica/media/media.h
index bdb3cd8a..f9f1e7df 100644
--- a/src/ballistica/media/media.h
+++ b/src/ballistica/media/media.h
@@ -8,17 +8,14 @@
#include
#include
-#include "ballistica/core/context.h"
#include "ballistica/core/object.h"
-#include "ballistica/generic/runnable.h"
namespace ballistica {
/// Global media wrangling class.
class Media {
public:
- static void Init();
- ~Media();
+ Media();
/// Handy function to try to return a bit of media from a std::unordered_map
/// of weak-refs, loading/adding it if need be.
@@ -43,8 +40,8 @@ class Media {
}
}
- void AddPackage(const std::string& name, const std::string& path);
- void Prune(int level = 0);
+ auto AddPackage(const std::string& name, const std::string& path) -> void;
+ auto Prune(int level = 0) -> void;
/// Finish loading any media that has been preloaded but still needs to be
/// loaded by the proper thread.
@@ -55,26 +52,25 @@ class Media {
/// Return true if graphics loads remain to be done.
auto RunPendingGraphicsLoads() -> bool;
- void ClearPendingLoadsDoneList();
+ auto ClearPendingLoadsDoneList() -> void;
template
auto RunPendingLoadList(std::vector*>* cList) -> bool;
/// This function takes a newly allocated pointer which
/// is deleted once the load is completed.
- void AddPendingLoad(Object::Ref* c);
- struct PreloadRunnable;
+ auto AddPendingLoad(Object::Ref* c) -> void;
enum class FileType { kModel, kCollisionModel, kTexture, kSound, kData };
auto FindMediaFile(FileType fileType, const std::string& file_in)
-> std::string;
/// Unload renderer-specific bits only (gl display lists, etc) - used when
/// recreating/adjusting the renderer.
- void UnloadRendererBits(bool textures, bool models);
+ auto UnloadRendererBits(bool textures, bool models) -> void;
/// Should be called from the game thread after UnloadRendererBits();
/// kicks off bg loads for all existing unloaded media.
- void MarkAllMediaForLoad();
- void PrintLoadInfo();
+ auto MarkAllMediaForLoad() -> void;
+ auto PrintLoadInfo() -> void;
auto GetModelPendingLoadCount() -> int;
auto GetTexturePendingLoadCount() -> int;
@@ -135,7 +131,7 @@ class Media {
}
/// Load up hard-coded media for interface, etc.
- void LoadSystemMedia();
+ auto LoadSystemMedia() -> void;
auto total_model_count() const -> uint32_t {
return static_cast(models_.size());
@@ -150,20 +146,15 @@ class Media {
auto total_collide_model_count() const -> uint32_t {
return static_cast(collide_models_.size());
}
- struct PreloadRunnable : public Runnable {
- explicit PreloadRunnable(Object::Ref* c_in) : c(c_in) {}
- void Run() override;
- Object::Ref* c;
- };
private:
- Media();
- static void MarkComponentForLoad(MediaComponentData* c);
- void LoadSystemTexture(SystemTextureID id, const char* name);
- void LoadSystemCubeMapTexture(SystemCubeMapTextureID id, const char* name);
- void LoadSystemSound(SystemSoundID id, const char* name);
- void LoadSystemData(SystemDataID id, const char* name);
- void LoadSystemModel(SystemModelID id, const char* name);
+ static auto MarkComponentForLoad(MediaComponentData* c) -> void;
+ auto LoadSystemTexture(SystemTextureID id, const char* name) -> void;
+ auto LoadSystemCubeMapTexture(SystemCubeMapTextureID id, const char* name)
+ -> void;
+ auto LoadSystemSound(SystemSoundID id, const char* name) -> void;
+ auto LoadSystemData(SystemDataID id, const char* name) -> void;
+ auto LoadSystemModel(SystemModelID id, const char* name) -> void;
template
auto GetComponentPendingLoadCount(
diff --git a/src/ballistica/networking/network_reader.cc b/src/ballistica/networking/network_reader.cc
index 8ca323ff..653a28c6 100644
--- a/src/ballistica/networking/network_reader.cc
+++ b/src/ballistica/networking/network_reader.cc
@@ -8,7 +8,7 @@
#include "ballistica/generic/json.h"
#include "ballistica/input/remote_app.h"
#include "ballistica/math/vector3f.h"
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/networking/sockaddr.h"
#include "ballistica/platform/platform.h"
#include "ballistica/python/python.h"
@@ -158,7 +158,7 @@ static auto HandleGameQuery(const char* buffer, size_t size,
std::vector msg_buffer(msg_len);
memcpy(msg_buffer.data(), msg, msg_len);
- g_network_write_module->PushSendToCall(msg_buffer, SockAddr(*from));
+ g_network_writer->PushSendToCall(msg_buffer, SockAddr(*from));
} else {
Log("Error: Got invalid game-query packet of len " + std::to_string(size)
@@ -505,6 +505,4 @@ auto NetworkReader::OpenSockets() -> void {
}
}
-NetworkReader::~NetworkReader() = default;
-
} // namespace ballistica
diff --git a/src/ballistica/networking/network_reader.h b/src/ballistica/networking/network_reader.h
index a21b1ab6..0e70cd2f 100644
--- a/src/ballistica/networking/network_reader.h
+++ b/src/ballistica/networking/network_reader.h
@@ -13,8 +13,8 @@
namespace ballistica {
-// This is a special thread that manages the game's main network sockets;
-// it handles creating/destroying them as well as listening for incoming
+// A subsystem that manages the game's main network sockets.
+// It handles creating/destroying them as well as listening for incoming
// packets. it is not a normal BA thread so doesn't have the ability to receive
// messages (it generally sits blocked in a select() call). Writing to these
// sockets takes place in other threads; just make sure to lock the mutex and
@@ -22,7 +22,6 @@ namespace ballistica {
class NetworkReader {
public:
explicit NetworkReader(int port);
- ~NetworkReader();
auto Pause() -> void;
auto Resume() -> void;
auto port4() const { return port4_; }
diff --git a/src/ballistica/networking/network_write_module.cc b/src/ballistica/networking/network_writer.cc
similarity index 86%
rename from src/ballistica/networking/network_write_module.cc
rename to src/ballistica/networking/network_writer.cc
index 93dbde63..c6a1a269 100644
--- a/src/ballistica/networking/network_write_module.cc
+++ b/src/ballistica/networking/network_writer.cc
@@ -1,6 +1,6 @@
// Released under the MIT License. See LICENSE for details.
-#include "ballistica/networking/network_write_module.h"
+#include "ballistica/networking/network_writer.h"
#include "ballistica/core/thread.h"
#include "ballistica/networking/networking.h"
@@ -10,8 +10,8 @@ namespace ballistica {
NetworkWriteModule::NetworkWriteModule(Thread* thread) : thread_(thread) {
// we're a singleton
- assert(g_network_write_module == nullptr);
- g_network_write_module = this;
+ assert(g_network_writer == nullptr);
+ g_network_writer = this;
}
void NetworkWriteModule::PushSendToCall(const std::vector& msg,
diff --git a/src/ballistica/networking/network_write_module.h b/src/ballistica/networking/network_writer.h
similarity index 66%
rename from src/ballistica/networking/network_write_module.h
rename to src/ballistica/networking/network_writer.h
index 20a01131..1c8235c6 100644
--- a/src/ballistica/networking/network_write_module.h
+++ b/src/ballistica/networking/network_writer.h
@@ -1,7 +1,7 @@
// Released under the MIT License. See LICENSE for details.
-#ifndef BALLISTICA_NETWORKING_NETWORK_WRITE_MODULE_H_
-#define BALLISTICA_NETWORKING_NETWORK_WRITE_MODULE_H_
+#ifndef BALLISTICA_NETWORKING_NETWORK_WRITER_H_
+#define BALLISTICA_NETWORKING_NETWORK_WRITER_H_
#include
@@ -9,7 +9,7 @@
namespace ballistica {
-// this thread handles network output and whatnot
+// A subsystem handling outbound network traffic.
class NetworkWriteModule {
public:
void PushSendToCall(const std::vector& msg, const SockAddr& addr);
@@ -22,4 +22,4 @@ class NetworkWriteModule {
} // namespace ballistica
-#endif // BALLISTICA_NETWORKING_NETWORK_WRITE_MODULE_H_
+#endif // BALLISTICA_NETWORKING_NETWORK_WRITER_H_