source: network-game/design/algorithms.txt@ ace001a

Last change on this file since ace001a was e437a19, checked in by dportnoy <dmp1488@…>, 11 years ago

New network headers in Common.cpp

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[e437a19]1This file general algorithms used in the game, such as how players login/logout and how the create games or join existing games.
2
3Currently, there is no distinction between logging in and creating a game. There is essentially one game that always exists; when a player logs in, he joins that game, and when he logs out, he leaves that game.
4
5New Login/Logout Algorithm:
6
7When a player logs in, the db lookup and password check occurs just like it already does, and the player is added to some global player list. Other logged-in players get notified of this.
8
9When a player logs out, he gets removed from the list and everyone else also gets notified.
10
11All of this already happens, but it's tied to the signle game instance.
12
13STEPS:
14 - Un-implement/comment out the current code that sends messages about the game instance and just keep the code that adds/removes players from the global list.
15 - Make sure that chatting with players works.
16 - Modify the current game class to keep track of players in the game and re-implement (or possibly create) the messages for joining and leaving a game.
17 - Re-implement the movement/combat messages to use the list of players in the game, not the global list
18
19mapPlayers holds all players on the server and broadcasted messages are sent to everyone in the map
20
21A player logs in by sending a LOGIN message. When the server receives the message and verifies user credentials, it sends the following messages:
22 To the new player
23 - PLAYER messages for existing players (still needed)
24 - OBJECT messages for existing objects on the map (only send for new game)
25 - SCORE messages (only send for new game)
26 - PLAYER message to each existing player about the new one
27 - LOGIN message to the new player to indicate successful login (final reply)
28
29For logout messages, the logic can basically be kept the same. Just move the part related to restoring the flag in case the player is carrying one.
30
31Logic for sending chat messages
32
33Server receives a chat message and sends the following:
34 - The received chat message is simply broadcast to all other players
35 - An error will result in a chat message only being sent back to the sender
Note: See TracBrowser for help on using the repository browser.