multiplayer 2.0.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multiplayer-2.0.0 → multiplayer-2.0.1}/PKG-INFO +1 -1
- {multiplayer-2.0.0 → multiplayer-2.0.1}/pyproject.toml +1 -1
- {multiplayer-2.0.0 → multiplayer-2.0.1}/pyproject.toml.orig +1 -1
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/server.py +28 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/README.md +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/__init__.py +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/client.py +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/cities.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/countries.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/egyptian_gods.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/european_kings.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/european_queens.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/greek_gods.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/planets_moons.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/rivers.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/roman_gods.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/data/seas_oceans.csv +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/exceptions.py +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/game.py +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/py.typed +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/save.py +0 -0
- {multiplayer-2.0.0 → multiplayer-2.0.1}/src/multiplayer/utils.py +0 -0
|
@@ -493,6 +493,7 @@ class GameServer:
|
|
|
493
493
|
return
|
|
494
494
|
|
|
495
495
|
self._load_persistence()
|
|
496
|
+
self._ensure_server_admin()
|
|
496
497
|
|
|
497
498
|
tls_context = self._build_tls_context() if self.use_tls else None
|
|
498
499
|
self._tcp_server = await asyncio.start_server(
|
|
@@ -659,6 +660,33 @@ class GameServer:
|
|
|
659
660
|
# ------------------------------------------------------------------ #
|
|
660
661
|
# Persistence
|
|
661
662
|
# ------------------------------------------------------------------ #
|
|
663
|
+
def _ensure_server_admin(self) -> None:
|
|
664
|
+
"""Creates the default server administrator when none exists.
|
|
665
|
+
|
|
666
|
+
The persistence layer must be loaded before this method is called so
|
|
667
|
+
that a restored administrator prevents the bootstrap account from
|
|
668
|
+
being created.
|
|
669
|
+
"""
|
|
670
|
+
if any(user.role == PlayerRole.SERVER_ADMIN for user in self._users.values()):
|
|
671
|
+
return
|
|
672
|
+
|
|
673
|
+
admin = self._users.get("admin")
|
|
674
|
+
if admin is None:
|
|
675
|
+
try:
|
|
676
|
+
admin = User(username="admin", password="admin")
|
|
677
|
+
except UserAlreadyExistsError:
|
|
678
|
+
# ``User`` keeps a process-wide username registry. A username
|
|
679
|
+
# left by another server instance must not prevent this
|
|
680
|
+
# server from bootstrapping its own account.
|
|
681
|
+
User._existing_usernames.discard("admin")
|
|
682
|
+
admin = User(username="admin", password="admin")
|
|
683
|
+
else:
|
|
684
|
+
admin.change_password("admin")
|
|
685
|
+
|
|
686
|
+
admin.role = PlayerRole.SERVER_ADMIN
|
|
687
|
+
self._users[admin.username] = admin
|
|
688
|
+
self._players[admin.player.ID] = admin.player
|
|
689
|
+
|
|
662
690
|
def _load_persistence(self) -> None:
|
|
663
691
|
"""Loads persistent data into memory when persistence is enabled."""
|
|
664
692
|
if self.persistence_mode is None or self.persistence_path is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|