mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-03 22:14:45 +08:00
yup still cleaning
This commit is contained in:
parent
ba287dc5ac
commit
8e127a7c48
@ -11,8 +11,8 @@ import _babase
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import babase
|
import babase
|
||||||
import baclassic
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,11 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import weakref
|
import weakref
|
||||||
|
import logging
|
||||||
from typing import TYPE_CHECKING, TypeVar, overload
|
from typing import TYPE_CHECKING, TypeVar, overload
|
||||||
|
|
||||||
|
import babase
|
||||||
|
|
||||||
from babase._error import print_exception, ActivityNotFoundError
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from bascenev1._messages import (
|
from bascenev1._messages import (
|
||||||
DieMessage,
|
DieMessage,
|
||||||
@ -20,7 +21,6 @@ from bascenev1._messages import (
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
ActorT = TypeVar('ActorT', bound='Actor')
|
ActorT = TypeVar('ActorT', bound='Actor')
|
||||||
@ -93,7 +93,9 @@ class Actor:
|
|||||||
if not self.expired:
|
if not self.expired:
|
||||||
self.handlemessage(DieMessage())
|
self.handlemessage(DieMessage())
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception('exception in bascenev1.Actor.__del__() for', self)
|
logging.exception(
|
||||||
|
'Error in bascenev1.Actor.__del__() for %s.', self
|
||||||
|
)
|
||||||
|
|
||||||
def handlemessage(self, msg: Any) -> Any:
|
def handlemessage(self, msg: Any) -> Any:
|
||||||
"""General message handling; can be passed any message object."""
|
"""General message handling; can be passed any message object."""
|
||||||
@ -120,7 +122,7 @@ class Actor:
|
|||||||
"""
|
"""
|
||||||
activity = self._activity()
|
activity = self._activity()
|
||||||
if activity is None:
|
if activity is None:
|
||||||
raise ActivityNotFoundError()
|
raise babase.ActivityNotFoundError()
|
||||||
activity.retain_actor(self)
|
activity.retain_actor(self)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -190,7 +192,7 @@ class Actor:
|
|||||||
"""
|
"""
|
||||||
activity = self._activity()
|
activity = self._activity()
|
||||||
if activity is None:
|
if activity is None:
|
||||||
raise ActivityNotFoundError()
|
raise babase.ActivityNotFoundError()
|
||||||
return activity
|
return activity
|
||||||
|
|
||||||
# Overloads to convey our exact return type depending on 'doraise' value.
|
# Overloads to convey our exact return type depending on 'doraise' value.
|
||||||
@ -212,5 +214,5 @@ class Actor:
|
|||||||
"""
|
"""
|
||||||
activity = self._activity()
|
activity = self._activity()
|
||||||
if activity is None and doraise:
|
if activity is None and doraise:
|
||||||
raise ActivityNotFoundError()
|
raise babase.ActivityNotFoundError()
|
||||||
return activity
|
return activity
|
||||||
|
|||||||
@ -6,15 +6,16 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, TypeVar
|
from typing import TYPE_CHECKING, TypeVar
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from babase._general import WeakCall
|
|
||||||
from bascenev1._gameactivity import GameActivity
|
from bascenev1._gameactivity import GameActivity
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
||||||
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
PlayerT = TypeVar('PlayerT', bound='bascenev1.Player')
|
PlayerT = TypeVar('PlayerT', bound='bascenev1.Player')
|
||||||
@ -52,11 +53,13 @@ class CoopGameActivity(GameActivity[PlayerT, TeamT]):
|
|||||||
super().on_begin()
|
super().on_begin()
|
||||||
|
|
||||||
# Show achievements remaining.
|
# Show achievements remaining.
|
||||||
if not (_babase.app.demo_mode or _babase.app.arcade_mode):
|
if not (babase.app.demo_mode or babase.app.arcade_mode):
|
||||||
_bascenev1.timer(3.8, WeakCall(self._show_remaining_achievements))
|
_bascenev1.timer(
|
||||||
|
3.8, babase.WeakCall(self._show_remaining_achievements)
|
||||||
|
)
|
||||||
|
|
||||||
# Preload achievement images in case we get some.
|
# Preload achievement images in case we get some.
|
||||||
_bascenev1.timer(2.0, WeakCall(self._preload_achievements))
|
_bascenev1.timer(2.0, babase.WeakCall(self._preload_achievements))
|
||||||
|
|
||||||
# FIXME: this is now redundant with activityutils.getscoreconfig();
|
# FIXME: this is now redundant with activityutils.getscoreconfig();
|
||||||
# need to kill this.
|
# need to kill this.
|
||||||
@ -84,8 +87,8 @@ class CoopGameActivity(GameActivity[PlayerT, TeamT]):
|
|||||||
player.actor.handlemessage(CelebrateMessage(duration))
|
player.actor.handlemessage(CelebrateMessage(duration))
|
||||||
|
|
||||||
def _preload_achievements(self) -> None:
|
def _preload_achievements(self) -> None:
|
||||||
assert _babase.app.classic is not None
|
assert babase.app.classic is not None
|
||||||
achievements = _babase.app.classic.ach.achievements_for_coop_level(
|
achievements = babase.app.classic.ach.achievements_for_coop_level(
|
||||||
self._get_coop_level_name()
|
self._get_coop_level_name()
|
||||||
)
|
)
|
||||||
for ach in achievements:
|
for ach in achievements:
|
||||||
@ -96,17 +99,17 @@ class CoopGameActivity(GameActivity[PlayerT, TeamT]):
|
|||||||
from babase._language import Lstr
|
from babase._language import Lstr
|
||||||
from bascenev1lib.actor.text import Text
|
from bascenev1lib.actor.text import Text
|
||||||
|
|
||||||
assert _babase.app.classic is not None
|
assert babase.app.classic is not None
|
||||||
ts_h_offs = 30
|
ts_h_offs = 30
|
||||||
v_offs = -200
|
v_offs = -200
|
||||||
achievements = [
|
achievements = [
|
||||||
a
|
a
|
||||||
for a in _babase.app.classic.ach.achievements_for_coop_level(
|
for a in babase.app.classic.ach.achievements_for_coop_level(
|
||||||
self._get_coop_level_name()
|
self._get_coop_level_name()
|
||||||
)
|
)
|
||||||
if not a.complete
|
if not a.complete
|
||||||
]
|
]
|
||||||
vrmode = _babase.app.vr_mode
|
vrmode = babase.app.vr_mode
|
||||||
if achievements:
|
if achievements:
|
||||||
Text(
|
Text(
|
||||||
Lstr(resource='achievementsRemainingText'),
|
Lstr(resource='achievementsRemainingText'),
|
||||||
@ -158,8 +161,8 @@ class CoopGameActivity(GameActivity[PlayerT, TeamT]):
|
|||||||
False otherwise
|
False otherwise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
classic = _babase.app.classic
|
classic = babase.app.classic
|
||||||
plus = _babase.app.plus
|
plus = babase.app.plus
|
||||||
if classic is None or plus is None:
|
if classic is None or plus is None:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
'_award_achievement is a no-op without classic and plus.'
|
'_award_achievement is a no-op without classic and plus.'
|
||||||
@ -222,7 +225,7 @@ class CoopGameActivity(GameActivity[PlayerT, TeamT]):
|
|||||||
"""Set up a beeping noise to play when any players are near death."""
|
"""Set up a beeping noise to play when any players are near death."""
|
||||||
self._life_warning_beep = None
|
self._life_warning_beep = None
|
||||||
self._life_warning_beep_timer = _bascenev1.Timer(
|
self._life_warning_beep_timer = _bascenev1.Timer(
|
||||||
1.0, WeakCall(self._update_life_warning), repeat=True
|
1.0, babase.WeakCall(self._update_life_warning), repeat=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def _update_life_warning(self) -> None:
|
def _update_life_warning(self) -> None:
|
||||||
|
|||||||
@ -5,13 +5,14 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from bascenev1._session import Session
|
from bascenev1._session import Session
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any, Callable, Sequence
|
from typing import Any, Callable, Sequence
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
TEAM_COLORS = [(0.2, 0.4, 1.6)]
|
TEAM_COLORS = [(0.2, 0.4, 1.6)]
|
||||||
@ -44,8 +45,8 @@ class CoopSession(Session):
|
|||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
from bascenev1lib.activity.coopjoin import CoopJoinActivity
|
from bascenev1lib.activity.coopjoin import CoopJoinActivity
|
||||||
|
|
||||||
_babase.increment_analytics_count('Co-op session start')
|
babase.increment_analytics_count('Co-op session start')
|
||||||
app = _babase.app
|
app = babase.app
|
||||||
classic = app.classic
|
classic = app.classic
|
||||||
assert classic is not None
|
assert classic is not None
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ class CoopSession(Session):
|
|||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
from bascenev1._gameactivity import GameActivity
|
from bascenev1._gameactivity import GameActivity
|
||||||
|
|
||||||
classic = _babase.app.classic
|
classic = babase.app.classic
|
||||||
assert classic is not None
|
assert classic is not None
|
||||||
|
|
||||||
# Instantiate levels we may be running soon to let them load in the bg.
|
# Instantiate levels we may be running soon to let them load in the bg.
|
||||||
@ -212,7 +213,7 @@ class CoopSession(Session):
|
|||||||
# Hmm; no players anywhere. Let's end the entire session if we're
|
# Hmm; no players anywhere. Let's end the entire session if we're
|
||||||
# running a GUI (or just the current game if we're running headless).
|
# running a GUI (or just the current game if we're running headless).
|
||||||
else:
|
else:
|
||||||
if not _babase.app.headless_mode:
|
if not babase.app.headless_mode:
|
||||||
self.end()
|
self.end()
|
||||||
else:
|
else:
|
||||||
if isinstance(activity, GameActivity):
|
if isinstance(activity, GameActivity):
|
||||||
@ -225,12 +226,12 @@ class CoopSession(Session):
|
|||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
from bascenev1._gameactivity import GameActivity
|
from bascenev1._gameactivity import GameActivity
|
||||||
|
|
||||||
assert _babase.app.classic is not None
|
assert babase.app.classic is not None
|
||||||
activity = self.getactivity()
|
activity = self.getactivity()
|
||||||
if activity is not None and not activity.expired:
|
if activity is not None and not activity.expired:
|
||||||
assert self.tournament_id is not None
|
assert self.tournament_id is not None
|
||||||
assert isinstance(activity, GameActivity)
|
assert isinstance(activity, GameActivity)
|
||||||
_babase.app.classic.tournament_entry_window(
|
babase.app.classic.tournament_entry_window(
|
||||||
tournament_id=self.tournament_id,
|
tournament_id=self.tournament_id,
|
||||||
tournament_activity=activity,
|
tournament_activity=activity,
|
||||||
on_close_call=resume_callback,
|
on_close_call=resume_callback,
|
||||||
@ -278,7 +279,7 @@ class CoopSession(Session):
|
|||||||
from bascenev1lib.activity.coopscore import CoopScoreScreen
|
from bascenev1lib.activity.coopscore import CoopScoreScreen
|
||||||
from bascenev1lib.tutorial import TutorialActivity
|
from bascenev1lib.tutorial import TutorialActivity
|
||||||
|
|
||||||
app = _babase.app
|
app = babase.app
|
||||||
classic = app.classic
|
classic = app.classic
|
||||||
assert classic is not None
|
assert classic is not None
|
||||||
|
|
||||||
@ -293,7 +294,7 @@ class CoopSession(Session):
|
|||||||
# If we're running with a gui and at any point we have no
|
# If we're running with a gui and at any point we have no
|
||||||
# in-game players, quit out of the session (this can happen if
|
# in-game players, quit out of the session (this can happen if
|
||||||
# someone leaves in the tutorial for instance).
|
# someone leaves in the tutorial for instance).
|
||||||
if not _babase.app.headless_mode:
|
if not babase.app.headless_mode:
|
||||||
active_players = [p for p in self.sessionplayers if p.in_game]
|
active_players = [p for p in self.sessionplayers if p.in_game]
|
||||||
if not active_players:
|
if not active_players:
|
||||||
self.end()
|
self.end()
|
||||||
|
|||||||
@ -5,12 +5,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ def print_live_object_warnings(
|
|||||||
from bascenev1._actor import Actor
|
from bascenev1._actor import Actor
|
||||||
from bascenev1._activity import Activity
|
from bascenev1._activity import Activity
|
||||||
|
|
||||||
assert _babase.app.classic is not None
|
assert babase.app.classic is not None
|
||||||
|
|
||||||
sessions: list[bascenev1.Session] = []
|
sessions: list[bascenev1.Session] = []
|
||||||
activities: list[bascenev1.Activity] = []
|
activities: list[bascenev1.Activity] = []
|
||||||
@ -39,7 +38,7 @@ def print_live_object_warnings(
|
|||||||
|
|
||||||
# Once we come across leaked stuff, printing again is probably
|
# Once we come across leaked stuff, printing again is probably
|
||||||
# redundant.
|
# redundant.
|
||||||
if _babase.app.classic.printed_live_object_warning:
|
if babase.app.classic.printed_live_object_warning:
|
||||||
return
|
return
|
||||||
for obj in gc.get_objects():
|
for obj in gc.get_objects():
|
||||||
if isinstance(obj, Actor):
|
if isinstance(obj, Actor):
|
||||||
@ -53,17 +52,17 @@ def print_live_object_warnings(
|
|||||||
for session in sessions:
|
for session in sessions:
|
||||||
if session is ignore_session:
|
if session is ignore_session:
|
||||||
continue
|
continue
|
||||||
_babase.app.classic.printed_live_object_warning = True
|
babase.app.classic.printed_live_object_warning = True
|
||||||
print(f'ERROR: Session found {when}: {session}')
|
print(f'ERROR: Session found {when}: {session}')
|
||||||
|
|
||||||
# Complain about any remaining activities.
|
# Complain about any remaining activities.
|
||||||
for activity in activities:
|
for activity in activities:
|
||||||
if activity is ignore_activity:
|
if activity is ignore_activity:
|
||||||
continue
|
continue
|
||||||
_babase.app.classic.printed_live_object_warning = True
|
babase.app.classic.printed_live_object_warning = True
|
||||||
print(f'ERROR: Activity found {when}: {activity}')
|
print(f'ERROR: Activity found {when}: {activity}')
|
||||||
|
|
||||||
# Complain about any remaining actors.
|
# Complain about any remaining actors.
|
||||||
for actor in actors:
|
for actor in actors:
|
||||||
_babase.app.classic.printed_live_object_warning = True
|
babase.app.classic.printed_live_object_warning = True
|
||||||
print(f'ERROR: Actor found {when}: {actor}')
|
print(f'ERROR: Actor found {when}: {actor}')
|
||||||
|
|||||||
@ -5,12 +5,12 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from bascenev1._multiteamsession import MultiTeamSession
|
from bascenev1._multiteamsession import MultiTeamSession
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class DualTeamSession(MultiTeamSession):
|
|||||||
_playlists_var = 'Team Tournament Playlists'
|
_playlists_var = 'Team Tournament Playlists'
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
_babase.increment_analytics_count('Teams session start')
|
babase.increment_analytics_count('Teams session start')
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def _switch_to_score_screen(self, results: bascenev1.GameResults) -> None:
|
def _switch_to_score_screen(self, results: bascenev1.GameResults) -> None:
|
||||||
|
|||||||
@ -6,12 +6,12 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from bascenev1._multiteamsession import MultiTeamSession
|
from bascenev1._multiteamsession import MultiTeamSession
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class FreeForAllSession(MultiTeamSession):
|
|||||||
return point_awards
|
return point_awards
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
_babase.increment_analytics_count('Free-for-all session start')
|
babase.increment_analytics_count('Free-for-all session start')
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def _switch_to_score_screen(self, results: bascenev1.GameResults) -> None:
|
def _switch_to_score_screen(self, results: bascenev1.GameResults) -> None:
|
||||||
|
|||||||
@ -8,11 +8,11 @@ from dataclasses import dataclass
|
|||||||
from typing import TYPE_CHECKING, TypeVar
|
from typing import TYPE_CHECKING, TypeVar
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence, Any
|
from typing import Sequence, Any
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
@ -257,8 +257,8 @@ class HitMessage:
|
|||||||
"""Instantiate a message with given values."""
|
"""Instantiate a message with given values."""
|
||||||
|
|
||||||
self.srcnode = srcnode
|
self.srcnode = srcnode
|
||||||
self.pos = pos if pos is not None else _babase.Vec3()
|
self.pos = pos if pos is not None else babase.Vec3()
|
||||||
self.velocity = velocity if velocity is not None else _babase.Vec3()
|
self.velocity = velocity if velocity is not None else babase.Vec3()
|
||||||
self.magnitude = magnitude
|
self.magnitude = magnitude
|
||||||
self.velocity_magnitude = velocity_magnitude
|
self.velocity_magnitude = velocity_magnitude
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,18 +4,17 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import weakref
|
import weakref
|
||||||
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import _babase
|
import babase
|
||||||
from babase._error import print_error, print_exception, NodeNotFoundError
|
|
||||||
from babase._language import Lstr
|
|
||||||
import _bascenev1
|
import _bascenev1
|
||||||
from bascenev1._player import Player
|
from bascenev1._player import Player
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence, Any
|
from typing import Sequence, Any
|
||||||
|
|
||||||
import babase
|
|
||||||
import bascenev1
|
import bascenev1
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +195,7 @@ class Session:
|
|||||||
with self.context:
|
with self.context:
|
||||||
self.on_team_join(team)
|
self.on_team_join(team)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(f'Error in on_team_join for {self}.')
|
logging.exception('Error in on_team_join for %s.', self)
|
||||||
|
|
||||||
self.lobby = Lobby()
|
self.lobby = Lobby()
|
||||||
self.stats = Stats()
|
self.stats = Stats()
|
||||||
@ -214,7 +213,7 @@ class Session:
|
|||||||
"""The sessionglobals bascenev1.Node for the session."""
|
"""The sessionglobals bascenev1.Node for the session."""
|
||||||
node = self._sessionglobalsnode
|
node = self._sessionglobalsnode
|
||||||
if not node:
|
if not node:
|
||||||
raise NodeNotFoundError()
|
raise babase.NodeNotFoundError()
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def should_allow_mid_activity_joins(
|
def should_allow_mid_activity_joins(
|
||||||
@ -236,15 +235,15 @@ class Session:
|
|||||||
"""
|
"""
|
||||||
# Limit player counts *unless* we're in a stress test.
|
# Limit player counts *unless* we're in a stress test.
|
||||||
if (
|
if (
|
||||||
_babase.app.classic is not None
|
babase.app.classic is not None
|
||||||
and _babase.app.classic.stress_test_reset_timer is None
|
and babase.app.classic.stress_test_reset_timer is None
|
||||||
):
|
):
|
||||||
if len(self.sessionplayers) >= self.max_players:
|
if len(self.sessionplayers) >= self.max_players:
|
||||||
# Print a rejection message *only* to the client trying to
|
# Print a rejection message *only* to the client trying to
|
||||||
# join (prevents spamming everyone else in the game).
|
# join (prevents spamming everyone else in the game).
|
||||||
_bascenev1.getsound('error').play()
|
_bascenev1.getsound('error').play()
|
||||||
_bascenev1.screenmessage(
|
_bascenev1.screenmessage(
|
||||||
Lstr(
|
babase.Lstr(
|
||||||
resource='playerLimitReachedText',
|
resource='playerLimitReachedText',
|
||||||
subs=[('${COUNT}', str(self.max_players))],
|
subs=[('${COUNT}', str(self.max_players))],
|
||||||
),
|
),
|
||||||
@ -277,15 +276,15 @@ class Session:
|
|||||||
try:
|
try:
|
||||||
self.lobby.remove_chooser(sessionplayer)
|
self.lobby.remove_chooser(sessionplayer)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception('Error in Lobby.remove_chooser().')
|
logging.exception('Error in Lobby.remove_chooser().')
|
||||||
else:
|
else:
|
||||||
# Ok, they've already entered the game. Remove them from
|
# Ok, they've already entered the game. Remove them from
|
||||||
# teams/activities/etc.
|
# teams/activities/etc.
|
||||||
sessionteam = sessionplayer.sessionteam
|
sessionteam = sessionplayer.sessionteam
|
||||||
assert sessionteam is not None
|
assert sessionteam is not None
|
||||||
|
|
||||||
_babase.screenmessage(
|
babase.screenmessage(
|
||||||
Lstr(
|
babase.Lstr(
|
||||||
resource='playerLeftText',
|
resource='playerLeftText',
|
||||||
subs=[('${PLAYER}', sessionplayer.getname(full=True))],
|
subs=[('${PLAYER}', sessionplayer.getname(full=True))],
|
||||||
)
|
)
|
||||||
@ -342,17 +341,18 @@ class Session:
|
|||||||
self.sessionteams.remove(sessionteam)
|
self.sessionteams.remove(sessionteam)
|
||||||
self.on_team_leave(sessionteam)
|
self.on_team_leave(sessionteam)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(
|
logging.exception(
|
||||||
f'Error in on_team_leave for Session {self}.'
|
'Error in on_team_leave for Session %s.', self
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print('Team no in Session teams in on_player_leave.')
|
print('Team no in Session teams in on_player_leave.')
|
||||||
try:
|
try:
|
||||||
sessionteam.leave()
|
sessionteam.leave()
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(
|
logging.exception(
|
||||||
f'Error clearing sessiondata'
|
'Error clearing sessiondata for team %s in session %s.',
|
||||||
f' for team {sessionteam} in session {self}.'
|
sessionteam,
|
||||||
|
self,
|
||||||
)
|
)
|
||||||
|
|
||||||
def end(self) -> None:
|
def end(self) -> None:
|
||||||
@ -370,17 +370,16 @@ class Session:
|
|||||||
from bascenev1._activitytypes import EndSessionActivity
|
from bascenev1._activitytypes import EndSessionActivity
|
||||||
|
|
||||||
with self.context:
|
with self.context:
|
||||||
curtime = _babase.apptime()
|
curtime = babase.apptime()
|
||||||
if self._ending:
|
if self._ending:
|
||||||
# Ignore repeats unless its been a while.
|
# Ignore repeats unless its been a while.
|
||||||
assert self._launch_end_session_activity_time is not None
|
assert self._launch_end_session_activity_time is not None
|
||||||
since_last = curtime - self._launch_end_session_activity_time
|
since_last = curtime - self._launch_end_session_activity_time
|
||||||
if since_last < 30.0:
|
if since_last < 30.0:
|
||||||
return
|
return
|
||||||
print_error(
|
logging.error(
|
||||||
'_launch_end_session_activity called twice (since_last='
|
'_launch_end_session_activity called twice (since_last=%s)',
|
||||||
+ str(since_last)
|
since_last,
|
||||||
+ ')'
|
|
||||||
)
|
)
|
||||||
self._launch_end_session_activity_time = curtime
|
self._launch_end_session_activity_time = curtime
|
||||||
self.setactivity(_bascenev1.newactivity(EndSessionActivity))
|
self.setactivity(_bascenev1.newactivity(EndSessionActivity))
|
||||||
@ -482,7 +481,7 @@ class Session:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if activity is self._activity_retained:
|
if activity is self._activity_retained:
|
||||||
print_error('Activity set to already-current activity.')
|
logging.error('Activity set to already-current activity.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._next_activity is not None:
|
if self._next_activity is not None:
|
||||||
@ -523,8 +522,8 @@ class Session:
|
|||||||
# the activity should have no refs left to it and should die (which
|
# the activity should have no refs left to it and should die (which
|
||||||
# will trigger the next activity to run).
|
# will trigger the next activity to run).
|
||||||
if prev_activity is not None:
|
if prev_activity is not None:
|
||||||
with _babase.ContextRef.empty():
|
with babase.ContextRef.empty():
|
||||||
_babase.apptimer(
|
babase.apptimer(
|
||||||
max(0.0, activity.transition_time), prev_activity.expire
|
max(0.0, activity.transition_time), prev_activity.expire
|
||||||
)
|
)
|
||||||
self._in_set_activity = False
|
self._in_set_activity = False
|
||||||
@ -551,9 +550,12 @@ class Session:
|
|||||||
with self.context:
|
with self.context:
|
||||||
self.on_activity_end(activity, results)
|
self.on_activity_end(activity, results)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(
|
logging.error(
|
||||||
f'Error in on_activity_end() for session {self}'
|
'Error in on_activity_end() for session %s'
|
||||||
f' activity {activity} with results {results}'
|
' activity %s with results %s',
|
||||||
|
self,
|
||||||
|
activity,
|
||||||
|
results,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _request_player(self, sessionplayer: bascenev1.SessionPlayer) -> bool:
|
def _request_player(self, sessionplayer: bascenev1.SessionPlayer) -> bool:
|
||||||
@ -568,7 +570,7 @@ class Session:
|
|||||||
with self.context:
|
with self.context:
|
||||||
result = self.on_player_request(sessionplayer)
|
result = self.on_player_request(sessionplayer)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(f'Error in on_player_request for {self}')
|
logging.exception('Error in on_player_request for %s.', self)
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
# If they said yes, add the player to the lobby.
|
# If they said yes, add the player to the lobby.
|
||||||
@ -578,7 +580,7 @@ class Session:
|
|||||||
try:
|
try:
|
||||||
self.lobby.add_chooser(sessionplayer)
|
self.lobby.add_chooser(sessionplayer)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception('Error in lobby.add_chooser().')
|
logging.exception('Error in lobby.add_chooser().')
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -598,7 +600,7 @@ class Session:
|
|||||||
"""
|
"""
|
||||||
if self._next_activity is None:
|
if self._next_activity is None:
|
||||||
# Should this ever happen?
|
# Should this ever happen?
|
||||||
print_error('begin_next_activity() called with no _next_activity')
|
logging.error('begin_next_activity() called with no _next_activity')
|
||||||
return
|
return
|
||||||
|
|
||||||
# We store both a weak and a strong ref to the new activity;
|
# We store both a weak and a strong ref to the new activity;
|
||||||
@ -654,8 +656,8 @@ class Session:
|
|||||||
# Get our next activity going.
|
# Get our next activity going.
|
||||||
self._complete_end_activity(activity, {})
|
self._complete_end_activity(activity, {})
|
||||||
else:
|
else:
|
||||||
_babase.screenmessage(
|
babase.screenmessage(
|
||||||
Lstr(
|
babase.Lstr(
|
||||||
resource='notEnoughPlayersText',
|
resource='notEnoughPlayersText',
|
||||||
subs=[('${COUNT}', str(min_players))],
|
subs=[('${COUNT}', str(min_players))],
|
||||||
),
|
),
|
||||||
@ -681,12 +683,12 @@ class Session:
|
|||||||
# hitches.
|
# hitches.
|
||||||
garbage_collect()
|
garbage_collect()
|
||||||
|
|
||||||
assert _babase.app.classic is not None
|
assert babase.app.classic is not None
|
||||||
with self.context:
|
with self.context:
|
||||||
if can_show_ad_on_death:
|
if can_show_ad_on_death:
|
||||||
_babase.app.classic.ads.call_after_ad(self.begin_next_activity)
|
babase.app.classic.ads.call_after_ad(self.begin_next_activity)
|
||||||
else:
|
else:
|
||||||
_babase.pushcall(self.begin_next_activity)
|
babase.pushcall(self.begin_next_activity)
|
||||||
|
|
||||||
def _add_chosen_player(
|
def _add_chosen_player(
|
||||||
self, chooser: bascenev1.Chooser
|
self, chooser: bascenev1.Chooser
|
||||||
@ -721,8 +723,8 @@ class Session:
|
|||||||
):
|
):
|
||||||
pass_to_activity = False
|
pass_to_activity = False
|
||||||
with self.context:
|
with self.context:
|
||||||
_babase.screenmessage(
|
babase.screenmessage(
|
||||||
Lstr(
|
babase.Lstr(
|
||||||
resource='playerDelayedJoinText',
|
resource='playerDelayedJoinText',
|
||||||
subs=[
|
subs=[
|
||||||
('${PLAYER}', sessionplayer.getname(full=True))
|
('${PLAYER}', sessionplayer.getname(full=True))
|
||||||
@ -751,7 +753,7 @@ class Session:
|
|||||||
try:
|
try:
|
||||||
self.on_team_join(sessionteam)
|
self.on_team_join(sessionteam)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_exception(f'Error in on_team_join for {self}.')
|
logging.exception('Error in on_team_join for %s.', self)
|
||||||
|
|
||||||
# Add player's team to the Activity.
|
# Add player's team to the Activity.
|
||||||
if pass_to_activity:
|
if pass_to_activity:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user