MOT_spec 1.93 KB
MAZE_MAGIC 0x6D7A
ADD_PLAYER 0x4E45
HUNTER 0x4855
ILLEGAL_MOV 0xF000
PLAYER_MOV 0x4D4F
PLAYER_DC 0x4443
PLAYER_DIE 0x4B4F
PLAYER_WIN 0x5749
SRV_BUSY 0xEEEE
MAX_PLAYERNUM 32
all the magic numbers will be uint16_t...
TYPES
unsigned short magical instruction things
short Maze player locations (x, y)
unsigned char Player number
char Player name, SHOULD BE 32 BYTES (pad with zeroes)
unsigned int sizes of things
Server: is TCP
handles 32 players max
- If the game already started and someone tries to connect, send SRV_BUSY
and close the connection...
send the maze for the client.
* send MAZE_MAGIC
* send unsigned int, data width of maze (in unsigned chars) (MAZE.w)
* send unsigned int, size of maze in bytes
* send the whole maze byte by byte
* wait for MAZE_MAGIC packet
expect player name right after sending the maze (the player chooses name
before connecting)
* receive null terminated string
send current client player's number
add players to the connecting pre-game screen as they connect (as well as
the ones connected before this player, if any, AND the current player)
* send ADD_PLAYER
* send unsigned char player number
* send short X, Y in maze
* send null-terminated string for the name
Choose hunter (which means the game begins)
* send HUNTER
* send the unsigned char value of the hunter player
Player updates
==============
from server - other players to the client:
A player MOVES on the maze
* PLAYER_MOV
* unsigned char pnum, short x, short y
> Allow players to walk through each other???
A player wins
* send PLAYER_WIN
* send unsigned char pnum
Player disconnects/loses/get hunted
* send PLAYER_DC for disconnect
* send PLAYER_DIE for lose
* send unsigned char pnum
> clear the player from the screen
from the client to the server:
Move
* PLAYER_MOV
* short x, short y
* if the move is illegal, send ILLEGAL_MOV and don't send move update to
players