
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 
		1: Miss
		2: Boo
		3: Good
		4: Great
		5: Perfect
		6: Marvelous
		7: NG
		8: OK

    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		
010:	User entered/exited Network Music Selection Screen
 Size:
    1		
		If this value is 0 then the user exited the screen
		If this value is 1 then the user entered the screen
		*****If this value is 2 then the user exited the options screen  < Normall is not sent
		If this value is 3 then the user entered options screen
		If this value is 4 then the user exited the evaluation screen
		If this value is 5 then the user entered evaluation screen

011:	User has changed player options
 Size:
    NT		Player 0's options
    NT		Player 1's options


012:	SMOnline Packet.	//SPECIAL CASE!!!
	NOTE: The smonline packet is not defined here.
	The SMLan packet 12 is a wrapper for the SMOnline packet.
	This is so that we can have "protection" of sorts when 
	it comes to the coding of SMOnline, so we don't have to
	use the lower level commands when dealing with SMOnline.
 Size:
    2		SMOnline command
 <VARIABLE>	SMOnline data

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)
    NT		Player's options
	<Other player's options>


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
		3: Blindly start 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)
	2	In Selection Screen
	3	In Options
	4 	In Evaluation

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

011:	Reserved


012:	SMOnline Packet.	//SPECIAL CASE!!!
	NOTE: The smonline packet is not defined here.
	The SMLan packet 12 is a wrapper for the SMOnline packet.
	This is so that we can have "protection" of sorts when 
	it comes to the coding of SMOnline, so we don't have to
	use the lower level commands when dealing with SMOnline.
 Size:
    2		SMOnline command
 <VARIABLE>	SMOnline data














----------------------------------------------------------------
Client SMOnline packets:
000:  Send Login Information
 Size:
    1		Encryption text
		0: Plain Text
		(More will be added)
    NT		Username
    NT		Password

001:  Room Update
 Size:
    1		Type of update
		0: Change Room Title
		1: Update List of other rooms (or games)

	If Room Title Update:
    NT		Room Title
    NT		Room Description
	
	If Room List Update:
    1		Number of rooms
    NT		Room1 Title
    NT		Room1 Description		
    NT		Room2 Title
    NT		Room2 Description		
	...
    NT		RoomN Title
    NT		RoomN Description		

Server SMOnline packets:
000:  Login Responce
    1		Approval Status
		0: Approved
		1: Approval Failed
    NT		MOTD (if passed)
	    or	Reason for failure (if failed)

001: User asks to enter room
 Size:
    1		Enter/Exit?
		0: User wishes to exit room
		1: User wishes to enter room 
    NT		Room Name (Used when entering rooms)