
PRELIMINARY - - - - - - - - 09/01/2004
Protocol version not yet 1.  
  But 0x01 will be its version for inter-prtocol purposes.

This protocol is only intended to replace current protocol.  Because current protocol
not expanable

SMLAN PROTCOL TCP/8765

Protcol is entirelly packaged in EzSockets Data Packets (use send and receive packet)

This will prevent any out-of-sync errors with future or past versions.

The protocol is impervious to fragmented, or bonded TCP packets.

Basic Representation:

Octet 0123 4 5
     +----+-+---//--+
     |ssss|C|Payload|
     +----+-+---//--+

ssss    - size of packet, stripped and created by ezsockets
C       - Command.
Payload - variable size based on command

The payload may contain more data than expected, i.e. new protocol version.

If the size is 	"NT" then that means it's a null-terminating string.
		"MSN" most significant 4 bits
		"LSN" least significant 4 bits


Note: Primary player is 0x0, secondary player is 0x1

CLIENT to SERVER protocol:

000:	No Operation
 Desc:		This command will cause server to respond with a no op responce.
 Payload:	None
 Responce:	Server 001
 
001:	No Operation Responce
 Desc:		This command is used to respond to a no operation.
 Payload:	None
 Responce:	None

002:	Hello
 Desc:		This is the first packet from a client to server, stating below 
		information  (NOTE: Names are no longer sent in this packet)
 Payload:	
    Size	Description:
    1		Client protocol version
    NT		Name of build of StepMania
 Responce:	Server 002



003:	Game Start Request
 Desc:		This command is called once after most loading is done, and
		again immediately before the sound starts.
 Payload:	
    Size	Description
    MSN		Primary player difficulty (feet)   (0 for no player)
    LSN		Secondary player difficulty (feet) (0 for no player)
    MSN		Primary player difficulty (0=Beginner, 1=easy, etc.) 
    LSN		Second player difficulty (0=Beginner, 1=easy, etc.)
    MSN		Start Position (0 is pre-sync, 1 is for sync)
    LSN		Reserved
    NT		Song Title
    NT		Song Subtitle
    NT		Song Artist   
    NT		Course Title     (If none exists; make it just a null)
    NT		Song Options (in string-format)
    NT		Primary Player's options
    NT		Secondary Player's Options (Null if non-existant)
    
 Responce: 	Server 003


004:	Game Over Notice
 Desc:		This command is sent when end of game is encounterd
 Payload:	None.
 Responce:	None.

005:	Game Status update
 Desc:		Updates game info for each step
 Payload:
    Size	Description
    MSN		Player #
    LSN		StepID 
		0: Miss
		1: Boo
		2: Good
		3: Great
		4: Perfect
		5: Marvelous
		6: OK \
		7: NG  \These may be swapped 
    MSN		Projected Grade (StepMania enum int)
    LSN		Reserved
    4		Net-order long containing score.
    2		Net-order int containing combo.
    2		Net-order int containing health.
    2		Net-order # containing offset
			32767 would be DEAD on the note
			If the user is hitting late, the # will be higher
			It if the user is exactly 0.25 seconds off, the
			number will be different by 500, if 0.5, it will be
			different by 1000.
 Responce:	None.

006: Style Update    (PLEASE NOTE THIS HAS NOTHING TO DO WITH SERVER COMMAND 6)
 Desc:		This is sent when a style is chosen.  
 Size:
    1		# of enabled players (1 means 1, 2 means 2)
    1		Player #   (0 means 1st, 1 means 2nd)
    NT		Player Name for #
   (Additional player's and #'s) (enabled players ONLY)

 Responce:	None

007:	Chat message
 Desc:		The user typed a message for general chat.
 Size:
    NT		Message

008:	Request Start Game and Tell server existance/non existance of song.
 Desc:		The user selected a song on a Net-enabled selection
 Size:
    1		Usage of message
		0: (in responce to server 8) User has specified song
		1: (in responce to server 8) User does NOT have specified song
		2: User requested a start game on given song
    NT		Song Title    (As gotten by GetTranslitMainTitle)
    NT		Song Artist   (As Gotten by GetTranslitArtist)
    NT		Song Subtitle (As gotten by GetTranslitSubTitle)

009: //Reserved

