Skip to content

Commit

Permalink
v2 - Remove Deprecations (#816)
Browse files Browse the repository at this point in the history
* Remove modvault

* Remove create_account

* Remove id and login from welcome message

* Remove mod from game_matchmaking command

* Remove QDataStreamProtocol

* Remove 'faction' parameter from game_matchmaking command

* Stop sending game_launch when match is cancelled

* Remove InitMode

* Remove search boundaries from matchmaker_info
  • Loading branch information
Askaholic committed Oct 16, 2023
1 parent 455912e commit 34558ca
Show file tree
Hide file tree
Showing 31 changed files with 141 additions and 397 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ USER faf
# Main entrypoint and the default command that will be run
CMD ["/usr/local/bin/python3", "main.py"]

# lobby server runs on 8001/tcp (QDataStream) and 8002/tcp (JSON)
EXPOSE 8001 8002
# lobby server runs on 8002/tcp (JSON)
EXPOSE 8002

RUN python3 -V
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,8 @@ list see [https://faforever.github.io/server/](https://faforever.github.io/serve
The protocol is mainly JSON-encoded maps, containing at minimum a `command` key,
representing the command to dispatch.

The wire format uses [QDataStream](http://doc.qt.io/qt-5/qdatastream.html) (UTF-16, BigEndian).

For the lobbyconnection, each message is of the form:
```
ACTION: QString
```
With most carrying a footer containing:
```
LOGIN: QString
SESSION: QString
```

## Incoming Packages

##### Mod Vault

- (deprecated) `{command: modvault, type: start}`: show the last 100 mods
- (deprecated) `{command: modvault, type: like, uid: <uid>}`: check if user liked the mod, otherwise increase the like counter
- (deprecated) `{command: modvault, type: download, uid: <uid>}`: notify server about a download (for download counter), does not start the download

##### Social
- `{command: social_add, friend|foe: <player_id>}`: Add a friend or foe
- `{command: social_remove, friend|foe: <player_id>}`: Remove a friend or foe
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Manager():
def __init__(self):
self.clients = []

async def add_client(self, host="test.faforever.com", port=8001):
async def add_client(self, host="test.faforever.com", port=8002):
client = FAFClient()
await client.connect(host, port)
self.clients.append(client)
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/fafclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess
from hashlib import sha256

from server.protocol import QDataStreamProtocol
from server.protocol import SimpleJsonProtocol
from tests.integration_tests.conftest import read_until, read_until_command


Expand All @@ -29,7 +29,7 @@ async def close(self):
await self.proto.close()

async def connect(self, host, port):
self.proto = QDataStreamProtocol(
self.proto = SimpleJsonProtocol(
*(await asyncio.open_connection(host, port))
)

Expand Down Expand Up @@ -91,8 +91,8 @@ async def login(self, username, password):
"unique_id": unique_id
})
msg = await self.read_until_command("welcome")
self.player_id = msg["id"]
self.player_name = msg["login"]
self.player_id = msg["me"]["id"]
self.player_name = msg["me"]["login"]
return msg

def get_unique_id(self, session):
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ async def test_user_existence(client_factory, username):
"""Verify that these users exist on the test server"""
client, welcome_message = await client_factory.login(username, "foo")

assert welcome_message["login"] == welcome_message["me"]["login"] == username
assert welcome_message["id"] == welcome_message["me"]["id"]
assert welcome_message["me"]["login"] == username
assert client.is_connected()
4 changes: 2 additions & 2 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
from .oauth_service import OAuthService
from .party_service import PartyService
from .player_service import PlayerService
from .protocol import Protocol, QDataStreamProtocol
from .protocol import Protocol, SimpleJsonProtocol
from .rating_service.rating_service import RatingService
from .servercontext import ServerContext
from .stats.game_stats_service import GameStatsService
Expand Down Expand Up @@ -244,7 +244,7 @@ async def listen(
self,
address: tuple[str, int],
name: Optional[str] = None,
protocol_class: type[Protocol] = QDataStreamProtocol,
protocol_class: type[Protocol] = SimpleJsonProtocol,
proxy: bool = False,
) -> ServerContext:
"""
Expand Down
2 changes: 0 additions & 2 deletions server/games/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
GameConnectionState,
GameState,
GameType,
InitMode,
ValidityState,
Victory,
VisibilityState
Expand All @@ -39,7 +38,6 @@ class FeaturedMod(NamedTuple):
"GameError",
"GameState",
"GameType",
"InitMode",
"LadderGame",
"ValidityState",
"Victory",
Expand Down
3 changes: 1 addition & 2 deletions server/games/coop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from .game import Game
from .typedefs import FA, GameType, InitMode, ValidityState, Victory
from .typedefs import FA, GameType, ValidityState, Victory


class CoopGame(Game):
"""Class for coop game"""
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.COOP

def __init__(self, *args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions server/games/custom_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from server.rating import RatingType

from .game import Game
from .typedefs import GameType, InitMode, ValidityState
from .typedefs import GameType, ValidityState


@with_logger
class CustomGame(Game):
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.CUSTOM

def __init__(self, id_, *args, **kwargs):
Expand Down
2 changes: 0 additions & 2 deletions server/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
GameConnectionState,
GameState,
GameType,
InitMode,
ValidityState,
Victory,
VisibilityState
Expand All @@ -51,7 +50,6 @@ class Game:
"""
Object that lasts for the lifetime of a game on FAF.
"""
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.CUSTOM

def __init__(
Expand Down
4 changes: 1 addition & 3 deletions server/games/ladder_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from .game import Game
from .game_results import ArmyOutcome, GameOutcome
from .typedefs import GameState, GameType, InitMode
from .typedefs import GameState, GameType

logger = logging.getLogger(__name__)

Expand All @@ -23,8 +23,6 @@ def __init__(self, player: Player):

class LadderGame(Game):
"""Class for 1v1 ladder games"""

init_mode = InitMode.AUTO_LOBBY
game_type = GameType.MATCHMAKER

def __init__(self, id_, *args, **kwargs):
Expand Down
7 changes: 0 additions & 7 deletions server/games/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ class GameConnectionState(Enum):
ENDED = 3


@unique
class InitMode(Enum):
NORMAL_LOBBY = 0
AUTO_LOBBY = 1


@unique
class GameType(Enum):
COOP = "coop"
Expand Down Expand Up @@ -224,7 +218,6 @@ class FA(object):
"GameConnectionState",
"GameState",
"GameType",
"InitMode",
"TeamRatingSummary",
"ValidityState",
"Victory",
Expand Down
12 changes: 3 additions & 9 deletions server/ladder_service/ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)
from server.decorators import with_logger
from server.game_service import GameService
from server.games import InitMode, LadderGame
from server.games import LadderGame
from server.games.ladder_game import GameClosedError
from server.ladder_service.game_name import game_name
from server.ladder_service.violation_service import ViolationService
Expand Down Expand Up @@ -524,7 +524,6 @@ def get_displayed_rating(player: Player) -> float:
rating_type=queue.rating_type,
max_players=len(all_players)
)
game.init_mode = InitMode.AUTO_LOBBY
game.map_file_path = map_path
game.set_name_unchecked(game_name(team1, team2))

Expand Down Expand Up @@ -637,13 +636,8 @@ async def launch_match(
await game.wait_hosted(60)
except asyncio.TimeoutError:
raise NotConnectedError([host])
finally:
# TODO: Once the client supports `match_cancelled`, don't
# send `launch_game` to the client if the host timed out. Until
# then, failing to send `launch_game` will cause the client to
# think it is searching for ladder, even though the server has
# already removed it from the queue.

try:
# Launch the guests
not_connected_guests = [
player for player in guests
Expand All @@ -660,7 +654,7 @@ async def launch_match(
is_host=False,
options=make_game_options(guest)
)
try:

await game.wait_launched(60 + 10 * len(guests))
except asyncio.TimeoutError:
connected_players = game.get_connected_players()
Expand Down

0 comments on commit 34558ca

Please sign in to comment.