renaming game thread to logic thread

This commit is contained in:
Eric 2022-09-02 13:10:07 -07:00
parent a264121f85
commit a001dd24b2
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
103 changed files with 476 additions and 474 deletions

View File

@ -3995,50 +3995,50 @@
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e", "assets/src/ba_data/python/ba/_generated/__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", "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", "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/7e/d4/165a41fb2c8ea82de272c4645280", "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f2/56/753368778315cb50853cd14fcebd",
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cc/ca/31d9c869e86bf1594990bcbb6b09", "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/45/a1/f26ab1a6af5d324320d8c40ef013",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fb/0e/ea7694603962a6a9b776b63d3995", "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f7/e6/40091f52b26cee5b554ce9f2f969",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1e/07/f2f9fc20a3531891b2d8b87d5b08", "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b6/7b/ca36bdb0c07e6db54b589e85e386",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a5/0a/c5260449084a45f148bf84de1c8c", "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/f9/b7/dc87a15acdb8ff6cacb6bdbd5bd0",
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/d8/d6/9a7def584d935559fdaa9ae74275", "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/56/6a/045d3ec105543a0a47b3f1d02531",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b8/b6/a0a96ce6741bd0f40892be18366d", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/71/8b/ae034f8c196e776162f6a4274c41",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c9/44/bf67c3ec9a667a12e02b80411340", "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/dd/33/abf4b52a891cd048a64f509fd558",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/06/0b/3792ea5482a33dbdda335e0e9658", "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/cd/77/9898c6ebae2ec75423d54adf64be",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/23/2d/dd2dbc62263b191e2d4139f6a4d0", "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/49/21/7630a73dff681f5cf35237bd3fa8",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d6/b7/7a5975922a6856ada8ac57725e55", "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a4/37/65aae58712a1c91e77ceb7cff9cc",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a2/d1/302df0fb6647a0593629c6903ab1", "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/89/7a/97c2d82d85d0265d9425e2afe2fd",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/61/c0/3a75272f88e7e1ce6bbf33255451", "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d6/ba/f6d4503a8ff7a02a02918159de49",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/66/1e/ac5f028603d23f38bae63f9521f0", "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/1b/42/c6df0ef3208a824a91c6b6936e30",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/20/1e/56f492b79fc05288070b377ca031", "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/79/0f/2118c060b946ea72172e487a6673",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/73/c6/a36e3bca7df79c94f58315dab63a", "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/05/36/5279be68e915924f06f748699e36",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/3c/21/3a0ecdf854b98e5fa3cd0b9cbc24", "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ba/b3/961d8e8c573021c04c35ab97d0e2",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/df/5b/379e6f5d9dd2850413400f97adac", "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/ae/80/0eec304d81099449d86223d17be9",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/4f/db/7c14cee7267a31d5df6c90ec787d", "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/e0/c5/a1d8137e47716b475f9093904618",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/9f/f2/2353a84e64cfab0b95b890402869", "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/8a/81/0c3e2486e449768f7b1edb45281a",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3b/0c/2f4061ab877d415a1c30e0e736db", "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fa/42/0893b5c8467664b8704663277eca",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3c/5a/2b0714af254c64954ccfe51c70b3", "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/30/4b/6a415939115147395854d7c50716",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1f/ae/c8a885b1a1868b6846b606cdb456", "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ed/e0/a056311241b1b3700c70ca898178",
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a8/f7/5076f509e31ac616815b094a7ef8", "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2c/70/469b776f7919b514117bcdb16529",
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/02/94/9a3f49a8cafa51751a53515ed805", "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/84/dc/93fc2557c515ecb6ee080fb6b265",
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b4/64/33bac83d512e30ad625dbf78203d", "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ac/51/5c932c8d9f7ca698e28dcb8dc8d7",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ce/61/5685c4876a8fb81129982bcc13a6", "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/35/91/8e2437615406c43a15ae67d4714e",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/46/c8/f1649944e6f6cc9d2c2dd8bd2d19", "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fc/01/cf61a57ea19524febe7bd6edcf4a",
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7c/da/9787df7e37481f76011134020772", "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/61/b3/3a269bf8af399980fe46fda021a1",
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bd/0b/255c8b6098f9185f8b4b56ad94b0", "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a9/5b/bff1844978cef9390443b265cdef",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7a/5f/a84d7a8b97401b814de63d1c0dec", "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/52/1d/1e2e800f93b25923dfaaa022d2df",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2f/1c/88c1537599fa83d6bbd1a0d70096", "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c9/b2/c54c61e7585fc44c2b91dcb4bb3c",
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d2/da/f8494cc0118eec16f3d6481562a1", "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/03/04/09f6b3064533d3298ed6515f69d2",
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/44/df/efb51d1c226eac613d48e2cbf0b8", "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c2/b7/ac81850df03263c3e19b97cfda0b",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1c/f6/357fe951c86c9fc5b1b737cd91ae", "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9d/d2/39bd615a599f5ce014ccdea30924",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/04/17/e2de0ab5df6b938d828e8662ce6d", "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/02/39/5e65462a00188a67a438f29b60d1",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/ba/40/81867d90f50a7d4182528f0f7a70", "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/63/51/ef809ce32a76042890a3961d02ea",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/78/50/70f4eecb3a57958efaa42efecea7", "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/c4/7c/1d715d2c2a8b24b990c0f9ba0972",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/95/60/076b20219891d63577d7368530e3", "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/3f/94/ae4c341dc83347996d48e66af558",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/5f/e5/429995f1977370843d3a95c8a715", "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/34/b1/c4b1dba36aa71ebe9f60e85cd239",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/4a/f4/b9f59f182811447254afe0d9035e", "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/d9/ef/e7ded821c1c9e54cf14ebf987167",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/7f/24/dc93a242f74fb7cd4b28e360bb1e", "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/89/95/49ec2633cec7a163cdd674bf83e1",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/bc/f1/ffd0a226708a618dc7fa1ffcd06c", "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/3b/0f/5dd18fdd379cdad194556627282a",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/2c/00/556f149565fab34bc1890468f3ba", "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/5c/e3/50945f08ce1e42dde7faeb142bc0",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/7d/3e/229a581cb2454ed856f1d8b564a7", "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" "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/98/12/571b2160d69d42580e8f31fa6a8d"
} }

View File

@ -1,4 +1,4 @@
### 1.7.7 (build 20732, api 7, 2022-09-02) ### 1.7.7 (build 20734, api 7, 2022-09-02)
- Added `ba.app.meta.load_exported_classes()` for loading classes discovered by the meta subsystem cleanly in a background thread. - 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. - Improved logging of missing playlist game types.
- Some ba.Lstr functionality can now be used in background threads. - Some ba.Lstr functionality can now be used in background threads.
@ -13,6 +13,8 @@
- Continue window will now pause the game to avoid running up times in the background (thanks vishal332008!) - Continue window will now pause the game to avoid running up times in the background (thanks vishal332008!)
- Keepaway and KingOfTheHill now have epic options (thanks FAL-Guys!) - Keepaway and KingOfTheHill now have epic options (thanks FAL-Guys!)
- Spaz starting with gloves no longer loses it after picking up an expiring gloves powerup (thanks itsre3!) - Spaz starting with gloves no longer loses it after picking up an expiring gloves powerup (thanks itsre3!)
- Starting to rename the 'game' thread to the 'logic' thread. This is the thread where most high level app logic happen, not only game logic.
- `_ba.in_game_thread()` is now `_ba.in_logic_thread()`.
### 1.7.6 (build 20687, api 7, 2022-08-11) ### 1.7.6 (build 20687, api 7, 2022-08-11)
- Cleaned up da MetaSubsystem code. - Cleaned up da MetaSubsystem code.

View File

@ -1 +1 @@
255596494167977704690488419471262730072 185890701695841575150474995410209011627

View File

@ -2216,7 +2216,7 @@ def in_game_purchase(item: str, price: int) -> None:
return None return None
def in_game_thread() -> bool: def in_logic_thread() -> bool:
"""(internal) """(internal)
Returns whether or not the current thread is the game thread. Returns whether or not the current thread is the game thread.

View File

@ -351,7 +351,7 @@ class App:
from bastd.actor import spazappearance from bastd.actor import spazappearance
from ba._generated.enums import TimeType from ba._generated.enums import TimeType
assert _ba.in_game_thread() assert _ba.in_logic_thread()
self._aioloop = _asyncio.setup_asyncio() self._aioloop = _asyncio.setup_asyncio()
@ -448,7 +448,7 @@ class App:
def on_meta_scan_complete(self) -> None: def on_meta_scan_complete(self) -> None:
"""Called by meta-scan when it is done doing its thing.""" """Called by meta-scan when it is done doing its thing."""
assert _ba.in_game_thread() assert _ba.in_logic_thread()
self.plugins.on_meta_scan_complete() self.plugins.on_meta_scan_complete()
assert not self._meta_scan_completed assert not self._meta_scan_completed
@ -456,7 +456,7 @@ class App:
self._update_state() self._update_state()
def _update_state(self) -> None: def _update_state(self) -> None:
assert _ba.in_game_thread() assert _ba.in_logic_thread()
if self._app_paused: if self._app_paused:
self.state = self.State.PAUSED self.state = self.State.PAUSED

View File

@ -33,7 +33,7 @@ def setup_asyncio() -> asyncio.AbstractEventLoop:
import ba import ba
from ba._generated.enums import TimeType from ba._generated.enums import TimeType
assert _ba.in_game_thread() assert _ba.in_logic_thread()
# Create our event-loop. We don't expect there to be one # Create our event-loop. We don't expect there to be one
# running on this thread before we do. # running on this thread before we do.

View File