010:	User entered/exited Network Music Selection Screen
 Size:
    1		If this value is 1 then the user entered the screen
		If this value is 0 then the user exited the screen

SERVER to CLIENT protocol: (begins at 128)

NOTE: Server responces always add 128, thus a server responce for no operation
	is 128, not 000

000:	No Operation 
 Desc:		This command will cause server to respond with a no op responce.
 Payload:	None
 Responce:	Server 001

001:	No Operation Responce
 Desc:		This command is used to respond to a no operation.
 Payload:	None
 Responce:	None

002:	Server Hello Responce
 Desc:		This introduces the server.
 Payload:
    Size	Description
    1		Server protocol version
    NT		Server Name

003:	Allow Start
 Desc:		This will cause the client to start the game.
 Payload:	None
 Responce:	None

004: Game over stats
 Desc:		this packet is send in responce to the game over packet
		it contains information regarding how well each player did.
 Payload:
    1		# of players sent in this packet (active players)
	The way this works is to send every player's info for a given
	 field.  Like every player's score will be sent first, then every
	 player's grade.
    1		First player's player ID
	<Other player's IDs>
    4		Score
	<Other player's scores>
    1		Grade
	<Other player's Grades>
    1		Difficulty (0=beginner, 1=light, etc.)
	<Other player's difficulties>
    2           miss
	<Other player's misses>
    2		boo		
	<Other player's boos>
    2		good (All players)
    2		great (All players)
    2		perfect (All players)
    2		marvelous (All players)
    2		ok (All players)
    2		max_combo (All players)


005: 	Scoreboard update
 Desc:		This will update the client's scoreboard.
 Payload:	
    Size
    1		Which section
		0: Names
		1: Combos
		2: Projected Grades
    1		# of players to display

	If Names, then:
    1		Player in first place's ID
    1		Player in second place's ID
    ...
    1		Last player's ID
	If Combos, then:
    2		First player's combo
    2		Second Player's combo
    ...
    2		Last player's combo
	If Project grades
    1		Player 1's grade (in the same format used when reporting projected grades)
    1		Player 2's grade
    ...
    1		Last player's projected grade


006: 	System Message  (PLEASE NOTE THIS HAS NOTHING TO DO WITH CLIENT COMMAND 6)
 Desc: 		Send system message to user
 Payload:
    Size	Description
    NT		Message

007:	Chat Message
 Desc:		Add a chat message to the chat window on some StepMania screens.
 Payload:	
    Size	Description
    NT		Message

008:	Tell client to start song/ask if client has song
 Desc:		The user selected a song on a Net-enabled selection
 Size:
    1		Usage of message
		0: See if client has song
		1: See if client has song, if so, scroll to song
		2: See if client has song, if so, scroll to song, and play that song
    NT		Song Title    (As gotten by GetTranslitMainTitle)
    NT		Song Artist   (As Gotten by GetTranslitArtist)
    NT		Song Subtitle (As gotten by GetTranslitSubTitle)

009:	Update user list
 Desc:		This sends all the users currently connected
 Size:
    1		Max # of players
    1		# of players in this packet
    1		Player 0's status
    NT		Player 0's name (if there is no player here... make it a null (""))
    1		Player 1's status
    NT		Player 1's name
    ...
    1		Last player's status
    NT		Last player's name
     Status:  
	0	Inative (no info on this user yet)
	1	Active (you know who it is)

010:	Force change to Networking select music screen.
 Size:
    NT		Set Specified gametype
    NT		Set Specified style

///Potential for SMOnline/SMLAN  (Changed to 020)
020:	SMonline Packet.  (Adam)
      Bytemap(Game Packet - SMO/TCP[C=010] Data)
      +----+---//---+-+---//---+-+---+------+-----+
      |iiii|GameName|0|SongName|0|pmd|Length|Steps|
      +----+-//-----+-+-//-----+-+---+------+-----+
      Byte[4]      iiii         IPAddress of Host/Creator(WAN)
      char*        GameName     Name of the Game
      char*        SongName     Title of the Song
      Byte         p            Current number of Players
      Byte         m            Maximum allowed Players(Set by creator; values 1-14 valid)
      Enum Byte    d            Average Player Difficulty(values 0-4 valid)
      Long         Length       Length of .sm file for Song in Bytes(For validation)
      Long         Steps        Total number of steps in all stepcharts for this song(For validation)