@ -32,7 +32,7 @@ def bootstrap() -> None:
# Give a soft warning if we're being used with a different binary # Give a soft warning if we're being used with a different binary
# version than we expect. # version than we expect.
expected_build = 20732 expected_build = 20734
running_build: int = env['build_number'] running_build: int = env['build_number']
if running_build != expected_build: if running_build != expected_build:
print( print(

View File

@ -24,7 +24,7 @@ if TYPE_CHECKING:
def finish_bootstrapping() -> None: def finish_bootstrapping() -> None:
"""Do final bootstrapping related bits.""" """Do final bootstrapping related bits."""
assert _ba.in_game_thread() assert _ba.in_logic_thread()
# Kick off our asyncio event handling, allowing us to use coroutines # Kick off our asyncio event handling, allowing us to use coroutines
# in our game thread alongside our internal event handling. # in our game thread alongside our internal event handling.

View File

@ -144,7 +144,7 @@ class MetadataSubsystem:
def _wait_for_scan_results(self) -> ScanResults: def _wait_for_scan_results(self) -> ScanResults:
"""Return scan results, blocking if the scan is not yet complete.""" """Return scan results, blocking if the scan is not yet complete."""
if self.scanresults is None: if self.scanresults is None:
if _ba.in_game_thread(): if _ba.in_logic_thread():
logging.warning( logging.warning(
'ba.meta._wait_for_scan_results()' 'ba.meta._wait_for_scan_results()'
' called in logic thread before scan completed;' ' called in logic thread before scan completed;'
@ -177,7 +177,7 @@ class MetadataSubsystem:
def _handle_scan_results(self) -> None: def _handle_scan_results(self) -> None:
"""Called in the logic thread with results of a completed scan.""" """Called in the logic thread with results of a completed scan."""
from ba._language import Lstr from ba._language import Lstr
assert _ba.in_game_thread() assert _ba.in_logic_thread()
results = self.scanresults results = self.scanresults
assert results is not None assert results is not None

View File

@ -133,7 +133,7 @@ class PlaylistAddGameWindow(ba.Window):
# We asked for a bg thread completion cb so we can do some # We asked for a bg thread completion cb so we can do some
# filtering here in the bg thread where its not gonna cause hitches. # filtering here in the bg thread where its not gonna cause hitches.
assert not _ba.in_game_thread() assert not _ba.in_logic_thread()
sessiontype = self._editcontroller.get_session_type() sessiontype = self._editcontroller.get_session_type()
unowned = get_unowned_game_types() unowned = get_unowned_game_types()
self._game_types = [ self._game_types = [

View File

@ -8,7 +8,7 @@
namespace ballistica { namespace ballistica {
Audio::Audio() { assert(InGameThread()); } Audio::Audio() { assert(InLogicThread()); }
void Audio::Init() { void Audio::Init() {
// Init our singleton. // Init our singleton.
@ -17,7 +17,7 @@ void Audio::Init() {
} }
void Audio::Reset() { void Audio::Reset() {
assert(InGameThread()); assert(InLogicThread());
g_audio_server->PushResetCall(); g_audio_server->PushResetCall();
} }
@ -129,7 +129,7 @@ auto Audio::ShouldPlay(SoundData* sound) -> bool {
} }
void Audio::PlaySound(SoundData* sound, float volume) { void Audio::PlaySound(SoundData* sound, float volume) {
assert(InGameThread()); assert(InLogicThread());
BA_DEBUG_FUNCTION_TIMER_BEGIN(); BA_DEBUG_FUNCTION_TIMER_BEGIN();
assert(sound); assert(sound);
if (!ShouldPlay(sound)) { if (!ShouldPlay(sound)) {

View File

@ -1123,7 +1123,7 @@ void AudioServer::AddSoundRefDelete(const Object::Ref<SoundData>* c) {
} }
void AudioServer::ClearSoundRefDeleteList() { void AudioServer::ClearSoundRefDeleteList() {
assert(InGameThread()); assert(InLogicThread());
std::lock_guard<std::mutex> lock(sound_ref_delete_list_mutex_); std::lock_guard<std::mutex> lock(sound_ref_delete_list_mutex_);
for (const Object::Ref<SoundData>* i : sound_ref_delete_list_) { for (const Object::Ref<SoundData>* i : sound_ref_delete_list_) {
delete i; delete i;

View File

@ -21,7 +21,7 @@
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 kAppBuildNumber = 20732; const int kAppBuildNumber = 20734;
const char* kAppVersion = "1.7.7"; const char* kAppVersion = "1.7.7";
// Our standalone globals. // Our standalone globals.
@ -102,13 +102,13 @@ auto BallisticaMain(int argc, char** argv) -> int {
g_app_globals->pausable_threads.push_back(media_thread); g_app_globals->pausable_threads.push_back(media_thread);
auto* audio_thread = new Thread(ThreadIdentifier::kAudio); auto* audio_thread = new Thread(ThreadIdentifier::kAudio);
g_app_globals->pausable_threads.push_back(audio_thread); g_app_globals->pausable_threads.push_back(audio_thread);
auto* game_thread = new Thread(ThreadIdentifier::kGame); auto* logic_thread = new Thread(ThreadIdentifier::kLogic);
g_app_globals->pausable_threads.push_back(game_thread); g_app_globals->pausable_threads.push_back(logic_thread);
auto* network_write_thread = new Thread(ThreadIdentifier::kNetworkWrite); auto* network_write_thread = new Thread(ThreadIdentifier::kNetworkWrite);
g_app_globals->pausable_threads.push_back(network_write_thread); g_app_globals->pausable_threads.push_back(network_write_thread);
// And add our other standard modules to them. // And add our other standard modules to them.
game_thread->AddModule<Game>(); logic_thread->AddModule<Game>();
network_write_thread->AddModule<NetworkWriteModule>(); network_write_thread->AddModule<NetworkWriteModule>();
media_thread->AddModule<MediaServer>(); media_thread->AddModule<MediaServer>();
g_main_thread->AddModule<GraphicsServer>(); g_main_thread->AddModule<GraphicsServer>();
@ -238,7 +238,7 @@ auto GetAppInstanceUUID() -> const std::string& {
return session_id; return session_id;
} }
auto InGameThread() -> bool { auto InLogicThread() -> bool {
return (g_game && g_game->thread()->IsCurrent()); return (g_game && g_game->thread()->IsCurrent());
} }

View File

@ -180,7 +180,7 @@ auto AppInternalPushPurchaseTransactionCall(const std::string& item,
const std::string& order_id, const std::string& order_id,
bool user_initiated) -> void; bool user_initiated) -> void;
auto AppInternalGetPublicAccountID() -> std::string; auto AppInternalGetPublicAccountID() -> std::string;
auto AppInternalOnGameThreadPause() -> void; auto AppInternalOnLogicThreadPause() -> void;
auto AppInternalDirectSendLogs(const std::string& prefix, auto AppInternalDirectSendLogs(const std::string& prefix,
const std::string& suffix, bool instant, const std::string& suffix, bool instant,
int* result = nullptr) -> void; int* result = nullptr) -> void;
@ -215,7 +215,7 @@ auto FatalError(const std::string& message = "") -> void;
// Check current-threads. // Check current-threads.
auto InMainThread() -> bool; // (main and graphics are same currently) auto InMainThread() -> bool; // (main and graphics are same currently)
auto InGraphicsThread() -> bool; // (main and graphics are same currently) auto InGraphicsThread() -> bool; // (main and graphics are same currently)
auto InGameThread() -> bool; auto InLogicThread() -> bool;
auto InAudioThread() -> bool; auto InAudioThread() -> bool;
auto InBGDynamicsThread() -> bool; auto InBGDynamicsThread() -> bool;
auto InMediaThread() -> bool; auto InMediaThread() -> bool;

View File

@ -25,7 +25,7 @@ auto ContextTarget::GetAsHostActivity() -> HostActivity* { return nullptr; }
auto ContextTarget::GetAsUIContext() -> UI* { return nullptr; } auto ContextTarget::GetAsUIContext() -> UI* { return nullptr; }
auto ContextTarget::GetMutableScene() -> Scene* { return nullptr; } auto ContextTarget::GetMutableScene() -> Scene* { return nullptr; }
Context::Context() : target(g_context->target) { assert(InGameThread()); } Context::Context() : target(g_context->target) { assert(InLogicThread()); }
auto Context::operator==(const Context& other) const -> bool { auto Context::operator==(const Context& other) const -> bool {
return (target.get() == other.target.get()); return (target.get() == other.target.get());
@ -34,7 +34,7 @@ auto Context::operator==(const Context& other) const -> bool {
Context::Context(ContextTarget* target_in) : target(target_in) {} Context::Context(ContextTarget* target_in) : target(target_in) {}
auto Context::GetHostSession() const -> HostSession* { auto Context::GetHostSession() const -> HostSession* {
assert(InGameThread()); assert(InLogicThread());
if (target.exists()) return target->GetHostSession(); if (target.exists()) return target->GetHostSession();
return nullptr; return nullptr;
} }
@ -60,28 +60,28 @@ auto Context::GetUIContext() const -> UI* {
} }
ScopedSetContext::ScopedSetContext(const Object::Ref<ContextTarget>& target) { ScopedSetContext::ScopedSetContext(const Object::Ref<ContextTarget>& target) {
assert(InGameThread()); assert(InLogicThread());
assert(g_context); assert(g_context);
context_prev_ = *g_context; context_prev_ = *g_context;
g_context->target = target; g_context->target = target;
} }
ScopedSetContext::ScopedSetContext(ContextTarget* target) { ScopedSetContext::ScopedSetContext(ContextTarget* target) {
assert(InGameThread()); assert(InLogicThread());
assert(g_context); assert(g_context);
context_prev_ = *g_context; context_prev_ = *g_context;
g_context->target = target; g_context->target = target;
} }
ScopedSetContext::ScopedSetContext(const Context& context) { ScopedSetContext::ScopedSetContext(const Context& context) {
assert(InGameThread()); assert(InLogicThread());
assert(g_context); assert(g_context);
context_prev_ = *g_context; context_prev_ = *g_context;
*g_context = context; *g_context = context;
} }
ScopedSetContext::~ScopedSetContext() { ScopedSetContext::~ScopedSetContext() {
assert(InGameThread()); assert(InLogicThread());
assert(g_context); assert(g_context);
// Restore old. // Restore old.
*g_context = context_prev_; *g_context = context_prev_;

View File

@ -20,13 +20,13 @@ class Context {
assert(g_context); assert(g_context);
// Context can only be accessed from the game thread. // Context can only be accessed from the game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
return *g_context; return *g_context;
} }
static void set_current(const Context& context) { static void set_current(const Context& context) {
// Context can only be accessed from the game thread. // Context can only be accessed from the game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
*g_context = context; *g_context = context;
} }

View File

@ -137,7 +137,7 @@ auto Object::GetThreadOwnership() const -> Object::ThreadOwnership {
} }
auto Object::GetDefaultOwnerThread() const -> ThreadIdentifier { auto Object::GetDefaultOwnerThread() const -> ThreadIdentifier {
return ThreadIdentifier::kGame; return ThreadIdentifier::kLogic;
} }
#if BA_DEBUG_BUILD #if BA_DEBUG_BUILD
@ -145,8 +145,8 @@ auto Object::GetDefaultOwnerThread() const -> ThreadIdentifier {
static auto GetCurrentThreadIdentifier() -> ThreadIdentifier { static auto GetCurrentThreadIdentifier() -> ThreadIdentifier {
if (InMainThread()) { if (InMainThread()) {
return ThreadIdentifier::kMain; return ThreadIdentifier::kMain;
} else if (InGameThread()) { } else if (InLogicThread()) {
return ThreadIdentifier::kGame; return ThreadIdentifier::kLogic;
} else if (InAudioThread()) { } else if (InAudioThread()) {
return ThreadIdentifier::kAudio; return ThreadIdentifier::kAudio;
} else if (InNetworkWriteThread()) { } else if (InNetworkWriteThread()) {
@ -194,9 +194,9 @@ void Object::ObjectThreadCheck() {
DO_FAIL("Main"); DO_FAIL("Main");
} }
break; break;
case ThreadIdentifier::kGame: case ThreadIdentifier::kLogic:
if (!InGameThread()) { if (!InLogicThread()) {
DO_FAIL("Game"); DO_FAIL("Logic");
} }
break; break;
case ThreadIdentifier::kAudio: case ThreadIdentifier::kAudio:

View File

@ -59,7 +59,7 @@ class Object {
/// Return the exact thread to check for with ThreadOwnership::kClassDefault /// Return the exact thread to check for with ThreadOwnership::kClassDefault
/// (in the default ObjectThreadCheck implementation at least). /// (in the default ObjectThreadCheck implementation at least).
/// Default returns ThreadIdentifier::kGame /// Default returns ThreadIdentifier::kLogic
virtual auto GetDefaultOwnerThread() const -> ThreadIdentifier; virtual auto GetDefaultOwnerThread() const -> ThreadIdentifier;
/// Set thread ownership values for an individual object. /// Set thread ownership values for an individual object.
@ -70,7 +70,7 @@ class Object {
/// with just set_thread_checks_enabled() for temp special cases... /// with just set_thread_checks_enabled() for temp special cases...
void SetThreadOwnership( void SetThreadOwnership(
ThreadOwnership ownership, ThreadOwnership ownership,
ThreadIdentifier thread_identifier = ThreadIdentifier::kGame) { ThreadIdentifier thread_identifier = ThreadIdentifier::kLogic) {
#if BA_DEBUG_BUILD #if BA_DEBUG_BUILD
thread_ownership_ = ownership; thread_ownership_ = ownership;
if (thread_ownership_ == ThreadOwnership::kNextReferencing) { if (thread_ownership_ == ThreadOwnership::kNextReferencing) {

View File

@ -71,7 +71,7 @@ void Thread::KillModules() {
// These are all exactly the same, but by running different ones for // These are all exactly the same, but by running different ones for
// different thread groups makes its easy to see which thread is which // different thread groups makes its easy to see which thread is which
// in profilers, backtraces, etc. // in profilers, backtraces, etc.
auto Thread::RunGameThread(void* data) -> int { auto Thread::RunLogicThread(void* data) -> int {
return static_cast<Thread*>(data)->ThreadMain(); return static_cast<Thread*>(data)->ThreadMain();
} }
@ -295,8 +295,8 @@ Thread::Thread(ThreadIdentifier identifier_in, ThreadType type_in)
// it's ready to go. // it's ready to go.
int (*func)(void*); int (*func)(void*);
switch (identifier_) { switch (identifier_) {
case ThreadIdentifier::kGame: case ThreadIdentifier::kLogic:
func = RunGameThread; func = RunLogicThread;
break; break;
case ThreadIdentifier::kMedia: case ThreadIdentifier::kMedia:
func = RunMediaThread; func = RunMediaThread;
@ -354,8 +354,8 @@ auto Thread::ThreadMain() -> int {
const char* id_string; const char* id_string;
switch (identifier_) { switch (identifier_) {
case ThreadIdentifier::kGame: case ThreadIdentifier::kLogic:
id_string = "ballistica game"; id_string = "ballistica logic";
break; break;
case ThreadIdentifier::kStdin: case ThreadIdentifier::kStdin:
id_string = "ballistica stdin"; id_string = "ballistica stdin";

View File

@ -223,7 +223,7 @@ class Thread {
// These are all exactly the same, but by running different ones for // These are all exactly the same, but by running different ones for
// different thread groups makes its easy to see which thread is which // different thread groups makes its easy to see which thread is which
// in profilers, backtraces, etc. // in profilers, backtraces, etc.
static auto RunGameThread(void* data) -> int; static auto RunLogicThread(void* data) -> int;
static auto RunAudioThread(void* data) -> int; static auto RunAudioThread(void* data) -> int;
static auto RunBGDynamicThread(void* data) -> int; static auto RunBGDynamicThread(void* data) -> int;
static auto RunNetworkWriteThread(void* data) -> int; static auto RunNetworkWriteThread(void* data) -> int;

View File

@ -995,10 +995,10 @@ enum class ThreadType {
/// Used for module-thread identification. /// Used for module-thread identification.
/// Mostly just for debugging, through a few things are affected by this /// Mostly just for debugging, through a few things are affected by this
/// (the GAME thread manages the python GIL, etc). /// (the Logic thread manages the python GIL, etc).
enum class ThreadIdentifier { enum class ThreadIdentifier {
kInvalid, kInvalid,
kGame, kLogic,
kMedia, kMedia,
kFileOut, kFileOut,
kMain, kMain,

View File

@ -20,13 +20,13 @@ void BGDynamics::Init() {
} }
BGDynamics::BGDynamics() { BGDynamics::BGDynamics() {
assert(InGameThread()); assert(InLogicThread());
assert(g_bg_dynamics == nullptr); assert(g_bg_dynamics == nullptr);
g_bg_dynamics = this; g_bg_dynamics = this;
} }
void BGDynamics::AddTerrain(CollideModelData* o) { void BGDynamics::AddTerrain(CollideModelData* o) {
assert(InGameThread()); assert(InLogicThread());
// Allocate a fresh reference to keep this collide-model alive as long as // Allocate a fresh reference to keep this collide-model alive as long as
// we're using it. Once we're done, we'll pass the pointer back to the // we're using it. Once we're done, we'll pass the pointer back to the
@ -36,18 +36,18 @@ void BGDynamics::AddTerrain(CollideModelData* o) {
} }
void BGDynamics::RemoveTerrain(CollideModelData* o) { void BGDynamics::RemoveTerrain(CollideModelData* o) {
assert(InGameThread()); assert(InLogicThread());
g_bg_dynamics_server->PushRemoveTerrainCall(o); g_bg_dynamics_server->PushRemoveTerrainCall(o);
} }
void BGDynamics::Emit(const BGDynamicsEmission& e) { void BGDynamics::Emit(const BGDynamicsEmission& e) {
assert(InGameThread()); assert(InLogicThread());
g_bg_dynamics_server->PushEmitCall(e); g_bg_dynamics_server->PushEmitCall(e);
} }
// Call friend client to step our sim. // Call friend client to step our sim.
void BGDynamics::Step(const Vector3f& cam_pos) { void BGDynamics::Step(const Vector3f& cam_pos) {
assert(InGameThread()); assert(InLogicThread());
// The BG dynamics thread just processes steps as fast as it can; // The BG dynamics thread just processes steps as fast as it can;
// we need to throttle what we send or tell it to cut back if its behind // we need to throttle what we send or tell it to cut back if its behind
@ -158,17 +158,17 @@ void BGDynamics::TooSlow() {
} }
void BGDynamics::SetDebrisFriction(float val) { void BGDynamics::SetDebrisFriction(float val) {
assert(InGameThread()); assert(InLogicThread());
g_bg_dynamics_server->PushSetDebrisFrictionCall(val); g_bg_dynamics_server->PushSetDebrisFrictionCall(val);
} }
void BGDynamics::SetDebrisKillHeight(float val) { void BGDynamics::SetDebrisKillHeight(float val) {
assert(InGameThread()); assert(InLogicThread());
g_bg_dynamics_server->PushSetDebrisKillHeightCall(val); g_bg_dynamics_server->PushSetDebrisKillHeightCall(val);
} }
void BGDynamics::Draw(FrameDef* frame_def) { void BGDynamics::Draw(FrameDef* frame_def) {
assert(InGameThread()); assert(InLogicThread());
BGDynamicsDrawSnapshot* ds{draw_snapshot_.get()}; BGDynamicsDrawSnapshot* ds{draw_snapshot_.get()};
if (!ds) { if (!ds) {

View File

@ -23,7 +23,7 @@ class BGDynamicsDrawSnapshot {
// These are created in the bg-dynamics thread, and object ownership // These are created in the bg-dynamics thread, and object ownership
// needs to be switched back to the game-thread default when it is passed // needs to be switched back to the game-thread default when it is passed
// over or else the debug thread-access-checks will error. // over or else the debug thread-access-checks will error.
void SetGameThreadOwnership() { void SetLogicThreadOwnership() {
if (g_buildconfig.debug_build()) { if (g_buildconfig.debug_build()) {
for (Object* o : {static_cast<Object*>(tendril_indices.get()), for (Object* o : {static_cast<Object*>(tendril_indices.get()),
static_cast<Object*>(tendril_vertices.get()), static_cast<Object*>(tendril_vertices.get()),

View File

@ -8,7 +8,7 @@ namespace ballistica {
BGDynamicsFuse::BGDynamicsFuse() { BGDynamicsFuse::BGDynamicsFuse() {
assert(g_bg_dynamics_server); assert(g_bg_dynamics_server);
assert(InGameThread()); assert(InLogicThread());
// Allocate our data. We'll pass this to the BGDynamics thread, and // Allocate our data. We'll pass this to the BGDynamics thread, and
// it'll then own it. // it'll then own it.
@ -18,7 +18,7 @@ BGDynamicsFuse::BGDynamicsFuse() {
BGDynamicsFuse::~BGDynamicsFuse() { BGDynamicsFuse::~BGDynamicsFuse() {
assert(g_bg_dynamics_server); assert(g_bg_dynamics_server);
assert(InGameThread()); assert(InLogicThread());
// Let the data know the client side is dead // Let the data know the client side is dead
// so that we're no longer included in step messages. // so that we're no longer included in step messages.
@ -28,13 +28,13 @@ BGDynamicsFuse::~BGDynamicsFuse() {
} }
void BGDynamicsFuse::SetTransform(const Matrix44f& t) { void BGDynamicsFuse::SetTransform(const Matrix44f& t) {
assert(InGameThread()); assert(InLogicThread());
data_->transform_client_ = t; data_->transform_client_ = t;
data_->have_transform_client_ = true; data_->have_transform_client_ = true;
} }
void BGDynamicsFuse::SetLength(float length) { void BGDynamicsFuse::SetLength(float length) {
assert(InGameThread()); assert(InLogicThread());
data_->length_client_ = length; data_->length_client_ = length;
} }

View File

@ -2314,7 +2314,7 @@ void BGDynamicsServer::Step(StepData* step_data) {
// so they can draw us. // so they can draw us.
BGDynamicsDrawSnapshot* snapshot = CreateDrawSnapshot(); BGDynamicsDrawSnapshot* snapshot = CreateDrawSnapshot();
g_game->PushCall([snapshot] { g_game->PushCall([snapshot] {
snapshot->SetGameThreadOwnership(); snapshot->SetLogicThreadOwnership();
g_bg_dynamics->SetDrawSnapshot(snapshot); g_bg_dynamics->SetDrawSnapshot(snapshot);
}); });

View File

@ -9,7 +9,7 @@
namespace ballistica { namespace ballistica {
BGDynamicsShadow::BGDynamicsShadow(float height_scaling) { BGDynamicsShadow::BGDynamicsShadow(float height_scaling) {
assert(InGameThread()); assert(InLogicThread());
// allocate our shadow data... we'll pass this to the BGDynamics thread, // allocate our shadow data... we'll pass this to the BGDynamics thread,
// which will then own it. // which will then own it.
@ -19,7 +19,7 @@ BGDynamicsShadow::BGDynamicsShadow(float height_scaling) {
} }
BGDynamicsShadow::~BGDynamicsShadow() { BGDynamicsShadow::~BGDynamicsShadow() {
assert(InGameThread()); assert(InLogicThread());
assert(g_bg_dynamics_server); assert(g_bg_dynamics_server);
// let the data know the client side is dead, // let the data know the client side is dead,
@ -30,17 +30,17 @@ BGDynamicsShadow::~BGDynamicsShadow() {
} }
void BGDynamicsShadow::SetPosition(const Vector3f& pos) { void BGDynamicsShadow::SetPosition(const Vector3f& pos) {
assert(InGameThread()); assert(InLogicThread());
data_->pos_client = pos; data_->pos_client = pos;
} }
auto BGDynamicsShadow::GetPosition() const -> const Vector3f& { auto BGDynamicsShadow::GetPosition() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return data_->pos_client; return data_->pos_client;
} }
void BGDynamicsShadow::GetValues(float* scale, float* density) const { void BGDynamicsShadow::GetValues(float* scale, float* density) const {
assert(InGameThread()); assert(InLogicThread());
assert(scale); assert(scale);
assert(density); assert(density);

View File

@ -7,7 +7,7 @@
namespace ballistica { namespace ballistica {
BGDynamicsVolumeLight::BGDynamicsVolumeLight() { BGDynamicsVolumeLight::BGDynamicsVolumeLight() {
assert(InGameThread()); assert(InLogicThread());
// allocate our light data... we'll pass this to the BGDynamics thread, // allocate our light data... we'll pass this to the BGDynamics thread,
// which will then own it // which will then own it
data_ = new BGDynamicsVolumeLightData(); data_ = new BGDynamicsVolumeLightData();
@ -16,7 +16,7 @@ BGDynamicsVolumeLight::BGDynamicsVolumeLight() {
} }
BGDynamicsVolumeLight::~BGDynamicsVolumeLight() { BGDynamicsVolumeLight::~BGDynamicsVolumeLight() {
assert(InGameThread()); assert(InLogicThread());
// let the data know the client side is dead, // let the data know the client side is dead,
// so we're no longer included in step messages // so we're no longer included in step messages
@ -28,17 +28,17 @@ BGDynamicsVolumeLight::~BGDynamicsVolumeLight() {
} }
void BGDynamicsVolumeLight::SetPosition(const Vector3f& pos) { void BGDynamicsVolumeLight::SetPosition(const Vector3f& pos) {
assert(InGameThread()); assert(InLogicThread());
data_->pos_client = pos; data_->pos_client = pos;
} }
void BGDynamicsVolumeLight::SetRadius(float radius) { void BGDynamicsVolumeLight::SetRadius(float radius) {
assert(InGameThread()); assert(InLogicThread());
data_->radius_client = radius; data_->radius_client = radius;
} }
void BGDynamicsVolumeLight::SetColor(float r, float g, float b) { void BGDynamicsVolumeLight::SetColor(float r, float g, float b) {
assert(InGameThread()); assert(InLogicThread());
data_->r_client = r; data_->r_client = r;
data_->g_client = g; data_->g_client = g;
data_->b_client = b; data_->b_client = b;

View File

@ -14,7 +14,7 @@ namespace ballistica {
class MaterialComponent : public Object { class MaterialComponent : public Object {
public: public:
auto GetDefaultOwnerThread() const -> ThreadIdentifier override { auto GetDefaultOwnerThread() const -> ThreadIdentifier override {
return ThreadIdentifier::kGame; return ThreadIdentifier::kLogic;
} }
auto GetFlattenedSize() -> size_t; auto GetFlattenedSize() -> size_t;

View File

@ -150,7 +150,7 @@ void Account::SetLogin(V1AccountType account_type, V1LoginState login_state,
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
// We call out to Python so need to be in game thread. // We call out to Python so need to be in game thread.
assert(InGameThread()); assert(InLogicThread());
if (login_state_ != login_state if (login_state_ != login_state
|| g_app_globals->account_type != account_type || login_id_ != login_id || g_app_globals->account_type != account_type || login_id_ != login_id
|| login_name_ != login_name) { || login_name_ != login_name) {

View File

@ -61,7 +61,7 @@ auto ConnectionSet::Update() -> void {
} }
auto ConnectionSet::GetConnectedClientCount() const -> int { auto ConnectionSet::GetConnectedClientCount() const -> int {
assert(InGameThread()); assert(InLogicThread());
int count = 0; int count = 0;
for (auto&& i : connections_to_clients_) { for (auto&& i : connections_to_clients_) {
if (i.second.exists() && i.second->can_communicate()) { if (i.second.exists() && i.second->can_communicate()) {
@ -312,7 +312,7 @@ auto ConnectionSet::HandleClientDisconnected(int id) -> void {
} }
auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool { auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool {
assert(InGameThread()); assert(InLogicThread());
if (connection_to_host_.exists()) { if (connection_to_host_.exists()) {
// Kick-votes first appeared in 14248 // Kick-votes first appeared in 14248

View File

@ -24,7 +24,7 @@ class ConnectionSet {
// Quick test as to whether there are clients. Does not check if they are // Quick test as to whether there are clients. Does not check if they are
// fully connected. // fully connected.
auto has_connection_to_clients() const -> bool { auto has_connection_to_clients() const -> bool {
assert(InGameThread()); assert(InLogicThread());
return (!connections_to_clients_.empty()); return (!connections_to_clients_.empty());
} }

View File

@ -270,7 +270,7 @@ void ConnectionToHost::HandleGamePacket(const std::vector<uint8_t>& data) {
#pragma clang diagnostic pop #pragma clang diagnostic pop
void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) { void ConnectionToHost::HandleMessagePacket(const std::vector<uint8_t>& buffer) {
assert(InGameThread()); assert(InLogicThread());
if (buffer.empty()) { if (buffer.empty()) {
Log("Error: got invalid HandleMessagePacket"); Log("Error: got invalid HandleMessagePacket");

View File

@ -249,7 +249,7 @@ void Game::PushVRHandsState(const VRHandsState& state) {
void Game::PushMediaPruneCall(int level) { void Game::PushMediaPruneCall(int level) {
PushCall([level] { PushCall([level] {
assert(InGameThread()); assert(InLogicThread());
g_media->Prune(level); g_media->Prune(level);
}); });
} }
@ -268,7 +268,7 @@ void Game::PushInitialScreenCreatedCall() {
} }
void Game::InitialScreenCreated() { void Game::InitialScreenCreated() {
assert(InGameThread()); assert(InLogicThread());
// Ok; graphics-server is telling us we've got a screen. // Ok; graphics-server is telling us we've got a screen.
@ -305,7 +305,7 @@ void Game::Prune() { g_media->Prune(); }
// Launch into main menu or whatever else. // Launch into main menu or whatever else.
void Game::RunAppLaunchCommands() { void Game::RunAppLaunchCommands() {
assert(InGameThread()); assert(InLogicThread());
assert(!ran_app_launch_commands_); assert(!ran_app_launch_commands_);
// First off, run our python app-launch call. // First off, run our python app-launch call.
@ -336,7 +336,7 @@ Game::~Game() = default;
// Set up our sleeping based on what we're doing. // Set up our sleeping based on what we're doing.
void Game::UpdateProcessTimer() { void Game::UpdateProcessTimer() {
assert(InGameThread()); assert(InLogicThread());
// This might get called before we set up our timer in some cases. (such as // This might get called before we set up our timer in some cases. (such as
// very early) should be safe to ignore since we update the interval // very early) should be safe to ignore since we update the interval
@ -496,7 +496,7 @@ void Game::HandleQuitOnIdle() {
idle_exiting_ = true; idle_exiting_ = true;
PushCall([this, idle_seconds] { PushCall([this, idle_seconds] {
assert(InGameThread()); assert(InLogicThread());
// Just go through _ba.quit() // Just go through _ba.quit()
// FIXME: Shouldn't need to go out to the python layer here... // FIXME: Shouldn't need to go out to the python layer here...
@ -509,7 +509,7 @@ void Game::HandleQuitOnIdle() {
// Bring our scenes, real-time timers, etc up to date. // Bring our scenes, real-time timers, etc up to date.
void Game::Update() { void Game::Update() {
auto startms{Platform::GetCurrentMilliseconds()}; auto startms{Platform::GetCurrentMilliseconds()};
assert(InGameThread()); assert(InLogicThread());
millisecs_t real_time = GetRealTime(); millisecs_t real_time = GetRealTime();
g_platform->SetDebugKey("LastUpdateTime", std::to_string(startms)); g_platform->SetDebugKey("LastUpdateTime", std::to_string(startms));
if (first_update_) { if (first_update_) {
@ -667,7 +667,7 @@ void Game::Update() {
// Reset the game to a blank slate. // Reset the game to a blank slate.
void Game::Reset() { void Game::Reset() {
assert(InGameThread()); assert(InLogicThread());
// Tear down any existing setup. // Tear down any existing setup.
// This should allow high-level objects to die gracefully. // This should allow high-level objects to die gracefully.
@ -707,7 +707,7 @@ auto Game::IsInUIContext() const -> bool {
void Game::PushShowURLCall(const std::string& url) { void Game::PushShowURLCall(const std::string& url) {
PushCall([url] { PushCall([url] {
assert(InGameThread()); assert(InLogicThread());
assert(g_python); assert(g_python);
g_python->ShowURL(url); g_python->ShowURL(url);
}); });
@ -724,7 +724,7 @@ auto Game::GetForegroundContext() -> Context {
void Game::PushBackButtonCall(InputDevice* input_device) { void Game::PushBackButtonCall(InputDevice* input_device) {
PushCall([this, input_device] { PushCall([this, input_device] {
assert(InGameThread()); assert(InLogicThread());
// Ignore if UI isn't up yet. // Ignore if UI isn't up yet.
if (!g_ui || !g_ui->overlay_root_widget() || !g_ui->screen_root_widget()) { if (!g_ui || !g_ui->overlay_root_widget() || !g_ui->screen_root_widget()) {
@ -773,12 +773,12 @@ void Game::PushStringEditCancelCall() {
// Called by a newly made Session instance to set itself as the current // Called by a newly made Session instance to set itself as the current
// session. // session.
void Game::SetForegroundSession(Session* s) { void Game::SetForegroundSession(Session* s) {
assert(InGameThread()); assert(InLogicThread());
foreground_session_ = s; foreground_session_ = s;
} }
void Game::SetForegroundScene(Scene* sg) { void Game::SetForegroundScene(Scene* sg) {
assert(InGameThread()); assert(InLogicThread());
if (foreground_scene_.get() != sg) { if (foreground_scene_.get() != sg) {
foreground_scene_ = sg; foreground_scene_ = sg;
@ -795,7 +795,7 @@ void Game::LaunchClientSession() {
"can't launch a session from within a session update; use " "can't launch a session from within a session update; use "
"ba.pushcall()"); "ba.pushcall()");
} }
assert(InGameThread()); assert(InLogicThread());
// Don't want to pick up any old stuff in here. // Don't want to pick up any old stuff in here.
ScopedSetContext cp(nullptr); ScopedSetContext cp(nullptr);
@ -824,7 +824,7 @@ void Game::LaunchReplaySession(const std::string& file_name) {
"can't launch a session from within a session update; use " "can't launch a session from within a session update; use "
"ba.pushcall()"); "ba.pushcall()");
assert(InGameThread()); assert(InLogicThread());
// Don't want to pick up any old stuff in here. // Don't want to pick up any old stuff in here.
ScopedSetContext cp(nullptr); ScopedSetContext cp(nullptr);
@ -856,7 +856,7 @@ void Game::LaunchHostSession(PyObject* session_type_obj,
"ba.pushcall()"); "ba.pushcall()");
} }
assert(InGameThread()); assert(InLogicThread());
connections_->PrepareForLaunchHostSession(); connections_->PrepareForLaunchHostSession();
@ -884,12 +884,12 @@ void Game::LaunchHostSession(PyObject* session_type_obj,
} }
void Game::RunMainMenu() { void Game::RunMainMenu() {
assert(InGameThread()); assert(InLogicThread());
if (g_app_globals->shutting_down) { if (g_app_globals->shutting_down) {
return; return;
} }
assert(g_python); assert(g_python);
assert(InGameThread()); assert(InLogicThread());
PythonRef result = PythonRef result =
g_python->obj(Python::ObjID::kLaunchMainMenuSessionCall).Call(); g_python->obj(Python::ObjID::kLaunchMainMenuSessionCall).Call();
if (!result.exists()) { if (!result.exists()) {
@ -964,7 +964,7 @@ void Game::PushStdinScriptCommand(const std::string& command) {
void Game::PushInterruptSignalCall() { void Game::PushInterruptSignalCall() {
PushCall([this] { PushCall([this] {
assert(InGameThread()); assert(InLogicThread());
// Special case; when running under the server-wrapper, we completely // Special case; when running under the server-wrapper, we completely
// ignore interrupt signals (the wrapper acts on them). // ignore interrupt signals (the wrapper acts on them).
@ -979,7 +979,7 @@ void Game::PushInterruptSignalCall() {
void Game::PushAskUserForTelnetAccessCall() { void Game::PushAskUserForTelnetAccessCall() {
PushCall([this] { PushCall([this] {
assert(InGameThread()); assert(InLogicThread());
ScopedSetContext cp(GetUIContext()); ScopedSetContext cp(GetUIContext());
g_python->obj(Python::ObjID::kTelnetAccessRequestCall).Call(); g_python->obj(Python::ObjID::kTelnetAccessRequestCall).Call();
}); });
@ -990,12 +990,12 @@ void Game::HandleThreadPause() {
// Let Python and internal layers do their thing. // Let Python and internal layers do their thing.
g_python->obj(Python::ObjID::kOnAppPauseCall).Call(); g_python->obj(Python::ObjID::kOnAppPauseCall).Call();
AppInternalOnGameThreadPause(); AppInternalOnLogicThreadPause();
} }
void Game::PushPythonCall(const Object::Ref<PythonContextCall>& call) { void Game::PushPythonCall(const Object::Ref<PythonContextCall>& call) {
// Since we're mucking with refs, need to limit to game thread. // Since we're mucking with refs, need to limit to game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
BA_PRECONDITION(call->object_strong_ref_count() > 0); BA_PRECONDITION(call->object_strong_ref_count() > 0);
PushCall([call] { PushCall([call] {
assert(call.exists()); assert(call.exists());
@ -1006,7 +1006,7 @@ void Game::PushPythonCall(const Object::Ref<PythonContextCall>& call) {
void Game::PushPythonCallArgs(const Object::Ref<PythonContextCall>& call, void Game::PushPythonCallArgs(const Object::Ref<PythonContextCall>& call,
const PythonRef& args) { const PythonRef& args) {
// Since we're mucking with refs, need to limit to game thread. // Since we're mucking with refs, need to limit to game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
BA_PRECONDITION(call->object_strong_ref_count() > 0); BA_PRECONDITION(call->object_strong_ref_count() > 0);
PushCall([call, args] { PushCall([call, args] {
assert(call.exists()); assert(call.exists());
@ -1016,7 +1016,7 @@ void Game::PushPythonCallArgs(const Object::Ref<PythonContextCall>& call,
void Game::PushPythonWeakCall(const Object::WeakRef<PythonContextCall>& call) { void Game::PushPythonWeakCall(const Object::WeakRef<PythonContextCall>& call) {
// Since we're mucking with refs, need to limit to game thread. // Since we're mucking with refs, need to limit to game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
// Even though we only hold a weak ref, we expect a valid strong-reffed // Even though we only hold a weak ref, we expect a valid strong-reffed
// object to be passed in. // object to be passed in.
@ -1033,7 +1033,7 @@ void Game::PushPythonWeakCall(const Object::WeakRef<PythonContextCall>& call) {
void Game::PushPythonWeakCallArgs( void Game::PushPythonWeakCallArgs(
const Object::WeakRef<PythonContextCall>& call, const PythonRef& args) { const Object::WeakRef<PythonContextCall>& call, const PythonRef& args) {
// Since we're mucking with refs, need to limit to game thread. // Since we're mucking with refs, need to limit to game thread.
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
// Even though we only hold a weak ref, we expect a valid strong-reffed // Even though we only hold a weak ref, we expect a valid strong-reffed
// object to be passed in. // object to be passed in.
@ -1046,7 +1046,7 @@ void Game::PushPythonWeakCallArgs(
void Game::PushPythonRawCallable(PyObject* callable) { void Game::PushPythonRawCallable(PyObject* callable) {
PushCall([this, callable] { PushCall([this, callable] {
assert(InGameThread()); assert(InLogicThread());
// Lets run this in the UI context. // Lets run this in the UI context.
// (can add other options if we need later) // (can add other options if we need later)
@ -1079,7 +1079,7 @@ void Game::SetDebugSpeedExponent(int val) {
} }
void Game::ChangeGameSpeed(int offs) { void Game::ChangeGameSpeed(int offs) {
assert(InGameThread()); assert(InLogicThread());
// If we're in a replay session, adjust playback speed there. // If we're in a replay session, adjust playback speed there.
if (dynamic_cast<ReplayClientSession*>(GetForegroundSession())) { if (dynamic_cast<ReplayClientSession*>(GetForegroundSession())) {
@ -1126,7 +1126,7 @@ void Game::PushMainMenuPressCall(InputDevice* device) {
} }
void Game::MainMenuPress(InputDevice* device) { void Game::MainMenuPress(InputDevice* device) {
assert(InGameThread()); assert(InLogicThread());
g_python->HandleDeviceMenuPress(device); g_python->HandleDeviceMenuPress(device);
} }
@ -1139,7 +1139,7 @@ void Game::PushScreenResizeCall(float virtual_width, float virtual_height,
void Game::ScreenResize(float virtual_width, float virtual_height, void Game::ScreenResize(float virtual_width, float virtual_height,
float pixel_width, float pixel_height) { float pixel_width, float pixel_height) {
assert(InGameThread()); assert(InLogicThread());
assert(g_graphics != nullptr); assert(g_graphics != nullptr);
if (g_graphics) { if (g_graphics) {
g_graphics->ScreenResize(virtual_width, virtual_height, pixel_width, g_graphics->ScreenResize(virtual_width, virtual_height, pixel_width,
@ -1161,7 +1161,7 @@ void Game::PushGameServiceAchievementListCall(
void Game::GameServiceAchievementList( void Game::GameServiceAchievementList(
const std::set<std::string>& achievements) { const std::set<std::string>& achievements) {
assert(g_python); assert(g_python);
assert(InGameThread()); assert(InLogicThread());
AppInternalDispatchRemoteAchievementList(achievements); AppInternalDispatchRemoteAchievementList(achievements);
} }
@ -1177,7 +1177,7 @@ void Game::ScoresToBeatResponse(bool success,
const std::list<ScoreToBeat>& scores, const std::list<ScoreToBeat>& scores,
void* py_callback) { void* py_callback) {
assert(g_python); assert(g_python);
assert(InGameThread()); assert(InLogicThread());
g_python->DispatchScoresToBeatResponse(success, scores, py_callback); g_python->DispatchScoresToBeatResponse(success, scores, py_callback);
} }
@ -1191,7 +1191,7 @@ void Game::PushFriendScoreSetCall(const FriendScoreSet& score_set) {
void Game::PushConfirmQuitCall() { void Game::PushConfirmQuitCall() {
PushCall([this] { PushCall([this] {
assert(InGameThread()); assert(InLogicThread());
if (HeadlessMode()) { if (HeadlessMode()) {
Log("PushConfirmQuitCall() unhandled on headless."); Log("PushConfirmQuitCall() unhandled on headless.");
} else { } else {
@ -1266,7 +1266,7 @@ void Game::PushOnAppResumeCall() {
// Look through everything in our config dict and act on it. // Look through everything in our config dict and act on it.
void Game::ApplyConfig() { void Game::ApplyConfig() {
assert(InGameThread()); assert(InLogicThread());
// Not relevant for fullscreen anymore // Not relevant for fullscreen anymore
// since we're fullscreen windows everywhere. // since we're fullscreen windows everywhere.
@ -1451,7 +1451,7 @@ void Game::PushHavePendingLoadsDoneCall() {
} }
void Game::ToggleConsole() { void Game::ToggleConsole() {
assert(InGameThread()); assert(InLogicThread());
if (auto console = g_app_globals->console) { if (auto console = g_app_globals->console) {
console->ToggleState(); console->ToggleState();
} }
@ -1481,7 +1481,7 @@ void Game::PushShutdownCall(bool soft) {
} }
void Game::Shutdown(bool soft) { void Game::Shutdown(bool soft) {
assert(InGameThread()); assert(InLogicThread());
if (!g_app_globals->shutting_down) { if (!g_app_globals->shutting_down) {
g_app_globals->shutting_down = true; g_app_globals->shutting_down = true;
@ -1508,13 +1508,13 @@ void Game::Shutdown(bool soft) {
} }
void Game::ResetInput() { void Game::ResetInput() {
assert(InGameThread()); assert(InLogicThread());
g_input->ResetKeyboardHeldKeys(); g_input->ResetKeyboardHeldKeys();
g_input->ResetJoyStickHeldButtons(); g_input->ResetJoyStickHeldButtons();
} }
auto Game::RemovePlayer(Player* player) -> void { auto Game::RemovePlayer(Player* player) -> void {
assert(InGameThread()); assert(InLogicThread());
if (HostSession* host_session = player->GetHostSession()) { if (HostSession* host_session = player->GetHostSession()) {
host_session->RemovePlayer(player); host_session->RemovePlayer(player);
} else { } else {
@ -1542,13 +1542,13 @@ void Game::SetRealTimerLength(int timer_id, millisecs_t length) {
} }
void Game::Process() { void Game::Process() {
have_pending_loads_ = g_media->RunPendingLoadsGameThread(); have_pending_loads_ = g_media->RunPendingLoadsLogicThread();
UpdateProcessTimer(); UpdateProcessTimer();
} }
void Game::SetLanguageKeys( void Game::SetLanguageKeys(
const std::unordered_map<std::string, std::string>& language) { const std::unordered_map<std::string, std::string>& language) {
assert(InGameThread()); assert(InLogicThread());
{ {
std::lock_guard<std::mutex> lock(language_mutex_); std::lock_guard<std::mutex> lock(language_mutex_);
language_ = language; language_ = language;
@ -1818,7 +1818,7 @@ auto Game::CharStr(SpecialChar id) -> std::string {
} }
auto Game::ShouldAnnouncePartyJoinsAndLeaves() -> bool { auto Game::ShouldAnnouncePartyJoinsAndLeaves() -> bool {
assert(InGameThread()); assert(InLogicThread());
// At the moment we don't announce these for public internet parties.. (too // At the moment we don't announce these for public internet parties.. (too
// much noise). // much noise).
@ -1840,7 +1840,7 @@ void Game::CleanUpBeforeConnectingToHost() {
} }
auto Game::GetPartySize() const -> int { auto Game::GetPartySize() const -> int {
assert(InGameThread()); assert(InLogicThread());
assert(game_roster_ != nullptr); assert(game_roster_ != nullptr);
return cJSON_GetArraySize(game_roster_); return cJSON_GetArraySize(game_roster_);
} }
@ -2020,7 +2020,7 @@ void Game::BanPlayer(const PlayerSpec& spec, millisecs_t duration) {
} }
void Game::UpdateGameRoster() { void Game::UpdateGameRoster() {
assert(InGameThread()); assert(InLogicThread());
assert(game_roster_ != nullptr); assert(game_roster_ != nullptr);
if (game_roster_ != nullptr) { if (game_roster_ != nullptr) {
@ -2131,7 +2131,7 @@ void Game::UpdateGameRoster() {
} }
void Game::SetPublicPartyEnabled(bool val) { void Game::SetPublicPartyEnabled(bool val) {
assert(InGameThread()); assert(InLogicThread());
if (val == public_party_enabled_) { if (val == public_party_enabled_) {
return; return;
} }
@ -2140,7 +2140,7 @@ void Game::SetPublicPartyEnabled(bool val) {
} }
void Game::SetPublicPartySize(int count) { void Game::SetPublicPartySize(int count) {
assert(InGameThread()); assert(InLogicThread());
if (count == public_party_size_) { if (count == public_party_size_) {
return; return;
} }
@ -2154,7 +2154,7 @@ void Game::SetPublicPartySize(int count) {
} }
void Game::SetPublicPartyMaxSize(int count) { void Game::SetPublicPartyMaxSize(int count) {
assert(InGameThread()); assert(InLogicThread());
if (count == public_party_max_size_) { if (count == public_party_max_size_) {
return; return;
} }
@ -2168,7 +2168,7 @@ void Game::SetPublicPartyMaxSize(int count) {
} }
void Game::SetPublicPartyName(const std::string& name) { void Game::SetPublicPartyName(const std::string& name) {
assert(InGameThread()); assert(InLogicThread());
if (name == public_party_name_) { if (name == public_party_name_) {
return; return;
} }
@ -2182,7 +2182,7 @@ void Game::SetPublicPartyName(const std::string& name) {
} }
void Game::SetPublicPartyStatsURL(const std::string& url) { void Game::SetPublicPartyStatsURL(const std::string& url) {
assert(InGameThread()); assert(InLogicThread());
if (url == public_party_stats_url_) { if (url == public_party_stats_url_) {
return; return;
} }
@ -2196,7 +2196,7 @@ void Game::SetPublicPartyStatsURL(const std::string& url) {
} }
void Game::SetPublicPartyPlayerCount(int count) { void Game::SetPublicPartyPlayerCount(int count) {
assert(InGameThread()); assert(InLogicThread());
if (count == public_party_player_count_) { if (count == public_party_player_count_) {
return; return;
} }

View File

@ -172,7 +172,7 @@ class Game : public Module {
// Used to know which globals is in control currently/etc. // Used to know which globals is in control currently/etc.
auto GetForegroundScene() const -> Scene* { auto GetForegroundScene() const -> Scene* {
assert(InGameThread()); assert(InLogicThread());
return foreground_scene_.get(); return foreground_scene_.get();
} }
auto SetForegroundScene(Scene* sg) -> void; auto SetForegroundScene(Scene* sg) -> void;

View File

@ -125,7 +125,7 @@ void HostActivity::StepScene() {
} }
for (int cycle = 0; cycle < cycle_count; ++cycle) { for (int cycle = 0; cycle < cycle_count; ++cycle) {
assert(InGameThread()); assert(InLogicThread());
// Clear our player-positions for this step. // Clear our player-positions for this step.
// FIXME: Move this to scene and/or player node. // FIXME: Move this to scene and/or player node.
@ -365,19 +365,19 @@ auto HostActivity::NewBaseTimer(millisecs_t length, bool repeat,
} }
void HostActivity::DeleteSimTimer(int timer_id) { void HostActivity::DeleteSimTimer(int timer_id) {
assert(InGameThread()); assert(InLogicThread());
if (shutting_down_) return; if (shutting_down_) return;
sim_timers_.DeleteTimer(timer_id); sim_timers_.DeleteTimer(timer_id);
} }
void HostActivity::DeleteBaseTimer(int timer_id) { void HostActivity::DeleteBaseTimer(int timer_id) {
assert(InGameThread()); assert(InLogicThread());
if (shutting_down_) return; if (shutting_down_) return;
base_timers_.DeleteTimer(timer_id); base_timers_.DeleteTimer(timer_id);
} }
auto HostActivity::Update(millisecs_t time_advance) -> millisecs_t { auto HostActivity::Update(millisecs_t time_advance) -> millisecs_t {
assert(InGameThread()); assert(InLogicThread());
// We can be killed at any time, so let's keep an eye out for that. // We can be killed at any time, so let's keep an eye out for that.
WeakRef<HostActivity> test_ref(this); WeakRef<HostActivity> test_ref(this);

View File

@ -17,11 +17,11 @@ namespace ballistica {
Player::Player(int id_in, HostSession* host_session) Player::Player(int id_in, HostSession* host_session)
: id_(id_in), creation_time_(GetRealTime()), host_session_(host_session) { : id_(id_in), creation_time_(GetRealTime()), host_session_(host_session) {
assert(host_session); assert(host_session);
assert(InGameThread()); assert(InLogicThread());
} }
Player::~Player() { Player::~Player() {
assert(InGameThread()); assert(InLogicThread());
// If we have an input-device attached to us, detach it. // If we have an input-device attached to us, detach it.
InputDevice* input_device = input_device_.get(); InputDevice* input_device = input_device_.get();
@ -56,7 +56,7 @@ auto Player::GetHostActivity() const -> HostActivity* {
} }
void Player::SetHostActivity(HostActivity* a) { void Player::SetHostActivity(HostActivity* a) {
assert(InGameThread()); assert(InLogicThread());
// Make sure we get pulled out of one activity before being added to another. // Make sure we get pulled out of one activity before being added to another.
if (a && in_activity_) { if (a && in_activity_) {
@ -137,7 +137,7 @@ auto Player::GetPyActivityPlayer() -> PyObject* {
} }
auto Player::GetPyRef(bool new_ref) -> PyObject* { auto Player::GetPyRef(bool new_ref) -> PyObject* {
assert(InGameThread()); assert(InLogicThread());
if (py_ref_ == nullptr) { if (py_ref_ == nullptr) {
py_ref_ = PythonClassSessionPlayer::Create(this); py_ref_ = PythonClassSessionPlayer::Create(this);
} }
@ -148,7 +148,7 @@ auto Player::GetPyRef(bool new_ref) -> PyObject* {
} }
void Player::AssignInputCall(InputType type, PyObject* call_obj) { void Player::AssignInputCall(InputType type, PyObject* call_obj) {
assert(InGameThread()); assert(InLogicThread());
assert(static_cast<int>(type) >= 0 assert(static_cast<int>(type) >= 0
&& static_cast<int>(type) < static_cast<int>(InputType::kLast)); && static_cast<int>(type) < static_cast<int>(InputType::kLast));
@ -203,7 +203,7 @@ void Player::AssignInputCall(InputType type, PyObject* call_obj) {
} }
void Player::RunInput(InputType type, float value) { void Player::RunInput(InputType type, float value) {
assert(InGameThread()); assert(InLogicThread());
const float threshold = kJoystickDiscreteThresholdFloat; const float threshold = kJoystickDiscreteThresholdFloat;
@ -357,7 +357,7 @@ auto Player::GetHostSession() const -> HostSession* {
void Player::SetName(const std::string& name, const std::string& full_name, void Player::SetName(const std::string& name, const std::string& full_name,
bool is_real) { bool is_real) {
assert(InGameThread()); assert(InLogicThread());
HostSession* host_session = GetHostSession(); HostSession* host_session = GetHostSession();
BA_PRECONDITION(host_session); BA_PRECONDITION(host_session);
name_is_real_ = is_real; name_is_real_ = is_real;
@ -372,7 +372,7 @@ void Player::SetName(const std::string& name, const std::string& full_name,
} }
void Player::InputCommand(InputType type, float value) { void Player::InputCommand(InputType type, float value) {
assert(InGameThread()); assert(InLogicThread());
switch (type) { switch (type) {
case InputType::kUpDown: case InputType::kUpDown:
case InputType::kLeftRight: case InputType::kLeftRight:
@ -393,7 +393,7 @@ void Player::SetInputDevice(InputDevice* input_device) {
} }
auto Player::GetPublicAccountID() const -> std::string { auto Player::GetPublicAccountID() const -> std::string {
assert(InGameThread()); assert(InLogicThread());
if (input_device_.exists()) { if (input_device_.exists()) {
return input_device_->GetPublicAccountID(); return input_device_->GetPublicAccountID();
} }

View File

@ -42,11 +42,11 @@ class Player : public Object {
// Set the player node for the current activity. // Set the player node for the current activity.
auto set_node(Node* node) -> void { auto set_node(Node* node) -> void {
assert(InGameThread()); assert(InLogicThread());
node_ = node; node_ = node;
} }
auto node() const -> Node* { auto node() const -> Node* {
assert(InGameThread()); assert(InLogicThread());
return node_.get(); return node_.get();
} }

View File

@ -965,7 +965,7 @@ void ClientSession::End() {
} }
void ClientSession::HandleSessionMessage(const std::vector<uint8_t>& buffer) { void ClientSession::HandleSessionMessage(const std::vector<uint8_t>& buffer) {
assert(InGameThread()); assert(InLogicThread());
BA_PRECONDITION(!buffer.empty()); BA_PRECONDITION(!buffer.empty());

View File

@ -22,7 +22,7 @@ namespace ballistica {
HostSession::HostSession(PyObject* session_type_obj) HostSession::HostSession(PyObject* session_type_obj)
: last_kick_idle_players_decrement_time_(GetRealTime()) { : last_kick_idle_players_decrement_time_(GetRealTime()) {
assert(g_game); assert(g_game);
assert(InGameThread()); assert(InLogicThread());
assert(session_type_obj != nullptr); assert(session_type_obj != nullptr);
ScopedSetContext cp(this); ScopedSetContext cp(this);
@ -196,7 +196,7 @@ auto HostSession::NewTimer(TimerMedium length, bool repeat,
} }
void HostSession::DeleteTimer(int timer_id) { void HostSession::DeleteTimer(int timer_id) {
assert(InGameThread()); assert(InLogicThread());
if (shutting_down_) return; if (shutting_down_) return;
sim_timers_.DeleteTimer(timer_id); sim_timers_.DeleteTimer(timer_id);
} }
@ -237,7 +237,7 @@ auto HostSession::GetForegroundContext() -> Context {
} }
void HostSession::RequestPlayer(InputDevice* device) { void HostSession::RequestPlayer(InputDevice* device) {
assert(InGameThread()); assert(InLogicThread());
// Ignore if we have no Python session obj. // Ignore if we have no Python session obj.
if (!GetSessionPyObj()) { if (!GetSessionPyObj()) {
@ -309,7 +309,7 @@ void HostSession::RemovePlayer(Player* player) {
void HostSession::IssuePlayerLeft(Player* player) { void HostSession::IssuePlayerLeft(Player* player) {
assert(player); assert(player);
assert(InGameThread()); assert(InLogicThread());
try { try {
if (GetSessionPyObj()) { if (GetSessionPyObj()) {
@ -334,7 +334,7 @@ void HostSession::IssuePlayerLeft(Player* player) {
void HostSession::SetKickIdlePlayers(bool enable) { void HostSession::SetKickIdlePlayers(bool enable) {
// If this has changed, reset our disconnect-time reporting. // If this has changed, reset our disconnect-time reporting.
assert(InGameThread()); assert(InLogicThread());
if (enable != kick_idle_players_) { if (enable != kick_idle_players_) {
last_kick_idle_players_decrement_time_ = GetRealTime(); last_kick_idle_players_decrement_time_ = GetRealTime();
} }
@ -343,7 +343,7 @@ void HostSession::SetKickIdlePlayers(bool enable) {
void HostSession::SetForegroundHostActivity(HostActivity* a) { void HostSession::SetForegroundHostActivity(HostActivity* a) {
assert(a); assert(a);
assert(InGameThread()); assert(InLogicThread());
if (shutting_down_) { if (shutting_down_) {
Log("WARNING: SetForegroundHostActivity called during session shutdown; " Log("WARNING: SetForegroundHostActivity called during session shutdown; "
@ -490,7 +490,7 @@ void HostSession::StepScene() {
} }
void HostSession::Update(int time_advance) { void HostSession::Update(int time_advance) {
assert(InGameThread()); assert(InLogicThread());
// We can be killed at any time, so let's keep an eye out for that. // We can be killed at any time, so let's keep an eye out for that.
WeakRef<HostSession> test_ref(this); WeakRef<HostSession> test_ref(this);

View File

@ -17,16 +17,16 @@ class RealTimer : public Object {
public: public:
RealTimer(millisecs_t length, bool repeat, T* delegate) { RealTimer(millisecs_t length, bool repeat, T* delegate) {
assert(g_game); assert(g_game);
assert(InGameThread()); assert(InLogicThread());
timer_id_ = g_game->NewRealTimer( timer_id_ = g_game->NewRealTimer(
length, repeat, Object::New<Runnable, Callback>(delegate, this)); length, repeat, Object::New<Runnable, Callback>(delegate, this));
} }
void SetLength(uint32_t length) { void SetLength(uint32_t length) {
assert(InGameThread()); assert(InLogicThread());
g_game->SetRealTimerLength(timer_id_, length); g_game->SetRealTimerLength(timer_id_, length);
} }
~RealTimer() override { ~RealTimer() override {
assert(InGameThread()); assert(InLogicThread());
g_game->DeleteRealTimer(timer_id_); g_game->DeleteRealTimer(timer_id_);
} }

View File

@ -428,7 +428,7 @@ static const char* g_default_random_names[] = {
static std::list<std::string>* g_random_names_list = nullptr; static std::list<std::string>* g_random_names_list = nullptr;
auto Utils::GetRandomNameList() -> const std::list<std::string>& { auto Utils::GetRandomNameList() -> const std::list<std::string>& {
assert(InGameThread()); assert(InLogicThread());
if (g_random_names_list == nullptr) { if (g_random_names_list == nullptr) {
// This will init the list with our default english names. // This will init the list with our default english names.
SetRandomNameList(std::list<std::string>(1, "DEFAULT_NAMES")); SetRandomNameList(std::list<std::string>(1, "DEFAULT_NAMES"));
@ -445,7 +445,7 @@ auto Utils::GetRandomNameList() -> const std::list<std::string>& {
} }
void Utils::SetRandomNameList(const std::list<std::string>& custom_names) { void Utils::SetRandomNameList(const std::list<std::string>& custom_names) {
assert(InGameThread()); assert(InLogicThread());
if (!g_random_names_list) { if (!g_random_names_list) {
g_random_names_list = new std::list<std::string>; g_random_names_list = new std::list<std::string>;
} else { } else {

View File

@ -852,13 +852,13 @@ void Camera::ManualHandleMouseMove(float move_h, float move_v) {
} }
auto Camera::NewAreaOfInterest(bool in_focus) -> AreaOfInterest* { auto Camera::NewAreaOfInterest(bool in_focus) -> AreaOfInterest* {
assert(InGameThread()); assert(InLogicThread());
areas_of_interest_.emplace_back(in_focus); areas_of_interest_.emplace_back(in_focus);
return &areas_of_interest_.back(); return &areas_of_interest_.back();
} }
void Camera::DeleteAreaOfInterest(AreaOfInterest* a) { void Camera::DeleteAreaOfInterest(AreaOfInterest* a) {
assert(InGameThread()); assert(InLogicThread());
for (auto i = areas_of_interest_.begin(); i != areas_of_interest_.end(); for (auto i = areas_of_interest_.begin(); i != areas_of_interest_.end();
++i) { ++i) {
if (&(*i) == a) { if (&(*i) == a) {

View File

@ -14,7 +14,7 @@ void RenderComponent::ScissorPush(const Rect& rIn) {
#if BA_DEBUG_BUILD #if BA_DEBUG_BUILD
void RenderComponent::ConfigForEmptyDebugChecks(bool transparent) { void RenderComponent::ConfigForEmptyDebugChecks(bool transparent) {
assert(InGameThread()); assert(InLogicThread());
if (g_graphics->drawing_opaque_only() && transparent) { if (g_graphics->drawing_opaque_only() && transparent) {
throw Exception("Transparent component submitted in opaque-only section"); throw Exception("Transparent component submitted in opaque-only section");
} }
@ -24,7 +24,7 @@ void RenderComponent::ConfigForEmptyDebugChecks(bool transparent) {
} }
void RenderComponent::ConfigForShadingDebugChecks(ShadingType shading_type) { void RenderComponent::ConfigForShadingDebugChecks(ShadingType shading_type) {
assert(InGameThread()); assert(InLogicThread());
if (g_graphics->drawing_opaque_only() if (g_graphics->drawing_opaque_only()
&& Graphics::IsShaderTransparent(shading_type)) { && Graphics::IsShaderTransparent(shading_type)) {
throw Exception("Transparent component submitted in opaque-only section"); throw Exception("Transparent component submitted in opaque-only section");

View File

@ -26,10 +26,10 @@ FrameDef::FrameDef()
new RenderPass(RenderPass::Type::kOverlayFlatPass, this)), new RenderPass(RenderPass::Type::kOverlayFlatPass, this)),
blit_pass_(new RenderPass(RenderPass::Type::kBlitPass, this)) {} blit_pass_(new RenderPass(RenderPass::Type::kBlitPass, this)) {}
FrameDef::~FrameDef() { assert(InGameThread()); } FrameDef::~FrameDef() { assert(InLogicThread()); }
void FrameDef::Reset() { void FrameDef::Reset() {
assert(InGameThread()); assert(InLogicThread());
real_time_ = 0; real_time_ = 0;
base_time_ = 0; base_time_ = 0;
base_time_elapsed_ = 0; base_time_elapsed_ = 0;

View File

@ -788,7 +788,7 @@ void Graphics::AddScreenMessage(const std::string& msg, const Vector3f& color,
// So we know we're always dealing with valid utf8. // So we know we're always dealing with valid utf8.
std::string m = Utils::GetValidUTF8(msg.c_str(), "ga9msg"); std::string m = Utils::GetValidUTF8(msg.c_str(), "ga9msg");
assert(InGameThread()); assert(InLogicThread());
if (top) { if (top) {
float start_v = -40.0f; float start_v = -40.0f;
if (!screen_messages_top_.empty()) { if (!screen_messages_top_.empty()) {
@ -842,7 +842,7 @@ void Graphics::InitInternalComponents(FrameDef* frame_def) {
} }
auto Graphics::GetEmptyFrameDef() -> FrameDef* { auto Graphics::GetEmptyFrameDef() -> FrameDef* {
assert(InGameThread()); assert(InLogicThread());
FrameDef* frame_def; FrameDef* frame_def;
// Grab a ready-to-use recycled one if available. // Grab a ready-to-use recycled one if available.
@ -857,7 +857,7 @@ auto Graphics::GetEmptyFrameDef() -> FrameDef* {
} }
void Graphics::ClearFrameDefDeleteList() { void Graphics::ClearFrameDefDeleteList() {
assert(InGameThread()); assert(InLogicThread());
std::lock_guard<std::mutex> lock(frame_def_delete_list_mutex_); std::lock_guard<std::mutex> lock(frame_def_delete_list_mutex_);
for (auto& i : frame_def_delete_list_) { for (auto& i : frame_def_delete_list_) {
@ -986,7 +986,7 @@ void Graphics::DrawWorld(Session* session, FrameDef* frame_def) {
} }
void Graphics::BuildAndPushFrameDef() { void Graphics::BuildAndPushFrameDef() {
assert(InGameThread()); assert(InLogicThread());
assert(camera_.exists()); assert(camera_.exists());
// We should not be building/pushing any frames until after // We should not be building/pushing any frames until after
@ -1320,7 +1320,7 @@ void Graphics::DrawFades(FrameDef* frame_def, millisecs_t real_time) {
} }
void Graphics::DrawCursor(RenderPass* pass, millisecs_t real_time) { void Graphics::DrawCursor(RenderPass* pass, millisecs_t real_time) {
assert(InGameThread()); assert(InLogicThread());
bool can_show_cursor = g_platform->IsRunningOnDesktop(); bool can_show_cursor = g_platform->IsRunningOnDesktop();
bool should_show_cursor = camera_->manual() || g_input->IsCursorVisible(); bool should_show_cursor = camera_->manual() || g_input->IsCursorVisible();
@ -1427,7 +1427,7 @@ void Graphics::ReturnCompletedFrameDef(FrameDef* frame_def) {
} }
void Graphics::AddMeshDataCreate(MeshData* d) { void Graphics::AddMeshDataCreate(MeshData* d) {
assert(InGameThread()); assert(InLogicThread());
assert(g_graphics); assert(g_graphics);
// Add this to our list of new-mesh-datas. We'll include this with our // Add this to our list of new-mesh-datas. We'll include this with our
@ -1437,7 +1437,7 @@ void Graphics::AddMeshDataCreate(MeshData* d) {
} }
void Graphics::AddMeshDataDestroy(MeshData* d) { void Graphics::AddMeshDataDestroy(MeshData* d) {
assert(InGameThread()); assert(InLogicThread());
assert(g_graphics); assert(g_graphics);
// Add this to our list of delete-mesh-datas; we'll include this with our // Add this to our list of delete-mesh-datas; we'll include this with our
@ -1447,7 +1447,7 @@ void Graphics::AddMeshDataDestroy(MeshData* d) {
} }
void Graphics::EnableProgressBar(bool fade_in) { void Graphics::EnableProgressBar(bool fade_in) {
assert(InGameThread()); assert(InLogicThread());
progress_bar_loads_ = g_media->GetGraphicalPendingLoadCount(); progress_bar_loads_ = g_media->GetGraphicalPendingLoadCount();
assert(progress_bar_loads_ >= 0); assert(progress_bar_loads_ >= 0);
if (progress_bar_loads_ > 0) { if (progress_bar_loads_ > 0) {
@ -1460,7 +1460,7 @@ void Graphics::EnableProgressBar(bool fade_in) {
} }
void Graphics::ToggleManualCamera() { void Graphics::ToggleManualCamera() {
assert(InGameThread()); assert(InLogicThread());
camera_->SetManual(!camera_->manual()); camera_->SetManual(!camera_->manual());
if (camera_->manual()) { if (camera_->manual()) {
ScreenMessage("Manual Camera On"); ScreenMessage("Manual Camera On");
@ -1470,14 +1470,14 @@ void Graphics::ToggleManualCamera() {
} }
void Graphics::LocalCameraShake(float mag) { void Graphics::LocalCameraShake(float mag) {
assert(InGameThread()); assert(InLogicThread());
if (camera_.exists()) { if (camera_.exists()) {
camera_->Shake(mag); camera_->Shake(mag);
} }
} }
void Graphics::ToggleNetworkDebugDisplay() { void Graphics::ToggleNetworkDebugDisplay() {
assert(InGameThread()); assert(InLogicThread());
network_debug_display_enabled_ = !network_debug_display_enabled_; network_debug_display_enabled_ = !network_debug_display_enabled_;
if (network_debug_display_enabled_) { if (network_debug_display_enabled_) {
ScreenMessage("Network Debug Display Enabled"); ScreenMessage("Network Debug Display Enabled");
@ -1487,7 +1487,7 @@ void Graphics::ToggleNetworkDebugDisplay() {
} }
void Graphics::ToggleDebugDraw() { void Graphics::ToggleDebugDraw() {
assert(InGameThread()); assert(InLogicThread());
debug_draw_ = !debug_draw_; debug_draw_ = !debug_draw_;
if (g_graphics_server->renderer()) { if (g_graphics_server->renderer()) {
g_graphics_server->renderer()->set_debug_draw_mode(debug_draw_); g_graphics_server->renderer()->set_debug_draw_mode(debug_draw_);
@ -1522,7 +1522,7 @@ void Graphics::DoDrawBlotch(std::vector<uint16_t>* indices,
std::vector<VertexSprite>* verts, std::vector<VertexSprite>* verts,
const Vector3f& pos, float size, float r, float g, const Vector3f& pos, float size, float r, float g,
float b, float a) { float b, float a) {
assert(InGameThread()); assert(InLogicThread());
assert(indices && verts); assert(indices && verts);
// Add verts. // Add verts.
@ -1789,7 +1789,7 @@ auto Graphics::ScreenMessageEntry::GetText() -> TextGroup& {
void Graphics::ScreenResize(float virtual_width, float virtual_height, void Graphics::ScreenResize(float virtual_width, float virtual_height,
float pixel_width, float pixel_height) { float pixel_width, float pixel_height) {
assert(InGameThread()); assert(InLogicThread());
res_x_virtual_ = virtual_width; res_x_virtual_ = virtual_width;
res_y_virtual_ = virtual_height; res_y_virtual_ = virtual_height;
res_x_ = pixel_width; res_x_ = pixel_width;

View File

@ -136,70 +136,70 @@ class Graphics {
auto ToggleNetworkDebugDisplay() -> void; auto ToggleNetworkDebugDisplay() -> void;
auto SetGyroEnabled(bool enable) -> void; auto SetGyroEnabled(bool enable) -> void;
auto floor_reflection() const -> bool { auto floor_reflection() const -> bool {
assert(InGameThread()); assert(InLogicThread());
return floor_reflection_; return floor_reflection_;
} }
auto set_floor_reflection(bool val) -> void { auto set_floor_reflection(bool val) -> void {
assert(InGameThread()); assert(InLogicThread());
floor_reflection_ = val; floor_reflection_ = val;
} }
auto set_shadow_offset(const Vector3f& val) -> void { auto set_shadow_offset(const Vector3f& val) -> void {
assert(InGameThread()); assert(InLogicThread());
shadow_offset_ = val; shadow_offset_ = val;
} }
auto set_shadow_scale(float x, float y) -> void { auto set_shadow_scale(float x, float y) -> void {
assert(InGameThread()); assert(InLogicThread());
shadow_scale_.x = x; shadow_scale_.x = x;
shadow_scale_.y = y; shadow_scale_.y = y;
} }
auto set_shadow_ortho(bool o) -> void { auto set_shadow_ortho(bool o) -> void {
assert(InGameThread()); assert(InLogicThread());
shadow_ortho_ = o; shadow_ortho_ = o;
} }
auto tint() -> const Vector3f& { return tint_; } auto tint() -> const Vector3f& { return tint_; }
auto set_tint(const Vector3f& val) -> void { auto set_tint(const Vector3f& val) -> void {
assert(InGameThread()); assert(InLogicThread());
tint_ = val; tint_ = val;
} }
auto set_ambient_color(const Vector3f& val) -> void { auto set_ambient_color(const Vector3f& val) -> void {
assert(InGameThread()); assert(InLogicThread());
ambient_color_ = val; ambient_color_ = val;
} }
auto set_vignette_outer(const Vector3f& val) -> void { auto set_vignette_outer(const Vector3f& val) -> void {
assert(InGameThread()); assert(InLogicThread());
vignette_outer_ = val; vignette_outer_ = val;
} }
auto set_vignette_inner(const Vector3f& val) -> void { auto set_vignette_inner(const Vector3f& val) -> void {
assert(InGameThread()); assert(InLogicThread());
vignette_inner_ = val; vignette_inner_ = val;
} }
auto shadow_offset() const -> const Vector3f& { auto shadow_offset() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return shadow_offset_; return shadow_offset_;
} }
auto shadow_scale() const -> const Vector2f& { auto shadow_scale() const -> const Vector2f& {
assert(InGameThread()); assert(InLogicThread());
return shadow_scale_; return shadow_scale_;
} }
auto tint() const -> const Vector3f& { auto tint() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return tint_; return tint_;
} }
auto ambient_color() const -> const Vector3f& { auto ambient_color() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return ambient_color_; return ambient_color_;
} }
auto vignette_outer() const -> const Vector3f& { auto vignette_outer() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return vignette_outer_; return vignette_outer_;
} }
auto vignette_inner() const -> const Vector3f& { auto vignette_inner() const -> const Vector3f& {
assert(InGameThread()); assert(InLogicThread());
return vignette_inner_; return vignette_inner_;
} }
auto shadow_ortho() const -> bool { auto shadow_ortho() const -> bool {
assert(InGameThread()); assert(InLogicThread());
return shadow_ortho_; return shadow_ortho_;
} }
auto SetShadowRange(float lower_bottom, float lower_top, float upper_bottom, auto SetShadowRange(float lower_bottom, float lower_top, float upper_bottom,
@ -209,11 +209,11 @@ class Graphics {
// FIXME - move to graphics_server // FIXME - move to graphics_server
auto set_tv_border(bool val) -> void { auto set_tv_border(bool val) -> void {
assert(InGameThread()); assert(InLogicThread());
tv_border_ = val; tv_border_ = val;
} }
auto tv_border() const -> bool { auto tv_border() const -> bool {
assert(InGameThread()); assert(InLogicThread());
return tv_border_; return tv_border_;
} }

View File

@ -20,7 +20,7 @@ class TextGraphics::TextSpanBoundsCacheEntry : public Object {
}; };
void TextGraphics::Init() { void TextGraphics::Init() {
assert(InGameThread()); assert(InLogicThread());
assert(g_text_graphics == nullptr); assert(g_text_graphics == nullptr);
g_text_graphics = new TextGraphics(); g_text_graphics = new TextGraphics();
} }
@ -1000,7 +1000,7 @@ auto TextGraphics::GetGlyph(uint32_t val, bool big) -> TextGraphics::Glyph* {
void TextGraphics::GetOSTextSpanBoundsAndWidth(const std::string& s, Rect* r, void TextGraphics::GetOSTextSpanBoundsAndWidth(const std::string& s, Rect* r,
float* width) { float* width) {
assert(InGameThread()); assert(InLogicThread());
// Asking the OS to calculate text bounds sounds expensive, // Asking the OS to calculate text bounds sounds expensive,
// so let's use a cache of recent results. // so let's use a cache of recent results.

View File

@ -39,14 +39,14 @@ class VRGraphics : public Graphics {
void set_vr_head_up(const Vector3f& v) { vr_head_up_ = v; } void set_vr_head_up(const Vector3f& v) { vr_head_up_ = v; }
void set_vr_head_translate(const Vector3f& v) { vr_head_translate_ = v; } void set_vr_head_translate(const Vector3f& v) { vr_head_translate_ = v; }
void set_vr_overlay_center(const Vector3f& val) { void set_vr_overlay_center(const Vector3f& val) {
assert(InGameThread()); assert(InLogicThread());
vr_overlay_center_ = val; vr_overlay_center_ = val;
} }
auto vr_overlay_center() const -> const Vector3f& { auto vr_overlay_center() const -> const Vector3f& {
return vr_overlay_center_; return vr_overlay_center_;
} }
void set_vr_overlay_center_enabled(bool val) { void set_vr_overlay_center_enabled(bool val) {
assert(InGameThread()); assert(InLogicThread());
vr_overlay_center_enabled_ = val; vr_overlay_center_enabled_ = val;
} }
auto vr_overlay_center_enabled() const -> bool { auto vr_overlay_center_enabled() const -> bool {

View File

@ -41,7 +41,7 @@ auto ClientInputDevice::GetPlayerProfiles() const -> PyObject* {
} }
auto ClientInputDevice::GetAccountName(bool full) const -> std::string { auto ClientInputDevice::GetAccountName(bool full) const -> std::string {
assert(InGameThread()); assert(InLogicThread());
if (connection_to_client_.exists()) { if (connection_to_client_.exists()) {
if (full) { if (full) {
return connection_to_client_->peer_spec().GetDisplayString(); return connection_to_client_->peer_spec().GetDisplayString();
@ -53,7 +53,7 @@ auto ClientInputDevice::GetAccountName(bool full) const -> std::string {
} }
auto ClientInputDevice::GetPublicAccountID() const -> std::string { auto ClientInputDevice::GetPublicAccountID() const -> std::string {
assert(InGameThread()); assert(InLogicThread());
if (connection_to_client_.exists()) { if (connection_to_client_.exists()) {
return connection_to_client_->peer_public_account_id(); return connection_to_client_->peer_public_account_id();
} }

View File

@ -28,12 +28,12 @@ auto InputDevice::ShouldBeHiddenFromUser() -> bool {
} }
auto InputDevice::GetDeviceName() -> std::string { auto InputDevice::GetDeviceName() -> std::string {
assert(InGameThread()); assert(InLogicThread());
return GetRawDeviceName(); return GetRawDeviceName();
} }
void InputDevice::ResetRandomNames() { void InputDevice::ResetRandomNames() {
assert(InGameThread()); assert(InLogicThread());
if (g_rand_name_registry == nullptr) return; if (g_rand_name_registry == nullptr) return;
g_rand_name_registry->clear(); g_rand_name_registry->clear();
} }
@ -41,7 +41,7 @@ void InputDevice::ResetRandomNames() {
// Given a full name "SomeJoyStick #3" etc, reserves/returns a persistent random // Given a full name "SomeJoyStick #3" etc, reserves/returns a persistent random
// name for it. // name for it.
static auto GetRandomName(const std::string& full_name) -> std::string { static auto GetRandomName(const std::string& full_name) -> std::string {
assert(InGameThread()); assert(InLogicThread());
// Hmm; statically allocating this is giving some crashes on shutdown :-( // Hmm; statically allocating this is giving some crashes on shutdown :-(
if (g_rand_name_registry == nullptr) { if (g_rand_name_registry == nullptr) {
@ -75,7 +75,7 @@ static auto GetRandomName(const std::string& full_name) -> std::string {
auto InputDevice::GetPlayerProfiles() const -> PyObject* { return nullptr; } auto InputDevice::GetPlayerProfiles() const -> PyObject* { return nullptr; }
auto InputDevice::GetPublicAccountID() const -> std::string { auto InputDevice::GetPublicAccountID() const -> std::string {
assert(InGameThread()); assert(InLogicThread());
// This default implementation assumes the device is local // This default implementation assumes the device is local
// so just returns the locally signed in account's public id. // so just returns the locally signed in account's public id.
@ -84,7 +84,7 @@ auto InputDevice::GetPublicAccountID() const -> std::string {
} }
auto InputDevice::GetAccountName(bool full) const -> std::string { auto InputDevice::GetAccountName(bool full) const -> std::string {
assert(InGameThread()); assert(InLogicThread());
if (full) { if (full) {
return PlayerSpec::GetAccountPlayerSpec().GetDisplayString(); return PlayerSpec::GetAccountPlayerSpec().GetDisplayString();
} else { } else {
@ -97,7 +97,7 @@ auto InputDevice::IsRemoteClient() const -> bool { return false; }
auto InputDevice::GetClientID() const -> int { return -1; } auto InputDevice::GetClientID() const -> int { return -1; }
auto InputDevice::GetDefaultPlayerName() -> std::string { auto InputDevice::GetDefaultPlayerName() -> std::string {
assert(InGameThread()); assert(InLogicThread());
char buffer[256]; char buffer[256];
snprintf(buffer, sizeof(buffer), "%s %s", GetDeviceName().c_str(), snprintf(buffer, sizeof(buffer), "%s %s", GetDeviceName().c_str(),
GetPersistentIdentifier().c_str()); GetPersistentIdentifier().c_str());
@ -120,14 +120,14 @@ auto InputDevice::GetAxisName(int id) -> std::string {
auto InputDevice::HasMeaningfulButtonNames() -> bool { return false; } auto InputDevice::HasMeaningfulButtonNames() -> bool { return false; }
auto InputDevice::GetPersistentIdentifier() const -> std::string { auto InputDevice::GetPersistentIdentifier() const -> std::string {
assert(InGameThread()); assert(InLogicThread());
char buffer[128]; char buffer[128];
snprintf(buffer, sizeof(buffer), "#%d", number_); snprintf(buffer, sizeof(buffer), "#%d", number_);
return buffer; return buffer;
} }
InputDevice::~InputDevice() { InputDevice::~InputDevice() {
assert(InGameThread()); assert(InLogicThread());
assert(!player_.exists()); assert(!player_.exists());
// release our python ref to ourself if we have one // release our python ref to ourself if we have one
if (py_ref_) { if (py_ref_) {
@ -203,7 +203,7 @@ auto InputDevice::GetRemotePlayer() const -> ConnectionToHost* {
// Called to let the current host/client-session know that we'd like to control // Called to let the current host/client-session know that we'd like to control
// something please. // something please.
void InputDevice::RequestPlayer() { void InputDevice::RequestPlayer() {
assert(InGameThread()); assert(InLogicThread());
// Make note that we're being used in some way. // Make note that we're being used in some way.
last_input_time_ = g_game->master_time(); last_input_time_ = g_game->master_time();
@ -274,7 +274,7 @@ void InputDevice::UpdateLastInputTime() {
} }
void InputDevice::InputCommand(InputType type, float value) { void InputDevice::InputCommand(InputType type, float value) {
assert(InGameThread()); assert(InLogicThread());
// Make note that we're being used in some way. // Make note that we're being used in some way.
UpdateLastInputTime(); UpdateLastInputTime();
@ -306,7 +306,7 @@ void InputDevice::InputCommand(InputType type, float value) {
void InputDevice::ResetHeldStates() {} void InputDevice::ResetHeldStates() {}
auto InputDevice::GetPyInputDevice(bool new_ref) -> PyObject* { auto InputDevice::GetPyInputDevice(bool new_ref) -> PyObject* {
assert(InGameThread()); assert(InLogicThread());
if (py_ref_ == nullptr) { if (py_ref_ == nullptr) {
py_ref_ = PythonClassInputDevice::Create(this); py_ref_ = PythonClassInputDevice::Create(this);
} }

View File

@ -286,7 +286,7 @@ auto Joystick::GetButtonName(int index) -> std::string {
} }
Joystick::~Joystick() { Joystick::~Joystick() {
if (!InGameThread()) { if (!InLogicThread()) {
Log("Error: Joystick dying in wrong thread."); Log("Error: Joystick dying in wrong thread.");
} }
@ -320,7 +320,7 @@ auto Joystick::GetDefaultPlayerName() -> std::string {
return InputDevice::GetDefaultPlayerName(); return InputDevice::GetDefaultPlayerName();
} }
void Joystick::ConnectionComplete() { assert(InGameThread()); } void Joystick::ConnectionComplete() { assert(InLogicThread()); }
auto Joystick::ShouldBeHiddenFromUser() -> bool { auto Joystick::ShouldBeHiddenFromUser() -> bool {
std::string d_name = GetDeviceName(); std::string d_name = GetDeviceName();
@ -362,7 +362,7 @@ auto Joystick::GetCalibratedValue(float raw, float neutral) const -> int32_t {
void Joystick::Update() { void Joystick::Update() {
InputDevice::Update(); InputDevice::Update();
assert(InGameThread()); assert(InLogicThread());
// We seem to get a fair amount of bogus direction-pressed events from newly // We seem to get a fair amount of bogus direction-pressed events from newly
// plugged in joysticks.. this leads to continuous scrolling in menus and such // plugged in joysticks.. this leads to continuous scrolling in menus and such
@ -530,7 +530,7 @@ void Joystick::ResetHeldStates() {
} }
void Joystick::HandleSDLEvent(const SDL_Event* e) { void Joystick::HandleSDLEvent(const SDL_Event* e) {
assert(InGameThread()); assert(InLogicThread());
// If we've got a child joystick, send them any events they're set to handle. // If we've got a child joystick, send them any events they're set to handle.
if (child_joy_stick_) { if (child_joy_stick_) {
@ -1290,7 +1290,7 @@ void Joystick::UpdateRunningState() {
} }
void Joystick::UpdateMapping() { void Joystick::UpdateMapping() {
assert(InGameThread()); assert(InLogicThread());
// This doesn't apply to manual ones (except children which are). // This doesn't apply to manual ones (except children which are).
if (!can_configure_ && !parent_joy_stick_) { if (!can_configure_ && !parent_joy_stick_) {

View File

@ -373,7 +373,7 @@ void KeyboardInput::UpdateRun(SDL_Keycode key, bool down) {
} }
void KeyboardInput::UpdateMapping() { void KeyboardInput::UpdateMapping() {
assert(InGameThread()); assert(InLogicThread());
SDL_Keycode up_key_default, down_key_default, left_key_default, SDL_Keycode up_key_default, down_key_default, left_key_default,
right_key_default, jump_key_default, punch_key_default, bomb_key_default, right_key_default, jump_key_default, punch_key_default, bomb_key_default,

View File

@ -351,7 +351,7 @@ void TouchInput::UpdateDPad() {
} }
void TouchInput::Draw(FrameDef* frame_def) { void TouchInput::Draw(FrameDef* frame_def) {
assert(InGameThread()); assert(InLogicThread());
bool active = (!g_ui->IsWindowPresent()); bool active = (!g_ui->IsWindowPresent());
millisecs_t real_time = frame_def->real_time(); millisecs_t real_time = frame_def->real_time();
@ -831,7 +831,7 @@ void TouchInput::Draw(FrameDef* frame_def) {
} }
void TouchInput::UpdateMapping() { void TouchInput::UpdateMapping() {
assert(InGameThread()); assert(InLogicThread());
std::string touch_movement_type = std::string touch_movement_type =
g_app_config->Resolve(AppConfig::StringID::kTouchMovementControlType); g_app_config->Resolve(AppConfig::StringID::kTouchMovementControlType);
@ -895,7 +895,7 @@ void TouchInput::UpdateMapping() {
} }
auto TouchInput::HandleTouchDown(void* touch, float x, float y) -> bool { auto TouchInput::HandleTouchDown(void* touch, float x, float y) -> bool {
assert(InGameThread()); assert(InLogicThread());
float width = g_graphics->screen_virtual_width(); float width = g_graphics->screen_virtual_width();
float height = g_graphics->screen_virtual_height(); float height = g_graphics->screen_virtual_height();
@ -985,7 +985,7 @@ auto TouchInput::HandleTouchDown(void* touch, float x, float y) -> bool {
} }
auto TouchInput::HandleTouchUp(void* touch, float x, float y) -> bool { auto TouchInput::HandleTouchUp(void* touch, float x, float y) -> bool {
assert(InGameThread()); assert(InLogicThread());
// Release dpad drag touch. // Release dpad drag touch.
if (touch == d_pad_drag_touch_) { if (touch == d_pad_drag_touch_) {
@ -1027,7 +1027,7 @@ auto TouchInput::HandleTouchUp(void* touch, float x, float y) -> bool {
} }
auto TouchInput::HandleTouchMoved(void* touch, float x, float y) -> bool { auto TouchInput::HandleTouchMoved(void* touch, float x, float y) -> bool {
assert(InGameThread()); assert(InLogicThread());
if (touch == d_pad_drag_touch_) { if (touch == d_pad_drag_touch_) {
float width = g_graphics->screen_virtual_width(); float width = g_graphics->screen_virtual_width();
float height = g_graphics->screen_virtual_height(); float height = g_graphics->screen_virtual_height();

View File

@ -322,7 +322,7 @@ Input::Input() {
// assert(g_input == nullptr); // assert(g_input == nullptr);
// g_input = this; // g_input = this;
assert(InGameThread()); assert(InLogicThread());
// Config should have always been read by this point; right? // Config should have always been read by this point; right?
// assert(g_python); // assert(g_python);
@ -334,7 +334,7 @@ void Input::PushCreateKeyboardInputDevices() {
} }
void Input::CreateKeyboardInputDevices() { void Input::CreateKeyboardInputDevices() {
assert(InGameThread()); assert(InLogicThread());
if (keyboard_input_ != nullptr || keyboard_input_2_ != nullptr) { if (keyboard_input_ != nullptr || keyboard_input_2_ != nullptr) {
Log("Error: CreateKeyboardInputDevices called with existing kbs."); Log("Error: CreateKeyboardInputDevices called with existing kbs.");
return; return;
@ -350,7 +350,7 @@ void Input::PushDestroyKeyboardInputDevices() {
} }
void Input::DestroyKeyboardInputDevices() { void Input::DestroyKeyboardInputDevices() {
assert(InGameThread()); assert(InLogicThread());
if (keyboard_input_ == nullptr || keyboard_input_2_ == nullptr) { if (keyboard_input_ == nullptr || keyboard_input_2_ == nullptr) {
Log("Error: DestroyKeyboardInputDevices called with null kb(s)."); Log("Error: DestroyKeyboardInputDevices called with null kb(s).");
return; return;
@ -372,7 +372,7 @@ auto Input::GetInputDevice(int id) -> InputDevice* {
auto Input::GetInputDevice(const std::string& name, auto Input::GetInputDevice(const std::string& name,
const std::string& unique_id) -> InputDevice* { const std::string& unique_id) -> InputDevice* {
assert(InGameThread()); assert(InLogicThread());
for (auto&& i : input_devices_) { for (auto&& i : input_devices_) {
if (i.exists() && (i->GetDeviceName() == name) if (i.exists() && (i->GetDeviceName() == name)
&& i->GetPersistentIdentifier() == unique_id) { && i->GetPersistentIdentifier() == unique_id) {
@ -384,7 +384,7 @@ auto Input::GetInputDevice(const std::string& name,
auto Input::GetNewNumberedIdentifier(const std::string& name, auto Input::GetNewNumberedIdentifier(const std::string& name,
const std::string& identifier) -> int { const std::string& identifier) -> int {
assert(InGameThread()); assert(InLogicThread());
// Stuff like reserved_identifiers["JoyStickType"]["0x812312314"] = 2; // Stuff like reserved_identifiers["JoyStickType"]["0x812312314"] = 2;
@ -520,7 +520,7 @@ void Input::AnnounceDisconnects() {
} }
void Input::ShowStandardInputDeviceConnectedMessage(InputDevice* j) { void Input::ShowStandardInputDeviceConnectedMessage(InputDevice* j) {
assert(InGameThread()); assert(InLogicThread());
std::string suffix; std::string suffix;
suffix += j->GetPersistentIdentifier(); suffix += j->GetPersistentIdentifier();
suffix += j->GetDeviceExtraDescription(); suffix += j->GetDeviceExtraDescription();
@ -538,7 +538,7 @@ void Input::ShowStandardInputDeviceConnectedMessage(InputDevice* j) {
} }
void Input::ShowStandardInputDeviceDisconnectedMessage(InputDevice* j) { void Input::ShowStandardInputDeviceDisconnectedMessage(InputDevice* j) {
assert(InGameThread()); assert(InLogicThread());
newly_disconnected_controllers_.push_back(j->GetDeviceName() + " " newly_disconnected_controllers_.push_back(j->GetDeviceName() + " "
+ j->GetPersistentIdentifier() + j->GetPersistentIdentifier()
@ -560,7 +560,7 @@ void Input::PushAddInputDeviceCall(InputDevice* input_device,
} }
void Input::AddInputDevice(InputDevice* input, bool standard_message) { void Input::AddInputDevice(InputDevice* input, bool standard_message) {
assert(InGameThread()); assert(InLogicThread());
// Lets go through and find the first unused input-device id and use that // Lets go through and find the first unused input-device id and use that
// (might as well keep our list small if we can). // (might as well keep our list small if we can).
@ -622,7 +622,7 @@ void Input::PushRemoveInputDeviceCall(InputDevice* input_device,
} }
void Input::RemoveInputDevice(InputDevice* input, bool standard_message) { void Input::RemoveInputDevice(InputDevice* input, bool standard_message) {
assert(InGameThread()); assert(InLogicThread());
if (standard_message && !input->ShouldBeHiddenFromUser()) { if (standard_message && !input->ShouldBeHiddenFromUser()) {
ShowStandardInputDeviceDisconnectedMessage(input); ShowStandardInputDeviceDisconnectedMessage(input);
@ -668,7 +668,7 @@ void Input::RemoveInputDevice(InputDevice* input, bool standard_message) {
} }
void Input::UpdateInputDeviceCounts() { void Input::UpdateInputDeviceCounts() {
assert(InGameThread()); assert(InLogicThread());
have_button_using_inputs_ = false; have_button_using_inputs_ = false;
have_start_activated_default_button_inputs_ = false; have_start_activated_default_button_inputs_ = false;
@ -711,7 +711,7 @@ void Input::UpdateInputDeviceCounts() {
} }
auto Input::GetLocalActiveInputDeviceCount() -> int { auto Input::GetLocalActiveInputDeviceCount() -> int {
assert(InGameThread()); assert(InLogicThread());
// This can get called alot so lets cache the value. // This can get called alot so lets cache the value.
millisecs_t current_time = g_game->master_time(); millisecs_t current_time = g_game->master_time();
@ -737,7 +737,7 @@ auto Input::GetLocalActiveInputDeviceCount() -> int {
} }
auto Input::HaveControllerWithPlayer() -> bool { auto Input::HaveControllerWithPlayer() -> bool {
assert(InGameThread()); assert(InLogicThread());
// NOLINTNEXTLINE(readability-use-anyofallof) // NOLINTNEXTLINE(readability-use-anyofallof)
for (auto& input_device : input_devices_) { for (auto& input_device : input_devices_) {
if (input_device.exists() && (*input_device).IsController() if (input_device.exists() && (*input_device).IsController()
@ -749,7 +749,7 @@ auto Input::HaveControllerWithPlayer() -> bool {
} }
auto Input::HaveRemoteAppController() -> bool { auto Input::HaveRemoteAppController() -> bool {
assert(InGameThread()); assert(InLogicThread());
// NOLINTNEXTLINE(readability-use-anyofallof) // NOLINTNEXTLINE(readability-use-anyofallof)
for (auto& input_device : input_devices_) { for (auto& input_device : input_devices_) {
if (input_device.exists() && (*input_device).IsRemoteApp()) { if (input_device.exists() && (*input_device).IsRemoteApp()) {
@ -776,7 +776,7 @@ auto Input::GetInputDevicesWithName(const std::string& name)
} }
auto Input::GetConfigurableGamePads() -> std::vector<InputDevice*> { auto Input::GetConfigurableGamePads() -> std::vector<InputDevice*> {
assert(InGameThread()); assert(InLogicThread());
std::vector<InputDevice*> vals; std::vector<InputDevice*> vals;
if (!HeadlessMode()) { if (!HeadlessMode()) {
for (auto& input_device : input_devices_) { for (auto& input_device : input_devices_) {
@ -830,7 +830,7 @@ void Input::UpdateEnabledControllerSubsystems() {
// Tells all inputs to update their controls based on the app config. // Tells all inputs to update their controls based on the app config.
void Input::ApplyAppConfig() { void Input::ApplyAppConfig() {
assert(InGameThread()); assert(InLogicThread());
UpdateEnabledControllerSubsystems(); UpdateEnabledControllerSubsystems();
@ -846,7 +846,7 @@ void Input::ApplyAppConfig() {
} }
void Input::Update() { void Input::Update() {
assert(InGameThread()); assert(InLogicThread());
millisecs_t real_time = GetRealTime(); millisecs_t real_time = GetRealTime();
@ -890,7 +890,7 @@ void Input::Update() {
} }
void Input::Reset() { void Input::Reset() {
assert(InGameThread()); assert(InLogicThread());
// Detach all inputs from players. // Detach all inputs from players.
for (auto& input_device : input_devices_) { for (auto& input_device : input_devices_) {
@ -901,7 +901,7 @@ void Input::Reset() {
} }
void Input::LockAllInput(bool permanent, const std::string& label) { void Input::LockAllInput(bool permanent, const std::string& label) {
assert(InGameThread()); assert(InLogicThread());
if (permanent) { if (permanent) {
input_lock_count_permanent_++; input_lock_count_permanent_++;
input_lock_permanent_labels_.push_back(label); input_lock_permanent_labels_.push_back(label);
@ -921,7 +921,7 @@ void Input::LockAllInput(bool permanent, const std::string& label) {
} }
void Input::UnlockAllInput(bool permanent, const std::string& label) { void Input::UnlockAllInput(bool permanent, const std::string& label) {
assert(InGameThread()); assert(InLogicThread());
recent_input_locks_unlocks_.push_back( recent_input_locks_unlocks_.push_back(
permanent permanent
@ -1057,7 +1057,7 @@ void Input::ProcessStressTesting(int player_count) {
} }
void Input::HandleBackPress(bool from_toolbar) { void Input::HandleBackPress(bool from_toolbar) {
assert(InGameThread()); assert(InLogicThread());
// This can come through occasionally before our UI is up it seems? // This can come through occasionally before our UI is up it seems?
// Just ignore in that case. // Just ignore in that case.
@ -1112,7 +1112,7 @@ auto Input::PushJoystickEvent(const SDL_Event& event, InputDevice* input_device)
void Input::HandleJoystickEvent(const SDL_Event& event, void Input::HandleJoystickEvent(const SDL_Event& event,
InputDevice* input_device) { InputDevice* input_device) {
assert(InGameThread()); assert(InLogicThread());
assert(input_device); assert(input_device);
if (ShouldCompletelyIgnoreInputDevice(input_device)) { if (ShouldCompletelyIgnoreInputDevice(input_device)) {
@ -1145,7 +1145,7 @@ void Input::PushKeyReleaseEvent(const SDL_Keysym& keysym) {
} }
void Input::HandleKeyPress(const SDL_Keysym* keysym) { void Input::HandleKeyPress(const SDL_Keysym* keysym) {
assert(InGameThread()); assert(InLogicThread());
mark_input_active(); mark_input_active();
@ -1319,7 +1319,7 @@ void Input::HandleKeyPress(const SDL_Keysym* keysym) {
} }
void Input::HandleKeyRelease(const SDL_Keysym* keysym) { void Input::HandleKeyRelease(const SDL_Keysym* keysym) {
assert(InGameThread()); assert(InLogicThread());
// Note: we want to let these through even if input is locked. // Note: we want to let these through even if input is locked.
@ -1396,7 +1396,7 @@ auto Input::PushMouseScrollEvent(const Vector2f& amount) -> void {
} }
auto Input::HandleMouseScroll(const Vector2f& amount) -> void { auto Input::HandleMouseScroll(const Vector2f& amount) -> void {
assert(InGameThread()); assert(InLogicThread());
if (IsInputLocked()) { if (IsInputLocked()) {
return; return;
} }
@ -1432,7 +1432,7 @@ auto Input::PushSmoothMouseScrollEvent(const Vector2f& velocity, bool momentum)
auto Input::HandleSmoothMouseScroll(const Vector2f& velocity, bool momentum) auto Input::HandleSmoothMouseScroll(const Vector2f& velocity, bool momentum)
-> void { -> void {
assert(InGameThread()); assert(InLogicThread());
if (IsInputLocked()) { if (IsInputLocked()) {
return; return;
} }
@ -1465,7 +1465,7 @@ auto Input::PushMouseMotionEvent(const Vector2f& position) -> void {
auto Input::HandleMouseMotion(const Vector2f& position) -> void { auto Input::HandleMouseMotion(const Vector2f& position) -> void {
assert(g_graphics); assert(g_graphics);
assert(InGameThread()); assert(InLogicThread());
mark_input_active(); mark_input_active();
float old_cursor_pos_x = cursor_pos_x_; float old_cursor_pos_x = cursor_pos_x_;
@ -1517,7 +1517,7 @@ auto Input::PushMouseDownEvent(int button, const Vector2f& position) -> void {
auto Input::HandleMouseDown(int button, const Vector2f& position) -> void { auto Input::HandleMouseDown(int button, const Vector2f& position) -> void {
assert(g_graphics); assert(g_graphics);
assert(InGameThread()); assert(InLogicThread());
if (IsInputLocked()) { if (IsInputLocked()) {
return; return;
@ -1593,7 +1593,7 @@ auto Input::PushMouseUpEvent(int button, const Vector2f& position) -> void {
} }
auto Input::HandleMouseUp(int button, const Vector2f& position) -> void { auto Input::HandleMouseUp(int button, const Vector2f& position) -> void {
assert(InGameThread()); assert(InLogicThread());
mark_input_active(); mark_input_active();
// Convert normalized view coords to our virtual ones. // Convert normalized view coords to our virtual ones.
@ -1641,7 +1641,7 @@ void Input::PushTouchEvent(const TouchEvent& e) {
} }
void Input::HandleTouchEvent(const TouchEvent& e) { void Input::HandleTouchEvent(const TouchEvent& e) {
assert(InGameThread()); assert(InLogicThread());
assert(g_graphics); assert(g_graphics);
if (IsInputLocked()) { if (IsInputLocked()) {
@ -1713,7 +1713,7 @@ void Input::ResetJoyStickHeldButtons() {
// Send key-ups for any currently-held keys. // Send key-ups for any currently-held keys.
void Input::ResetKeyboardHeldKeys() { void Input::ResetKeyboardHeldKeys() {
assert(InGameThread()); assert(InLogicThread());
if (!HeadlessMode()) { if (!HeadlessMode()) {
// Synthesize key-ups for all our held keys. // Synthesize key-ups for all our held keys.
while (!keys_held_.empty()) { while (!keys_held_.empty()) {
@ -1733,7 +1733,7 @@ void Input::Draw(FrameDef* frame_def) {
} }
auto Input::IsCursorVisible() const -> bool { auto Input::IsCursorVisible() const -> bool {
assert(InGameThread()); assert(InLogicThread());
if (!g_ui) { if (!g_ui) {
return false; return false;
} }

View File

@ -10,7 +10,7 @@ namespace ballistica {
CollideModel::CollideModel(const std::string& name, Scene* scene) CollideModel::CollideModel(const std::string& name, Scene* scene)
: MediaComponent(name, scene), dead_(false) { : MediaComponent(name, scene), dead_(false) {
assert(InGameThread()); assert(InLogicThread());
if (scene) { if (scene) {
if (GameStream* os = scene->GetGameStream()) { if (GameStream* os = scene->GetGameStream()) {
os->AddCollideModel(this); os->AddCollideModel(this);

View File

@ -8,7 +8,7 @@ namespace ballistica {
CubeMapTexture::CubeMapTexture(const std::string& name, Scene* scene) CubeMapTexture::CubeMapTexture(const std::string& name, Scene* scene)
: MediaComponent(name, scene) { : MediaComponent(name, scene) {
assert(InGameThread()); assert(InLogicThread());
// cant currently add these to scenes so nothing to do here.. // cant currently add these to scenes so nothing to do here..
{ {

View File

@ -10,7 +10,7 @@ namespace ballistica {
Data::Data(const std::string& name, Scene* scene) Data::Data(const std::string& name, Scene* scene)
: MediaComponent(name, scene), dead_(false) { : MediaComponent(name, scene), dead_(false) {
assert(InGameThread()); assert(InLogicThread());
if (scene) { if (scene) {
if (GameStream* os = scene->GetGameStream()) { if (GameStream* os = scene->GetGameStream()) {

View File

@ -10,7 +10,7 @@ namespace ballistica {
Model::Model(const std::string& name, Scene* scene) Model::Model(const std::string& name, Scene* scene)
: MediaComponent(name, scene), dead_(false) { : MediaComponent(name, scene), dead_(false) {
assert(InGameThread()); assert(InLogicThread());
if (scene) { if (scene) {
if (GameStream* os = scene->GetGameStream()) { if (GameStream* os = scene->GetGameStream()) {

View File

@ -12,7 +12,7 @@ namespace ballistica {
Sound::Sound(const std::string& name, Scene* scene) Sound::Sound(const std::string& name, Scene* scene)
: MediaComponent(name, scene) { : MediaComponent(name, scene) {
assert(InGameThread()); assert(InLogicThread());
if (scene) { if (scene) {
if (GameStream* os = scene->GetGameStream()) { if (GameStream* os = scene->GetGameStream()) {
os->AddSound(this); os->AddSound(this);

View File

@ -11,7 +11,7 @@ namespace ballistica {
Texture::Texture(const std::string& name, Scene* scene) Texture::Texture(const std::string& name, Scene* scene)
: MediaComponent(name, scene), dead_(false) { : MediaComponent(name, scene), dead_(false) {
assert(InGameThread()); assert(InLogicThread());
// Add to the provided scene to get a numeric ID. // Add to the provided scene to get a numeric ID.
if (scene) { if (scene) {
@ -28,7 +28,7 @@ Texture::Texture(const std::string& name, Scene* scene)
// qrcode version // qrcode version
Texture::Texture(const std::string& qr_url) : MediaComponent(qr_url, nullptr) { Texture::Texture(const std::string& qr_url) : MediaComponent(qr_url, nullptr) {
assert(InGameThread()); assert(InLogicThread());
{ {
Media::MediaListsLock lock; Media::MediaListsLock lock;
texture_data_ = g_media->GetTextureDataQRCode(qr_url); texture_data_ = g_media->GetTextureDataQRCode(qr_url);

View File

@ -97,7 +97,7 @@ void CollideModelData::DoPreload() {
#endif // dSINGLE #endif // dSINGLE
} // namespace ballistica } // namespace ballistica
void CollideModelData::DoLoad() { assert(InGameThread()); } void CollideModelData::DoLoad() { assert(InLogicThread()); }
void CollideModelData::DoUnload() { void CollideModelData::DoUnload() {
// TODO(ericf): if we want to support in-game reloading we need // TODO(ericf): if we want to support in-game reloading we need

View File

@ -32,7 +32,7 @@ void DataData::DoPreload() {
} }
void DataData::DoLoad() { void DataData::DoLoad() {
assert(InGameThread()); assert(InLogicThread());
assert(valid_); assert(valid_);
PythonRef args(Py_BuildValue("(s)", raw_input_.c_str()), PythonRef::kSteal); PythonRef args(Py_BuildValue("(s)", raw_input_.c_str()), PythonRef::kSteal);
object_ = g_python->obj(Python::ObjID::kJsonLoadsCall).Call(args); object_ = g_python->obj(Python::ObjID::kJsonLoadsCall).Call(args);
@ -42,7 +42,7 @@ void DataData::DoLoad() {
} }
void DataData::DoUnload() { void DataData::DoUnload() {
assert(InGameThread()); assert(InLogicThread());
assert(valid_); assert(valid_);
object_.Release(); object_.Release();
} }

View File

@ -28,7 +28,7 @@ class DataData : public MediaComponentData {
} }
} }
auto object() -> const PythonRef& { auto object() -> const PythonRef& {
assert(InGameThread()); assert(InLogicThread());
assert(loaded()); assert(loaded());
return object_; return object_;
} }

View File

@ -5,7 +5,7 @@
namespace ballistica { namespace ballistica {
MediaComponentData::MediaComponentData() { MediaComponentData::MediaComponentData() {
assert(InGameThread()); assert(InLogicThread());
assert(g_media); assert(g_media);
last_used_time_ = GetRealTime(); last_used_time_ = GetRealTime();
} }

View File

@ -79,7 +79,7 @@ void Media::LoadSystemModel(SystemModelID id, const char* name) {
} }
void Media::LoadSystemMedia() { void Media::LoadSystemMedia() {
assert(InGameThread()); assert(InLogicThread());
assert(g_audio_server && g_media_server && g_graphics_server); assert(g_audio_server && g_media_server && g_graphics_server);
assert(g_graphics_server assert(g_graphics_server
&& g_graphics_server->texture_compression_types_are_set()); && g_graphics_server->texture_compression_types_are_set());
@ -378,7 +378,7 @@ void Media::PrintLoadInfo() {
} }
void Media::MarkAllMediaForLoad() { void Media::MarkAllMediaForLoad() {
assert(InGameThread()); assert(InLogicThread());
// Need to keep lists locked while iterating over them. // Need to keep lists locked while iterating over them.
MediaListsLock m_lock; MediaListsLock m_lock;
@ -465,7 +465,7 @@ auto Media::GetComponentData(
const std::string& file_name, const std::string& file_name,
std::unordered_map<std::string, Object::Ref<T> >* c_list) std::unordered_map<std::string, Object::Ref<T> >* c_list)
-> Object::Ref<T> { -> Object::Ref<T> {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
auto i = c_list->find(file_name); auto i = c_list->find(file_name);
if (i != c_list->end()) { if (i != c_list->end()) {
@ -484,7 +484,7 @@ auto Media::GetComponentData(
} }
auto Media::GetTextureData(TextPacker* packer) -> Object::Ref<TextureData> { auto Media::GetTextureData(TextPacker* packer) -> Object::Ref<TextureData> {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
const std::string& hash(packer->hash()); const std::string& hash(packer->hash());
auto i = text_textures_.find(hash); auto i = text_textures_.find(hash);
@ -505,7 +505,7 @@ auto Media::GetTextureData(TextPacker* packer) -> Object::Ref<TextureData> {
auto Media::GetTextureDataQRCode(const std::string& url) auto Media::GetTextureDataQRCode(const std::string& url)
-> Object::Ref<TextureData> { -> Object::Ref<TextureData> {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
auto i = qr_textures_.find(url); auto i = qr_textures_.find(url);
if (i != qr_textures_.end()) { if (i != qr_textures_.end()) {
@ -527,7 +527,7 @@ auto Media::GetTextureDataQRCode(const std::string& url)
// ..should fix. // ..should fix.
auto Media::GetCubeMapTextureData(const std::string& file_name) auto Media::GetCubeMapTextureData(const std::string& file_name)
-> Object::Ref<TextureData> { -> Object::Ref<TextureData> {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
auto i = textures_.find(file_name); auto i = textures_.find(file_name);
if (i != textures_.end()) { if (i != textures_.end()) {
@ -550,7 +550,7 @@ auto Media::GetCubeMapTextureData(const std::string& file_name)
// settings, etc). Should fix. // settings, etc). Should fix.
auto Media::GetTextureData(const std::string& file_name) auto Media::GetTextureData(const std::string& file_name)
-> Object::Ref<TextureData> { -> Object::Ref<TextureData> {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
auto i = textures_.find(file_name); auto i = textures_.find(file_name);
if (i != textures_.end()) { if (i != textures_.end()) {
@ -603,7 +603,7 @@ auto Media::GetTextureData(const std::string& file_name)
} }
void Media::MarkComponentForLoad(MediaComponentData* c) { void Media::MarkComponentForLoad(MediaComponentData* c) {
assert(InGameThread()); assert(InLogicThread());
assert(c->locked()); assert(c->locked());
@ -708,7 +708,7 @@ template <class T>
auto Media::GetComponentPendingLoadCount( auto Media::GetComponentPendingLoadCount(
std::unordered_map<std::string, Object::Ref<T> >* t_list, MediaType type) std::unordered_map<std::string, Object::Ref<T> >* t_list, MediaType type)
-> int { -> int {
assert(InGameThread()); assert(InLogicThread());
assert(media_lists_locked_); assert(media_lists_locked_);
int c = 0; int c = 0;
@ -742,8 +742,8 @@ auto Media::RunPendingGraphicsLoads() -> bool {
// Runs the pending loads that run in the main thread. Also clears the list of // Runs the pending loads that run in the main thread. Also clears the list of
// done loads. // done loads.
auto Media::RunPendingLoadsGameThread() -> bool { auto Media::RunPendingLoadsLogicThread() -> bool {
assert(InGameThread()); assert(InLogicThread());
return RunPendingLoadList(&pending_loads_other_); return RunPendingLoadList(&pending_loads_other_);
} }
@ -826,7 +826,7 @@ auto Media::RunPendingLoadList(std::vector<Object::Ref<T>*>* c_list) -> bool {
} }
void Media::Prune(int level) { void Media::Prune(int level) {
assert(InGameThread()); assert(InLogicThread());
millisecs_t current_time = GetRealTime(); millisecs_t current_time = GetRealTime();
// need lists locked while accessing/modifying them // need lists locked while accessing/modifying them
@ -1066,7 +1066,7 @@ auto Media::FindMediaFile(FileType type, const std::string& name)
std::string file_out; std::string file_out;
// We don't protect package-path access so make sure its always from here. // We don't protect package-path access so make sure its always from here.
assert(InGameThread()); assert(InLogicThread());
const char* ext = ""; const char* ext = "";
const char* prefix = ""; const char* prefix = "";
@ -1199,7 +1199,7 @@ void Media::AddPendingLoad(Object::Ref<MediaComponentData>* c) {
} }
void Media::ClearPendingLoadsDoneList() { void Media::ClearPendingLoadsDoneList() {
assert(InGameThread()); assert(InLogicThread());
std::lock_guard<std::mutex> lock(pending_load_list_mutex_); std::lock_guard<std::mutex> lock(pending_load_list_mutex_);
@ -1229,7 +1229,7 @@ void Media::PreloadRunnable::Run() {
void Media::AddPackage(const std::string& name, const std::string& path) { 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.. // we don't protect package-path access so make sure its always from here..
assert(InGameThread()); assert(InLogicThread());
#if BA_DEBUG_BUILD #if BA_DEBUG_BUILD
if (packages_.find(name) != packages_.end()) { if (packages_.find(name) != packages_.end()) {
Log("WARNING: adding duplicate package: '" + name + "'"); Log("WARNING: adding duplicate package: '" + name + "'");

View File

@ -25,7 +25,7 @@ class Media {
static auto GetMedia( static auto GetMedia(
std::unordered_map<std::string, Object::WeakRef<T> >* list, std::unordered_map<std::string, Object::WeakRef<T> >* list,
const std::string& name, Scene* scene) -> Object::Ref<T> { const std::string& name, Scene* scene) -> Object::Ref<T> {
assert(InGameThread()); assert(InLogicThread());
assert(list); assert(list);
auto i = list->find(name); auto i = list->find(name);
@ -47,7 +47,7 @@ class Media {
/// Finish loading any media that has been preloaded but still needs to be /// Finish loading any media that has been preloaded but still needs to be
/// loaded by the proper thread. /// loaded by the proper thread.
auto RunPendingLoadsGameThread() -> bool; auto RunPendingLoadsLogicThread() -> bool;
/// Return true if audio loads remain to be done. /// Return true if audio loads remain to be done.
auto RunPendingAudioLoads() -> bool; auto RunPendingAudioLoads() -> bool;
@ -110,25 +110,25 @@ class Media {
// Get system assets. // Get system assets.
auto GetTexture(SystemTextureID id) -> TextureData* { auto GetTexture(SystemTextureID id) -> TextureData* {
BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later. BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later.
assert(InGameThread()); assert(InLogicThread());
assert(static_cast<size_t>(id) < system_textures_.size()); assert(static_cast<size_t>(id) < system_textures_.size());
return system_textures_[static_cast<int>(id)].get(); return system_textures_[static_cast<int>(id)].get();
} }
auto GetCubeMapTexture(SystemCubeMapTextureID id) -> TextureData* { auto GetCubeMapTexture(SystemCubeMapTextureID id) -> TextureData* {
BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later. BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later.
assert(InGameThread()); assert(InLogicThread());
assert(static_cast<size_t>(id) < system_cube_map_textures_.size()); assert(static_cast<size_t>(id) < system_cube_map_textures_.size());
return system_cube_map_textures_[static_cast<int>(id)].get(); return system_cube_map_textures_[static_cast<int>(id)].get();
} }
auto GetSound(SystemSoundID id) -> SoundData* { auto GetSound(SystemSoundID id) -> SoundData* {
BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later. BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later.
assert(InGameThread()); assert(InLogicThread());
assert(static_cast<size_t>(id) < system_sounds_.size()); assert(static_cast<size_t>(id) < system_sounds_.size());
return system_sounds_[static_cast<int>(id)].get(); return system_sounds_[static_cast<int>(id)].get();
} }
auto GetModel(SystemModelID id) -> ModelData* { auto GetModel(SystemModelID id) -> ModelData* {
BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later. BA_PRECONDITION_FATAL(system_media_loaded_); // Revert to assert later.
assert(InGameThread()); assert(InLogicThread());
assert(static_cast<size_t>(id) < system_models_.size()); assert(static_cast<size_t>(id) < system_models_.size());
return system_models_[static_cast<int>(id)].get(); return system_models_[static_cast<int>(id)].get();
} }

View File

@ -18,7 +18,7 @@ struct Networking::ScanResultsEntryPriv {
}; };
Networking::Networking() { Networking::Networking() {
assert(InGameThread()); assert(InLogicThread());
Resume(); Resume();
} }
@ -29,7 +29,7 @@ Networking::~Networking() = default;
// non-blocking mode they're still blocking for 3-4ms sometimes. But for now // non-blocking mode they're still blocking for 3-4ms sometimes. But for now
// since this is only used minimally and only while in the UI i guess it's ok. // since this is only used minimally and only while in the UI i guess it's ok.
void Networking::HostScanCycle() { void Networking::HostScanCycle() {
assert(InGameThread()); assert(InLogicThread());
// We need to create a scanner socket - an ipv4 socket we can send out // We need to create a scanner socket - an ipv4 socket we can send out
// broadcast messages from. // broadcast messages from.

View File

@ -222,7 +222,7 @@ void TelnetServer::PushPrint(const std::string& s) {
void TelnetServer::Print(const std::string& s) { void TelnetServer::Print(const std::string& s) {
// Currently we make the assumption that *only* the game thread writes to our // Currently we make the assumption that *only* the game thread writes to our
// socket. // socket.
assert(InGameThread()); assert(InLogicThread());
if (client_sd_ != -1) { if (client_sd_ != -1) {
send(client_sd_, s.c_str(), send(client_sd_, s.c_str(),
static_cast_check_fit<socket_send_length_t>(s.size()), 0); static_cast_check_fit<socket_send_length_t>(s.size()), 0);

View File

@ -678,7 +678,7 @@ void Platform::CreateApp() {
} }
auto Platform::CreateGraphics() -> Graphics* { auto Platform::CreateGraphics() -> Graphics* {
assert(InGameThread()); assert(InLogicThread());
#if BA_VR_BUILD #if BA_VR_BUILD
return new VRGraphics(); return new VRGraphics();
#else #else

View File

@ -64,7 +64,7 @@ auto PythonClassActivityData::tp_new(PyTypeObject* type, PyObject* args,
reinterpret_cast<PythonClassActivityData*>(type->tp_alloc(type, 0)); reinterpret_cast<PythonClassActivityData*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -81,7 +81,7 @@ void PythonClassActivityData::tp_dealloc(PythonClassActivityData* self) {
// These have to be destructed in the game thread; send them along to // These have to be destructed in the game thread; send them along to
// it if need be; otherwise do it immediately. // it if need be; otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<HostActivity>* h = self->host_activity_; Object::WeakRef<HostActivity>* h = self->host_activity_;
g_game->PushCall([h] { delete h; }); g_game->PushCall([h] { delete h; });
} else { } else {

View File

@ -66,7 +66,7 @@ auto PythonClassCollideModel::tp_new(PyTypeObject* type, PyObject* args,
reinterpret_cast<PythonClassCollideModel*>(type->tp_alloc(type, 0)); reinterpret_cast<PythonClassCollideModel*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -87,7 +87,7 @@ auto PythonClassCollideModel::tp_new(PyTypeObject* type, PyObject* args,
#pragma clang diagnostic pop #pragma clang diagnostic pop
void PythonClassCollideModel::Delete(Object::Ref<CollideModel>* ref) { void PythonClassCollideModel::Delete(Object::Ref<CollideModel>* ref) {
assert(InGameThread()); assert(InLogicThread());
// if we're the py-object for a collide_model, clear them out // if we're the py-object for a collide_model, clear them out
// (FIXME - we should pass the old pointer in here to sanity-test that we // (FIXME - we should pass the old pointer in here to sanity-test that we
// were their ref) // were their ref)
@ -101,7 +101,7 @@ void PythonClassCollideModel::tp_dealloc(PythonClassCollideModel* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be deleted in the game thread - send the ptr along if need // these have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately // be; otherwise do it immediately
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<CollideModel>* c = self->collide_model_; Object::Ref<CollideModel>* c = self->collide_model_;
g_game->PushCall([c] { Delete(c); }); g_game->PushCall([c] { Delete(c); });
} else { } else {

View File

@ -132,7 +132,7 @@ auto PythonClassContext::tp_new(PyTypeObject* type, PyObject* args,
return nullptr; return nullptr;
} }
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -184,7 +184,7 @@ void PythonClassContext::tp_dealloc(PythonClassContext* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// Contexts have to be deleted in the game thread; // Contexts have to be deleted in the game thread;
// ship them to it for deletion if need be; otherwise do it immediately. // ship them to it for deletion if need be; otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Context* c = self->context_; Context* c = self->context_;
Context* c2 = self->context_prev_; Context* c2 = self->context_prev_;
g_game->PushCall([c, c2] { g_game->PushCall([c, c2] {

View File

@ -98,7 +98,7 @@ auto PythonClassContextCall::tp_new(PyTypeObject* type, PyObject* args,
// something goes wrong afterwards // something goes wrong afterwards
PyObject* source_obj = Py_None; PyObject* source_obj = Py_None;
if (!PyArg_ParseTuple(args, "O", &source_obj)) return nullptr; if (!PyArg_ParseTuple(args, "O", &source_obj)) return nullptr;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -115,7 +115,7 @@ void PythonClassContextCall::tp_dealloc(PythonClassContextCall* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be deleted in the game thread - send the ptr along if need // these have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately // be; otherwise do it immediately
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<PythonContextCall>* c = self->context_call_; Object::Ref<PythonContextCall>* c = self->context_call_;
g_game->PushCall([c] { delete c; }); g_game->PushCall([c] { delete c; });
} else { } else {

View File

@ -63,7 +63,7 @@ auto PythonClassData::tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
auto* self = reinterpret_cast<PythonClassData*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassData*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -83,7 +83,7 @@ auto PythonClassData::tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
#pragma clang diagnostic pop #pragma clang diagnostic pop
void PythonClassData::Delete(Object::Ref<Data>* ref) { void PythonClassData::Delete(Object::Ref<Data>* ref) {
assert(InGameThread()); assert(InLogicThread());
// if we're the py-object for a data, clear them out // if we're the py-object for a data, clear them out
// (FIXME - wej should pass the old pointer in here to sanity-test that we // (FIXME - wej should pass the old pointer in here to sanity-test that we
@ -98,7 +98,7 @@ void PythonClassData::tp_dealloc(PythonClassData* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be deleted in the game thread - send the ptr along if need // these have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately // be; otherwise do it immediately
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<Data>* s = self->data_; Object::Ref<Data>* s = self->data_;
g_game->PushCall([s] { Delete(s); }); g_game->PushCall([s] { Delete(s); });
} else { } else {

View File

@ -122,7 +122,7 @@ auto PythonClassInputDevice::tp_new(PyTypeObject* type, PyObject* args,
reinterpret_cast<PythonClassInputDevice*>(type->tp_alloc(type, 0)); reinterpret_cast<PythonClassInputDevice*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -140,7 +140,7 @@ void PythonClassInputDevice::tp_dealloc(PythonClassInputDevice* self) {
// need be. // need be.
// FIXME: Technically the main thread has a pointer to a dead PyObject // FIXME: Technically the main thread has a pointer to a dead PyObject
// until the delete goes through; could that ever be a problem? // until the delete goes through; could that ever be a problem?
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<InputDevice>* d = self->input_device_; Object::WeakRef<InputDevice>* d = self->input_device_;
g_game->PushCall([d] { delete d; }); g_game->PushCall([d] { delete d; });
} else { } else {
@ -347,7 +347,7 @@ auto PythonClassInputDevice::GetAxisName(PythonClassInputDevice* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
int id; int id;
static const char* kwlist[] = {"axis_id", nullptr}; static const char* kwlist[] = {"axis_id", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", if (!PyArg_ParseTupleAndKeywords(args, keywds, "i",
@ -366,7 +366,7 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
int id{}; int id{};
static const char* kwlist[] = {"button_id", nullptr}; static const char* kwlist[] = {"button_id", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", if (!PyArg_ParseTupleAndKeywords(args, keywds, "i",

View File

@ -88,7 +88,7 @@ auto PythonClassMaterial::tp_new(PyTypeObject* type, PyObject* args,
// Do anything that might throw an exception *before* our placement-new // Do anything that might throw an exception *before* our placement-new
// stuff so we don't have to worry about cleaning it up on errors. // stuff so we don't have to worry about cleaning it up on errors.
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -130,7 +130,7 @@ auto PythonClassMaterial::tp_new(PyTypeObject* type, PyObject* args,
} }
void PythonClassMaterial::Delete(Object::Ref<Material>* m) { void PythonClassMaterial::Delete(Object::Ref<Material>* m) {
assert(InGameThread()); assert(InLogicThread());
// If we're the py-object for a material, clear them out. // If we're the py-object for a material, clear them out.
if (m->exists()) { if (m->exists()) {
@ -145,7 +145,7 @@ void PythonClassMaterial::tp_dealloc(PythonClassMaterial* self) {
// These have to be deleted in the game thread - push a call if // These have to be deleted in the game thread - push a call if
// need be.. otherwise do it immediately. // need be.. otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<Material>* ptr = self->material_; Object::Ref<Material>* ptr = self->material_;
g_game->PushCall([ptr] { Delete(ptr); }); g_game->PushCall([ptr] { Delete(ptr); });
} else { } else {
@ -229,7 +229,7 @@ auto PythonClassMaterial::Dir(PythonClassMaterial* self) -> PyObject* {
auto PythonClassMaterial::AddActions(PythonClassMaterial* self, PyObject* args, auto PythonClassMaterial::AddActions(PythonClassMaterial* self, PyObject* args,
PyObject* keywds) -> PyObject* { PyObject* keywds) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* conditions_obj{Py_None}; PyObject* conditions_obj{Py_None};
PyObject* actions_obj{nullptr}; PyObject* actions_obj{nullptr};
const char* kwlist[] = {"actions", "conditions", nullptr}; const char* kwlist[] = {"actions", "conditions", nullptr};
@ -430,7 +430,7 @@ PyMethodDef PythonClassMaterial::tp_methods[] = {
void DoAddConditions(PyObject* cond_obj, void DoAddConditions(PyObject* cond_obj,
Object::Ref<MaterialConditionNode>* c) { Object::Ref<MaterialConditionNode>* c) {
assert(InGameThread()); assert(InLogicThread());
if (PyTuple_Check(cond_obj)) { if (PyTuple_Check(cond_obj)) {
Py_ssize_t size = PyTuple_GET_SIZE(cond_obj); Py_ssize_t size = PyTuple_GET_SIZE(cond_obj);
if (size < 1) { if (size < 1) {
@ -560,7 +560,7 @@ void DoAddConditions(PyObject* cond_obj,
void DoAddAction(PyObject* actions_obj, void DoAddAction(PyObject* actions_obj,
std::vector<Object::Ref<MaterialAction> >* actions) { std::vector<Object::Ref<MaterialAction> >* actions) {
assert(InGameThread()); assert(InLogicThread());
if (!PyTuple_Check(actions_obj)) { if (!PyTuple_Check(actions_obj)) {
throw Exception("Expected a tuple.", PyExcType::kType); throw Exception("Expected a tuple.", PyExcType::kType);
} }

View File

@ -64,7 +64,7 @@ auto PythonClassModel::tp_new(PyTypeObject* type, PyObject* args,
auto* self = reinterpret_cast<PythonClassModel*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassModel*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -84,7 +84,7 @@ auto PythonClassModel::tp_new(PyTypeObject* type, PyObject* args,
#pragma clang diagnostic pop #pragma clang diagnostic pop
void PythonClassModel::Delete(Object::Ref<Model>* ref) { void PythonClassModel::Delete(Object::Ref<Model>* ref) {
assert(InGameThread()); assert(InLogicThread());
// if we're the py-object for a model, clear them out // if we're the py-object for a model, clear them out
// (FIXME - we should pass the old pointer in here to sanity-test that we // (FIXME - we should pass the old pointer in here to sanity-test that we
@ -99,7 +99,7 @@ void PythonClassModel::tp_dealloc(PythonClassModel* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be deleted in the game thread - send the ptr along if need // these have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately // be; otherwise do it immediately
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<Model>* m = self->model_; Object::Ref<Model>* m = self->model_;
g_game->PushCall([m] { Delete(m); }); g_game->PushCall([m] { Delete(m); });
} else { } else {

View File

@ -83,7 +83,7 @@ auto PythonClassNode::tp_new(PyTypeObject* type, PyObject* args,
auto* self = reinterpret_cast<PythonClassNode*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassNode*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -111,7 +111,7 @@ void PythonClassNode::tp_dealloc(PythonClassNode* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// These have to be deleted in the game thread; send the ptr along if need // These have to be deleted in the game thread; send the ptr along if need
// be; otherwise do it immediately. // be; otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<Node>* n = self->node_; Object::WeakRef<Node>* n = self->node_;
g_game->PushCall([n] { delete n; }); g_game->PushCall([n] { delete n; });
} else { } else {

View File

@ -61,7 +61,7 @@ auto PythonClassSessionData::tp_new(PyTypeObject* type, PyObject* args,
reinterpret_cast<PythonClassSessionData*>(type->tp_alloc(type, 0)); reinterpret_cast<PythonClassSessionData*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -79,7 +79,7 @@ void PythonClassSessionData::tp_dealloc(PythonClassSessionData* self) {
// ...send the ptr along if need be. // ...send the ptr along if need be.
// FIXME: technically the main thread has a pointer to a dead PyObject // FIXME: technically the main thread has a pointer to a dead PyObject
// until the delete goes through; could that ever be a problem? // until the delete goes through; could that ever be a problem?
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<Session>* s = self->session_; Object::WeakRef<Session>* s = self->session_;
g_game->PushCall([s] { delete s; }); g_game->PushCall([s] { delete s; });
} else { } else {

View File

@ -153,7 +153,7 @@ auto PythonClassSessionPlayer::tp_new(PyTypeObject* type, PyObject* args,
reinterpret_cast<PythonClassSessionPlayer*>(type->tp_alloc(type, 0)); reinterpret_cast<PythonClassSessionPlayer*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -185,7 +185,7 @@ void PythonClassSessionPlayer::tp_dealloc(PythonClassSessionPlayer* self) {
// These have to be deleted in the game thread - send the ptr along if need // These have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately. // be; otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<Player>* p = self->player_; Object::WeakRef<Player>* p = self->player_;
g_game->PushCall([p] { delete p; }); g_game->PushCall([p] { delete p; });
} else { } else {
@ -199,7 +199,7 @@ auto PythonClassSessionPlayer::tp_getattro(PythonClassSessionPlayer* self,
PyObject* attr) -> PyObject* { PyObject* attr) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
// Assuming this will always be a str? // Assuming this will always be a str?
assert(PyUnicode_Check(attr)); assert(PyUnicode_Check(attr));
@ -336,7 +336,7 @@ auto PythonClassSessionPlayer::GetName(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
int full = false; int full = false;
int icon = true; int icon = true;
static const char* kwlist[] = {"full", "icon", nullptr}; static const char* kwlist[] = {"full", "icon", nullptr};
@ -356,7 +356,7 @@ auto PythonClassSessionPlayer::GetName(PythonClassSessionPlayer* self,
auto PythonClassSessionPlayer::Exists(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::Exists(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
if (self->player_->exists()) { if (self->player_->exists()) {
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
@ -368,7 +368,7 @@ auto PythonClassSessionPlayer::SetName(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* name_obj; PyObject* name_obj;
PyObject* full_name_obj = Py_None; PyObject* full_name_obj = Py_None;
@ -395,7 +395,7 @@ auto PythonClassSessionPlayer::SetName(PythonClassSessionPlayer* self,
auto PythonClassSessionPlayer::ResetInput(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::ResetInput(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* p = self->player_->get(); Player* p = self->player_->get();
if (!p) { if (!p) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);
@ -409,7 +409,7 @@ auto PythonClassSessionPlayer::AssignInputCall(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* input_type_obj; PyObject* input_type_obj;
PyObject* call_obj; PyObject* call_obj;
static const char* kwlist[] = {"type", "call", nullptr}; static const char* kwlist[] = {"type", "call", nullptr};
@ -449,7 +449,7 @@ auto PythonClassSessionPlayer::AssignInputCall(PythonClassSessionPlayer* self,
auto PythonClassSessionPlayer::RemoveFromGame(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::RemoveFromGame(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* player = self->player_->get(); Player* player = self->player_->get();
if (!player) { if (!player) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);
@ -468,7 +468,7 @@ auto PythonClassSessionPlayer::RemoveFromGame(PythonClassSessionPlayer* self)
auto PythonClassSessionPlayer::GetTeam(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::GetTeam(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* p = self->player_->get(); Player* p = self->player_->get();
if (!p) { if (!p) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);
@ -484,7 +484,7 @@ auto PythonClassSessionPlayer::GetTeam(PythonClassSessionPlayer* self)
auto PythonClassSessionPlayer::GetV1AccountID(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::GetV1AccountID(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* p = self->player_->get(); Player* p = self->player_->get();
if (!p) { if (!p) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);
@ -501,7 +501,7 @@ auto PythonClassSessionPlayer::SetData(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* team_obj; PyObject* team_obj;
PyObject* character_obj; PyObject* character_obj;
PyObject* color_obj; PyObject* color_obj;
@ -529,7 +529,7 @@ auto PythonClassSessionPlayer::SetData(PythonClassSessionPlayer* self,
auto PythonClassSessionPlayer::GetIconInfo(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::GetIconInfo(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* p = self->player_->get(); Player* p = self->player_->get();
if (!p) { if (!p) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);
@ -547,7 +547,7 @@ auto PythonClassSessionPlayer::SetIconInfo(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* texture_name_obj; PyObject* texture_name_obj;
PyObject* tint_texture_name_obj; PyObject* tint_texture_name_obj;
PyObject* tint_color_obj; PyObject* tint_color_obj;
@ -582,7 +582,7 @@ auto PythonClassSessionPlayer::SetActivity(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* activity_obj; PyObject* activity_obj;
static const char* kwlist[] = {"activity", nullptr}; static const char* kwlist[] = {"activity", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O", if (!PyArg_ParseTupleAndKeywords(args, keywds, "O",
@ -608,7 +608,7 @@ auto PythonClassSessionPlayer::SetNode(PythonClassSessionPlayer* self,
PyObject* args, PyObject* keywds) PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* node_obj; PyObject* node_obj;
static const char* kwlist[] = {"node", nullptr}; static const char* kwlist[] = {"node", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O", if (!PyArg_ParseTupleAndKeywords(args, keywds, "O",
@ -634,7 +634,7 @@ auto PythonClassSessionPlayer::SetNode(PythonClassSessionPlayer* self,
auto PythonClassSessionPlayer::GetIcon(PythonClassSessionPlayer* self) auto PythonClassSessionPlayer::GetIcon(PythonClassSessionPlayer* self)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
Player* p = self->player_->get(); Player* p = self->player_->get();
if (!p) { if (!p) {
throw Exception(PyExcType::kSessionPlayerNotFound); throw Exception(PyExcType::kSessionPlayerNotFound);

View File

@ -63,7 +63,7 @@ auto PythonClassSound::tp_new(PyTypeObject* type, PyObject* args,
auto* self = reinterpret_cast<PythonClassSound*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassSound*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -83,7 +83,7 @@ auto PythonClassSound::tp_new(PyTypeObject* type, PyObject* args,
#pragma clang diagnostic pop #pragma clang diagnostic pop
void PythonClassSound::Delete(Object::Ref<Sound>* ref) { void PythonClassSound::Delete(Object::Ref<Sound>* ref) {
assert(InGameThread()); assert(InLogicThread());
// if we're the py-object for a sound, clear them out // if we're the py-object for a sound, clear them out
// (FIXME - wej should pass the old pointer in here to sanity-test that we // (FIXME - wej should pass the old pointer in here to sanity-test that we
@ -98,7 +98,7 @@ void PythonClassSound::tp_dealloc(PythonClassSound* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be deleted in the game thread - send the ptr along if need // these have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately // be; otherwise do it immediately
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<Sound>* s = self->sound_; Object::Ref<Sound>* s = self->sound_;
g_game->PushCall([s] { Delete(s); }); g_game->PushCall([s] { Delete(s); });
} else { } else {

View File

@ -58,7 +58,7 @@ auto PythonClassTexture::tp_new(PyTypeObject* type, PyObject* args,
auto* self = reinterpret_cast<PythonClassTexture*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassTexture*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -76,7 +76,7 @@ auto PythonClassTexture::tp_new(PyTypeObject* type, PyObject* args,
} }
void PythonClassTexture::Delete(Object::Ref<Texture>* ref) { void PythonClassTexture::Delete(Object::Ref<Texture>* ref) {
assert(InGameThread()); assert(InLogicThread());
// If we're the py-object for a texture, kill our reference to it. // If we're the py-object for a texture, kill our reference to it.
// (FIXME - we should pass the old py obj pointer in here to // (FIXME - we should pass the old py obj pointer in here to
@ -91,7 +91,7 @@ void PythonClassTexture::tp_dealloc(PythonClassTexture* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// These have to be deleted in the game thread - send the ptr along if need // These have to be deleted in the game thread - send the ptr along if need
// be; otherwise do it immediately. // be; otherwise do it immediately.
if (!InGameThread()) { if (!InLogicThread()) {
Object::Ref<Texture>* t = self->texture_; Object::Ref<Texture>* t = self->texture_;
g_game->PushCall([t] { Delete(t); }); g_game->PushCall([t] { Delete(t); });
} else { } else {

View File

@ -72,7 +72,7 @@ auto PythonClassTimer::tp_new(PyTypeObject* type, PyObject* args,
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -148,7 +148,7 @@ auto PythonClassTimer::tp_new(PyTypeObject* type, PyObject* args,
} }
void PythonClassTimer::DoDelete(bool have_timer, TimeType time_type, void PythonClassTimer::DoDelete(bool have_timer, TimeType time_type,
int timer_id, Context* context) { int timer_id, Context* context) {
assert(InGameThread()); assert(InLogicThread());
if (!context) { if (!context) {
return; return;
} }
@ -161,7 +161,7 @@ void PythonClassTimer::DoDelete(bool have_timer, TimeType time_type,
void PythonClassTimer::tp_dealloc(PythonClassTimer* self) { void PythonClassTimer::tp_dealloc(PythonClassTimer* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// These have to be deleted in the game thread. // These have to be deleted in the game thread.
if (!InGameThread()) { if (!InLogicThread()) {
auto a0 = self->have_timer_; auto a0 = self->have_timer_;
auto a1 = self->time_type_; auto a1 = self->time_type_;
auto a2 = self->timer_id_; auto a2 = self->timer_id_;

View File

@ -73,7 +73,7 @@ auto PythonClassWidget::tp_new(PyTypeObject* type, PyObject* args,
auto* self = reinterpret_cast<PythonClassWidget*>(type->tp_alloc(type, 0)); auto* self = reinterpret_cast<PythonClassWidget*>(type->tp_alloc(type, 0));
if (self) { if (self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception( throw Exception(
"ERROR: " + std::string(type_obj.tp_name) "ERROR: " + std::string(type_obj.tp_name)
+ " objects must only be created in the game thread (current is (" + " objects must only be created in the game thread (current is ("
@ -89,7 +89,7 @@ void PythonClassWidget::tp_dealloc(PythonClassWidget* self) {
BA_PYTHON_TRY; BA_PYTHON_TRY;
// these have to be destructed in the game thread - send them along to it if // these have to be destructed in the game thread - send them along to it if
// need be // need be
if (!InGameThread()) { if (!InLogicThread()) {
Object::WeakRef<Widget>* w = self->widget_; Object::WeakRef<Widget>* w = self->widget_;
g_game->PushCall([w] { delete w; }); g_game->PushCall([w] { delete w; });
} else { } else {

View File

@ -130,7 +130,7 @@ auto PyNewReplaySession(PyObject* self, PyObject* args, PyObject* keywds)
auto PyIsInReplay(PyObject* self, PyObject* args, PyObject* keywds) auto PyIsInReplay(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
static const char* kwlist[] = {nullptr}; static const char* kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "", if (!PyArg_ParseTupleAndKeywords(args, keywds, "",
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {
@ -147,7 +147,7 @@ auto PyIsInReplay(PyObject* self, PyObject* args, PyObject* keywds)
auto PyRegisterSession(PyObject* self, PyObject* args, PyObject* keywds) auto PyRegisterSession(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* session_obj; PyObject* session_obj;
static const char* kwlist[] = {"session", nullptr}; static const char* kwlist[] = {"session", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O", if (!PyArg_ParseTupleAndKeywords(args, keywds, "O",
@ -169,7 +169,7 @@ auto PyRegisterSession(PyObject* self, PyObject* args, PyObject* keywds)
auto PyRegisterActivity(PyObject* self, PyObject* args, PyObject* keywds) auto PyRegisterActivity(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* activity_obj; PyObject* activity_obj;
static const char* kwlist[] = {"activity", nullptr}; static const char* kwlist[] = {"activity", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "O", if (!PyArg_ParseTupleAndKeywords(args, keywds, "O",
@ -197,7 +197,7 @@ auto PyGetForegroundHostSession(PyObject* self, PyObject* args,
} }
// Note: we return None if not in the game thread. // Note: we return None if not in the game thread.
HostSession* s = InGameThread() HostSession* s = InLogicThread()
? g_game->GetForegroundContext().GetHostSession() ? g_game->GetForegroundContext().GetHostSession()
: nullptr; : nullptr;
if (s != nullptr) { if (s != nullptr) {
@ -259,7 +259,7 @@ auto PyGetActivity(PyObject* self, PyObject* args, PyObject* keywds)
} }
// Fail gracefully if called from outside the game thread. // Fail gracefully if called from outside the game thread.
if (!InGameThread()) { if (!InLogicThread()) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -293,8 +293,8 @@ auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
if (from_other_thread) { if (from_other_thread) {
// Warn the user not to use this from the game thread since it doesnt // Warn the user not to use this from the game thread since it doesnt
// save/restore context. // save/restore context.
if (!suppress_warning && InGameThread()) { if (!suppress_warning && InLogicThread()) {
g_python->IssueCallInGameThreadWarning(call_obj); g_python->IssueCallInLogicThreadWarning(call_obj);
} }
// This gets called from other python threads so we can't construct // This gets called from other python threads so we can't construct
@ -304,7 +304,7 @@ auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
Py_INCREF(call_obj); Py_INCREF(call_obj);
g_game->PushPythonRawCallable(call_obj); g_game->PushPythonRawCallable(call_obj);
} else { } else {
if (!InGameThread()) { if (!InLogicThread()) {
throw Exception("You must use from_other_thread mode."); throw Exception("You must use from_other_thread mode.");
} }
g_game->PushPythonCall(Object::New<PythonContextCall>(call_obj)); g_game->PushPythonCall(Object::New<PythonContextCall>(call_obj));
@ -361,7 +361,7 @@ auto PyTime(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
auto PyTimer(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { auto PyTimer(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* length_obj; PyObject* length_obj;
int64_t length; int64_t length;

View File

@ -182,7 +182,7 @@ auto PyGetCollisionInfo(PyObject* self, PyObject* args) -> PyObject* {
auto PyCameraShake(PyObject* self, PyObject* args, PyObject* keywds) auto PyCameraShake(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
float intensity = 1.0f; float intensity = 1.0f;
static const char* kwlist[] = {"intensity", nullptr}; static const char* kwlist[] = {"intensity", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|f", if (!PyArg_ParseTupleAndKeywords(args, keywds, "|f",
@ -198,7 +198,7 @@ auto PyPlaySound(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
PyObject* sound_obj; PyObject* sound_obj;
float volume = 1.0f; float volume = 1.0f;
int host_only = 0; int host_only = 0;
@ -253,7 +253,7 @@ auto PyEmitFx(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
const char* chunk_type_str = "rock"; const char* chunk_type_str = "rock";
const char* emit_type_str = "chunks"; const char* emit_type_str = "chunks";
const char* tendril_type_str = "smoke"; const char* tendril_type_str = "smoke";
assert(InGameThread()); assert(InLogicThread());
if (!PyArg_ParseTupleAndKeywords( if (!PyArg_ParseTupleAndKeywords(
args, keywds, "O|Oiffsss", const_cast<char**>(kwlist), &pos_obj, args, keywds, "O|Oiffsss", const_cast<char**>(kwlist), &pos_obj,
&vel_obj, &count, &scale, &spread, &chunk_type_str, &emit_type_str, &vel_obj, &count, &scale, &spread, &chunk_type_str, &emit_type_str,
@ -361,7 +361,7 @@ auto PySetMapBounds(PyObject* self, PyObject* args) -> PyObject* {
throw Exception(PyExcType::kContext); throw Exception(PyExcType::kContext);
} }
float xmin, ymin, zmin, xmax, ymax, zmax; float xmin, ymin, zmin, xmax, ymax, zmax;
assert(InGameThread()); assert(InLogicThread());
if (!PyArg_ParseTuple(args, "(ffffff)", &xmin, &ymin, &zmin, &xmax, &ymax, if (!PyArg_ParseTuple(args, "(ffffff)", &xmin, &ymin, &zmin, &xmax, &ymax,
&zmax)) { &zmax)) {
return nullptr; return nullptr;
@ -381,7 +381,7 @@ auto PyGetForegroundHostActivity(PyObject* self, PyObject* args,
} }
// Note: we return None if not in the game thread. // Note: we return None if not in the game thread.
HostActivity* h = InGameThread() HostActivity* h = InLogicThread()
? g_game->GetForegroundContext().GetHostActivity() ? g_game->GetForegroundContext().GetHostActivity()
: nullptr; : nullptr;
if (h != nullptr) { if (h != nullptr) {
@ -396,7 +396,7 @@ auto PyGetForegroundHostActivity(PyObject* self, PyObject* args,
auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds) auto PyGetGameRoster(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
static const char* kwlist[] = {nullptr}; static const char* kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "", if (!PyArg_ParseTupleAndKeywords(args, keywds, "",
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {

View File

@ -56,7 +56,7 @@ auto PySetTouchscreenEditing(PyObject* self, PyObject* args) -> PyObject* {
auto PyCaptureGamePadInput(PyObject* self, PyObject* args) -> PyObject* { auto PyCaptureGamePadInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
assert(g_python); assert(g_python);
PyObject* obj; PyObject* obj;
if (!PyArg_ParseTuple(args, "O", &obj)) { if (!PyArg_ParseTuple(args, "O", &obj)) {
@ -69,7 +69,7 @@ auto PyCaptureGamePadInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyReleaseGamePadInput(PyObject* self, PyObject* args) -> PyObject* { auto PyReleaseGamePadInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
assert(g_python); assert(g_python);
g_python->ReleaseGamePadInput(); g_python->ReleaseGamePadInput();
Py_RETURN_NONE; Py_RETURN_NONE;
@ -78,7 +78,7 @@ auto PyReleaseGamePadInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyCaptureKeyboardInput(PyObject* self, PyObject* args) -> PyObject* { auto PyCaptureKeyboardInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
if (!g_python) { if (!g_python) {
return nullptr; return nullptr;
} }
@ -93,7 +93,7 @@ auto PyCaptureKeyboardInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyReleaseKeyboardInput(PyObject* self, PyObject* args) -> PyObject* { auto PyReleaseKeyboardInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
if (!g_python) { if (!g_python) {
return nullptr; return nullptr;
} }
@ -104,7 +104,7 @@ auto PyReleaseKeyboardInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyLockAllInput(PyObject* self, PyObject* args) -> PyObject* { auto PyLockAllInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
assert(g_input); assert(g_input);
g_input->LockAllInput(false, Python::GetPythonFileLocation()); g_input->LockAllInput(false, Python::GetPythonFileLocation());
Py_RETURN_NONE; Py_RETURN_NONE;
@ -113,7 +113,7 @@ auto PyLockAllInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyUnlockAllInput(PyObject* self, PyObject* args) -> PyObject* { auto PyUnlockAllInput(PyObject* self, PyObject* args) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
assert(g_input); assert(g_input);
g_input->UnlockAllInput(false, Python::GetPythonFileLocation()); g_input->UnlockAllInput(false, Python::GetPythonFileLocation());
Py_RETURN_NONE; Py_RETURN_NONE;
@ -123,7 +123,7 @@ auto PyUnlockAllInput(PyObject* self, PyObject* args) -> PyObject* {
auto PyGetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds) auto PyGetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
static const char* kwlist[] = {nullptr}; static const char* kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "", if (!PyArg_ParseTupleAndKeywords(args, keywds, "",
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {
@ -141,7 +141,7 @@ auto PyGetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds)
auto PySetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds) auto PySetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
static const char* kwlist[] = {"input", nullptr}; static const char* kwlist[] = {"input", nullptr};
PyObject* input_device_obj = Py_None; PyObject* input_device_obj = Py_None;
if (!PyArg_ParseTupleAndKeywords( if (!PyArg_ParseTupleAndKeywords(
@ -159,7 +159,7 @@ auto PySetUIInputDevice(PyObject* self, PyObject* args, PyObject* keywds)
auto PyGetInputDevice(PyObject* self, PyObject* args, PyObject* keywds) auto PyGetInputDevice(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
const char* name; const char* name;
const char* unique_id; const char* unique_id;
int doraise = true; int doraise = true;

View File

@ -336,7 +336,7 @@ auto PySetMasterServerSource(PyObject* self, PyObject* args) -> PyObject* {
auto PySetTelnetAccessEnabled(PyObject* self, PyObject* args, PyObject* keywds) auto PySetTelnetAccessEnabled(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
assert(InGameThread()); assert(InLogicThread());
int enable; int enable;
static const char* kwlist[] = {"enable", nullptr}; static const char* kwlist[] = {"enable", nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "p", if (!PyArg_ParseTupleAndKeywords(args, keywds, "p",

View File

@ -97,7 +97,7 @@ auto PyIsRunningOnFireTV(PyObject* self, PyObject* args) -> PyObject* {
auto PyHavePermission(PyObject* self, PyObject* args, PyObject* keywds) auto PyHavePermission(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
Permission permission; Permission permission;
PyObject* permission_obj; PyObject* permission_obj;
static const char* kwlist[] = {"permission", nullptr}; static const char* kwlist[] = {"permission", nullptr};
@ -118,7 +118,7 @@ auto PyHavePermission(PyObject* self, PyObject* args, PyObject* keywds)
auto PyRequestPermission(PyObject* self, PyObject* args, PyObject* keywds) auto PyRequestPermission(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
Permission permission; Permission permission;
PyObject* permission_obj; PyObject* permission_obj;
static const char* kwlist[] = {"permission", nullptr}; static const char* kwlist[] = {"permission", nullptr};
@ -134,7 +134,7 @@ auto PyRequestPermission(PyObject* self, PyObject* args, PyObject* keywds)
BA_PYTHON_CATCH; BA_PYTHON_CATCH;
} }
auto PyInGameThread(PyObject* self, PyObject* args, PyObject* keywds) auto PyInLogicThread(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
static const char* kwlist[] = {nullptr}; static const char* kwlist[] = {nullptr};
@ -142,7 +142,7 @@ auto PyInGameThread(PyObject* self, PyObject* args, PyObject* keywds)
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {
return nullptr; return nullptr;
} }
if (InGameThread()) { if (InLogicThread()) {
Py_RETURN_TRUE; Py_RETURN_TRUE;
} }
Py_RETURN_FALSE; Py_RETURN_FALSE;
@ -1052,9 +1052,9 @@ auto PythonMethodsSystem::GetMethods() -> std::vector<PyMethodDef> {
"available). Thread names are only for debugging and should not be\n" "available). Thread names are only for debugging and should not be\n"
"used in logic, as naming behavior can vary across platforms.\n"}, "used in logic, as naming behavior can vary across platforms.\n"},
{"in_game_thread", (PyCFunction)PyInGameThread, {"in_logic_thread", (PyCFunction)PyInLogicThread,
METH_VARARGS | METH_KEYWORDS, METH_VARARGS | METH_KEYWORDS,
"in_game_thread() -> bool\n" "in_logic_thread() -> bool\n"
"\n" "\n"
"(internal)\n" "(internal)\n"
"\n" "\n"

View File

@ -1841,7 +1841,7 @@ auto PyFocusWindow(PyObject* self, PyObject* args, PyObject* keywds)
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {
return nullptr; return nullptr;
} }
assert(InGameThread()); assert(InLogicThread());
#if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD \ #if BA_OSTYPE_MACOS && BA_XCODE_BUILD && !BA_HEADLESS_BUILD \
&& !BA_XCODE_NEW_PROJECT && !BA_XCODE_NEW_PROJECT
SDL_ericf_focus(); SDL_ericf_focus();
@ -1898,7 +1898,7 @@ auto PyFadeScreen(PyObject* self, PyObject* args, PyObject* keywds)
auto PyShowAd(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { auto PyShowAd(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
const char* purpose; const char* purpose;
PyObject* on_completion_call_obj = Py_None; PyObject* on_completion_call_obj = Py_None;
int pass_actually_showed = false; int pass_actually_showed = false;
@ -1928,7 +1928,7 @@ auto PyShowAd(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
auto PyShowAd2(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* { auto PyShowAd2(PyObject* self, PyObject* args, PyObject* keywds) -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
const char* purpose; const char* purpose;
PyObject* on_completion_call_obj = Py_None; PyObject* on_completion_call_obj = Py_None;
int pass_actually_showed = true; int pass_actually_showed = true;
@ -2040,7 +2040,7 @@ auto PyGetChatMessages(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
static const char* kwlist[] = {nullptr}; static const char* kwlist[] = {nullptr};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "", if (!PyArg_ParseTupleAndKeywords(args, keywds, "",
const_cast<char**>(kwlist))) { const_cast<char**>(kwlist))) {
@ -2114,7 +2114,7 @@ auto PyCanShowAd(PyObject* self, PyObject* args, PyObject* keywds)
-> PyObject* { -> PyObject* {
BA_PYTHON_TRY; BA_PYTHON_TRY;
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
// if we've got any network connections, no ads.. // if we've got any network connections, no ads..
// (don't want to make someone on the other end wait or risk disconnecting // (don't want to make someone on the other end wait or risk disconnecting
// them or whatnot) also disallow ads if remote apps are connected; at least // them or whatnot) also disallow ads if remote apps are connected; at least

View File

@ -852,7 +852,7 @@ auto Python::GetPyVector3f(PyObject* o) -> Vector3f {
Python::Python() = default; Python::Python() = default;
void Python::Reset(bool do_init) { void Python::Reset(bool do_init) {
assert(InGameThread()); assert(InLogicThread());
assert(g_python); assert(g_python);
bool was_inited = inited_; bool was_inited = inited_;
@ -1149,7 +1149,7 @@ auto Python::GetTranslation(const char* category, const char* s)
} }
void Python::RunDeepLink(const std::string& url) { void Python::RunDeepLink(const std::string& url) {
assert(InGameThread()); assert(InLogicThread());
if (objexists(ObjID::kDeepLinkCall)) { if (objexists(ObjID::kDeepLinkCall)) {
ScopedSetContext cp(g_game->GetUIContext()); ScopedSetContext cp(g_game->GetUIContext());
PythonRef args(Py_BuildValue("(s)", url.c_str()), PythonRef::kSteal); PythonRef args(Py_BuildValue("(s)", url.c_str()), PythonRef::kSteal);
@ -1160,7 +1160,7 @@ void Python::RunDeepLink(const std::string& url) {
} }
void Python::PlayMusic(const std::string& music_type, bool continuous) { void Python::PlayMusic(const std::string& music_type, bool continuous) {
assert(InGameThread()); assert(InLogicThread());
if (music_type.empty()) { if (music_type.empty()) {
PythonRef args( PythonRef args(
Py_BuildValue("(OO)", Py_None, continuous ? Py_True : Py_False), Py_BuildValue("(OO)", Py_None, continuous ? Py_True : Py_False),
@ -1992,7 +1992,7 @@ auto Python::GetNodeAttr(Node* node, const char* attr_name) -> PyObject* {
return nullptr; return nullptr;
} }
void Python::IssueCallInGameThreadWarning(PyObject* call_obj) { void Python::IssueCallInLogicThreadWarning(PyObject* call_obj) {
Log("WARNING: ba.pushcall() called from the game thread with " Log("WARNING: ba.pushcall() called from the game thread with "
"from_other_thread set to true (call " "from_other_thread set to true (call "
+ ObjToString(call_obj) + " at " + GetPythonFileLocation() + ObjToString(call_obj) + " at " + GetPythonFileLocation()
@ -2000,7 +2000,7 @@ void Python::IssueCallInGameThreadWarning(PyObject* call_obj) {
} }
void Python::LaunchStringEdit(TextWidget* w) { void Python::LaunchStringEdit(TextWidget* w) {
assert(InGameThread()); assert(InLogicThread());
BA_PRECONDITION(w); BA_PRECONDITION(w);
ScopedSetContext cp(g_game->GetUIContext()); ScopedSetContext cp(g_game->GetUIContext());
@ -2016,7 +2016,7 @@ void Python::LaunchStringEdit(TextWidget* w) {
} }
void Python::CaptureGamePadInput(PyObject* obj) { void Python::CaptureGamePadInput(PyObject* obj) {
assert(InGameThread()); assert(InLogicThread());
ReleaseGamePadInput(); ReleaseGamePadInput();
if (PyCallable_Check(obj)) { if (PyCallable_Check(obj)) {
game_pad_call_.Acquire(obj); game_pad_call_.Acquire(obj);
@ -2028,7 +2028,7 @@ void Python::CaptureGamePadInput(PyObject* obj) {
void Python::ReleaseGamePadInput() { game_pad_call_.Release(); } void Python::ReleaseGamePadInput() { game_pad_call_.Release(); }
void Python::CaptureKeyboardInput(PyObject* obj) { void Python::CaptureKeyboardInput(PyObject* obj) {
assert(InGameThread()); assert(InLogicThread());
ReleaseKeyboardInput(); ReleaseKeyboardInput();
if (PyCallable_Check(obj)) { if (PyCallable_Check(obj)) {
keyboard_call_.Acquire(obj); keyboard_call_.Acquire(obj);
@ -2073,7 +2073,7 @@ void Python::HandleFriendScoresCB(const FriendScoreSet& score_set) {
} }
auto Python::HandleKeyPressEvent(const SDL_Keysym& keysym) -> bool { auto Python::HandleKeyPressEvent(const SDL_Keysym& keysym) -> bool {
assert(InGameThread()); assert(InLogicThread());
if (!keyboard_call_.exists()) { if (!keyboard_call_.exists()) {
return false; return false;
} }
@ -2088,7 +2088,7 @@ auto Python::HandleKeyPressEvent(const SDL_Keysym& keysym) -> bool {
return true; return true;
} }
auto Python::HandleKeyReleaseEvent(const SDL_Keysym& keysym) -> bool { auto Python::HandleKeyReleaseEvent(const SDL_Keysym& keysym) -> bool {
assert(InGameThread()); assert(InLogicThread());
if (!keyboard_call_.exists()) { if (!keyboard_call_.exists()) {
return false; return false;
} }
@ -2104,7 +2104,7 @@ auto Python::HandleKeyReleaseEvent(const SDL_Keysym& keysym) -> bool {
auto Python::HandleJoystickEvent(const SDL_Event& event, auto Python::HandleJoystickEvent(const SDL_Event& event,
InputDevice* input_device) -> bool { InputDevice* input_device) -> bool {
assert(InGameThread()); assert(InLogicThread());
assert(input_device != nullptr); assert(input_device != nullptr);
if (!game_pad_call_.exists()) { if (!game_pad_call_.exists()) {
return false; return false;
@ -2208,21 +2208,21 @@ auto Python::GetContextBaseString() -> std::string {
} }
void Python::LogContextForCallableLabel(const char* label) { void Python::LogContextForCallableLabel(const char* label) {
assert(InGameThread()); assert(InLogicThread());
assert(label); assert(label);
std::string s = std::string(" root call: ") + label; std::string s = std::string(" root call: ") + label;
s += g_python->GetContextBaseString(); s += g_python->GetContextBaseString();
Log(s); Log(s);
} }
void Python::LogContextNonGameThread() { void Python::LogContextNonLogicThread() {
std::string s = std::string s =
std::string(" root call: <not in game thread; context unavailable>"); std::string(" root call: <not in game thread; context unavailable>");
Log(s); Log(s);
} }
void Python::LogContextEmpty() { void Python::LogContextEmpty() {
assert(InGameThread()); assert(InLogicThread());
std::string s = std::string(" root call: <unavailable>"); std::string s = std::string(" root call: <unavailable>");
s += g_python->GetContextBaseString(); s += g_python->GetContextBaseString();
Log(s); Log(s);
@ -2232,8 +2232,8 @@ void Python::LogContextAuto() {
// Lets print whatever context info is available. // Lets print whatever context info is available.
// FIXME: If we have recursive calls this may not print // FIXME: If we have recursive calls this may not print
// the context we'd expect; we'd need a unified stack. // the context we'd expect; we'd need a unified stack.
if (!InGameThread()) { if (!InLogicThread()) {
LogContextNonGameThread(); LogContextNonLogicThread();
} else if (const char* label = ScopedCallLabel::current_label()) { } else if (const char* label = ScopedCallLabel::current_label()) {
LogContextForCallableLabel(label); LogContextForCallableLabel(label);
} else if (PythonCommand* cmd = PythonCommand::current_command()) { } else if (PythonCommand* cmd = PythonCommand::current_command()) {
@ -2402,7 +2402,7 @@ void Python::StoreObjCallable(ObjID id, const char* expr, PyObject* context) {
} }
void Python::SetRawConfigValue(const char* name, float value) { void Python::SetRawConfigValue(const char* name, float value) {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PythonRef value_obj(PyFloat_FromDouble(value), PythonRef::kSteal); PythonRef value_obj(PyFloat_FromDouble(value), PythonRef::kSteal);
int result = int result =
@ -2416,14 +2416,14 @@ void Python::SetRawConfigValue(const char* name, float value) {
} }
auto Python::GetRawConfigValue(const char* name) -> PyObject* { auto Python::GetRawConfigValue(const char* name) -> PyObject* {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
return PyDict_GetItemString(obj(ObjID::kConfig).get(), name); return PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
} }
auto Python::GetRawConfigValue(const char* name, const char* default_value) auto Python::GetRawConfigValue(const char* name, const char* default_value)
-> std::string { -> std::string {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name); PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
if (value == nullptr || !PyUnicode_Check(value)) { if (value == nullptr || !PyUnicode_Check(value)) {
@ -2433,7 +2433,7 @@ auto Python::GetRawConfigValue(const char* name, const char* default_value)
} }
auto Python::GetRawConfigValue(const char* name, float default_value) -> float { auto Python::GetRawConfigValue(const char* name, float default_value) -> float {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name); PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
if (value == nullptr) { if (value == nullptr) {
@ -2450,7 +2450,7 @@ auto Python::GetRawConfigValue(const char* name, float default_value) -> float {
auto Python::GetRawConfigValue(const char* name, auto Python::GetRawConfigValue(const char* name,
std::optional<float> default_value) std::optional<float> default_value)
-> std::optional<float> { -> std::optional<float> {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name); PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
if (value == nullptr) { if (value == nullptr) {
@ -2468,7 +2468,7 @@ auto Python::GetRawConfigValue(const char* name,
} }
auto Python::GetRawConfigValue(const char* name, int default_value) -> int { auto Python::GetRawConfigValue(const char* name, int default_value) -> int {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name); PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
if (value == nullptr) { if (value == nullptr) {
@ -2483,7 +2483,7 @@ auto Python::GetRawConfigValue(const char* name, int default_value) -> int {
} }
auto Python::GetRawConfigValue(const char* name, bool default_value) -> bool { auto Python::GetRawConfigValue(const char* name, bool default_value) -> bool {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kConfig)); assert(objexists(ObjID::kConfig));
PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name); PyObject* value = PyDict_GetItemString(obj(ObjID::kConfig).get(), name);
if (value == nullptr) { if (value == nullptr) {
@ -2549,7 +2549,7 @@ void Python::TimeFormatCheck(TimeFormat time_format, PyObject* length_obj) {
auto Python::ValidatedPackageAssetName(PyObject* package, const char* name) auto Python::ValidatedPackageAssetName(PyObject* package, const char* name)
-> std::string { -> std::string {
assert(InGameThread()); assert(InLogicThread());
assert(objexists(ObjID::kAssetPackageClass)); assert(objexists(ObjID::kAssetPackageClass));
if (!PyObject_IsInstance(package, obj(ObjID::kAssetPackageClass).get())) { if (!PyObject_IsInstance(package, obj(ObjID::kAssetPackageClass).get())) {

View File

@ -78,7 +78,7 @@ class Python {
static void LogContextForCallableLabel(const char* label); static void LogContextForCallableLabel(const char* label);
static void LogContextEmpty(); static void LogContextEmpty();
static void LogContextAuto(); static void LogContextAuto();
static void LogContextNonGameThread(); static void LogContextNonLogicThread();
Python(); Python();
~Python(); ~Python();
@ -105,7 +105,7 @@ class Python {
void CaptureKeyboardInput(PyObject* obj); void CaptureKeyboardInput(PyObject* obj);
void ReleaseKeyboardInput(); void ReleaseKeyboardInput();
void HandleFriendScoresCB(const FriendScoreSet& ss); void HandleFriendScoresCB(const FriendScoreSet& ss);
void IssueCallInGameThreadWarning(PyObject* call); void IssueCallInLogicThreadWarning(PyObject* call);
/// Borrowed from python's source code: used in overriding of objects' dir() /// Borrowed from python's source code: used in overriding of objects' dir()
/// results. /// results.

View File

@ -13,7 +13,7 @@ namespace ballistica {
PythonContextCall* PythonContextCall::current_call_ = nullptr; PythonContextCall* PythonContextCall::current_call_ = nullptr;
PythonContextCall::PythonContextCall(PyObject* obj_in) { PythonContextCall::PythonContextCall(PyObject* obj_in) {
assert(InGameThread()); assert(InLogicThread());
// as a sanity test, store the current context ptr just to make sure it // as a sanity test, store the current context ptr just to make sure it
// hasn't changed when we run // hasn't changed when we run
#if BA_DEBUG_BUILD #if BA_DEBUG_BUILD
@ -125,7 +125,7 @@ void PythonContextCall::Run(PyObject* args) {
} }
void PythonContextCall::LogContext() { void PythonContextCall::LogContext() {
assert(InGameThread()); assert(InLogicThread());
std::string s = std::string(" root call: ") + object().Str(); std::string s = std::string(" root call: ") + object().Str();
s += ("\n root call origin: " + file_loc()); s += ("\n root call origin: " + file_loc());
s += g_python->GetContextBaseString(); s += g_python->GetContextBaseString();

View File

@ -222,7 +222,7 @@ void Node::SetDelegate(PyObject* delegate_obj) {
} }
auto Node::GetPyRef(bool new_ref) -> PyObject* { auto Node::GetPyRef(bool new_ref) -> PyObject* {
assert(InGameThread()); assert(InLogicThread());
if (py_ref_ == nullptr) { if (py_ref_ == nullptr) {
py_ref_ = PythonClassNode::Create(this); py_ref_ = PythonClassNode::Create(this);
} }
@ -353,7 +353,7 @@ void Node::DispatchImpactDamageMessage(float intensity) {
} }
void Node::DispatchUserMessage(PyObject* obj, const char* label) { void Node::DispatchUserMessage(PyObject* obj, const char* label) {
assert(InGameThread()); assert(InLogicThread());
if (scene_->shutting_down()) { if (scene_->shutting_down()) {
return; return;
} }

View File

@ -43,7 +43,7 @@ TimeDisplayNode::TimeDisplayNode(Scene* scene) : Node(scene, node_type) {}
TimeDisplayNode::~TimeDisplayNode() = default; TimeDisplayNode::~TimeDisplayNode() = default;
auto TimeDisplayNode::GetOutput() -> std::string { auto TimeDisplayNode::GetOutput() -> std::string {
assert(InGameThread()); assert(InLogicThread());
if (translations_dirty_) { if (translations_dirty_) {
time_suffix_hours_ = time_suffix_hours_ =
g_game->CompileResourceString(R"({"r":"timeSuffixHoursText"})", "tda"); g_game->CompileResourceString(R"({"r":"timeSuffixHoursText"})", "tda");

View File

@ -314,21 +314,21 @@ void Scene::DeleteNode(Node* node) {
} }
void Scene::GraphicsQualityChanged(GraphicsQuality q) { void Scene::GraphicsQualityChanged(GraphicsQuality q) {
assert(InGameThread()); assert(InLogicThread());
for (auto&& i : nodes_) { for (auto&& i : nodes_) {
i->OnGraphicsQualityChanged(q); i->OnGraphicsQualityChanged(q);
} }
} }
void Scene::ScreenSizeChanged() { void Scene::ScreenSizeChanged() {
assert(InGameThread()); assert(InLogicThread());
for (auto&& i : nodes_) { for (auto&& i : nodes_) {
i->OnScreenSizeChange(); // New. i->OnScreenSizeChange(); // New.
} }
} }
void Scene::LanguageChanged() { void Scene::LanguageChanged() {
assert(InGameThread()); assert(InLogicThread());
for (auto&& i : nodes_) { for (auto&& i : nodes_) {
i->OnLanguageChange(); // New. i->OnLanguageChange(); // New.
} }
@ -344,7 +344,7 @@ auto Scene::GetNodeMessageFormat(NodeMessageType type) -> const char* {
auto Scene::NewNode(const std::string& type_string, const std::string& name, auto Scene::NewNode(const std::string& type_string, const std::string& name,
PyObject* delegate) -> Node* { PyObject* delegate) -> Node* {
assert(InGameThread()); assert(InLogicThread());
// Clion incorrectly things in_step_ will always be false. // Clion incorrectly things in_step_ will always be false.
#pragma clang diagnostic push #pragma clang diagnostic push
@ -373,7 +373,7 @@ auto Scene::NewNode(const std::string& type_string, const std::string& name,
} }
void Scene::Dump(GameStream* stream) { void Scene::Dump(GameStream* stream) {
assert(InGameThread()); assert(InLogicThread());
stream->AddScene(this); stream->AddScene(this);
// If we're the foreground one, communicate that fact as well. // If we're the foreground one, communicate that fact as well.

View File

@ -21,7 +21,7 @@ const int kActivateKey1 = SDLK_BACKQUOTE;
const int kActivateKey2 = SDLK_F2; const int kActivateKey2 = SDLK_F2;
Console::Console() { Console::Console() {
assert(InGameThread()); assert(InLogicThread());
std::string title = std::string("BallisticaCore ") + kAppVersion + " (" std::string title = std::string("BallisticaCore ") + kAppVersion + " ("
+ std::to_string(kAppBuildNumber) + ")"; + std::to_string(kAppBuildNumber) + ")";
if (g_buildconfig.debug_build()) { if (g_buildconfig.debug_build()) {
@ -45,7 +45,7 @@ Console::Console() {
Console::~Console() = default; Console::~Console() = default;
auto Console::HandleKeyPress(const SDL_Keysym* keysym) -> bool { auto Console::HandleKeyPress(const SDL_Keysym* keysym) -> bool {
assert(InGameThread()); assert(InLogicThread());
// Handle our toggle buttons no matter whether we're active. // Handle our toggle buttons no matter whether we're active.
switch (keysym->sym) { switch (keysym->sym) {
@ -158,7 +158,7 @@ void Console::ToggleState() {
} }
auto Console::HandleTextEditing(const std::string& text) -> bool { auto Console::HandleTextEditing(const std::string& text) -> bool {
assert(InGameThread()); assert(InLogicThread());
if (state_ == State::kInactive) { if (state_ == State::kInactive) {
return false; return false;
} }
@ -186,7 +186,7 @@ auto Console::HandleKeyRelease(const SDL_Keysym* keysym) -> bool {
#pragma ide diagnostic ignored "LocalValueEscapesScope" #pragma ide diagnostic ignored "LocalValueEscapesScope"
void Console::Print(const std::string& s_in) { void Console::Print(const std::string& s_in) {
assert(InGameThread()); assert(InLogicThread());
std::string s = Utils::GetValidUTF8(s_in.c_str(), "cspr"); std::string s = Utils::GetValidUTF8(s_in.c_str(), "cspr");
last_line_ += s; last_line_ += s;
std::vector<std::string> broken_up; std::vector<std::string> broken_up;

View File

@ -42,7 +42,7 @@ RootUI::RootUI() {
RootUI::~RootUI() = default; RootUI::~RootUI() = default;
void RootUI::TogglePartyWindowKeyPress() { void RootUI::TogglePartyWindowKeyPress() {
assert(InGameThread()); assert(InLogicThread());
if (g_game->GetPartySize() > 1 || g_game->connections()->connection_to_host() if (g_game->GetPartySize() > 1 || g_game->connections()->connection_to_host()
|| always_draw_party_icon()) { || always_draw_party_icon()) {
ActivatePartyIcon(); ActivatePartyIcon();
@ -50,7 +50,7 @@ void RootUI::TogglePartyWindowKeyPress() {
} }
void RootUI::ActivatePartyIcon() const { void RootUI::ActivatePartyIcon() const {
assert(InGameThread()); assert(InLogicThread());
ScopedSetContext cp(g_game->GetUIContext()); ScopedSetContext cp(g_game->GetUIContext());
// Originate from center of party icon. If menu button is shown, it is to the // Originate from center of party icon. If menu button is shown, it is to the

View File

@ -89,7 +89,7 @@ auto UI::IsWindowPresent() const -> bool {
} }
void UI::SetUIInputDevice(InputDevice* input_device) { void UI::SetUIInputDevice(InputDevice* input_device) {
assert(InGameThread()); assert(InLogicThread());
ui_input_device_ = input_device; ui_input_device_ = input_device;
@ -99,7 +99,7 @@ void UI::SetUIInputDevice(InputDevice* input_device) {
UI::UILock::UILock(bool write) { UI::UILock::UILock(bool write) {
assert(g_ui); assert(g_ui);
assert(InGameThread()); assert(InLogicThread());
if (write && g_ui->ui_lock_count_ != 0) { if (write && g_ui->ui_lock_count_ != 0) {
BA_LOG_ERROR_TRACE_ONCE("Illegal operation: UI is locked"); BA_LOG_ERROR_TRACE_ONCE("Illegal operation: UI is locked");
@ -122,7 +122,7 @@ void UI::StepScene() {
} }
void UI::Update(millisecs_t time_advance) { void UI::Update(millisecs_t time_advance) {
assert(InGameThread()); assert(InLogicThread());
millisecs_t target_base_time = base_time_ + time_advance; millisecs_t target_base_time = base_time_ + time_advance;
while (!base_timers_.empty() while (!base_timers_.empty()
@ -209,7 +209,7 @@ auto UI::ShouldShowButtonShortcuts() const -> bool {
} }
void UI::AddWidget(Widget* w, ContainerWidget* parent) { void UI::AddWidget(Widget* w, ContainerWidget* parent) {
assert(InGameThread()); assert(InLogicThread());
BA_PRECONDITION(parent != nullptr); BA_PRECONDITION(parent != nullptr);
@ -249,13 +249,13 @@ void UI::ScreenSizeChanged() {
} }
auto UI::GetUIInputDevice() const -> InputDevice* { auto UI::GetUIInputDevice() const -> InputDevice* {
assert(InGameThread()); assert(InLogicThread());
return ui_input_device_.get(); return ui_input_device_.get();
} }
auto UI::GetWidgetForInput(InputDevice* input_device) -> Widget* { auto UI::GetWidgetForInput(InputDevice* input_device) -> Widget* {
assert(input_device); assert(input_device);
assert(InGameThread()); assert(InLogicThread());
// We only allow input-devices to control the UI when there's a window/dialog // We only allow input-devices to control the UI when there's a window/dialog
// on the screen (even though our top/bottom bars still exist). // on the screen (even though our top/bottom bars still exist).

View File

@ -1055,7 +1055,7 @@ void ContainerWidget::Activate() {
} }
void ContainerWidget::AddWidget(Widget* w) { void ContainerWidget::AddWidget(Widget* w) {
BA_PRECONDITION(InGameThread()); BA_PRECONDITION(InLogicThread());
Object::WeakRef<ContainerWidget> weakthis(this); Object::WeakRef<ContainerWidget> weakthis(this);
{ {
BA_DEBUG_UI_WRITE_LOCK; BA_DEBUG_UI_WRITE_LOCK;

Some files were not shown because too many files have changed in this diff Show More